Пример #1
0
def test_14_verbose_reporting():
    '''
    check if a failure is reported properly (if puppet is 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 check for the specific error message in the output
    error_msg = "change from stopped to running failed"
    RHUIManager.screen(RHUA, "cds")
    Expect.enter(RHUA, "a")
    Expect.expect(RHUA, "Hostname")
    Expect.enter(RHUA, cds.hostname)
    Expect.expect(RHUA, "Username")
    Expect.enter(RHUA, SUDO_USER_NAME)
    Expect.expect(RHUA, "Absolute")
    Expect.enter(RHUA, SUDO_USER_KEY)
    Expect.expect(RHUA, "Proceed")
    Expect.enter(RHUA, "y")
    state = Expect.expect_list(RHUA,
                               [(re.compile(".*%s.*" % error_msg, re.DOTALL), 1),
                                (re.compile(".*Aborting.*", re.DOTALL), 2),
                                (re.compile(".*was successfully configured.*", re.DOTALL), 3)],
                               timeout=180)
    # quit rhui-manager, clean up, fail if the error message didn't appear
    Expect.enter(RHUA, "q")
    Expect.enter(cds, CTRL_C)
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    if cds_list:
        RHUIManagerInstance.delete_all(RHUA, "cds")
    if state != 1:
        raise AssertionError("The expected error message was not seen in rhui-manager's output.")
Пример #2
0
def test_01_login_add_cds_hap():
    """log in to RHUI, add CDS and HAProxy nodes"""
    RHUIManager.initial_run(RHUA)
    for cds in HOSTNAMES["CDS"]:
        RHUIManagerInstance.add_instance(RHUA, "cds", cds)
    for haproxy in HOSTNAMES["HAProxy"]:
        RHUIManagerInstance.add_instance(RHUA, "loadbalancers", haproxy)
 def test_03_add_hap():
     '''
        add an HAProxy Load-balancer
     '''
     hap_list = RHUIManagerInstance.list(RHUA, "loadbalancers")
     nose.tools.assert_equal(hap_list, [])
     RHUIManagerInstance.add_instance(RHUA, "loadbalancers")
 def test_02_add_cds():
     '''
        add a CDS
     '''
     cds_list = RHUIManagerInstance.list(RHUA, "cds")
     nose.tools.assert_equal(cds_list, [])
     RHUIManagerInstance.add_instance(RHUA, "cds")
 def test_03_add_cds():
     '''
         add a CDS
     '''
     if not getenv("RHUISKIPSETUP"):
         cds_list = RHUIManagerInstance.list(RHUA, "cds")
         nose.tools.assert_equal(cds_list, [])
         RHUIManagerInstance.add_instance(RHUA, "cds")
 def test_04_add_hap():
     '''
         add an HAProxy Load-balancer
     '''
     if not getenv("RHUISKIPSETUP"):
         hap_list = RHUIManagerInstance.list(RHUA, "loadbalancers")
         nose.tools.assert_equal(hap_list, [])
         RHUIManagerInstance.add_instance(RHUA, "loadbalancers")
def test_00_rhui_init():
    '''
        add a CDS and run rhui-subscription-sync to ensure their log files exist
    '''
    #  use initial_run first to ensure we're logged in to rhui-manager
    RHUIManager.initial_run(CONNECTION_RHUA)
    RHUIManagerInstance.add_instance(CONNECTION_RHUA, "cds")
    # can't use expect_retval as the exit code can be 0 or 1 (sync is configured or unconfigured)
    Expect.ping_pong(CONNECTION_RHUA, "rhui-subscription-sync ; echo ACK",
                     "ACK")
 def test_99_cleanup(self):
     '''
        remove the repo, uninstall hap, cds, cli rpm artefacts; remove rpms from cli
     '''
     Util.remove_rpm(CLI, [self.test["test_package"], self.test["repo_id"]])
     # the errata must be removed in the DB directly:
     Expect.expect_retval(
         RHUA, "mongo pulp_database --eval 'db.units_erratum.remove({})'")
     RHUIManagerRepo.delete_all_repos(RHUA)
     Expect.expect_retval(RHUA, "rm -rf /tmp/%s*" % self.test["repo_id"])
     if not getenv("RHUISKIPSETUP"):
         RHUIManagerInstance.delete_all(RHUA, "loadbalancers")
         RHUIManagerInstance.delete_all(RHUA, "cds")
Пример #9
0
def test_99_cleanup():
    '''
       clean up
    '''
    Util.remove_rpm(CLI, [SIGNED_PACKAGE, "gpg-pubkey-%s" % SIG, REPO])
    rhel = Util.get_rhel_version(CLI)["major"]
    if rhel <= 7:
        cache = "/var/cache/yum/x86_64/%sServer/rhui-custom-%s/" % (rhel, REPO)
    else:
        cache = "/var/cache/dnf/rhui-custom-%s*/" % REPO
    Expect.expect_retval(CLI, "rm -rf %s" % cache)
    RHUIManagerRepo.delete_all_repos(RHUA)
    Expect.expect_retval(RHUA, "rm -rf /tmp/%s*" % REPO)
    if not getenv("RHUISKIPSETUP"):
        RHUIManagerInstance.delete_all(RHUA, "loadbalancers")
        RHUIManagerInstance.delete_all(RHUA, "cds")
 def test_99_cleanup(self):
     '''
        remove repos, certs, cli rpms; remove rpms from cli, uninstall cds, hap
     '''
     test_rpm_name = self.custom_rpm.rsplit('-', 2)[0]
     RHUIManagerRepo.delete_all_repos(RHUA)
     nose.tools.assert_equal(RHUIManagerRepo.list(RHUA), [])
     Expect.expect_retval(RHUA, "rm -f /root/test_ent_cli*")
     Expect.expect_retval(RHUA, "rm -rf /root/test_cli_rpm-3.0/")
     Util.remove_rpm(CLI,
                     [self.test_package, "test_cli_rpm", test_rpm_name])
     rmtree(TMPDIR)
     Helpers.del_legacy_ca(CDS, LEGACY_CA_FILE)
     if not getenv("RHUISKIPSETUP"):
         RHUIManagerInstance.delete_all(RHUA, "loadbalancers")
         RHUIManagerInstance.delete_all(RHUA, "cds")
         RHUIManager.remove_rh_certs(RHUA)
 def test_99_cleanup(self):
     '''
        remove the repo and RH cert, uninstall CDS and HAProxy, delete the ostree configuration
     '''
     RHUIManagerRepo.delete_all_repos(RHUA)
     nose.tools.assert_equal(RHUIManagerRepo.list(RHUA), [])
     RHUIManagerInstance.delete_all(RHUA, "loadbalancers")
     RHUIManagerInstance.delete_all(RHUA, "cds")
     Expect.expect_retval(RHUA, "rm -f /root/test_atomic_ent_cli*")
     Expect.expect_retval(RHUA, "rm -f /root/test_atomic_pkg.tar.gz")
     RHUIManager.remove_rh_certs(RHUA)
     if AH_EXISTS:
         Expect.expect_retval(
             ATOMIC_CLI,
             "ostree remote delete %s" % self.atomic_repo_remote)
         Expect.expect_retval(
             ATOMIC_CLI, "mv -f /etc/containers/registries.conf{.backup,}")
Пример #12
0
def test_99_cleanup():
    '''
        delete the archives and their checksum files, local caches; remove CDS
    '''
    with open(SOSREPORT_LOCATION_RHUA) as location:
        sosreport_file = location.read()
    Expect.ping_pong(
        CONNECTION_RHUA,
        "rm -f " + sosreport_file + "* ; " + "ls " + sosreport_file + "* 2>&1",
        "No such file or directory")
    with open(SOSREPORT_LOCATION_CDS) as location:
        sosreport_file = location.read()
    Expect.ping_pong(
        CONNECTION_CDS,
        "rm -f " + sosreport_file + "* ; " + "ls " + sosreport_file + "* 2>&1",
        "No such file or directory")
    rmtree(TMPDIR)
    RHUIManagerInstance.delete_all(CONNECTION_RHUA, "cds")
Пример #13
0
 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")
Пример #14
0
def test_13_delete_select_0():
    '''
    add a CDS and see if no issue occurs if it and "a zeroth" (ghost) CDSs are selected for deletion
    '''
    # for RHBZ#1305612
    # choose a random CDS and add it
    cds = random.choice(CDS_HOSTNAMES)
    RHUIManagerInstance.add_instance(RHUA, "cds", cds)
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_not_equal(cds_list, [])

    # try the deletion
    RHUIManager.screen(RHUA, "cds")
    Expect.enter(RHUA, "d")
    Expect.expect(RHUA, "Enter value")
    Expect.enter(RHUA, "0")
    Expect.expect(RHUA, "Enter value")
    Expect.enter(RHUA, "1")
    Expect.expect(RHUA, "Enter value")
    Expect.enter(RHUA, "c")
    state = Expect.expect_list(RHUA,
                               [(re.compile(".*Are you sure.*", re.DOTALL), 1),
                                (re.compile(".*An unexpected error.*", re.DOTALL), 2)])
    if state == 1:
        Expect.enter(RHUA, "y")
        RHUIManager.quit(RHUA, timeout=180)
    else:
        Expect.enter(RHUA, "q")

    # the CDS list ought to be empty now; if not, delete the CDS and fail
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    if cds_list:
        RHUIManagerInstance.delete_all(RHUA, "cds")
        raise AssertionError("The CDS list is not empty after the deletion attempt: %s." % cds_list)
Пример #15
0
def test_12_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)
    RHUIManagerInstance.add_instance(RHUA, "cds", cds)
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_not_equal(cds_list, [])

    Helpers.break_hostname(RHUA, cds)

    # delete it
    RHUIManagerInstance.delete(RHUA, "cds", [cds])
    # check it
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_equal(cds_list, [])

    Helpers.unbreak_hostname(RHUA)

    # the node remains configured (RHUI mount point, httpd)... unconfigure it properly
    RHUIManagerInstance.add_instance(RHUA, "cds", cds)
    RHUIManagerInstance.delete(RHUA, "cds", [cds])
Пример #16
0
def test_11_add_cds_uppercase():
    '''
        add (and delete) a CDS with uppercase characters
    '''
    # for RHBZ#1572623
    # choose a random CDS hostname from the list
    cds_up = random.choice(CDS_HOSTNAMES).replace("cds", "CDS")
    RHUIManagerInstance.add_instance(RHUA, "cds", cds_up)
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_equal(len(cds_list), 1)
    RHUIManagerInstance.delete(RHUA, "cds", [cds_up])
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_equal(len(cds_list), 0)
Пример #17
0
def test_04_add_second_cds():
    """[TUI] add the second CDS"""
    if not CDS2_EXISTS:
        raise nose.exc.SkipTest("The second CDS does not exist")
    RHUIManagerInstance.add_instance(RHUA, "cds", CDS_HOSTNAMES[1])
Пример #18
0
def test_99_cleanup():
    """delete CDS and HAProxy nodes"""
    RHUIManagerInstance.delete_all(RHUA, "loadbalancers")
    RHUIManagerInstance.delete_all(RHUA, "cds")
Пример #19
0
def test_08_delete_cds():
    '''
        delete all CDSs
    '''
    RHUIManagerInstance.delete_all(RHUA, "cds")
 def test_02_add_cds():
     '''
        add a CDS
     '''
     if not getenv("RHUISKIPSETUP"):
         RHUIManagerInstance.add_instance(RHUA, "cds")
 def test_03_add_hap():
     '''
        add an HAProxy Load-balancer
     '''
     if not getenv("RHUISKIPSETUP"):
         RHUIManagerInstance.add_instance(RHUA, "loadbalancers")
Пример #22
0
def test_08_delete_first_cds():
    """[TUI] delete the first CDS"""
    RHUIManagerInstance.delete(RHUA, "cds", [CDS_HOSTNAMES[0]])
Пример #23
0
def test_09_list_cds():
    '''
        list CDSs, expect none
    '''
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_equal(cds_list, [])
Пример #24
0
def test_06_list_cds():
    '''
        check if the CDSs are still tracked
    '''
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_equal(len(cds_list), len(CDS_HOSTNAMES))
Пример #25
0
def test_04_list_cds():
    '''
        list CDSs, expect as many as there are in /etc/hosts
    '''
    cds_list = RHUIManagerInstance.list(RHUA, "cds")
    nose.tools.assert_equal(len(cds_list), len(CDS_HOSTNAMES))
Пример #26
0
def test_02_add_first_cds():
    """[TUI] add the first CDS"""
    RHUIManagerInstance.add_instance(RHUA, "cds", CDS_HOSTNAMES[0])
Пример #27
0
def test_01_login_add_hap():
    """log in to RHUI, add an HAProxy Load-balancer"""
    RHUIManager.initial_run(RHUA)
    RHUIManagerInstance.add_instance(RHUA, "loadbalancers")
Пример #28
0
def test_99_cleanup():
    """delete the HAProxy Load-balancer"""
    RHUIManagerInstance.delete(RHUA, "loadbalancers", [HA_HOSTNAME])
    # also clean up the SSH keys (if left behind)
    ConMgr.remove_ssh_keys(RHUA)
Пример #29
0
def test_06_delete_second_cds():
    """[TUI] delete the second CDS"""
    if not CDS2_EXISTS:
        raise nose.exc.SkipTest("The second CDS does not exist")
    RHUIManagerInstance.delete(RHUA, "cds", [CDS_HOSTNAMES[1]])
Пример #30
0
def test_05_readd_cds():
    '''
        add one of the CDSs again (reapply the configuration)
    '''
    # choose a random CDS hostname from the list
    RHUIManagerInstance.add_instance(RHUA, "cds", random.choice(CDS_HOSTNAMES), update=True)