Merge pull request #25115 from menghanl/xds_missing_matching_tests

pull/25221/head
Menghan Li 4 years ago committed by GitHub
commit 874eaae07f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 77
      tools/run_tests/run_xds_tests.py

@ -285,6 +285,9 @@ _TESTS_TO_SEND_METADATA = ['header_matching']
_TEST_METADATA_KEY = 'xds_md'
_TEST_METADATA_VALUE_UNARY = 'unary_yranu'
_TEST_METADATA_VALUE_EMPTY = 'empty_ytpme'
# Extra RPC metadata whose value is a number, sent with UnaryCall only.
_TEST_METADATA_NUMERIC_KEY = 'xds_md_numeric'
_TEST_METADATA_NUMERIC_VALUE = '159'
_PATH_MATCHER_NAME = 'path-matcher'
_BASE_TEMPLATE_NAME = 'test-template'
_BASE_INSTANCE_GROUP_NAME = 'test-ig'
@ -1158,26 +1161,90 @@ def test_header_matching(gcp, original_backend_service, instance_group,
"EmptyCall": alternate_backend_instances,
"UnaryCall": original_backend_instances
}),
(
[{
'priority': 0,
# Header 'xds_md_numeric' present -> alternate_backend_service.
# UnaryCall is sent with the metadata, so will be sent to alternative.
'matchRules': [{
'prefixMatch':
'/',
'headerMatches': [{
'headerName': _TEST_METADATA_NUMERIC_KEY,
'presentMatch': True
}]
}],
'service': alternate_backend_service.url
}],
{
"EmptyCall": original_backend_instances,
"UnaryCall": alternate_backend_instances
}),
(
[{
'priority': 0,
# Header invert ExactMatch -> alternate_backend_service.
# EmptyCall is sent with the metadata, so will be sent to original.
# UnaryCall is sent with the metadata, so will be sent to
# original. EmptyCall will be sent to alternative.
'matchRules': [{
'prefixMatch':
'/',
'headerMatches': [{
'headerName': _TEST_METADATA_KEY,
'exactMatch': _TEST_METADATA_VALUE_EMPTY,
'exactMatch': _TEST_METADATA_VALUE_UNARY,
'invertMatch': True
}]
}],
'service': alternate_backend_service.url
}],
{
"EmptyCall": alternate_backend_instances,
"UnaryCall": original_backend_instances
}),
(
[{
'priority': 0,
# Header 'xds_md_numeric' range [100,200] -> alternate_backend_service.
# UnaryCall is sent with the metadata in range.
'matchRules': [{
'prefixMatch':
'/',
'headerMatches': [{
'headerName': _TEST_METADATA_NUMERIC_KEY,
'rangeMatch': {
'rangeStart': '100',
'rangeEnd': '200'
}
}]
}],
'service': alternate_backend_service.url
}],
{
"EmptyCall": original_backend_instances,
"UnaryCall": alternate_backend_instances
}),
(
[{
'priority': 0,
# Header RegexMatch -> alternate_backend_service.
# EmptyCall is sent with the metadata.
'matchRules': [{
'prefixMatch':
'/',
'headerMatches': [{
'headerName':
_TEST_METADATA_KEY,
'regexMatch':
"^%s.*%s$" % (_TEST_METADATA_VALUE_EMPTY[:2],
_TEST_METADATA_VALUE_EMPTY[-2:])
}]
}],
'service': alternate_backend_service.url
}],
{
"EmptyCall": alternate_backend_instances,
"UnaryCall": original_backend_instances
}),
]
for (route_rules, expected_instances) in test_cases:
@ -2214,11 +2281,13 @@ try:
rpcs_to_send = '--rpc="UnaryCall"'
if test_case in _TESTS_TO_SEND_METADATA:
metadata_to_send = '--metadata="EmptyCall:{keyE}:{valueE},UnaryCall:{keyU}:{valueU}"'.format(
metadata_to_send = '--metadata="EmptyCall:{keyE}:{valueE},UnaryCall:{keyU}:{valueU},UnaryCall:{keyNU}:{valueNU}"'.format(
keyE=_TEST_METADATA_KEY,
valueE=_TEST_METADATA_VALUE_EMPTY,
keyU=_TEST_METADATA_KEY,
valueU=_TEST_METADATA_VALUE_UNARY)
valueU=_TEST_METADATA_VALUE_UNARY,
keyNU=_TEST_METADATA_NUMERIC_KEY,
valueNU=_TEST_METADATA_NUMERIC_VALUE)
else:
# Setting the arg explicitly to empty with '--metadata=""'
# makes C# client fail

Loading…
Cancel
Save