From 5df8612cae3b4d3ed8c4d6cfda0d42ec10f2320f Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 2 Mar 2022 11:54:37 -0800 Subject: [PATCH] [PSM interop] Expand the support of test config validation (#28978) * [PSM interop] Expand the support of test config validation * Comment the usage and source of testing_version * Also include the comment for url-map tests --- tools/internal_ci/linux/grpc_xds_k8s_lb.sh | 10 ++- .../linux/grpc_xds_k8s_lb_python.sh | 8 ++- tools/internal_ci/linux/grpc_xds_k8s_xlang.sh | 7 ++ tools/internal_ci/linux/grpc_xds_url_map.sh | 5 ++ .../linux/grpc_xds_url_map_python.sh | 7 +- .../internal_ci/linux/psm-security-python.sh | 7 ++ tools/internal_ci/linux/psm-security.sh | 6 ++ .../framework/helpers/skips.py | 67 +++++++++++++++++++ .../framework/xds_k8s_testcase.py | 14 ++++ .../framework/xds_url_map_testcase.py | 60 +++-------------- .../tests/affinity_test.py | 8 ++- .../xds_k8s_test_driver/tests/authz_test.py | 9 +++ .../tests/security_test.py | 7 ++ .../tests/url_map/affinity_test.py | 8 +-- .../tests/url_map/retry_test.py | 7 +- .../tests/url_map/timeout_test.py | 8 +-- 16 files changed, 167 insertions(+), 71 deletions(-) create mode 100644 tools/run_tests/xds_k8s_test_driver/framework/helpers/skips.py diff --git a/tools/internal_ci/linux/grpc_xds_k8s_lb.sh b/tools/internal_ci/linux/grpc_xds_k8s_lb.sh index 8ae2895a4dd..46273f23ec9 100755 --- a/tools/internal_ci/linux/grpc_xds_k8s_lb.sh +++ b/tools/internal_ci/linux/grpc_xds_k8s_lb.sh @@ -95,12 +95,18 @@ run_test() { # Test driver usage: # https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage local test_name="${1:?Usage: run_test test_name}" + # testing_version is used by the framework to determine the supported PSM + # features. It's captured from Kokoro job name of the Core repo, which takes + # 2 forms: + # grpc/core/master/linux/... + # grpc/core/v1.42.x/branch/linux/... python3 -m "tests.${test_name}" \ --flagfile="${TEST_DRIVER_FLAGFILE}" \ --kube_context="${KUBE_CONTEXT}" \ --secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \ --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ + --testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \ --xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \ ${@:2} } @@ -136,8 +142,8 @@ main() { local script_dir script_dir="$(dirname "$0")" - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" + # Source the test captured from the master branch. + echo "Sourcing test driver install captured from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" activate_gke_cluster GKE_CLUSTER_PSM_LB diff --git a/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh b/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh index 16bffa48ae9..b9cb07dc007 100755 --- a/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh +++ b/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh @@ -96,12 +96,18 @@ run_test() { # Test driver usage: # https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage local test_name="${1:?Usage: run_test test_name}" + # testing_version is used by the framework to determine the supported PSM + # features. It's captured from Kokoro job name of the Core repo, which takes + # 2 forms: + # grpc/core/master/linux/... + # grpc/core/v1.42.x/branch/linux/... python3 -m "tests.${test_name}" \ --flagfile="${TEST_DRIVER_FLAGFILE}" \ --kube_context="${KUBE_CONTEXT}" \ --secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \ --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ --server_image="${SERVER_IMAGE_NAME}" \ + --testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \ --xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" } @@ -129,7 +135,7 @@ run_test() { main() { local script_dir script_dir="$(dirname "$0")" - + # Source the test driver from the master branch. echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" diff --git a/tools/internal_ci/linux/grpc_xds_k8s_xlang.sh b/tools/internal_ci/linux/grpc_xds_k8s_xlang.sh index abf4fadcac0..73d90edece7 100755 --- a/tools/internal_ci/linux/grpc_xds_k8s_xlang.sh +++ b/tools/internal_ci/linux/grpc_xds_k8s_xlang.sh @@ -48,12 +48,19 @@ run_test() { local server_image_name="${IMAGE_REPO}/${slang}-server:${tag}" local client_image_name="${IMAGE_REPO}/${clang}-client:${tag}" # TODO(sanjaypujare): skip test if image not found (by using gcloud_gcr_list_image_tags) + + # testing_version is used by the framework to determine the supported PSM + # features. It's captured from Kokoro job name of the Core repo, which takes + # 2 forms: + # grpc/core/master/linux/... + # grpc/core/v1.42.x/branch/linux/... set -x python -m "tests.security_test" \ --flagfile="${TEST_DRIVER_FLAGFILE}" \ --kube_context="${KUBE_CONTEXT}" \ --server_image="${server_image_name}" \ --client_image="${client_image_name}" \ + --testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \ --xml_output_file="${TEST_XML_OUTPUT_DIR}/${tag}/${clang}-${slang}/sponge_log.xml" \ --force_cleanup \ --nocheck_local_certs diff --git a/tools/internal_ci/linux/grpc_xds_url_map.sh b/tools/internal_ci/linux/grpc_xds_url_map.sh index b606fd5b888..12bec9497ee 100755 --- a/tools/internal_ci/linux/grpc_xds_url_map.sh +++ b/tools/internal_ci/linux/grpc_xds_url_map.sh @@ -84,6 +84,11 @@ run_test() { # Test driver usage: # https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage local test_name="${1:?Usage: run_test test_name}" + # testing_version is used by the framework to determine the supported PSM + # features. It's captured from Kokoro job name of the Core repo, which takes + # 2 forms: + # grpc/core/master/linux/... + # grpc/core/v1.42.x/branch/linux/... set -x python3 -m "tests.${test_name}" \ --flagfile="${TEST_DRIVER_FLAGFILE}" \ diff --git a/tools/internal_ci/linux/grpc_xds_url_map_python.sh b/tools/internal_ci/linux/grpc_xds_url_map_python.sh index f053a84bb66..2cb3cdc964c 100755 --- a/tools/internal_ci/linux/grpc_xds_url_map_python.sh +++ b/tools/internal_ci/linux/grpc_xds_url_map_python.sh @@ -94,6 +94,11 @@ run_test() { # Test driver usage: # https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage local test_name="${1:?Usage: run_test test_name}" + # testing_version is used by the framework to determine the supported PSM + # features. It's captured from Kokoro job name of the Core repo, which takes + # 2 forms: + # grpc/core/master/linux/... + # grpc/core/v1.42.x/branch/linux/... set -x python3 -m "tests.${test_name}" \ --flagfile="${TEST_DRIVER_FLAGFILE}" \ @@ -134,7 +139,7 @@ main() { source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" activate_gke_cluster GKE_CLUSTER_PSM_BASIC - + set -x if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" diff --git a/tools/internal_ci/linux/psm-security-python.sh b/tools/internal_ci/linux/psm-security-python.sh index b69406c5812..a00900d0ea0 100755 --- a/tools/internal_ci/linux/psm-security-python.sh +++ b/tools/internal_ci/linux/psm-security-python.sh @@ -114,12 +114,19 @@ run_test() { # Test driver usage: # https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage local test_name="${1:?Usage: run_test test_name}" + + # testing_version is used by the framework to determine the supported PSM + # features. It's captured from Kokoro job name of the Core repo, which takes + # 2 forms: + # grpc/core/master/linux/... + # grpc/core/v1.42.x/branch/linux/... set -x python3 -m "tests.${test_name}" \ --flagfile="${TEST_DRIVER_FLAGFILE}" \ --kube_context="${KUBE_CONTEXT}" \ --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ + --testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \ --xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \ --force_cleanup \ --nocheck_local_certs diff --git a/tools/internal_ci/linux/psm-security.sh b/tools/internal_ci/linux/psm-security.sh index 6f29462d87b..350c0dd2286 100755 --- a/tools/internal_ci/linux/psm-security.sh +++ b/tools/internal_ci/linux/psm-security.sh @@ -99,12 +99,18 @@ run_test() { # Test driver usage: # https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage local test_name="${1:?Usage: run_test test_name}" + # testing_version is used by the framework to determine the supported PSM + # features. It's captured from Kokoro job name of the Core repo, which takes + # 2 forms: + # grpc/core/master/linux/... + # grpc/core/v1.42.x/branch/linux/... set -x python3 -m "tests.${test_name}" \ --flagfile="${TEST_DRIVER_FLAGFILE}" \ --kube_context="${KUBE_CONTEXT}" \ --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ + --testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \ --xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \ --force_cleanup \ --nocheck_local_certs diff --git a/tools/run_tests/xds_k8s_test_driver/framework/helpers/skips.py b/tools/run_tests/xds_k8s_test_driver/framework/helpers/skips.py new file mode 100644 index 00000000000..efea6b07726 --- /dev/null +++ b/tools/run_tests/xds_k8s_test_driver/framework/helpers/skips.py @@ -0,0 +1,67 @@ +# Copyright 2022 The gRPC Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The classes and predicates to assist validate test config for test cases.""" +from dataclasses import dataclass +import re +from typing import Callable +import unittest + +from packaging import version as pkg_version + +from framework import xds_flags +from framework import xds_k8s_flags + + +def _get_lang(image_name: str) -> str: + return re.search(r'/(\w+)-(client|server):', image_name).group(1) + + +def _parse_version(s: str) -> pkg_version.Version: + if s.endswith(".x"): + s = s[:-2] + return pkg_version.Version(s) + + +@dataclass +class TestConfig: + """Describes the config for the test suite.""" + client_lang: str + server_lang: str + version: str + + def version_ge(self, another: str) -> bool: + """Returns a bool for whether the version is >= another one. + + A version is greater than or equal to another version means its version + number is greater than or equal to another version's number. Version + "master" is always considered latest. E.g., master >= v1.41.x >= v1.40.x + >= v1.9.x. + """ + if self.version == 'master': + return True + return _parse_version(self.version) >= _parse_version(another) + + +def evaluate_test_config(check: Callable[[TestConfig], bool]) -> None: + """Evaluates the test config check against Abseil flags.""" + # NOTE(lidiz) a manual skip mechanism is needed because absl/flags + # cannot be used in the built-in test-skipping decorators. See the + # official FAQs: + # https://abseil.io/docs/python/guides/flags#faqs + test_config = TestConfig( + client_lang=_get_lang(xds_k8s_flags.CLIENT_IMAGE.value), + server_lang=_get_lang(xds_k8s_flags.SERVER_IMAGE.value), + version=xds_flags.TESTING_VERSION.value) + if not check(test_config): + raise unittest.SkipTest(f'Unsupported test config: {test_config}') diff --git a/tools/run_tests/xds_k8s_test_driver/framework/xds_k8s_testcase.py b/tools/run_tests/xds_k8s_test_driver/framework/xds_k8s_testcase.py index 6096e5fdcb1..82a451ca0df 100644 --- a/tools/run_tests/xds_k8s_test_driver/framework/xds_k8s_testcase.py +++ b/tools/run_tests/xds_k8s_test_driver/framework/xds_k8s_testcase.py @@ -29,6 +29,7 @@ from framework import xds_flags from framework import xds_k8s_flags from framework import xds_url_map_testcase from framework.helpers import retryers +from framework.helpers import skips import framework.helpers.rand from framework.infrastructure import gcp from framework.infrastructure import k8s @@ -78,11 +79,24 @@ class XdsKubernetesTestCase(absltest.TestCase, metaclass=abc.ABCMeta): td: TrafficDirectorManager config_scope: str + @staticmethod + def isSupported(config: skips.TestConfig) -> bool: + """Overrided by the test class to decide if the config is supported. + + Returns: + A bool indicates if the given config is supported. + """ + return True + @classmethod def setUpClass(cls): """Hook method for setting up class fixture before running tests in the class. """ + # Raises unittest.SkipTest if given client/server/version does not + # support current test case. + skips.evaluate_test_config(cls.isSupported) + # GCP cls.project: str = xds_flags.PROJECT.value cls.network: str = xds_flags.NETWORK.value diff --git a/tools/run_tests/xds_k8s_test_driver/framework/xds_url_map_testcase.py b/tools/run_tests/xds_k8s_test_driver/framework/xds_url_map_testcase.py index 8f5b00707e0..2d9ca9f73c0 100644 --- a/tools/run_tests/xds_k8s_test_driver/framework/xds_url_map_testcase.py +++ b/tools/run_tests/xds_k8s_test_driver/framework/xds_url_map_testcase.py @@ -21,7 +21,7 @@ import os import re import sys import time -from typing import Any, Iterable, Mapping, Optional, Tuple, Union +from typing import Any, Iterable, Mapping, Optional, Tuple import unittest from absl import flags @@ -29,12 +29,11 @@ from absl import logging from absl.testing import absltest from google.protobuf import json_format import grpc -import packaging.version from framework import xds_k8s_testcase from framework import xds_url_map_test_resources from framework.helpers import retryers -from framework.rpc import grpc_testing +from framework.helpers import skips from framework.test_app import client_app # Load existing flags @@ -70,10 +69,6 @@ def _split_camel(s: str, delimiter: str = '-') -> str: for c in s).lstrip(delimiter) -def _get_lang(image_name: str) -> str: - return re.search(r'/(\w+)-(client|server):', image_name).group(1) - - class DumpedXdsConfig(dict): """A convenience class to check xDS config. @@ -204,27 +199,6 @@ class ExpectedResult: ratio: float = 1 -@dataclass -class TestConfig: - """Describes the config for the test suite.""" - client_lang: str - server_lang: str - version: str - - def version_ge(self, another: str) -> bool: - """Returns a bool for whether the version is >= another one. - - A version is greater than or equal to another version means its version - number is greater than or equal to another version's number. Version - "master" is always considered latest. E.g., master >= v1.41.x >= v1.40.x - >= v1.9.x. - """ - if self.version == 'master': - return True - return packaging.version.parse( - self.version) >= packaging.version.parse(another) - - class _MetaXdsUrlMapTestCase(type): """Tracking test case subclasses.""" @@ -270,7 +244,7 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase): """ @staticmethod - def is_supported(config: TestConfig) -> bool: + def is_supported(config: skips.TestConfig) -> bool: """Allow the test case to decide whether it supports the given config. Returns: @@ -355,25 +329,15 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase): @classmethod def setUpClass(cls): + # Raises unittest.SkipTest if given client/server/version does not + # support current test case. + skips.evaluate_test_config(cls.is_supported) + if not cls.started_test_cases: # Create the GCP resource once before the first test start GcpResourceManager().setup(cls.test_case_classes) cls.started_test_cases.add(cls.__name__) - # NOTE(lidiz) a manual skip mechanism is needed because absl/flags - # cannot be used in the built-in test-skipping decorators. See the - # official FAQs: - # https://abseil.io/docs/python/guides/flags#faqs - test_config = TestConfig( - client_lang=_get_lang(GcpResourceManager().client_image), - server_lang=_get_lang(GcpResourceManager().server_image), - version=GcpResourceManager().testing_version) - if not cls.is_supported(test_config): - cls.skip_reason = f'Unsupported test config: {test_config}' - return - else: - cls.skip_reason = None - # Create the test case's own client runner with it's own namespace, # enables concurrent running with other test cases. cls.test_client_runner = GcpResourceManager().create_test_client_runner( @@ -390,9 +354,7 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase): @classmethod def tearDownClass(cls): - if cls.skip_reason is None: - # Clean up related resources for the client - cls.test_client_runner.cleanup(force=True, force_namespace=True) + cls.test_client_runner.cleanup(force=True, force_namespace=True) cls.finished_test_cases.add(cls.__name__) if cls.finished_test_cases == cls.test_case_names: # Tear down the GCP resource after all tests finished @@ -422,9 +384,6 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase): super().run(result) def test_client_config(self): - if self.skip_reason: - logging.info('Skipping: %s', self.skip_reason) - self.skipTest(self.skip_reason) retryer = retryers.constant_retryer( wait_fixed=datetime.timedelta( seconds=_URL_MAP_PROPAGATE_CHECK_INTERVAL_SEC), @@ -440,9 +399,6 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase): self._xds_json_config)) def test_rpc_distribution(self): - if self.skip_reason: - logging.info('Skipping: %s', self.skip_reason) - self.skipTest(self.skip_reason) self.rpc_distribution_validate(self.test_client) @staticmethod diff --git a/tools/run_tests/xds_k8s_test_driver/tests/affinity_test.py b/tools/run_tests/xds_k8s_test_driver/tests/affinity_test.py index bc93c6c10cb..6032eb3d902 100644 --- a/tools/run_tests/xds_k8s_test_driver/tests/affinity_test.py +++ b/tools/run_tests/xds_k8s_test_driver/tests/affinity_test.py @@ -21,7 +21,7 @@ from google.protobuf import json_format from framework import xds_k8s_testcase from framework import xds_url_map_testcase -from framework.helpers import retryers +from framework.helpers import skips from framework.infrastructure import k8s from framework.rpc import grpc_channelz from framework.test_app import server_app @@ -44,6 +44,12 @@ _RPC_COUNT = 100 class AffinityTest(xds_k8s_testcase.RegularXdsKubernetesTestCase): + @staticmethod + def isSupported(config: skips.TestConfig) -> bool: + if config.client_lang in ['cpp', 'java', 'python', 'go']: + return config.version_ge('v1.40.x') + return False + def test_affinity(self) -> None: with self.subTest('00_create_health_check'): diff --git a/tools/run_tests/xds_k8s_test_driver/tests/authz_test.py b/tools/run_tests/xds_k8s_test_driver/tests/authz_test.py index ec0691eb6a7..47efa4399ab 100644 --- a/tools/run_tests/xds_k8s_test_driver/tests/authz_test.py +++ b/tools/run_tests/xds_k8s_test_driver/tests/authz_test.py @@ -21,6 +21,7 @@ from absl.testing import absltest import grpc from framework import xds_k8s_testcase +from framework.helpers import skips flags.adopt_module_key_flags(xds_k8s_testcase) @@ -45,6 +46,14 @@ class AuthzTest(xds_k8s_testcase.SecurityXdsKubernetesTestCase): 'EMPTY_CALL': 'UNARY_CALL', } + @staticmethod + def isSupported(config: skips.TestConfig) -> bool: + if config.client_lang in ['cpp', 'python']: + return config.version_ge('v1.44.x') + elif config.client_lang in ['java', 'go']: + return config.version_ge('v1.42.x') + return False + def setUp(self): super().setUp() self.next_rpc_type: Optional[int] = None diff --git a/tools/run_tests/xds_k8s_test_driver/tests/security_test.py b/tools/run_tests/xds_k8s_test_driver/tests/security_test.py index a4c71498e76..0d70f3083df 100644 --- a/tools/run_tests/xds_k8s_test_driver/tests/security_test.py +++ b/tools/run_tests/xds_k8s_test_driver/tests/security_test.py @@ -18,6 +18,7 @@ from absl.testing import absltest from framework import xds_k8s_testcase from framework.helpers import rand +from framework.helpers import skips logger = logging.getLogger(__name__) flags.adopt_module_key_flags(xds_k8s_testcase) @@ -30,6 +31,12 @@ _SecurityMode = xds_k8s_testcase.SecurityXdsKubernetesTestCase.SecurityMode class SecurityTest(xds_k8s_testcase.SecurityXdsKubernetesTestCase): + @staticmethod + def isSupported(config: skips.TestConfig) -> bool: + if config.client_lang in ['cpp', 'python', 'go']: + return config.version_ge('v1.41.x') + return False + def test_mtls(self): """mTLS test. diff --git a/tools/run_tests/xds_k8s_test_driver/tests/url_map/affinity_test.py b/tools/run_tests/xds_k8s_test_driver/tests/url_map/affinity_test.py index 504126efd2f..7eefa2d241b 100644 --- a/tools/run_tests/xds_k8s_test_driver/tests/url_map/affinity_test.py +++ b/tools/run_tests/xds_k8s_test_driver/tests/url_map/affinity_test.py @@ -12,14 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -import time from typing import Tuple from absl import flags from absl.testing import absltest -from framework import xds_k8s_flags from framework import xds_url_map_testcase +from framework.helpers import skips from framework.infrastructure import traffic_director from framework.rpc import grpc_channelz from framework.test_app import client_app @@ -31,7 +30,6 @@ GcpResourceManager = xds_url_map_testcase.GcpResourceManager DumpedXdsConfig = xds_url_map_testcase.DumpedXdsConfig RpcTypeUnaryCall = xds_url_map_testcase.RpcTypeUnaryCall RpcTypeEmptyCall = xds_url_map_testcase.RpcTypeEmptyCall -TestConfig = xds_url_map_testcase.TestConfig XdsTestClient = client_app.XdsTestClient logger = logging.getLogger(__name__) @@ -57,7 +55,7 @@ _ChannelzChannelState = grpc_channelz.ChannelState class TestHeaderBasedAffinity(xds_url_map_testcase.XdsUrlMapTestCase): @staticmethod - def is_supported(config: TestConfig) -> bool: + def is_supported(config: skips.TestConfig) -> bool: if config.client_lang in ['cpp', 'java']: return config.version_ge('v1.40.x') if config.client_lang in ['go']: @@ -126,7 +124,7 @@ class TestHeaderBasedAffinityMultipleHeaders( xds_url_map_testcase.XdsUrlMapTestCase): @staticmethod - def is_supported(config: TestConfig) -> bool: + def is_supported(config: skips.TestConfig) -> bool: if config.client_lang in ['cpp', 'java']: return config.version_ge('v1.40.x') if config.client_lang in ['go']: diff --git a/tools/run_tests/xds_k8s_test_driver/tests/url_map/retry_test.py b/tools/run_tests/xds_k8s_test_driver/tests/url_map/retry_test.py index b3eef2dbadf..28c28739dcc 100644 --- a/tools/run_tests/xds_k8s_test_driver/tests/url_map/retry_test.py +++ b/tools/run_tests/xds_k8s_test_driver/tests/url_map/retry_test.py @@ -19,8 +19,8 @@ from absl import flags from absl.testing import absltest import grpc -from framework import xds_k8s_flags from framework import xds_url_map_testcase +from framework.helpers import skips from framework.test_app import client_app # Type aliases @@ -31,7 +31,6 @@ DumpedXdsConfig = xds_url_map_testcase.DumpedXdsConfig RpcTypeUnaryCall = xds_url_map_testcase.RpcTypeUnaryCall XdsTestClient = client_app.XdsTestClient ExpectedResult = xds_url_map_testcase.ExpectedResult -TestConfig = xds_url_map_testcase.TestConfig logger = logging.getLogger(__name__) flags.adopt_module_key_flags(xds_url_map_testcase) @@ -67,7 +66,7 @@ def _build_retry_route_rule(retryConditions, num_retries): class TestRetryUpTo3AttemptsAndFail(xds_url_map_testcase.XdsUrlMapTestCase): @staticmethod - def is_supported(config: TestConfig) -> bool: + def is_supported(config: skips.TestConfig) -> bool: if config.client_lang in ['cpp', 'java', 'python']: return config.version_ge('v1.40.x') elif config.client_lang == 'go': @@ -110,7 +109,7 @@ class TestRetryUpTo3AttemptsAndFail(xds_url_map_testcase.XdsUrlMapTestCase): class TestRetryUpTo4AttemptsAndSucceed(xds_url_map_testcase.XdsUrlMapTestCase): @staticmethod - def is_supported(config: TestConfig) -> bool: + def is_supported(config: skips.TestConfig) -> bool: if config.client_lang in ['cpp', 'java', 'python']: return config.version_ge('v1.40.x') elif config.client_lang == 'go': diff --git a/tools/run_tests/xds_k8s_test_driver/tests/url_map/timeout_test.py b/tools/run_tests/xds_k8s_test_driver/tests/url_map/timeout_test.py index 33f4f431c71..70c580d6bbb 100644 --- a/tools/run_tests/xds_k8s_test_driver/tests/url_map/timeout_test.py +++ b/tools/run_tests/xds_k8s_test_driver/tests/url_map/timeout_test.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -import time from typing import Tuple import unittest @@ -20,8 +19,8 @@ from absl import flags from absl.testing import absltest import grpc -from framework import xds_k8s_flags from framework import xds_url_map_testcase +from framework.helpers import skips from framework.test_app import client_app # Type aliases @@ -34,7 +33,6 @@ RpcTypeEmptyCall = xds_url_map_testcase.RpcTypeEmptyCall ExpectedResult = xds_url_map_testcase.ExpectedResult XdsTestClient = client_app.XdsTestClient XdsUrlMapTestCase = xds_url_map_testcase.XdsUrlMapTestCase -TestConfig = xds_url_map_testcase.TestConfig logger = logging.getLogger(__name__) flags.adopt_module_key_flags(xds_url_map_testcase) @@ -82,7 +80,7 @@ class _BaseXdsTimeOutTestCase(XdsUrlMapTestCase): class TestTimeoutInRouteRule(_BaseXdsTimeOutTestCase): @staticmethod - def is_supported(config: TestConfig) -> bool: + def is_supported(config: skips.TestConfig) -> bool: # TODO(lidiz) either add support for rpc-behavior to other languages, or we # should always use Java server as backend. return config.server_lang == 'java' @@ -113,7 +111,7 @@ class TestTimeoutInRouteRule(_BaseXdsTimeOutTestCase): class TestTimeoutInApplication(_BaseXdsTimeOutTestCase): @staticmethod - def is_supported(config: TestConfig) -> bool: + def is_supported(config: skips.TestConfig) -> bool: return config.server_lang == 'java' def rpc_distribution_validate(self, test_client: XdsTestClient):