Refactor test specific config parsing & generation
The dictionary is generated once during test creation at suite startup. Change-Id: I4de511d64ccf65d2ec6eec45dcf28529b74c5d26
This commit is contained in:
parent
444129ee1f
commit
a75f85a058
|
@ -27,6 +27,8 @@ resources:
|
||||||
- times: '2'
|
- times: '2'
|
||||||
|
|
||||||
- run hello world test
|
- run hello world test
|
||||||
|
tst test_suite: DBG: {combining='config'}
|
||||||
|
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [test_suite↪{combining_scenarios='config'}]
|
||||||
|
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trial test_suite
|
trial test_suite
|
||||||
|
@ -179,6 +181,9 @@ FAIL: test_suite (fail: 1, skip: 6)
|
||||||
FAIL: test_fail_raise.py (N.N sec) ExpectedFail: This failure is expected
|
FAIL: test_fail_raise.py (N.N sec) ExpectedFail: This failure is expected
|
||||||
skip: test_suite_params.py
|
skip: test_suite_params.py
|
||||||
- test with half empty scenario
|
- test with half empty scenario
|
||||||
|
tst test_suite: DBG: {combining='config'} [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [test_suite↪{combining_scenarios='config'}] [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config', scenario='foo'}: DBG: {conf={}, scenario='foo'} [test_suite↪{combining_scenarios='config', scenario='foo'}] [suite.py:[LINENR]]
|
||||||
|
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trial test_suite
|
trial test_suite
|
||||||
|
@ -265,6 +270,9 @@ PASS: test_suite (pass: 1, skip: 6)
|
||||||
skip: test_fail_raise.py
|
skip: test_fail_raise.py
|
||||||
skip: test_suite_params.py
|
skip: test_suite_params.py
|
||||||
- test with scenario
|
- test with scenario
|
||||||
|
tst test_suite: DBG: {combining='config'} [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [test_suite↪{combining_scenarios='config'}] [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config', scenario='foo'}: DBG: {conf={}, scenario='foo'} [test_suite↪{combining_scenarios='config', scenario='foo'}] [suite.py:[LINENR]]
|
||||||
|
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trial test_suite
|
trial test_suite
|
||||||
|
@ -351,6 +359,9 @@ PASS: test_suite (pass: 1, skip: 6)
|
||||||
skip: test_fail_raise.py
|
skip: test_fail_raise.py
|
||||||
skip: test_suite_params.py
|
skip: test_suite_params.py
|
||||||
- test with scenario and modifiers
|
- test with scenario and modifiers
|
||||||
|
tst test_suite: DBG: {combining='config'} [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [test_suite↪{combining_scenarios='config'}] [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config', scenario='foo'}: DBG: {conf={}, scenario='foo'} [test_suite↪{combining_scenarios='config', scenario='foo'}] [suite.py:[LINENR]]
|
||||||
tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ... [suite.py:[LINENR]]
|
tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ... [suite.py:[LINENR]]
|
||||||
tst test_suite: DBG: {combining='resources'} [suite.py:[LINENR]]
|
tst test_suite: DBG: {combining='resources'} [suite.py:[LINENR]]
|
||||||
tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'label': 'sysmoCell 5000'}, {'label': 'sysmoCell 5000'}, {'type': 'sysmo'}], ip_address=[{}], modem=[{}, {}]}} [test_suite↪{combining_scenarios='resources'}] [suite.py:[LINENR]]
|
tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'label': 'sysmoCell 5000'}, {'label': 'sysmoCell 5000'}, {'type': 'sysmo'}], ip_address=[{}], modem=[{}, {}]}} [test_suite↪{combining_scenarios='resources'}] [suite.py:[LINENR]]
|
||||||
|
@ -483,6 +494,9 @@ PASS: test_suite (pass: 1, skip: 6)
|
||||||
skip: test_fail_raise.py
|
skip: test_fail_raise.py
|
||||||
skip: test_suite_params.py
|
skip: test_suite_params.py
|
||||||
- test with suite-specific config
|
- test with suite-specific config
|
||||||
|
tst test_suite: DBG: {combining='config'} [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [test_suite↪{combining_scenarios='config'}] [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config', scenario='foo'}: DBG: {conf={suite={test_suite={some_suite_global_param='heyho', test_suite_params={one_bool_parameter='true', second_list_parameter=['23', '45']}}}}, scenario='foo'} [test_suite↪{combining_scenarios='config', scenario='foo'}] [suite.py:[LINENR]]
|
||||||
tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ... [suite.py:[LINENR]]
|
tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ... [suite.py:[LINENR]]
|
||||||
tst test_suite: DBG: {combining='resources'} [suite.py:[LINENR]]
|
tst test_suite: DBG: {combining='resources'} [suite.py:[LINENR]]
|
||||||
tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'label': 'sysmoCell 5000'}, {'label': 'sysmoCell 5000'}, {'type': 'sysmo'}], ip_address=[{}], modem=[{}, {}]}} [test_suite↪{combining_scenarios='resources'}] [suite.py:[LINENR]]
|
tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'label': 'sysmoCell 5000'}, {'label': 'sysmoCell 5000'}, {'type': 'sysmo'}], ip_address=[{}], modem=[{}, {}]}} [test_suite↪{combining_scenarios='resources'}] [suite.py:[LINENR]]
|
||||||
|
@ -598,9 +612,6 @@ trial test_suite
|
||||||
trial test_suite test_suite_params.py
|
trial test_suite test_suite_params.py
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
tst test_suite_params.py:[LINENR]: starting test [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
tst test_suite_params.py:[LINENR]: starting test [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
||||||
tst test_suite: DBG: {combining='config'} [suite.py:[LINENR]]
|
|
||||||
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [test_suite↪{combining_scenarios='config'}] [suite.py:[LINENR]]
|
|
||||||
tst {combining_scenarios='config', scenario='foo'}: DBG: {conf={suite={test_suite={some_suite_global_param='heyho', test_suite_params={one_bool_parameter='true', second_list_parameter=['23', '45']}}}}, scenario='foo'} [test_suite↪{combining_scenarios='config', scenario='foo'}] [suite.py:[LINENR]]
|
|
||||||
tst test_suite_params.py:[LINENR]: SPECIFIC SUITE CONFIG: {'some_suite_global_param': 'heyho', [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
tst test_suite_params.py:[LINENR]: SPECIFIC SUITE CONFIG: {'some_suite_global_param': 'heyho', [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
||||||
tst test_suite_params.py:[LINENR]: 'test_suite_params': {'one_bool_parameter': 'true', [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
tst test_suite_params.py:[LINENR]: 'test_suite_params': {'one_bool_parameter': 'true', [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
||||||
tst test_suite_params.py:[LINENR]: 'second_list_parameter': ['23', '45']}} [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
tst test_suite_params.py:[LINENR]: 'second_list_parameter': ['23', '45']}} [test_suite↪test_suite_params.py:[LINENR]] [test_suite_params.py:[LINENR]]
|
||||||
|
@ -619,6 +630,8 @@ PASS: test_suite (pass: 1, skip: 6)
|
||||||
pass: test_suite_params.py (N.N sec)
|
pass: test_suite_params.py (N.N sec)
|
||||||
- test with template overlay
|
- test with template overlay
|
||||||
cnf suiteC: DBG: reading suite.conf [suite.py:[LINENR]]
|
cnf suiteC: DBG: reading suite.conf [suite.py:[LINENR]]
|
||||||
|
tst suiteC: DBG: {combining='config'} [suite.py:[LINENR]]
|
||||||
|
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [suiteC↪{combining_scenarios='config'}] [suite.py:[LINENR]]
|
||||||
|
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
trial suiteC
|
trial suiteC
|
||||||
|
@ -651,8 +664,6 @@ tst suiteC: DBG: Picked - _hash: fd103b22c7cf2480d609150e06f4bbd92ac78d8c
|
||||||
--- ReservedResources: DBG: {using={_hash='fd103b22c7cf2480d609150e06f4bbd92ac78d8c', _reserved_by='suiteC-[ID_NUM]-[ID_NUM]', addr='10.42.42.2'}} [resource.py:[LINENR]]
|
--- ReservedResources: DBG: {using={_hash='fd103b22c7cf2480d609150e06f4bbd92ac78d8c', _reserved_by='suiteC-[ID_NUM]-[ID_NUM]', addr='10.42.42.2'}} [resource.py:[LINENR]]
|
||||||
tst test_template_overlay.py:[LINENR]: - Testing: original template [suiteC↪test_template_overlay.py:[LINENR]] [test_template_overlay.py:[LINENR]]
|
tst test_template_overlay.py:[LINENR]: - Testing: original template [suiteC↪test_template_overlay.py:[LINENR]] [test_template_overlay.py:[LINENR]]
|
||||||
run osmo-stp_10.42.42.2: DBG: {config_file='test_trial_tmp/test_run_6/suiteC/test_template_overlay.py/osmo-stp_10.42.42.2/osmo-stp.cfg'} [suiteC↪test_template_overlay.py:[LINENR]↪test_template_overlay.py↪osmo-stp_10.42.42.2] [stp_osmo.py:[LINENR]]
|
run osmo-stp_10.42.42.2: DBG: {config_file='test_trial_tmp/test_run_6/suiteC/test_template_overlay.py/osmo-stp_10.42.42.2/osmo-stp.cfg'} [suiteC↪test_template_overlay.py:[LINENR]↪test_template_overlay.py↪osmo-stp_10.42.42.2] [stp_osmo.py:[LINENR]]
|
||||||
tst suiteC: DBG: {combining='config'} [suite.py:[LINENR]]
|
|
||||||
tst {combining_scenarios='config'}: DBG: {definition_conf={}} [suiteC↪{combining_scenarios='config'}] [suite.py:[LINENR]]
|
|
||||||
run osmo-stp_10.42.42.2: DBG: STP CONFIG:
|
run osmo-stp_10.42.42.2: DBG: STP CONFIG:
|
||||||
{'stp': {'ip_address': {'_hash': 'fd103b22c7cf2480d609150e06f4bbd92ac78d8c',
|
{'stp': {'ip_address': {'_hash': 'fd103b22c7cf2480d609150e06f4bbd92ac78d8c',
|
||||||
'_reserved_by': 'suiteC-[ID_NUM]-[ID_NUM]',
|
'_reserved_by': 'suiteC-[ID_NUM]-[ID_NUM]',
|
||||||
|
|
|
@ -98,7 +98,8 @@ class SuiteRun(log.Origin):
|
||||||
def load_tests(self):
|
def load_tests(self):
|
||||||
self.tests = []
|
self.tests = []
|
||||||
for test_basename in self.definition.test_basenames:
|
for test_basename in self.definition.test_basenames:
|
||||||
self.tests.append(test.Test(self, test_basename))
|
test_specific_config = self.config_suite_specific().get(test_basename.rstrip('.py'), {})
|
||||||
|
self.tests.append(test.Test(self, test_basename, test_specific_config))
|
||||||
|
|
||||||
def mark_start(self):
|
def mark_start(self):
|
||||||
self.start_timestamp = time.time()
|
self.start_timestamp = time.time()
|
||||||
|
|
|
@ -35,11 +35,12 @@ class Test(log.Origin):
|
||||||
PASS = 'pass'
|
PASS = 'pass'
|
||||||
FAIL = 'FAIL'
|
FAIL = 'FAIL'
|
||||||
|
|
||||||
def __init__(self, suite_run, test_basename):
|
def __init__(self, suite_run, test_basename, test_specific_config):
|
||||||
self.basename = test_basename
|
self.basename = test_basename
|
||||||
super().__init__(log.C_TST, self.basename)
|
super().__init__(log.C_TST, self.basename)
|
||||||
self._run_dir = None
|
self._run_dir = None
|
||||||
self.suite_run = suite_run
|
self.suite_run = suite_run
|
||||||
|
self._config_test_specific = test_specific_config
|
||||||
self.path = os.path.join(self.suite_run.definition.suite_dir, self.basename)
|
self.path = os.path.join(self.suite_run.definition.suite_dir, self.basename)
|
||||||
self.status = Test.UNKNOWN
|
self.status = Test.UNKNOWN
|
||||||
self.start_timestamp = 0
|
self.start_timestamp = 0
|
||||||
|
@ -134,6 +135,9 @@ class Test(log.Origin):
|
||||||
self.status = Test.SKIP
|
self.status = Test.SKIP
|
||||||
self.duration = 0
|
self.duration = 0
|
||||||
|
|
||||||
|
def config_test_specific(self):
|
||||||
|
return self._config_test_specific
|
||||||
|
|
||||||
def set_report_stdout(self, text):
|
def set_report_stdout(self, text):
|
||||||
'Overwrite stdout text stored in report from inside a test'
|
'Overwrite stdout text stored in report from inside a test'
|
||||||
self._report_stdout = text
|
self._report_stdout = text
|
||||||
|
|
|
@ -146,7 +146,7 @@ class TestEnv(log_module.Origin):
|
||||||
return self.suite_run.config_suite_specific()
|
return self.suite_run.config_suite_specific()
|
||||||
|
|
||||||
def config_test_specific(self):
|
def config_test_specific(self):
|
||||||
return self.suite_run.config_suite_specific().get(self._test.module_name(), {})
|
return self._test.config_test_specific()
|
||||||
|
|
||||||
def set_overlay_template_dir(self, template_dir=None):
|
def set_overlay_template_dir(self, template_dir=None):
|
||||||
'''Overlay a directory on top of default one when looking for
|
'''Overlay a directory on top of default one when looking for
|
||||||
|
|
Loading…
Reference in New Issue