def test_bad_plugins(self): """Make sure bad plugins don't kill Pavilion and print appropriate errors.""" error_strs = [ 'Plugin candidate rejected:', 'Unable to create plugin object:', 'Unable to import plugin:', ] yapsy_logger = logging.getLogger('yapsy') stream = io.StringIO() hndlr = logging.StreamHandler(stream) yapsy_logger.addHandler(hndlr) pav_cfg = self.pav_cfg.copy() cfg_dirs = list(pav_cfg.config_dirs) cfg_dirs.append(self.TEST_DATA_ROOT/'bad_plugins') pav_cfg.config_dirs = cfg_dirs # A bunch of plugins should fail to load, but this should be fine # anyway. plugins.initialize_plugins(pav_cfg) yapsy_logger.removeHandler(hndlr) stream.seek(0) logs = stream.read() for error_str in error_strs: self.assertIn(error_str, logs) plugins._reset_plugins()
def test_function_plugins(self): """Make sure each of the core function plugins work.""" plugins.initialize_plugins(self.pav_cfg) tests = { 'int': ('0x123', 16), 'floor': (1.2,), 'ceil': (1.3,), 'round': (1.4,), 'sum': ([1, 2, 3, 2.4],), 'avg': ([1, 2, 3, 2.4],), 'len': ([1, 2, 3, 2.4],), 'random': tuple(), } for func_name, args in tests.items(): func = expression_functions.get_plugin(func_name) # Make sure this doesn't throw errors func(*args) # Make sure we have a test for all core plugins. for plugin in plugins.list_plugins()['function']: if plugin.priority == expression_functions.FunctionPlugin.PRIO_CORE: self.assertIn(plugin.name, tests) plugins._reset_plugins()
def test_command_plugins(self): """Make sure command plugin loading is sane.""" # Get an empty pavilion config and set some config dirs on it. pav_cfg = config.PavilionConfigLoader().load_empty() # We're loading multiple directories of plugins - AT THE SAME TIME! pav_cfg.config_dirs = [ os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir'), os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir2') ] plugins.initialize_plugins(pav_cfg) commands.get_command('poof').run(pav_cfg, []) commands.get_command('blarg').run(pav_cfg, []) # Clean up our plugin initializations. plugins._reset_plugins() pav_cfg.config_dirs.append( os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir_conflicts')) self.assertRaises(plugins.PluginError, lambda: plugins.initialize_plugins(pav_cfg)) # Clean up our plugin initializations. plugins._reset_plugins()
def test_loading_tests(self): """Make sure get_tests can find tests and resolve inheritance.""" plugins.initialize_plugins(self.pav_cfg) tests = load_test_configs(self.pav_cfg, 'this', [], ['hello_world']) self.assertEqual(sorted(['narf', 'hello', 'world']), sorted([test['name'] for test in tests])) tests = load_test_configs(self.pav_cfg, 'this', [], ['hello_world.hello']) hello = tests.pop() # There should have only been 1 self.assertFalse(tests) # Check some basic test attributes. self.assertEqual(hello['scheduler'], 'raw') self.assertEqual(hello['suite'], 'hello_world') # Make sure the variable from the host config got propagated. self.assertIn('hosty', hello['variables']) tests = load_test_configs(self.pav_cfg, 'this', [], ['hello_world.narf']) narf = tests.pop() # Make sure this got overridden from 'world' self.assertEqual(narf['scheduler'], 'dummy') # Make sure this didn't get lost. self.assertEqual(narf['run']['cmds'], ['echo "Running World"']) plugins._reset_plugins()
def test_plugin_loading(self): """Check to make sure the plugin system initializes correctly. Separate tests will check the internal initialization of each plugin sub-system.""" # Get an empty pavilion config and set some config dirs on it. pav_cfg = config.PavilionConfigLoader().load_empty() # We're loading multiple directories of plugins - AT THE SAME TIME! pav_cfg.config_dirs = [ os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir'), os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir2') ] for path in pav_cfg.config_dirs: self.assertTrue(os.path.exists(path)) plugins.initialize_plugins(pav_cfg) created_manager = plugins._PLUGIN_MANAGER # Make sure this can run multiple times, plugins.initialize_plugins(pav_cfg) # Make sure only one of these is ever created. self.assertIs(created_manager, plugins._PLUGIN_MANAGER) # Clean up our plugin initializations. plugins._reset_plugins()
def test_module_wrappers(self): """Make sure module wrapper loading is sane too.""" # Get an empty pavilion config and set some config dirs on it. pav_cfg = config.PavilionConfigLoader().load_empty() # We're loading multiple directories of plugins - AT THE SAME TIME! pav_cfg.config_dirs = [ os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir'), os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir2') ] plugins.initialize_plugins(pav_cfg) module_wrapper.get_module_wrapper('foo', '1.0') bar1 = module_wrapper.get_module_wrapper('bar', '1.3') bar2 = module_wrapper.get_module_wrapper('bar', '1.2.0') self.assertIsNot(bar1, bar2) self.assertEqual('1.3', bar1.get_version('1.3')) self.assertEqual('1.2.0', bar2.get_version('1.2.0')) self.assertRaises(module_wrapper.ModuleWrapperError, lambda: bar2.get_version('1.3.0')) bar1.load({}) plugins._reset_plugins()
def test_result_parser_plugins(self): """Check basic result parser structure.""" plugins.initialize_plugins(self.pav_cfg) regex = result_parsers.get_plugin('regex') plugins._reset_plugins()
def test_show_cmds(self): plugins.initialize_plugins(self.pav_cfg) arg_lists = [ ('show', 'config'), ('show', 'config', '--template'), ('show', 'functions'), ('show', 'functions', '--detail', 'int'), ('show', 'hosts'), ('show', 'hosts', '--verbose'), ('show', 'hosts', '--vars', 'this'), ('show', 'hosts', '--config', 'this'), ('show', 'modes'), ('show', 'modes', '--verbose'), ('show', 'modes', '--vars', 'defaulted'), ('show', 'modes', '--config', 'defaulted'), ('show', 'module_wrappers'), ('show', 'module_wrappers', '--verbose'), ('show', 'pav_vars'), ('show', 'result_parsers'), ('show', 'result_parsers', '--doc=regex'), ('show', 'result_parsers', '--verbose'), ('show', 'sched'), ('show', 'sched', '--config=slurm'), ('show', 'sched', '--vars=slurm'), ('show', 'states'), ('show', 'suites'), ('show', 'suites', '--err'), ('show', 'suites', '--supersedes'), ('show', 'suites', '--verbose'), ('show', 'system_variables'), ('show', 'system_variables', '--verbose'), ('show', 'test_config'), ('show', 'tests'), ('show', 'tests', '--err'), ('show', 'tests', '--doc', 'hello_world.narf'), ('show', 'tests', '--hidden'), ('show', 'tests', '--verbose'), ] parser = arguments.get_parser() show_cmd = commands.get_command('show') show_cmd.silence() for arg_list in arg_lists: args = parser.parse_args(arg_list) show_cmd.run(self.pav_cfg, args) plugins._reset_plugins()
def test_loading_hidden(self): """Make sure we only get hidden tests when specifically requested.""" plugins.initialize_plugins(self.pav_cfg) tests = load_test_configs(self.pav_cfg, 'this', [], ['hidden']) names = sorted([t['name'] for t in tests]) self.assertEqual(names, ['hello', 'narf']) tests = load_test_configs(self.pav_cfg, 'this', [], ['hidden._hidden']) names = sorted([t['name'] for t in tests]) self.assertEqual(names, ['_hidden']) plugins._reset_plugins()
def test_copy_build(self): """Check that builds are copied correctly.""" plugins.initialize_plugins(self.pav_cfg) config = self._quick_test_cfg() # The copy_test source file contains several files to copy # for real and several to symlink. config['build']['source_location'] = 'file_tests.tgz' config['build']['copy_files'] = [ 'real.*', 'wild/real_?i*[0-9].dat', 'rec/**/real*', ] test = self._quick_test(config) # Make sure the following exist and are regular files. real_files = [ 'real.txt', 'wild/real_wild1.dat', 'wild/real_wild2.dat', 'rec/real_r1.txt', 'rec/rec2/real_r2.txt' ] for real in real_files: real = test.path / 'build' / real self.assertTrue(real.exists(), msg="Missing {}".format(real)) self.assertTrue(real.is_file(), msg="{} is not a regular file.".format(real)) # Make sure the following exist, but are symlinks. sym_files = [ 'pav_build_log', '.built_by', 'sym.txt', 'wild/sym.dat', 'rec/sym_r1.txt', 'rec/rec2/sym_r2.txt', ] for sym in sym_files: sym = test.path / 'build' / sym self.assertTrue(sym.exists(), msg="Missing {}".format(sym)) self.assertTrue(sym.is_symlink(), msg="{} is not a symlink".format(sym)) plugins._reset_plugins()
def test_show_cmds(self): plugins.initialize_plugins(self.pav_cfg) arg_lists = [ ('show', 'sched'), ('show', 'sched', '--config=slurm'), ('show', 'sched', '--vars=slurm'), ('show', 'result_parsers'), ('show', 'result_parsers', '--verbose'), ('show', 'result_parsers', '--config=regex'), ('show', 'states'), ('show', 'config'), ('show', 'config', '--template'), ('show', 'test_config'), ('show', 'module_wrappers'), ('show', 'module_wrappers', '--verbose'), ('show', 'system_variables'), ('show', 'system_variables', '--verbose'), ('show', 'pav_vars'), ('show', 'suites'), ('show', 'suites', '--verbose'), ('show', 'suites', '--err'), ('show', 'suites', '--supersedes'), ('show', 'tests'), ('show', 'tests', '--verbose'), ('show', 'tests', '--err'), ('show', 'tests', '--hidden'), ('show', 'hosts'), ('show', 'hosts', '--verbose'), ('show', 'modes'), ('show', 'modes', '--verbose'), ] parser = arguments.get_parser() show_cmd = commands.get_command('show') show_cmd.outfile = io.StringIO() show_cmd.errfile = io.StringIO() for arg_list in arg_lists: args = parser.parse_args(arg_list) show_cmd.run(self.pav_cfg, args) plugins._reset_plugins()
def test_result_parser_plugins(self): """Check basic result parser structure.""" # Get an empty pavilion config and set some config dirs on it. pav_cfg = config.PavilionConfigLoader().load_empty() plugins.initialize_plugins(pav_cfg) # We're loading multiple directories of plugins - AT THE SAME TIME! pav_cfg.config_dirs = [ os.path.join(self.TEST_DATA_ROOT, 'pav_config_dir') ] # We should have exactly one test plugin. self.assertEqual(len(result_parsers.list_plugins()), 1) regex = result_parsers.get_plugin('regex') plugins._reset_plugins()
def test_apply_overrides(self): """Make sure overrides get applied to test configs correctly.""" plugins.initialize_plugins(self.pav_cfg) tests = load_test_configs(self.pav_cfg, 'this', [], ['hello_world']) overrides = {'run': {'env': {'foo': 'bar'}}, 'scheduler': 'fuzzy'} for test in tests: otest = test.copy() apply_overrides(test, overrides) # Make sure the overrides were applied self.assertEqual(test['scheduler'], 'fuzzy') self.assertEqual(test['run']['env']['foo'], 'bar') # Make sure other stuff wasn't changed. self.assertEqual(test['build'], otest['build']) self.assertEqual(test['run']['cmds'], otest['run']['cmds']) plugins._reset_plugins()
def test_extended_variables(self): """Make sure default variables work as expected.""" plugins.initialize_plugins(self.pav_cfg) tests = load_test_configs(self.pav_cfg, host='extended', modes=['extended'], tests=['extended.test']) test = tests[0] self.assertEqual(test['variables']['long_base'], ['what', 'are', 'you', 'up', 'to', 'punk?']) self.assertEqual(test['variables']['single_base'], ['host', 'mode', 'test']) self.assertEqual(test['variables']['no_base_mode'], ['mode']) self.assertEqual(test['variables']['no_base'], ['test']) self.assertEqual(test['variables']['null_base_mode'], ['mode']) self.assertEqual(test['variables']['null_base'], ['test']) plugins._reset_plugins()
def test_env_order(self): """Make sure environment variables keep their order from the test config to the final run scripts.""" plugins.initialize_plugins(self.pav_cfg) test_conf = load_test_configs(self.pav_cfg, 'this', [], ['order'])[0] test = self._quick_test(test_conf, "order") # Each exported variable in this config has a value that denotes its # expected place in the order. The variable names are random letter # sequences in a random order; hash order should be decidedly different # than the listed order. exports = [] with (test.path / 'build.sh').open() as build_script: for line in build_script: if line.startswith('export'): if 'TEST_ID' in line or 'PAV_CONFIG_FILE' in line: continue _, var_val = line.split() var, val = line.split('=') try: val = int(val) except ValueError: raise exports.append((var, val)) # The values should be the numbers for 0..99, in that order. self.assertEqual(list(range(len(exports))), [val for var, val in exports], msg="Environment variable order not preserved. \n" "Got the following instead: \n{}".format(''.join( ["{}: {}\n".format(*v) for v in exports]))) plugins._reset_plugins()
def test_defaulted_variables(self): """Make sure default variables work as expected.""" plugins.initialize_plugins(self.pav_cfg) tests = load_test_configs(self.pav_cfg, host='defaulted', modes=['defaulted'], tests=['defaulted.test']) test = tests[0] self.assertEqual(test['variables']['host_def'], ['host']) self.assertEqual(test['variables']['mode_def'], ['mode']) self.assertEqual(test['variables']['test_def'], ['test']) self.assertNotIn('no_val', test['variables']) with self.assertRaises(TestConfigError): tests = load_test_configs(self.pav_cfg, host='defaulted', modes=['defaulted'], tests=['defaulted_error.error']) plugins._reset_plugins()
def test_layering(self): """Make sure test config layering works as expected.""" plugins.initialize_plugins(self.pav_cfg) for host in ('this', 'layer_host'): for modes in ([], ['layer_mode']): for test in ('layer_tests.layer_test', 'layer_tests.layer_test_part'): answer = 'standard' if host == 'layer_host': answer = 'host' if modes: answer = 'mode' if test.endswith('part'): answer = 'test' tests = load_test_configs(pav_cfg=self.pav_cfg, host=host, modes=modes, tests=[test]) self.assertEqual(tests[0]['slurm']['partition'], answer) plugins._reset_plugins()
def test_finalize(self): plugins.initialize_plugins(self.pav_cfg) cfg = self._quick_test_cfg() cfg['run']['cmds'] = ['echo "{{sys.host_name}}"'] cfg['results'] = { 'regex': [{ 'key': 'foo', 'regex': '{{sys.host_name}}', }] } test = self._quick_test(cfg, 'finalize_test', build=False, finalize=False) test.build() undefered_sys_vars = system_variables.SysVarDict( defer=False, unique=True, ) fin_var_man = variables.VariableSetManager() fin_var_man.add_var_set('sys', undefered_sys_vars) test.finalize(fin_var_man) results = test.gather_results(test.run()) test.save_results(results) plugins._reset_plugins()
def tearDown(self) -> None: """Perform test teardown.""" plugins._reset_plugins()
def test_check_args(self): plugins.initialize_plugins(self.pav_cfg) # Make sure we can check arguments. test_cfg = { 'results': { 'regex': [ {'key': 'ok', 'regex': r'foo'}, ] } } test = self._quick_test(test_cfg, 'check_args_test') result_parsers.check_args(test.config['results']) # Make sure duplicate keys aren't allowed. test_cfg = { 'results': { 'regex': [ {'key': 'repeated', 'regex': r'foo'}, {'key': 'repeated', 'regex': r'foo'}, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) # Make sure we handle bad key names. test_cfg = { 'results': { 'regex': [ {'key': '#!@123948aa', 'regex': r'foo'}, ] } } with self.assertRaises(ValueError): self._quick_test(test_cfg, 'check_args_test') # Make sure we handle missing the 'key' attribute as expected. test_cfg = { 'results': { 'regex': [ {'regex': r'foo'}, ] } } with self.assertRaises(ValueError): self._quick_test(test_cfg, 'check_args_test') # Make sure reserved keys aren't allowed. test_cfg = { 'results': { 'regex': [ {'key': 'started', 'regex': r'foo'}, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) # Missing a key for the parser plugin test_cfg = { 'results': { 'regex': [ {'key': 'nope'}, ] } } with self.assertRaises(yc.RequiredError): self._quick_test(test_cfg, 'check_args_test') test_cfg = { 'results': { 'regex': [ {'key': 'test', 'regex': '[[['}, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) test_cfg = { 'results': { 'regex': [ { 'key': 'test', 'regex': '^User:(.*)$', 'expected': ['12:11'] }, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) test_cfg = { 'results': { 'regex': [ { 'key': 'test', 'regex': '^User:(.*)$', 'expected': ['-11:-12'] }, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) test_cfg = { 'results': { 'regex': [ { 'key': 'test', 'regex': '^User:(.*)$', 'expected': ['11:12:13'] }, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) test_cfg = { 'results': { 'regex': [ { 'key': 'test', 'regex': '^User:(.*)$', 'expected': ['11:words'] }, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) test_cfg = { 'results': { 'regex': [ { 'key': 'test', 'regex': 'res', 'threshold': '-5', }, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) test_cfg = { 'results': { 'regex': [ { 'key': 'test', 'regex': 'res', 'threshold': 'A', }, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) test_cfg = { 'results': { 'regex': [ { 'key': 'test', 'regex': 'res', 'threshold': 'A', 'expected': '10:12', }, ] } } test = self._quick_test(test_cfg, 'check_args_test') with self.assertRaises(result_parsers.ResultParserError): result_parsers.check_args(test.config['results']) plugins._reset_plugins()
def test_parse_results(self): """Check all the different ways in which we handle parsed results.""" plugins.initialize_plugins(self.pav_cfg) test_cfg = { 'scheduler': 'raw', 'run': { # This will result in 4 output files. # run.log, other.log, other2.log, other3.log 'cmds': [ 'echo "Hello World."', 'echo "Goodbye Cruel World."', 'echo "In a World where..." >> other.log', 'echo "something happens..." >> other2.log', 'echo "and someone saves the World." >> other3.log', 'echo "I\'m here to cause Worldwide issues." >> other.txt' ] }, 'results': { 'regex': [ { # Look at the default output file. (run.log) 'key': 'basic', 'regex': r'.* World', }, { # Look all the log files, and save 'True' on match. 'key': 'true', 'files': ['../run.log'], 'regex': r'.* World', 'action': result_parsers.ACTION_TRUE, }, { # As before, but false. Also, with lists of data. 'key': 'false', # By multiple globs. 'files': ['../run.log', 'other.*'], 'regex': r'.* World', 'match_type': result_parsers.MATCH_ALL, 'action': result_parsers.ACTION_FALSE, }, { # As before, but keep match counts. 'key': 'count', 'files': ['../run.log', '*.log'], 'regex': r'.* World', 'match_type': result_parsers.MATCH_ALL, 'action': result_parsers.ACTION_COUNT, 'per_file': result_parsers.PER_FULLNAME, }, { # Store matches by fullname 'key': 'fullname', 'files': ['../run.log', '*.log'], 'regex': r'.* World', 'per_file': result_parsers.PER_FULLNAME, }, { # Store matches by name stub # Note there is a name conflict here between other.txt # and other.log. 'key': 'name', 'files': ['other.*'], 'regex': r'.* World', 'per_file': result_parsers.PER_NAME, }, { # Store matches by name stub # Note there is a name conflict here between other.txt # and other.log. 'key': 'name_list', 'files': ['*.log'], 'regex': r'World', 'per_file': result_parsers.PER_NAME_LIST, }, { # Store matches by name stub # Note there is a name conflict here between other.txt # and other.log. 'key': 'fullname_list', 'files': ['*.log'], 'regex': r'World', 'per_file': result_parsers.PER_FULLNAME_LIST, }, { 'key': 'lists', 'files': ['other*'], 'regex': r'.* World', 'match_type': result_parsers.MATCH_ALL, 'per_file': result_parsers.PER_LIST, }, { 'key': 'all', 'files': ['other*'], 'regex': r'.* World', 'action': result_parsers.ACTION_TRUE, 'per_file': result_parsers.PER_ALL }, { 'key': 'result', 'files': ['other*'], 'regex': r'.* World', 'action': result_parsers.ACTION_TRUE, 'per_file': result_parsers.PER_ANY }, ] } } test = self._quick_test(test_cfg, 'result_parser_test') test.run() results = result_parsers.parse_results( test=test, results={} ) # Check all the different results to make sure they're what we expect. self.assertEqual( results['basic'], 'Hello World') self.assertEqual( results['true'], True, ) self.assertEqual( results['false'], False, ) self.assertEqual(results['fn']['run.log']['count'], 2) self.assertEqual(results['fn']['other.log']['count'], 1) self.assertEqual(results['fn']['other.log']['fullname'], 'In a World') self.assertEqual(results['name_list'], ['other', 'other3']) self.assertEqual(results['fullname_list'], ['other.log', 'other3.log']) self.assertIn(results['n']['other']['name'], ['In a World', "I'm here to cause World"]) self.assertIn("Duplicate file key 'other' matched by name", [e['msg'] for e in results['pav_result_errors']]) self.assertEqual(sorted(results['lists']), sorted(['and someone saves the World', 'In a World', "I'm here to cause World"])) self.assertEqual(results['all'], False) self.assertEqual(results['result'], result_parsers.PASS) plugins._reset_plugins()
def tearDown(self): """Reset the plugins.""" plugins._reset_plugins()
def tearDown(self) -> None: plugins._reset_plugins()
def tearDown(self): plugins._reset_plugins()
def test_system_plugins(self): """Make sure system values appear as expected. Also that deferred variables behave as expected.""" # Get an empty pavilion config and set some config dirs on it. pav_cfg = config.PavilionConfigLoader().load_empty() plugins.initialize_plugins(pav_cfg) self.assertFalse(system_variables._LOADED_PLUGINS is None) host_arch = subprocess.check_output(['uname', '-i']) host_arch = host_arch.strip().decode('UTF-8') host_name = subprocess.check_output(['hostname', '-s']) host_name = host_name.strip().decode('UTF-8') with open('/etc/os-release', 'r') as release: rlines = release.readlines() host_os = {} for line in rlines: if line[:3] == 'ID=': host_os['ID'] = line[3:].strip().strip('"') elif line[:11] == 'VERSION_ID=': host_os['Version'] = line[11:].strip().strip('"') sys_vars = system_variables.get_system_plugin_dict(defer=False) self.assertFalse('sys_arch' in sys_vars) self.assertEqual(host_arch, sys_vars['sys_arch']) self.assertTrue('sys_arch' in sys_vars) self.assertFalse('sys_name' in sys_vars) self.assertEqual(host_name, sys_vars['sys_name']) self.assertTrue('sys_name' in sys_vars) self.assertFalse('sys_os' in sys_vars) self.assertEqual(host_os['ID'], sys_vars['sys_os']['ID']) self.assertEqual(host_os['Version'], sys_vars['sys_os']['Version']) self.assertTrue('sys_os' in sys_vars) self.assertFalse('host_arch' in sys_vars) self.assertEqual(host_arch, sys_vars['host_arch']) self.assertTrue('host_arch' in sys_vars) self.assertFalse('host_name' in sys_vars) self.assertEqual(host_name, sys_vars['host_name']) self.assertTrue('host_name' in sys_vars) self.assertFalse('host_os' in sys_vars) self.assertEqual(host_os['ID'], sys_vars['host_os']['ID']) self.assertEqual(host_os['Version'], sys_vars['host_os']['Version']) self.assertTrue('host_os' in sys_vars) # Re-initialize the plugin system. plugins._reset_plugins() # Make sure these have been wiped self.assertIsNone(system_variables._LOADED_PLUGINS) # Make sure these have been wiped. self.assertIsNone(system_variables._SYS_VAR_DICT) plugins.initialize_plugins(pav_cfg) # but these are back self.assertIsNotNone(system_variables._LOADED_PLUGINS) sys_vars = system_variables.get_system_plugin_dict(defer=True) self.assertTrue(len(system_variables._SYS_VAR_DICT.items()) == 0) # Check that the deferred values are actually deferred. self.assertFalse('host_arch' in sys_vars) self.assertTrue( isinstance(sys_vars['host_arch'], variables.DeferredVariable)) self.assertFalse('host_name' in sys_vars) self.assertTrue( isinstance(sys_vars['host_name'], variables.DeferredVariable)) self.assertFalse('host_os' in sys_vars) self.assertTrue( isinstance(sys_vars['host_os'], variables.DeferredVariable)) plugins._reset_plugins()