| 1 |
# Copyright 2020 gRPC authors. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
import logging |
| 15 |
|
| 16 |
from absl import flags |
| 17 |
from absl.testing import absltest |
| 18 |
|
| 19 |
from framework import xds_k8s_testcase |
| 20 |
|
| 21 |
logger = logging.getLogger(__name__) |
| 22 |
flags.adopt_module_key_flags(xds_k8s_testcase) |
| 23 |
|
| 24 |
# Type aliases |
| 25 |
_XdsTestServer = xds_k8s_testcase.XdsTestServer |
| 26 |
_XdsTestClient = xds_k8s_testcase.XdsTestClient |
| 27 |
|
| 28 |
|
| 29 |
class BaselineTest(xds_k8s_testcase.RegularXdsKubernetesTestCase): |
| 30 |
|
| 31 |
def test_traffic_director_grpc_setup(self): |
| 32 |
with self.subTest('0_create_health_check'): |
| 33 |
self.td.create_health_check() |
| 34 |
|
| 35 |
with self.subTest('1_create_backend_service'): |
| 36 |
self.td.create_backend_service() |
| 37 |
|
| 38 |
with self.subTest('2_create_url_map'): |
| 39 |
self.td.create_url_map(self.server_xds_host, self.server_xds_port) |
| 40 |
|
| 41 |
with self.subTest('3_create_target_proxy'): |
| 42 |
self.td.create_target_proxy() |
| 43 |
|
| 44 |
with self.subTest('4_create_forwarding_rule'): |
| 45 |
self.td.create_forwarding_rule(self.server_xds_port) |
| 46 |
|
| 47 |
with self.subTest('5_start_test_server'): |
| 48 |
test_server: _XdsTestServer = self.startTestServers()[0] |
| 49 |
|
| 50 |
with self.subTest('6_add_server_backends_to_backend_service'): |
| 51 |
self.setupServerBackends() |
| 52 |
|
| 53 |
with self.subTest('7_start_test_client'): |
| 54 |
test_client: _XdsTestClient = self.startTestClient(test_server) |
| 55 |
|
| 56 |
with self.subTest('8_test_client_xds_config_exists'): |
| 57 |
self.assertXdsConfigExists(test_client) |
| 58 |
|
| 59 |
with self.subTest('9_test_server_received_rpcs_from_test_client'): |
| 60 |
self.assertSuccessfulRpcs(test_client) |
| 61 |
|
| 62 |
|
| 63 |
if __name__ == '__main__': |
| 64 |
absltest.main(failfast=True) |