Ensure valid formatting of LoadTest names. (#26477)

Names must consist of lowercase alphanumeric characters and dashes, start with an alphabetical character, and not end with a dash.
reviewable/pr26471/r3^2
Paulo Castello da Costa 3 years ago committed by GitHub
parent f90716a821
commit 22cbc3a388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      tools/run_tests/performance/loadtest_config.py

@ -66,8 +66,10 @@ def validate_loadtest_name(name: str) -> None:
if len(name) > 253:
raise ValueError(
'LoadTest name must be less than 253 characters long: %s' % name)
if not all((s.isalnum() for s in name.split('-'))):
raise ValueError('Invalid elements in LoadTest name: %s' % name)
if not all(c.isalnum() and not c.isupper() for c in name if c != '-'):
raise ValueError('Invalid characters in LoadTest name: %s' % name)
if not name or not name[0].isalpha() or name[-1] == '-':
raise ValueError('Invalid format for LoadTest name: %s' % name)
def loadtest_base_name(scenario_name: str,
@ -75,7 +77,7 @@ def loadtest_base_name(scenario_name: str,
"""Constructs and returns the base name for a LoadTest resource."""
name_elements = scenario_name.split('_')
name_elements.extend(uniquifier_elements)
return '-'.join(name_elements)
return '-'.join(element.lower() for element in name_elements)
def loadtest_name(prefix: str, scenario_name: str,

Loading…
Cancel
Save