def test_99_cleanup(self): """clean up""" # remove the configuration RPM from the client Util.remove_rpm(CLI, [self.repo_with_mod_groups]) # remove comps info from MongoDB units = ["category", "environment", "group", "langpacks"] base_mongo_cmd = "db.units_package_%s.remove({})" all_mongo_cmds = [base_mongo_cmd % unit for unit in units] shell_cmd = "mongo pulp_database --eval '%s'" % "; ".join( all_mongo_cmds) Expect.expect_retval(RHUA, shell_cmd) # remove repos for repo in self.test_repos: RHUIManagerCLI.repo_delete(RHUA, repo) Expect.expect_retval(RHUA, "rm -rf /tmp/%s*" % repo) RHUIManagerCLI.repo_delete(RHUA, BIG_REPO) RHUIManagerCLI.repo_delete(RHUA, ZIP_REPO) # uninstall HAProxy & CDS, forget their keys if not getenv("RHUISKIPSETUP"): RHUICLI.delete(RHUA, "haproxy", force=True) RHUICLI.delete(RHUA, "cds", force=True) ConMgr.remove_ssh_keys(RHUA) # if running RHEL Beta, destroy the non-Beta repos again cmd = "if grep -c Beta /etc/redhat-release; then " \ "rm -f /etc/yum.repos.d/redhat-rhui.repo; fi" Expect.expect_retval(RHUA, cmd)
def test_15_add_bad_cds(): ''' try adding an incorrect CDS hostname, expect trouble and nothing added ''' status = RHUICLI.add(RHUA, "cds", "foo" + CDS_HOSTNAMES[0]) nose.tools.ok_(not status, msg="unexpected addition status: %s" % status) cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [])
def test_15_add_bad_hap(): ''' try adding an incorrect HAProxy hostname, expect trouble and nothing added ''' status = RHUICLI.add(RHUA, "haproxy", "foo" + HA_HOSTNAME) nose.tools.ok_(not status, msg="unexpected addition status: %s" % status) hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, [])
def test_11_delete_cds_noforce(): ''' check if rhui refuses to delete the node when it's the only/last one and force isn't used ''' # delete all but the first node (if there are more nodes to begin with) if len(CDS_HOSTNAMES) > 1: RHUICLI.delete(RHUA, "cds", CDS_HOSTNAMES[1:]) status = RHUICLI.delete(RHUA, "cds", [CDS_HOSTNAMES[0]]) nose.tools.ok_(not status, msg="unexpected deletion status: %s" % status)
def test_03_add_hap(): ''' add an HAProxy Load-Balancer ''' if not getenv("RHUISKIPSETUP"): RHUICLI.add(RHUA, "haproxy", unsafe=True) # check that hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.ok_(hap_list)
def test_02_add_cds(): ''' add a CDS ''' if not getenv("RHUISKIPSETUP"): RHUICLI.add(RHUA, "cds", unsafe=True) # check that cds_list = RHUICLI.list(RHUA, "cds") nose.tools.ok_(cds_list)
def test_99_cleanup(self): '''clean up''' Expect.expect_retval(CLI, "rhui-set-release --unset") Util.remove_rpm(CLI, [self.test_package, CONF_RPM_NAME]) RHUIManagerCLI.repo_delete(RHUA, self.repo_id) Expect.expect_retval(RHUA, "rm -rf /tmp/%s*" % CONF_RPM_NAME) if not getenv("RHUISKIPSETUP"): RHUIManager.remove_rh_certs(RHUA) RHUICLI.delete(RHUA, "haproxy", force=True) RHUICLI.delete(RHUA, "cds", force=True) ConMgr.remove_ssh_keys(RHUA)
def test_18_add_safe_unknown_key(): ''' try adding the Load-balancer when its SSH key is unknown, without using --unsafe; should fail ''' # for RHBZ#1409460 # make sure its key is unknown ConMgr.remove_ssh_keys(RHUA, [HA_HOSTNAME]) # try adding the Load-balancer status = RHUICLI.add(RHUA, "haproxy", HA_HOSTNAME) nose.tools.ok_(not status, msg="unexpected addition status: %s" % status) hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, [])
def test_17_add_hap_changed_case(): ''' add and delete an HAProxy Load-balancer with uppercase characters, should work ''' # for RHBZ#1572623 hap_up = HA_HOSTNAME.replace("hap", "HAP") status = RHUICLI.add(RHUA, "haproxy", hap_up, unsafe=True) nose.tools.ok_(status, msg="unexpected %s addition status: %s" % (hap_up, status)) hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, [hap_up]) status = RHUICLI.delete(RHUA, "haproxy", [hap_up], force=True) nose.tools.ok_(status, msg="unexpected deletion status: %s" % status)
def test_20_delete_unreachable(): ''' add a CDS, make it unreachable, and see if it can still be deleted from the RHUA ''' # for RHBZ#1639996 # choose a random CDS hostname from the list cds = random.choice(CDS_HOSTNAMES) status = RHUICLI.add(RHUA, "cds", cds, unsafe=True) nose.tools.ok_(status, msg="unexpected installation status: %s" % status) cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [cds]) Helpers.break_hostname(RHUA, cds) # delete it status = RHUICLI.delete(RHUA, "cds", [cds], force=True) nose.tools.ok_(status, msg="unexpected deletion status: %s" % status) # check it cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, []) Helpers.unbreak_hostname(RHUA) # the node remains configured (RHUI mount point, httpd)... unconfigure it properly # do so by adding and deleting it again RHUICLI.add(RHUA, "cds", cds, unsafe=True) RHUICLI.delete(RHUA, "cds", [cds], force=True)
def test_20_delete_unreachable(): ''' add a Load-balancer, make it unreachable, and see if it can still be deleted from the RHUA ''' # for RHBZ#1639996 status = RHUICLI.add(RHUA, "haproxy", HA_HOSTNAME, unsafe=True) nose.tools.ok_(status, msg="unexpected installation status: %s" % status) hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, [HA_HOSTNAME]) Helpers.break_hostname(RHUA, HA_HOSTNAME) # delete it status = RHUICLI.delete(RHUA, "haproxy", [HA_HOSTNAME], force=True) nose.tools.ok_(status, msg="unexpected deletion status: %s" % status) # check it hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, []) Helpers.unbreak_hostname(RHUA) # the node remains configured (haproxy)... unconfigure it properly # do so by adding and deleting it again RHUICLI.add(RHUA, "haproxy", HA_HOSTNAME, unsafe=True) RHUICLI.delete(RHUA, "haproxy", [HA_HOSTNAME], force=True) # clean up the SSH key ConMgr.remove_ssh_keys(RHUA, [HA_HOSTNAME])
def test_17_add_cds_changed_case(): ''' add and delete a CDS with uppercase characters, should work ''' # for RHBZ#1572623 # choose a random CDS hostname from the list cds_up = random.choice(CDS_HOSTNAMES).replace("cds", "CDS") status = RHUICLI.add(RHUA, "cds", cds_up, unsafe=True) nose.tools.ok_(status, msg="unexpected %s addition status: %s" % (cds_up, status)) cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [cds_up]) status = RHUICLI.delete(RHUA, "cds", [cds_up], force=True) nose.tools.ok_(status, msg="unexpected %s deletion status: %s" % (cds_up, status))
def test_18_add_safe_unknown_key(): ''' try adding a CDS whose SSH key is unknown, without using --unsafe; should fail ''' # for RHBZ#1409460 # choose a random CDS hostname from the list cds = random.choice(CDS_HOSTNAMES) # make sure its key is unknown ConMgr.remove_ssh_keys(RHUA, [cds]) # try adding the CDS status = RHUICLI.add(RHUA, "cds", cds) nose.tools.ok_(not status, msg="unexpected %s addition status: %s" % (cds, status)) cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [])
def test_19_add_safe_known_key(): ''' add and delete the Load-balancer when its SSH key is known, without using --unsafe; should work ''' # for RHBZ#1409460 # accept the host's SSH key ConMgr.add_ssh_keys(RHUA, [HA_HOSTNAME]) # actually add and delete the host status = RHUICLI.add(RHUA, "haproxy", HA_HOSTNAME) nose.tools.ok_(status, msg="unexpected addition status: %s" % status) hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, [HA_HOSTNAME]) status = RHUICLI.delete(RHUA, "haproxy", [HA_HOSTNAME], force=True) nose.tools.ok_(status, msg="unexpected deletion status: %s" % status) # clean up the SSH key ConMgr.remove_ssh_keys(RHUA, [HA_HOSTNAME])
def test_08_list_cds(): ''' check if nothing extra has been added ''' cds_list = RHUICLI.list(RHUA, "cds") # the readded CDS is now the last one in the list; the list may not be the same, sort it! cds_list.sort() nose.tools.eq_(cds_list, CDS_HOSTNAMES)
def test_06_list_cds(): ''' check if the CDSs are still tracked, and nothing extra has appeared ''' cds_list = RHUICLI.list(RHUA, "cds") # the reinstalled CDS is now the last one in the list; the list may not be the same, sort it! cds_list.sort() nose.tools.eq_(cds_list, CDS_HOSTNAMES)
def test_07_readd_cds_noforce(): ''' check if rhui refuses to add a CDS again if no extra parameter is used ''' # again choose a random CDS hostname from the list cds = random.choice(CDS_HOSTNAMES) status = RHUICLI.add(RHUA, "cds", cds, unsafe=True) nose.tools.ok_(not status, msg="unexpected %s readdition status: %s" % (cds, status))
def test_03_add_cds(): ''' add all known CDSs ''' for cds in CDS_HOSTNAMES: status = RHUICLI.add(RHUA, "cds", cds, unsafe=True) nose.tools.ok_(status, msg="unexpected %s installation status: %s" % (cds, status))
def test_09_readd_cds(): ''' add one of the CDSs again by using force ''' # again choose a random CDS hostname from the list cds = random.choice(CDS_HOSTNAMES) status = RHUICLI.add(RHUA, "cds", cds, force=True, unsafe=True) nose.tools.ok_(status, msg="unexpected %s readdition status: %s" % (cds, status))
def test_05_reinstall_cds(): ''' add one of the CDSs again by reinstalling it ''' # choose a random CDS hostname from the list cds = random.choice(CDS_HOSTNAMES) status = RHUICLI.reinstall(RHUA, "cds", cds) nose.tools.ok_(status, msg="unexpected %s reinstallation status: %s" % (cds, status))
def test_22_verbose_reporting(): ''' check if a failure is reported properly (if puppet is run with --verbose) ''' # for RHBZ#1751378 # choose a random CDS and open port 443 on it, which will later prevent Apache from starting cds = random.choice(CDS) Expect.enter(cds, "ncat -l 443 --keep-open") # try adding the CDS and capture the output error_msg = "change from stopped to running failed" out = Util.mktemp_remote(RHUA) cmd = "rhui cds add %s %s %s -u &> %s" % (cds.hostname, SUDO_USER_NAME, SUDO_USER_KEY, out) RHUA.recv_exit_status(cmd, timeout=120) # delete the CDS and free the port RHUICLI.delete(RHUA, "cds", [cds.hostname], force=True) Expect.enter(cds, CTRL_C) # check if the failure is in the output Expect.expect_retval(RHUA, "grep '%s' %s" % (error_msg, out)) Expect.expect_retval(RHUA, "rm -f %s" % out)
def test_19_add_safe_known_key(): ''' add and delete a CDS whose SSH key is known, without using --unsafe; should work ''' # for RHBZ#1409460 # choose a random CDS hostname from the list cds = random.choice(CDS_HOSTNAMES) # accept the host's SSH key ConMgr.add_ssh_keys(RHUA, [cds]) # actually add and delete the host status = RHUICLI.add(RHUA, "cds", cds) nose.tools.ok_(status, msg="unexpected %s addition status: %s" % (cds, status)) cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [cds]) status = RHUICLI.delete(RHUA, "cds", [cds], force=True) nose.tools.ok_(status, msg="unexpected %s deletion status: %s" % (cds, status)) # clean up the SSH key ConMgr.remove_ssh_keys(RHUA, [cds])
def test_01_setup(): """log in to RHUI, ensure CDS & HAProxy nodes have been added""" if not getenv("RHUISKIPSETUP"): RHUIManager.initial_run(RHUA) RHUICLI.add(RHUA, "cds", unsafe=True) RHUICLI.add(RHUA, "haproxy", unsafe=True) # check that cds_list = RHUICLI.list(RHUA, "cds") nose.tools.ok_(cds_list) hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.ok_(hap_list) # if running RHEL Beta, temporarily restore the non-Beta repos potentially disabled by choose_repo.py cmd = "if grep -q Beta /etc/redhat-release; then " \ "cp /etc/yum.repos.d/redhat-rhui.repo{.disabled,}; " \ "yum-config-manager --enable %s %s; fi" % (BIG_REPO, EMP_REPO) Expect.expect_retval(RHUA, cmd)
def test_16_delete_bad_hap(): ''' try deleting a non-existing HAProxy hostname, expect trouble ''' # for RHBZ#1409697 # first try a case where only an unknown (none known) hostname is used status = RHUICLI.delete(RHUA, "haproxy", ["bar" + HA_HOSTNAME], force=True) nose.tools.ok_(not status, msg="unexpected deletion status: %s" % status) # and now a combination of a known and an unknown hostname, # the known hostname should be delete, the unknown skipped, exit code 1 # so, add a node first RHUICLI.add(RHUA, "haproxy", HA_HOSTNAME, unsafe=True) hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, [HA_HOSTNAME]) # deleting now status = RHUICLI.delete(RHUA, "haproxy", ["baz" + HA_HOSTNAME, HA_HOSTNAME], force=True) nose.tools.ok_(not status, msg="unexpected deletion status: %s" % status) # check if the valid hostname was deleted and nothing remained hap_list = RHUICLI.list(RHUA, "haproxy") nose.tools.eq_(hap_list, [])
def test_16_delete_bad_cds(): ''' try deleting a non-existing CDS hostname, expect trouble ''' # for RHBZ#1409697 # first try a case where only an unknown (ie. no known) hostname is used on the command line status = RHUICLI.delete(RHUA, "cds", ["bar" + CDS_HOSTNAMES[0]], force=True) nose.tools.ok_(not status, msg="unexpected deletion status: %s" % status) # and now a combination of a known and an unknown hostname # the known hostname should be deleted, the unknown skipped, exit code 1 # so, add a node first cds = random.choice(CDS_HOSTNAMES) RHUICLI.add(RHUA, "cds", cds, unsafe=True) cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [cds]) # deleting now status = RHUICLI.delete(RHUA, "cds", ["baz" + cds, cds], force=True) nose.tools.ok_(not status, msg="unexpected deletion status: %s" % status) # check if the valid hostname was deleted and nothing remained cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [])
def test_14_list_cds(): ''' check if the last CDS has been deleted ''' cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [])
def test_04_list_cds(): ''' check if the CDSs have been added ''' cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, CDS_HOSTNAMES)
def test_02_list_cds(): ''' check if there are no CDSs ''' cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [])
def test_12_list_cds(): ''' check if the last CDS really hasn't been deleted ''' cds_list = RHUICLI.list(RHUA, "cds") nose.tools.eq_(cds_list, [CDS_HOSTNAMES[0]])
def test_13_delete_cds_force(): ''' delete the last CDS forcibly ''' status = RHUICLI.delete(RHUA, "cds", [CDS_HOSTNAMES[0]], force=True) nose.tools.ok_(status, msg="unexpected deletion status: %s" % status)