def test_06_sync_containers(self): ''' sync the containers ''' quay_repo_name = Util.safe_pulp_repo_name(self.container_quay["name"]) docker_repo_name = Util.safe_pulp_repo_name( self.container_docker["name"]) RHUIManagerSync.sync_repo( RHUA, [self.container_displayname, quay_repo_name, docker_repo_name]) RHUIManagerSync.wait_till_repo_synced( RHUA, [self.container_displayname, quay_repo_name, docker_repo_name])
def add_container(connection, containername, containerid="", displayname="", credentials=""): ''' add a new Red Hat container ''' default_registry = Helpers.get_registry_url("default", connection) # if the credentials parameter is supplied, it's supposed to be a list containing: # 0 - registry hostname if not using the default one # 1 - username (if required; the default registry requires the RH (CCSP) login) # 2 - password (if required) # do NOT supply them if they're in rhui-tools.conf and you want to use the default registry; # this method will fail otherwise, because it will expect rhui-manager to ask for them RHUIManager.screen(connection, "repo") Expect.enter(connection, "ad") Expect.expect(connection, "Specify URL of registry .*:") if credentials and credentials[0]: registry = credentials[0] Expect.enter(connection, registry) else: registry = default_registry Expect.enter(connection, "") Expect.expect(connection, "Name of the container in the registry:") Expect.enter(connection, containername) Expect.expect(connection, "Unique ID for the container .*]", 60) Expect.enter(connection, containerid) Expect.expect(connection, "Display name for the container.*]:") Expect.enter(connection, displayname) # login & password provided, or a non-default registry specified if credentials or registry != default_registry: Expect.expect(connection, "Registry username:"******"Registry password:"******"") if not containerid: containerid = Util.safe_pulp_repo_name(containername) if not displayname: displayname = Util.safe_pulp_repo_name(containername) RHUIManager.proceed_with_check(connection, "The following container will be added:", ["Registry URL: " + registry, "Container Id: " + containerid, "Display Name: " + displayname, "Upstream Container Name: " + containername]) RHUIManager.quit(connection)
def test_15_display_container(self): '''check detailed information on the RH container''' repo_name = Util.safe_pulp_repo_name(self.containers["rh"]["name"]) RHUIManagerRepo.check_detailed_information(RHUA, [self.containers["rh"]["displayname"], "https://%s/pulp/docker/%s/" % \ (ConMgr.get_cds_lb_hostname(), repo_name)], [False], [True, None, True], 0)
def test_10_check_images(self): ''' check if the container images are now available ''' if not self.cli_supported: raise nose.exc.SkipTest("Not supported on RHEL %s" % self.cli_os_version) quay_repo_name = Util.safe_pulp_repo_name(self.container_quay["name"]) docker_repo_name = Util.safe_pulp_repo_name( self.container_docker["name"]) _, stdout, _ = CLI.exec_command("docker images") images = stdout.read().decode().splitlines() images_cli = [image.split()[0].split("/")[1] \ for image in images if image.startswith(ConMgr.get_cds_lb_hostname())] nose.tools.eq_( sorted(images_cli), sorted([self.container_id, quay_repo_name, docker_repo_name]))
def test_99_cleanup(self): ''' remove the containers from the client and the RHUA, uninstall HAProxy and CDS ''' if self.cli_supported: Expect.expect_retval(CLI, "docker rm -f $(docker ps -a -f ancestor=%s -q)" % \ self.container_id) for container in [ self.container_id, Util.safe_pulp_repo_name(self.container_quay["name"]), Util.safe_pulp_repo_name(self.container_docker["name"]) ]: Expect.expect_retval(CLI, "docker rmi %s" % container) Util.remove_rpm(CLI, [CONF_RPM_NAME]) Util.restart_if_present(CLI, "docker") Expect.expect_retval(RHUA, "rm -rf /tmp/%s*" % CONF_RPM_NAME) RHUIManagerRepo.delete_all_repos(RHUA) if not getenv("RHUISKIPSETUP"): RHUIManagerInstance.delete_all(RHUA, "loadbalancers") RHUIManagerInstance.delete_all(RHUA, "cds")
def test_09_pull_image(self): ''' pull the container image ''' if not self.cli_supported: raise nose.exc.SkipTest("Not supported on RHEL %s" % self.cli_os_version) for container in [ self.container_id, Util.safe_pulp_repo_name(self.container_quay["name"]), Util.safe_pulp_repo_name(self.container_docker["name"]) ]: cmd = "docker pull %s" % container # in some cases the container is synced but pulling fails mysteriously # if that happens, try again in a minute try: Expect.expect_retval(CLI, cmd, timeout=30) except ExpectFailed: time.sleep(60) Expect.expect_retval(CLI, cmd, timeout=30)