From 6e0b6fb0747b045e97e915e9ff9aeeb80c4c7f40 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 25 May 2020 19:49:29 +0200 Subject: Support identifying different tgz files based on run_label attribute tgz files in trials can be categorized in subdirectories, allowing to select different bianry files at runtime based on the target run node which is going to run them. This way for instance one can have a binary linked against libs for eg. CentOS under run_label "centos/" or an ARM target under "arm", and then use "run_label: arm" on the resource using it. Change-Id: Iaf2e97da3aff693395f44f0e93b184d4846cf6da --- selftest/Makefile | 1 + selftest/trial_test/run_label/checksums.md5 | 2 ++ selftest/trial_test/run_label/foobar/sample.tar.gz | Bin 0 -> 131 bytes selftest/trial_test/run_label/sample.tar.gz | Bin 0 -> 128 bytes selftest/trial_test/trial_test.ok | 9 +++++++++ selftest/trial_test/trial_test.ok.ign | 2 +- selftest/trial_test/trial_test.py | 17 ++++++++++++++++- 7 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 selftest/trial_test/run_label/checksums.md5 create mode 100644 selftest/trial_test/run_label/foobar/sample.tar.gz create mode 100644 selftest/trial_test/run_label/sample.tar.gz (limited to 'selftest') diff --git a/selftest/Makefile b/selftest/Makefile index fb8618c..53d882c 100644 --- a/selftest/Makefile +++ b/selftest/Makefile @@ -12,6 +12,7 @@ set_pythonpath: clean: @find . -name "*__pycache__" -type d -print0 | xargs -0 rm -rvf @find . -name "*test_work" -type d -print0 | xargs -0 rm -rvf + @rm -rfv ./trial_test/run_label/inst @rm -fv ./set_pythonpath # vim: noexpandtab tabstop=8 shiftwidth=8 diff --git a/selftest/trial_test/run_label/checksums.md5 b/selftest/trial_test/run_label/checksums.md5 new file mode 100644 index 0000000..a162c56 --- /dev/null +++ b/selftest/trial_test/run_label/checksums.md5 @@ -0,0 +1,2 @@ +b13c9c94d41c45caaa08ad9ad3ee0f11 sample.tar.gz +430ec62329747b5f15fe6e2cb141b909 foobar/sample.tar.gz diff --git a/selftest/trial_test/run_label/foobar/sample.tar.gz b/selftest/trial_test/run_label/foobar/sample.tar.gz new file mode 100644 index 0000000..2c1b029 Binary files /dev/null and b/selftest/trial_test/run_label/foobar/sample.tar.gz differ diff --git a/selftest/trial_test/run_label/sample.tar.gz b/selftest/trial_test/run_label/sample.tar.gz new file mode 100644 index 0000000..3932964 Binary files /dev/null and b/selftest/trial_test/run_label/sample.tar.gz differ diff --git a/selftest/trial_test/trial_test.ok b/selftest/trial_test/trial_test.ok index 8c6a567..75bd1a7 100644 --- a/selftest/trial_test/trial_test.ok +++ b/selftest/trial_test/trial_test.ok @@ -14,3 +14,12 @@ None ok, got RuntimeError: Checksum mismatch for '[PATH]/trial_test/invalid_checksum/file2' vs. '[PATH]/trial_test/invalid_checksum/checksums.md5' line 2 - detect missing file ok, got RuntimeError: File listed in checksums file but missing in trials dir: '[PATH]/trial_test/missing_file/file2' vs. '[PATH]/trial_test/missing_file/checksums.md5' line 2 +- Verify trials based on run_label +tst run_label: DBG: has bin_tar {bin_name='sample', matches=['sample.tar.gz'], run_label='foobar'} +inst: [PATH]/trial_test/run_label/inst/foobar/sample +content file2: subhello + +tst run_label: DBG: has bin_tar {bin_name='sample', matches=['sample.tar.gz'], run_label=''} +inst: [PATH]/trial_test/run_label/inst/sample +content file1: hello + diff --git a/selftest/trial_test/trial_test.ok.ign b/selftest/trial_test/trial_test.ok.ign index 1a969de..46c3943 100644 --- a/selftest/trial_test/trial_test.ok.ign +++ b/selftest/trial_test/trial_test.ok.ign @@ -1,3 +1,3 @@ /tmp/[^/]* [TMP] ....-..-.._..-..-.. [TIMESTAMP] -'[^']*/trial_test '[PATH]/trial_test +/[^ ]*/trial_test/ [PATH]/trial_test/ diff --git a/selftest/trial_test/trial_test.py b/selftest/trial_test/trial_test.py index a99428a..cf91a85 100755 --- a/selftest/trial_test/trial_test.py +++ b/selftest/trial_test/trial_test.py @@ -1,8 +1,10 @@ #!/usr/bin/env python3 -import time import _prep + +import time import os + from osmo_gsm_tester.core import util from osmo_gsm_tester.core.trial import Trial @@ -46,4 +48,17 @@ try: except RuntimeError as e: print('ok, got RuntimeError: %s' % str(e)) +print('- Verify trials based on run_label') +d = util.Dir('trial_test') +t = Trial(d.child('run_label')) +t.verify() +inst = util.Dir(t.get_inst('sample', 'foobar')) +print('inst: ' + str(inst)) +with open(inst.child('file2'), 'r') as f: + print('content file2: %s' % f.read()) +inst = util.Dir( t.get_inst('sample')) +print('inst: ' + str(inst)) +with open(inst.child('file1'), 'r') as f: + print('content file1: %s' % f.read()) + # vim: expandtab tabstop=4 shiftwidth=4 -- cgit v1.2.3