From f309b4f9cbcb42b496479f8726f10506ec518149 Mon Sep 17 00:00:00 2001 From: Lukas Ruzicka Date: Jul 03 2019 15:04:11 +0000 Subject: Add tests for default modules and streams. --- diff --git a/modular.log b/modular.log new file mode 100644 index 0000000..dc05125 --- /dev/null +++ b/modular.log @@ -0,0 +1,32 @@ +INFO:root:Script started. +INFO:root:The test suite has been initialized. +INFO:root:The DNF operation of module_list ran successfully (0) +INFO:root:The kubernetes module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The lizardfs module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The openmpi module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The perl-bootstrap module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The rawtherapee module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The skychart module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The standard-test-roles 3.0 [d] module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The lizardfs module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The openmpi module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The perl-bootstrap module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The skychart module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The standard-test-roles 3.0 [d] module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The libgit2 module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The lizardfs module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The openmpi module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The perl-bootstrap module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The skychart module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The standard-test-roles 3.0 [d] module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity. +INFO:root:The "dnf module list" operation was succesful. +INFO:root:There were 58 problems found in module stream and profile definitions. +INFO:root:Script finished with exit code 1. diff --git a/modular_functions.py b/modular_functions.py index 53c6d33..c7022e9 100755 --- a/modular_functions.py +++ b/modular_functions.py @@ -79,9 +79,33 @@ class TestSuite: for line in strip: # Gets the modules lines from the output into a list of modules module = {} modName = line[0] + # Sometimes, when the name is longer, the input might be incorrectly parsed. + # This is a workaround to fix it. + stream = None + if ' ' in modName: + name = modName.split(' ')[0] + stream = modName.split(' ')[1] + modName = name + # The following is a parser of one line in module list output try: - module['stream'] = line[1].split('[')[0].strip() - module['profile'] = line[2].split('[')[0].strip() + # Parsing stream + if stream: + cleanstream = stream + else: + stream = line[1] + cleanstream = stream.split('[')[0].strip() + if '[d]' in stream: + module['default-stream'] = cleanstream + module['stream'] = cleanstream + + # Parsing profile + profile = line[2] + cleanprofile = line[2].split('[')[0].strip() + if '[d]' in profile: + module['default-profile'] = cleanprofile + module['profile'] = cleanprofile + + # Parsing info module['info'] = line[3] except IndexError: logging.info(f"The {line[0]} module probably does not meet standard criteria. Check 'dnf module list'. Skipping tests for broken validity.") @@ -359,6 +383,31 @@ class ModuleTest: logging.info(f"The result of switching {oldkey} for {newkey} is SOFTFAIL.") print('') + def find_no_defaults(self): + """Finds all modules without default streams and profiles set.""" + modules = self.suite.module_list() + print(f"{len(self.suite.modlist)} modules will be tested.") + nodefaults = [] + result = '' + for name in modules.keys(): + module = modules[name][0] + if 'default-stream' in module.keys() and 'default-profile' in module.keys(): + pass + elif 'default-stream' in module.keys(): + result = 'Default profile is not set.' + elif 'default-profile' in module.keys(): + result = 'Default stream is not set.' + else: + result = 'Neither default stream nor profile are set.' + nodefaults.append(f"{name} \t {result}") + print(f"{name} \t\t {result}") + if len(nodefaults) == 0: + self.overall['checkdefaults'] = 'pass' + logging.info(f"There were no errors in module stream and profile definitions found.") + else: + self.overall['checkdefaults'] = 'fail' + logging.info(f"There were {len(nodefaults)} problems found in module stream and profile definitions.") + def test_all(self): modules = self.suite.module_list() print(f"{len(self.suite.modlist)} modules will be tested.") @@ -369,7 +418,6 @@ class ModuleTest: self.newer = newer self.older = stream self.fail = fail - print(stream, profile, newer, fail) if stream != None: key = f"{module}:{stream}" else: @@ -395,6 +443,8 @@ class ModuleTest: print(f"Available streams and profiles of the {module} module:") print("----------------------------------") print(json.dumps(info, sort_keys=True, indent=4)) + elif s == 'checkdefaults': + self.find_no_defaults() elif s == 'testall': self.test_all()