Skip to content

Commit fa575fe

Browse files
committed
run_interop_matrix_tests.py fixes
1 parent f489b9b commit fa575fe

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

tools/interop_matrix/run_interop_matrix_tests.py

+27-17
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ def _read_test_cases_file(lang, runtime, release):
131131
# Check to see if we need to use a particular version of test cases.
132132
release_info = client_matrix.LANG_RELEASE_MATRIX[lang].get(release)
133133
if release_info:
134-
testcases_file = release_info.testcases_files
135-
else:
134+
testcases_file = release_info.testcases_file
135+
if not testcases_file:
136136
# TODO(jtattermusch): remove the double-underscore, it is pointless
137137
testcases_file = '%s__master' % lang
138138

139139
# For csharp, the testcases file used depends on the runtime
140140
# TODO(jtattermusch): remove this odd specialcase
141141
if lang == 'csharp' and runtime == 'csharpcoreclr':
142-
testcases_file.replace('csharp_', 'csharpcoreclr_')
142+
testcases_file = testcases_file.replace('csharp_', 'csharpcoreclr_')
143143

144144
testcases_filepath = os.path.join(
145145
os.path.dirname(__file__), 'testcases', testcases_file)
@@ -171,25 +171,35 @@ def _generate_test_case_jobspecs(lang, runtime, release, suite_name):
171171
for line in testcase_lines:
172172
# TODO(jtattermusch): revisit the logic for updating test case commands
173173
# what it currently being done seems fragile.
174-
m = re.search('--test_case=(.*)"', line)
175-
shortname = m.group(1) if m else 'unknown_test'
176-
m = re.search('--server_host_override=(.*).sandbox.googleapis.com',
177-
line)
174+
175+
# Extract test case name from the command line
176+
m = re.search(r'--test_case=(\w+)', line)
177+
testcase_name = m.group(1) if m else 'unknown_test'
178+
179+
# Extract the server name from the command line
180+
if '--server_host_override=' in line:
181+
m = re.search(
182+
r'--server_host_override=((.*).sandbox.googleapis.com)', line)
183+
else:
184+
m = re.search(r'--server_host=((.*).sandbox.googleapis.com)', line)
178185
server = m.group(1) if m else 'unknown_server'
186+
server_short = m.group(2) if m else 'unknown_server'
187+
188+
# replace original server_host argument
189+
assert '--server_host=' in line
190+
line = re.sub(r'--server_host=[^ ]*',
191+
r'--server_host=%s' % args.server_host, line)
179192

180-
# If server_host arg is not None, replace the original
181-
# server_host with the one provided or append to the end of
182-
# the command if server_host does not appear originally.
183-
if args.server_host:
184-
if line.find('--server_host=') > -1:
185-
line = re.sub('--server_host=[^ ]*',
186-
'--server_host=%s' % args.server_host, line)
187-
else:
188-
line = '%s --server_host=%s"' % (line[:-1], args.server_host)
193+
# some interop tests don't set server_host_override (see #17407),
194+
# but we need to use it if different host is set via cmdline args.
195+
if args.server_host != server and not '--server_host_override=' in line:
196+
line = re.sub(r'(--server_host=[^ ]*)',
197+
r'\1 --server_host_override=%s' % server, line)
189198

190199
spec = jobset.JobSpec(
191200
cmdline=line,
192-
shortname='%s:%s:%s:%s' % (suite_name, lang, server, shortname),
201+
shortname='%s:%s:%s:%s' % (suite_name, lang, server_short,
202+
testcase_name),
193203
timeout_seconds=_TEST_TIMEOUT_SECONDS,
194204
shell=True,
195205
flake_retries=5 if args.allow_flakes else 0)

0 commit comments

Comments
 (0)