Ejemplo n.º 1
0
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])
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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, [])
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
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))
Ejemplo n.º 10
0
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, [])
Ejemplo n.º 11
0
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])
Ejemplo n.º 12
0
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])
Ejemplo n.º 13
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)
Ejemplo n.º 14
0
def test_16_delete_first_cds():
    """[CLI] delete the first CDS"""
    RHUICLI.delete(RHUA, "cds", [CDS_HOSTNAMES[0]], True)
Ejemplo n.º 15
0
def test_11_delete_hap_noforce():
    '''
    check if rhui refuses to delete the node when it's the only/last one and force isn't used
    '''
    status = RHUICLI.delete(RHUA, "haproxy", [HA_HOSTNAME])
    nose.tools.ok_(not status, msg="unexpected deletion status: %s" % status)
Ejemplo n.º 16
0
def test_14_delete_second_cds():
    """[CLI] delete the second CDS"""
    if not CDS2_EXISTS:
        raise nose.exc.SkipTest("The second CDS does not exist")
    RHUICLI.delete(RHUA, "cds", [CDS_HOSTNAMES[1]])
Ejemplo n.º 17
0
def test_13_delete_hap_force():
    '''
    delete the HAProxy Load-balancer forcibly
    '''
    status = RHUICLI.delete(RHUA, "haproxy", [HA_HOSTNAME], force=True)
    nose.tools.ok_(status, msg="unexpected deletion status: %s" % status)