def _subdirectory_test(self, pkgs): """ Main method for the test, that is called when the test suite is started, does all the work """ for pkg in pkgs: name = os.path.basename(pkg) _subpkg = rename_default_subpkg(pkgsplit.get_subpackage_only(name)) if _subpkg not in self._get_expected_subdirectories(name).keys(): continue if not DefaultMock().postinstall_exception_checked(pkg): SubdirectoryTest.instance.log("Skipping subdirectory test for {}".format(_subpkg), vc.Verbosity.TEST) continue subdirectories = DefaultMock().execute_ls(JVM_DIR) if subdirectories[1] != 0: passed_or_failed(self, False, "Warning: " + JVM_DIR + " does not exist, skipping subdirectory test for" " given subpackage {}".format(_subpkg)) continue subdirectories = subdirectories[0].split("\n") subdirectories = self._remove_fake_subdirectories(subdirectories) expected_subdirectories = self._get_expected_subdirectories(name)[_subpkg] expected_subdirectories.append(self._get_nvra_suffix(name)) expected_subdirectories = set(expected_subdirectories) SubdirectoryTest.instance.log("Testing subdirectories for {}:".format(name), vc.Verbosity.TEST) SubdirectoryTest.instance.log("Expected: " + str(sorted(expected_subdirectories)), vc.Verbosity.TEST) SubdirectoryTest.instance.log("Presented: " + str(sorted(subdirectories)), vc.Verbosity.TEST) self._test_subdirectories_equals(subdirectories, expected_subdirectories, _subpkg, name) self._test_links_are_correct(subdirectories, name, _subpkg) if len(self.list_of_failed_tests) != 0: SubdirectoryTest.instance.log("Summary of failed tests: " + "\n ".join(self.list_of_failed_tests), vc.Verbosity.ERROR) return self.passed, self.failed
def _checkJreObsolete(self, obsoletes=None): self._document("Jdks in rhel must NOT obsolete anything. Possible exceptions: " + ",".join(JdkRhel.jreExceptionsObsolete)) tu.passed_or_failed(self, len(set(obsoletes)-set(JdkRhel.jreExceptionsObsolete)) == 0, "Number of obsoletes and obsoleteExceptions is not same.", "this test is checking only count of obsoletes vs count of exceptions, needs rework") return self.passed, self.failed
def _binary_in_path_contents(self, path_contents, binary): paths = set() for path in path_contents.keys(): if binary in path_contents[path]: paths.add(path) if len(paths) == 0: return None result = set() for p in paths: tg = "readlink " + p + "/" + binary res = DefaultMock().executeCommand([tg]) if passed_or_failed( self, res[1] == 0, "Command readlink " + p + "/" + binary + " failed."): result.add(res) if len(result) != 1: if len(result) > 1: passed_or_failed( self, False, "Links of one binary do not point on same target: " + ",".join(result)) else: passed_or_failed(self, False, "Links do not point on any target.") return paths
def test_release(self): _reinit(self) java = config.runtime_config.RuntimeConfig().getRpmList().getRelease() self.log("Release is: " + java) passed_or_failed(self, java is not None, "unable to determine tested java release") return self.passed, self.failed
def _checkJreObsolete(self, obsoletes=None): self._document("jre OpenJdk8 in Fedora must obsolate: " +",".join(Openjdk8Fedora.jreRequiredObsolete)) obsoleteJdk7Set = set(Openjdk8Fedora.jreRequiredObsolete).intersection(set(obsoletes)) tu.passed_or_failed(self, len(obsoleteJdk7Set) == len(Openjdk8Fedora.jreRequiredObsolete), "Number of obsoletes and obsoleteExceptions is not same.", "this test is checking only count of obsoletes vs count of exceptions, needs rework") return self.passed, self.failed
def test_dist(self): _reinit(self) java = config.runtime_config.RuntimeConfig().getRpmList().getDist() self.log("Dist is: " + java) passed_or_failed(self, java is not None, "unable to determine tested java distribution") return self.passed, self.failed
def test_subpackage(self): _reinit(self) subpkgs = config.runtime_config.RuntimeConfig().getRpmList( ).getSubpackageOnly() self.log("found subpackages only are: `" + "`,`".join(subpkgs) + "`") passed_or_failed(self, len(subpkgs) > 0, "No subpkgs to test") return self.passed, self.failed
def test_version(self): _reinit(self) java = config.runtime_config.RuntimeConfig().getRpmList().getVersion() self.log("Version is: " + java) passed_or_failed(self, java is not None, "Unable to determine the tested java version") return self.passed, self.failed
def cross_check_artificial_provides(self, this): files = self.rpms.files self._document( "according to Jvanek every provide should be provided only once per set of rpms with exception " + "of javadoc-zip having common provides with javadoc") files = [ x.replace("rpms/", "") for x in files if tu.validate_arch_for_rpms(this.current_arch) in x ] if files: la.LoggingAccess().log( " Testing VersionRelease: " + ns.get_version_full(files[0]), vc.Verbosity.TEST) for i in range(len(files) - 1): actual_provides = self._get_artificial_provides(files[i]) for j in range(i + 1, len(files)): if ns.get_arch(files[i]) == ns.get_arch(files[j]): if ("zip" in files[i] and "javadoc" in files[j]) or ( "zip" in files[j] and "javadoc" in files[i]): continue compared_provides = self._get_artificial_provides(files[j]) provides_intersection = [ provide for provide in actual_provides if provide in compared_provides ] tu.passed_or_failed( self, not (len(provides_intersection)), "{} and {} have common provides: {}".format( make_rpm_readable(files[i]), make_rpm_readable(files[j]), ", ".join(provides_intersection))) return
def check_debug_packages(self, pkg_priorities): """ Debug packages must have lower priority than normal packages. The standard difference is +-1.""" self._document( "Debug package should have lower priority than normal package.") pkgs = pkg_priorities.keys() for pkg in pkgs: wasdebug = False for suffix in get_debug_suffixes(): if suffix in pkg: name = pkg.replace(suffix, "") break if not wasdebug: continue for p in pkgs: if name == p: master_and_priority_debug = pkg_priorities[pkg] master_and_priority = pkg_priorities[p] else: continue master = master_and_priority.keys() for m in master: passed_or_failed( self, int(master_and_priority[m]) > int( master_and_priority_debug[m]), "Debug subpackage priority check failed for " + name + ", master " + m + ". Debug package should have lower priority. " + "Main package priority: {} Debug package" " priority: {}".format(master_and_priority[m], master_and_priority_debug[m]))
def _mainCheck(self, subpkgs): expected = self._getSubPackages() subpkgSetExpected = sorted(expected) ssGiven = sorted(set(subpkgs)) SubpackagesTest.instance.log( "Checking number of subpackages " + str(len(ssGiven)) + " of " + SubpackagesTest.instance.current_arch + " against " + str(len(subpkgSetExpected)), vc.Verbosity.TEST) SubpackagesTest.instance.log("Presented: " + str(ssGiven), vc.Verbosity.TEST) SubpackagesTest.instance.log("Expected: " + str(subpkgSetExpected), vc.Verbosity.TEST) #if not ssGiven == subpkgSetExpected: if not passed_or_failed( self, ssGiven == subpkgSetExpected, "Set of subpkgs not as expected. Differences will follow."): missingSubpackages = [] for subpkg in subpkgSetExpected: SubpackagesTest.instance.log( "Checking `" + subpkg + "` of " + SubpackagesTest.instance.current_arch, vc.Verbosity.TEST) if subpkg in ssGiven: ssGiven.remove(subpkg) else: missingSubpackages.append(subpkg) passed_or_failed( self, False, "Set of subpackages not as expected. \nextra subpkgs: " + str(ssGiven) + "\nmissing subpkgs: " + str(missingSubpackages)) passed_or_failed(self, subpkg in ssGiven, subpkg + " is missing in given set of rpms.")
def test_majorPackage(self): _reinit(self) java = config.runtime_config.RuntimeConfig().getRpmList( ).getMajorPackage() self.log("Package is: " + java) passed_or_failed(self, java is not None, "Unable to resolve java package from rpms name") return self.passed, self.failed
def test_vendor(self): _reinit(self) vendor = config.runtime_config.RuntimeConfig().getRpmList().getVendor() self.log("Vendor is: " + vendor) passed_or_failed(self, vendor is not None, "Unable to resolve java vendor") self.csch.checkVendor(vendor) return self.passed, self.failed
def test_java(self): _reinit(self) java = config.runtime_config.RuntimeConfig().getRpmList().getJava() self.log("prefix is: " + java) passed_or_failed(self, java is not None, "Could not determine the tested java prefix") self.csch.checkPrefix(java) return self.passed, self.failed
def check_dangling_symlinks(self, link, subpackage=None): """Even though the symlink is dangling, it can be valid for various reasons mentioned under. Most 'fake' fails are a result of missing dependencies (e.g. devel -> headless). We can not install these dependencies, as it would kill the framework idea. """ self._document("There are several types of links, that can be broken by design:\n " " - For links pointing at " + OPENJFXDIR + "/*, targets are provided by another " "subpackage.\n " " - Policytool binary is in JRE package, but policytool slave is in SDK, so the link is " "broken in case of single subpackage install. \n " " - Files in jvm-exports have links in SDK package and files in JRE package," " therefore the links must be broken in single subpackage install. \n " " - For links in proprietary JDK devel package in bin directory," " that point at /jre/bin directory, targets are" " provided by the JRE subpackage, so the links must be broken." ) valid_link = False # check openjfx links, that are expected to be broken (binary in ojfx-devel, but link in headless) # TODO: add additional check if OPENJFXDIR in link.points_at: SymlinkTest.instance.log("Links pointing at " + OPENJFXDIR + " are targeting files provided by openjfx" "subpackage. This is not treated as fail.") valid_link = True # check policytool links - binary is usually in jre, whether link in sdk, it is broken by design, but no way # to fix it if "policytool" in link.path_to_symlink: SymlinkTest.instance.log("Links on policytool binary and slaves are broken by design - the binary is " "usually present in jre, slave in sdk, this is not ment to be fixed.") valid_link = True # exports policies are broken by design - jre/sdk binary/link distribution if "jvm-exports" in link.path_to_symlink and ".jar" in link.points_at: SymlinkTest.instance.log("Export links are broken because links are in devel, whether the binaries are in " "headless, is not buggy behavior.") valid_link = True # links on jre binaries are broken in devel subpackages if get_arch(SymlinkTest.instance) + "/bin/" in link.path_to_symlink and "/jre/bin" in link.points_at and \ (subpackage == "devel" or subpackage == "devel-debug"): SymlinkTest.instance.log("Links in devel package in bin directory, that point at /jre/bin directory, " "targets are provided by the JRE subpackage, so the links must be broken.") valid_link = True # this is a dependency that has around 100 dependencies, installing this into clean chroot is sick if "/jre/lib/ext/java-atk-wrapper.jar" in link.path_to_symlink and \ ("/usr/lib64/java-atk-wrapper/java-atk-wrapper.jar" in link.points_at or "/usr/lib/java-atk-wrapper/java-atk-wrapper.jar" in link.points_at): SymlinkTest.instance.log("Java atk wrapper is provided by required package java-atk-wrapper. Installation" "of this dependency would hurt the test suite, therefore this hardcoded check.") valid_link = True passed_or_failed(self, valid_link, " Subpackage {}: link {} pointing at {} is invalid.".format(subpackage, link.path_to_symlink, link.points_at), "Link {} pointing at {} is valid.".format(link.path_to_symlink, link.points_at))
def test_majorVersion(self): _reinit(self) version = config.runtime_config.RuntimeConfig().getRpmList( ).getMajorVersion() self.log("Major version is: " + version) passed_or_failed(self, version is not None, "Could not determine major version of java") self.csch.checkMajorVersion(version) return self.passed, self.failed
def checkFilesAgainstComparator(self, values, function, comparator): _reinit(self) rpms = config.runtime_config.RuntimeConfig().getRpmList().getAllNames() for file in rpms: self.log("checking: " + file) val = function(file) self.log("have: " + val) tu.passed_or_failed(self, comparator(val, values), file + " is BAD", file + " is ok") return self.passed, self.failed
def iced_tea_web_check(self, manpages_with_postcript=None, manpages_without_postscript=None): itw_manpage_link = "icedtea-web.1.gz" itw_manpage_file = "icedtea-web.1.gz" self._document("IcedTea Web has an " + itw_manpage_file + " man page, that has no binary and " + itw_manpage_link + " man page, that has no slave.") tu.passed_or_failed(self, itw_manpage_file in manpages_without_postscript[tc.DEFAULT], itw_manpage_file + " manpage file missing in " + tc.DEFAULT) tu.passed_or_failed(self, itw_manpage_link in manpages_with_postcript[tc.DEFAULT], itw_manpage_link + " manpage link missing in " + tc.DEFAULT) return
def test_majorVersionSimplified(self): _reinit(self) version = config.runtime_config.RuntimeConfig().getRpmList( ).getMajorVersionSimplified() self.log("Major version simplified is: " + str(version)) passed_or_failed( self, version is not None, "Could not determine or simplify the tested java major version") self.csch.checkMajorVersionSimplified(version) return self.passed, self.failed
def _test_subdirectories_equals(self, subdirectories, expected_subdirectories, _subpkg, name): """ Check whether the subdirectories in /usr/lib/jvm are as expected, logs and counts fails/passes""" if not passed_or_failed(self, sorted(subdirectories) == sorted(expected_subdirectories), "Subdirectories are not as expected, list of differences will follow."): for subdirectory in expected_subdirectories: passed_or_failed(self, subdirectory in subdirectories, "Missing {} subdirectory in {} subpackage".format(subdirectory, _subpkg)) for subdirectory in subdirectories: passed_or_failed(self, subdirectory in expected_subdirectories, "Extra {} subdirectory in {} subpackage".format(subdirectory, _subpkg))
def _remove_excludes(self): exclude_list = tc.oracle_exclude_list() for exclude in exclude_list: self._document("{} is not a binary. It is present in {} subpackages binaries. It has " "no slave in alternatives.".format(exclude, tc.DEVEL)) try: self.installed_binaries[tc.DEVEL].remove(exclude) tu.passed_or_failed(self, True, "") except ValueError: tu.passed_or_failed(self, False, exclude + " not present in " + tc.DEVEL) return
def _scrubLvmCommand(self): o, e, r = exxec.processToStringsWithResult(self.mainCommand() + ["--scrub", "all"]) if r != 0: failed = "Build chroot is locked, please restart the testsuite." tu.passed_or_failed(self, False, failed) raise utils.mock.mock_execution_exception.MockExecutionException( failed) la.LoggingAccess().log(e, vc.Verbosity.MOCK) la.LoggingAccess().log(o, vc.Verbosity.MOCK) la.LoggingAccess().log(str(self.listSnapshots()), vc.Verbosity.MOCK)
def _check_plugin_bins_and_slaves_are_not_present(self, subpackages): for pbinary in tc.get_plugin_binaries(): for subpackage in subpackages: if not tu.passed_or_failed(self, pbinary not in self.installed_binaries[subpackage], pbinary + " should not be in " + subpackage + " because this subpackage must not contain any plugin binaries."): self.installed_binaries[subpackage].remove(pbinary) if not tu.passed_or_failed(self, pbinary not in self.installed_slaves[subpackage], pbinary + " should not be in " + subpackage + " because this subpackage must not contain plugin slaves."): self.installed_slaves[subpackage].remove(pbinary) return
def _check_binaries_against_hardcoded_list(self, binaries, subpackage): hardcoded_binaries = self._get_binaries_as_dict() if not tu.passed_or_failed(self, subpackage in hardcoded_binaries.keys(), "Binaries in unexpected subpackage: " + subpackage): return tu.passed_or_failed(self, sorted(binaries) == sorted(hardcoded_binaries[subpackage]), "Hardcode check: binaries are not as expected in {} subpackage. Missing binaries: {}." " Extra binaries: {}".format(subpackage, tu.two_lists_diff(hardcoded_binaries[subpackage], binaries), tu.two_lists_diff(binaries, hardcoded_binaries[subpackage]))) return
def test_arches(self): _reinit(self) arches = config.runtime_config.RuntimeConfig().getRpmList( ).getAllArches() self.log("All arches are: " + ",".join(arches)) if not config.runtime_config.RuntimeConfig().getRpmList().getJava( ) == gc.ITW: passed_or_failed(self, len(arches) > 1, "less than 1 arch to test") else: passed_or_failed(self, len(arches) == 1, "itw pkgs should be noarch only") return self.passed, self.failed
def remove_binaries_without_slaves(self, args=None): subpackage = self._get_jre_subpackage()[0] excludes = tc.get_ibm_k_bins() + tc.get_ibm_ikey_bins() self._document(" and ".join(excludes) + " are binaries present in {} subpackage. They are not in {} subpackage " "and have no slaves in alternatives.".format(subpackage, self._get_sdk_subpackage()[0])) for e in excludes: try: self.installed_binaries[subpackage].remove(e) tu.passed_or_failed(self, True, "") except ValueError: tu.passed_or_failed(self, False, e + " not present in " + subpackage + " binaries.") return
def _jfx_check(self, list_of_elements, subpackage, slave_or_bin): """ OpenJFX packaging is broken by design - binaries are in ojfx-devel, links are in headless. This is fixed by this method and documented. """ jfx_bins = tc.get_openjfx_binaries() for jfxbin in jfx_bins: try: list_of_elements[subpackage].remove(jfxbin) tu.passed_or_failed(self, True, "") except ValueError: tu.passed_or_failed(self, False, jfxbin + " " + slave_or_bin + " not found in " + subpackage) return
def manpage_links_check(self, bins, subpackage=None, manpages_with_postscript=None, manpage_files=None): """ Each man page has a link, that is located in /usr/shared/man/ and has a specific name bin.1.gz. This link points to alternatives. It must be present for every binary in given subpackages (except exludes). """ self._document("Each man page slave has {} suffix.".format(self._get_manpage_suffixes(tc.DEFAULT)[LINK])) links = self._get_manpage_link_names(bins[subpackage]) # now remove all files from man pages manpage_links = list(set(manpages_with_postscript[subpackage]) - set(manpage_files)) for l in links: link = l + self._get_manpage_suffixes(subpackage)[LINK] tu.passed_or_failed(self, link in manpage_links, link + " man page link not in " + subpackage)
def test_noarchesPackages(self): _reinit(self) noarches = config.runtime_config.RuntimeConfig().getRpmList( ).getNoArchesPackages() self.log("all no arches packages are: ") for pkg in noarches: self.log(" " + pkg) sufficient_noarch_number = len(noarches) > 0 if int( config.runtime_config.RuntimeConfig().getRpmList( ).getMajorVersionSimplified()) < 11 else len(noarches) == 0 passed_or_failed(self, sufficient_noarch_number, "Number of noarch pkgs to test is less than 1") return self.passed, self.failed
def test_file_list(self, current_arch): super().test_file_list(current_arch) for pkg in self.file_list.keys(): for file in self.file_list[pkg]: pkg_name = self.rpms.getRpmWholeName(pkg, current_arch).replace( ".rpm", "") tu.passed_or_failed( self, self.check_file_existence( file.replace("**NVRA**", pkg_name)), "requested file {} not found in specified pkg {}".format( file, "")) return self.passed, self.failed