|
|
|
@ -29,6 +29,7 @@ from absl import logging |
|
|
|
|
from absl.testing import absltest |
|
|
|
|
from google.protobuf import json_format |
|
|
|
|
import grpc |
|
|
|
|
import packaging |
|
|
|
|
|
|
|
|
|
from framework import xds_k8s_testcase |
|
|
|
|
from framework import xds_url_map_test_resources |
|
|
|
@ -62,10 +63,6 @@ JsonType = Any |
|
|
|
|
RpcTypeUnaryCall = 'UNARY_CALL' |
|
|
|
|
RpcTypeEmptyCall = 'EMPTY_CALL' |
|
|
|
|
|
|
|
|
|
# All client languages |
|
|
|
|
_CLIENT_LANGUAGES = ('cpp', 'java', 'go', 'python') |
|
|
|
|
_SERVER_LANGUAGES = _CLIENT_LANGUAGES |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _split_camel(s: str, delimiter: str = '-') -> str: |
|
|
|
|
"""Turn camel case name to snake-case-like name.""" |
|
|
|
@ -188,6 +185,27 @@ 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.""" |
|
|
|
|
|
|
|
|
@ -233,22 +251,13 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase): |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def supported_clients() -> Tuple[str]: |
|
|
|
|
"""Declare supported languages of clients. |
|
|
|
|
def is_supported(config: TestConfig) -> bool: |
|
|
|
|
"""Allow the test case to decide whether it supports the given config. |
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
|
A tuple of strings contains the supported languages for this test. |
|
|
|
|
A bool indicates if the given config is supported. |
|
|
|
|
""" |
|
|
|
|
return _CLIENT_LANGUAGES |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def supported_servers() -> Tuple[str]: |
|
|
|
|
"""Declare supported languages of servers. |
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
|
A tuple of strings contains the supported languages for this test. |
|
|
|
|
""" |
|
|
|
|
return _SERVER_LANGUAGES |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def client_init_config(rpc: str, metadata: str) -> Tuple[str, str]: |
|
|
|
@ -336,15 +345,12 @@ class XdsUrlMapTestCase(absltest.TestCase, metaclass=_MetaXdsUrlMapTestCase): |
|
|
|
|
# cannot be used in the built-in test-skipping decorators. See the |
|
|
|
|
# official FAQs: |
|
|
|
|
# https://abseil.io/docs/python/guides/flags#faqs |
|
|
|
|
client_lang = _get_lang(GcpResourceManager().client_image) |
|
|
|
|
server_lang = _get_lang(GcpResourceManager().server_image) |
|
|
|
|
if client_lang not in cls.supported_clients(): |
|
|
|
|
cls.skip_reason = (f'Unsupported client language {client_lang} ' |
|
|
|
|
f'not in {cls.supported_clients()}') |
|
|
|
|
return |
|
|
|
|
elif server_lang not in cls.supported_servers(): |
|
|
|
|
cls.skip_reason = (f'Unsupported server language {server_lang} ' |
|
|
|
|
f'not in {cls.supported_servers()}') |
|
|
|
|
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 |
|
|
|
|