Ejemplo n.º 1
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.º 2
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.º 3
0
 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)
Ejemplo n.º 4
0
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, [])
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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, [])
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
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.º 11
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.º 12
0
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, [])
Ejemplo n.º 13
0
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, [])
Ejemplo n.º 14
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.º 15
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.º 16
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.º 17
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.º 18
0
def test_04_list_hap():
    '''
    check if the HAProxy Load-balancer has been added
    '''
    hap_list = RHUICLI.list(RHUA, "haproxy")
    nose.tools.eq_(hap_list, [HA_HOSTNAME])
Ejemplo n.º 19
0
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]])
Ejemplo n.º 20
0
def test_14_list_hap():
    '''
    check if the HAProxy Load-balancer has been deleted
    '''
    hap_list = RHUICLI.list(RHUA, "haproxy")
    nose.tools.eq_(hap_list, [])
Ejemplo n.º 21
0
def test_10_list_hap():
    '''
    check if the HAProxy Load-balancer is still tracked, and only once
    '''
    hap_list = RHUICLI.list(RHUA, "haproxy")
    nose.tools.eq_(hap_list, [HA_HOSTNAME])
Ejemplo n.º 22
0
def test_08_list_hap():
    '''
    check if nothing extra has been added
    '''
    hap_list = RHUICLI.list(RHUA, "haproxy")
    nose.tools.eq_(hap_list, [HA_HOSTNAME])
Ejemplo n.º 23
0
def test_02_list_cds():
    '''
    check if there are no CDSs
    '''
    cds_list = RHUICLI.list(RHUA, "cds")
    nose.tools.eq_(cds_list, [])
Ejemplo n.º 24
0
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)
Ejemplo n.º 25
0
def test_14_list_cds():
    '''
    check if the last CDS has been deleted
    '''
    cds_list = RHUICLI.list(RHUA, "cds")
    nose.tools.eq_(cds_list, [])
Ejemplo n.º 26
0
def test_12_list_hap():
    '''
    check if the HAProxy Load-balancer really hasn't been deleted
    '''
    hap_list = RHUICLI.list(RHUA, "haproxy")
    nose.tools.eq_(hap_list, [HA_HOSTNAME])
Ejemplo n.º 27
0
def test_02_list_hap():
    '''
    check if there are no HAProxy Load-balancers
    '''
    hap_list = RHUICLI.list(RHUA, "haproxy")
    nose.tools.eq_(hap_list, [])