def upload_content(connection, repolist, path):
     '''
     upload content to a custom repository
     '''
     # Check whether "path" is a file or a directory.
     # If it is a directory, get a list of *.rpm files in it.
     path_type = Util.get_file_type(connection, path)
     if path_type == "regular file":
         content = [basename(path)]
     elif path_type == "directory":
         content = Util.get_rpms_in_dir(connection, path)
     else:
         # This should not happen. Getting here means that "path" is neither a file
         # nor a directory.
         # Anyway, going on with no content,
         # leaving it up to proceed_with_check() to handle this situation.
         content = []
     # Continue in rhui-manager.
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "u")
     RHUIManager.select(connection, repolist)
     Expect.expect(connection, "will be uploaded:")
     Expect.enter(connection, path)
     RHUIManager.proceed_with_check(connection, "The following RPMs will be uploaded:", content)
     RHUIManager.quit(connection, timeout=60)
示例#2
0
 def packages_upload(connection, repo_id, path):
     '''
     upload a package or a directory with packages to the custom repo
     '''
     cmd = "rhui-manager packages upload --repo_id %s --packages %s" % (
         repo_id, path)
     _, stdout, _ = connection.exec_command(cmd)
     output = stdout.read().decode().splitlines()
     successfully_uploaded_packages = [line.split()[0] for line in output \
                                       if line.endswith("successfully uploaded")]
     if not successfully_uploaded_packages:
         raise RuntimeError("\n".join(output)
                            or "no output from '%s'" % cmd)
     successfully_uploaded_packages.sort()
     path_type = Util.get_file_type(connection, path)
     if path_type == "regular file":
         expected_packages = [path]
     elif path_type == "directory":
         expected_packages = [
             join(path, rpm)
             for rpm in Util.get_rpms_in_dir(connection, path)
         ]
     else:
         expected_packages = []
     nose.tools.eq_(successfully_uploaded_packages, expected_packages)
示例#3
0
def test_05_upload_to_custom_repo():
    '''
        upload an unsigned and two differently signed packages to the custom repo
    '''
    avail_rpm_names = [
        pkg.rsplit('-', 2)[0]
        for pkg in Util.get_rpms_in_dir(RHUA, CUSTOM_RPMS_DIR)
    ]
    nose.tools.eq_(
        avail_rpm_names,
        sorted([SIGNED_PACKAGE, UNSIGNED_PACKAGE, SIGNED_PACKAGE_SIG2]),
        msg="Failed to find the packages to upload. Got: %s" % avail_rpm_names)
    RHUIManagerRepo.upload_content(RHUA, [REPO], CUSTOM_RPMS_DIR)
示例#4
0
 def __init__(self):
     self.custom_rpms = Util.get_rpms_in_dir(RHUA, CUSTOM_RPMS_DIR)
     if not self.custom_rpms:
         raise RuntimeError("No custom RPMs to test in %s" %
                            CUSTOM_RPMS_DIR)
     # Test the RHEL-6 repo for a change
     version = 6
     arch = "x86_64"
     with open("/etc/rhui3_tests/tested_repos.yaml") as configfile:
         doc = yaml.load(configfile)
         self.yum_repo_name = doc["yum_repos"][version][arch]["name"]
         self.yum_repo_version = doc["yum_repos"][version][arch]["version"]
         self.yum_repo_kind = doc["yum_repos"][version][arch]["kind"]
         self.yum_repo_path = doc["yum_repos"][version][arch]["path"]
         self.containers = {
             "rh": doc["container_primary"],
             "alt": doc["container_alt"]
         }
 def __init__(self):
     try:
         self.custom_rpm = Util.get_rpms_in_dir(RHUA, CUSTOM_RPMS_DIR)[0]
     except IndexError:
         raise RuntimeError("No custom RPMs to test in %s" %
                            CUSTOM_RPMS_DIR)
     self.version = Util.get_rhel_version(CLI)["major"]
     arch = Util.get_arch(CLI)
     with open("/etc/rhui3_tests/tested_repos.yaml") as configfile:
         doc = yaml.load(configfile)
         try:
             self.yum_repo_name = doc["yum_repos"][
                 self.version][arch]["name"]
             self.yum_repo_version = doc["yum_repos"][
                 self.version][arch]["version"]
             self.yum_repo_kind = doc["yum_repos"][
                 self.version][arch]["kind"]
             self.yum_repo_path = doc["yum_repos"][
                 self.version][arch]["path"]
             self.test_package = doc["yum_repos"][
                 self.version][arch]["test_package"]
         except KeyError:
             raise nose.SkipTest("No test repo defined for RHEL %s on %s" %
                                 (self.version, arch))