Skip to content

Commit

Permalink
Support func test zaza overlays
Browse files Browse the repository at this point in the history
Some charms define overlays in tests.yaml that map to
a job in osci.yaml.
  • Loading branch information
dosaboy committed Sep 27, 2024
1 parent 7cc5c23 commit f6cd34f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions openstack/tools/charmed_openstack_functest_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ for target in ${!func_targets[@]}; do
fi
[[ -d src ]] && pushd src &>/dev/null || true
fail=false
# Remove substitutions and replace with whitespace
target=${target//+/ }
if ! $MANUAL_FUNCTESTS; then
tox ${tox_args} -- $target || fail=true
model=`juju list-models| egrep -o "^zaza-\S+"|tr -d '*'`
Expand Down
33 changes: 24 additions & 9 deletions openstack/tools/func_test_tools/identify_charm_func_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ def extract_targets(bundle_list):
extracted = []
for item in bundle_list or []:
if isinstance(item, dict):
extracted.append(list(item.values())[0])
values = list(item.values())
if isinstance(values, list):
# these are overlays so we use the key name
bundle = list(item.keys())[0]
extracted.append(bundle)
else:
# its a bundle name
extracted.append(values[0])
else:
extracted.append(item)

return extracted


def get_aliased_targets():
def get_aliased_targets(bundles):
"""
Extract aliased targets. A charm can define aliased targets which is where
Zaza tests are run and use configuration steps from an alias section rather
Expand All @@ -38,23 +45,31 @@ def get_aliased_targets():
job definition in osci.yaml where the target name has a <alias>: prefix.
We extract any aliased targets here and return as a list.
@param bundles: list of extracted bundles
"""
targets = []
osci = OSCIConfig()
for jobname in osci.project_check_jobs:
jobs = list(osci.project_check_jobs) + bundles
for jobname in jobs:
for job in osci.jobs:
if job['name'] != jobname:
continue

if 'tox_extra_args' not in job['vars']:
continue

ret = re.search(r"-- (\S+:\S+)",
ret = re.search(r"-- (.+)",
str(job['vars']['tox_extra_args']))
if ret:
targets.append(ret.group(1))
target = ret.group(1)
# NOTE: will need to reverse this when we use the target name
target = target.replace(' ', '+')
targets.append(target)
if jobname in bundles:
bundles.remove(jobname)

return targets
return targets + bundles


def get_tests_bundles():
Expand All @@ -76,6 +91,6 @@ def get_tests_bundles():


if __name__ == "__main__":
aliased_bundles = get_aliased_targets()
tests_bundles = get_tests_bundles()
print(' '.join(sorted(set(tests_bundles + aliased_bundles))))
_bundles = get_tests_bundles()
_bundles = get_aliased_targets(_bundles)
print(' '.join(sorted(_bundles)))

0 comments on commit f6cd34f

Please sign in to comment.