Esempio n. 1
0
def test():
    global vm
    global test_host
    mn_vm_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config,
                                             test_lib.scenario_file)
    if len(mn_vm_host) != 1:
        test_util.test_fail('MN VM is running on %d host(s)' % len(mn_vm_host))
    mn_host_list = test_stub.get_mn_host(test_lib.all_scenario_config,
                                         test_lib.scenario_file)
    for mn_host in mn_host_list:
        if mn_host.ip_ != mn_vm_host[0].ip_:
            test_host = mn_host
            break
    if not test_host:
        test_util.test_fail('there is only one mn host')

    test_util.test_logger(
        "stop consul for host [%s] that mn vm is running on" % (test_host.ip_))
    test_stub.stop_consul(test_host, test_lib.all_scenario_config)
    test_util.test_logger(
        "wait for 20 seconds to see if management node VM starts on another host"
    )
    time.sleep(20)
    try:
        new_mn_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config,
                                                  test_lib.scenario_file)
        if len(new_mn_host) == 0:
            test_util.test_fail(
                "management node VM was destroyed after stopping another host's consul"
            )
        elif len(new_mn_host) > 1:
            test_util.test_fail(
                "management node VM starts on more than one host after stopping another host's consul"
            )
    except:
        test_util.test_fail(
            "management node VM was destroyed after stopping another host's consul"
        )
    if new_mn_host[0].ip_ != mn_vm_host[0].ip_:
        test_util.test_fail(
            'management node VM starts on another host when another host stopped consul'
        )

    test_stub.ensure_hosts_connected()
    test_stub.ensure_pss_connected()
    test_stub.ensure_bss_host_connected_from_stop(test_lib.scenario_file,
                                                  test_lib.all_scenario_config,
                                                  test_lib.deploy_config)
    test_stub.ensure_bss_connected()

    test_stub.return_pass_ahead_if_3sites("TEST PASS")
    vm = test_stub.create_basic_vm()
    vm.check()
    vm.destroy()

    test_util.test_pass('Create VM Test Success')
Esempio n. 2
0
def test():
    global vm
    global mn_host
    mn_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config,
                                          test_lib.scenario_file)
    if len(mn_host) != 1:
        test_util.test_fail('MN VM is running on %d host(s)' % len(mn_host))
    test_util.test_logger(
        "stop consul for host [%s] that mn vm is running on" %
        (mn_host[0].ip_))
    test_stub.stop_consul(mn_host[0], test_lib.all_scenario_config)
    test_util.test_logger(
        "wait for 50 seconds to see if management node VM starts on another host"
    )
    time.sleep(50)
    try:
        new_mn_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config,
                                                  test_lib.scenario_file)
        if len(new_mn_host) == 0:
            test_util.test_fail(
                "management node VM does not start after its former host's consul down"
            )
        elif len(new_mn_host) > 1:
            test_util.test_fail(
                "management node VM starts on more than one host after its former host's consul down"
            )
    except:
        test_util.test_fail(
            "management node VM does not start after its former host's consul down"
        )
    test_util.test_logger(
        "wait for 5 minutes to see if management node starts again")
    try:
        node_ops.wait_for_management_server_start(300)
    except:
        test_util.test_fail(
            "management node does not recover after its former host's consul down"
        )

    test_util.test_logger("try to create vm, timeout is 30s")
    time_out = 30
    while time_out > 0:
        try:
            vm = test_stub.create_basic_vm()
            break
        except:
            time.sleep(1)
            time_out -= 1
    if time_out == 0:
        test_util.test_fail('Fail to create vm after mn is ready')

    vm.check()
    vm.destroy()

    test_util.test_pass('Create VM Test Success')
def test():
    global vm
    global mn_host
    mn_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file)
    if len(mn_host) != 1:
        test_util.test_fail('MN VM is running on %d host(s)' % len(mn_host))
    test_util.test_logger("stop consul for host [%s] that mn vm is running on" % (mn_host[0].ip_))
    test_stub.stop_consul(mn_host[0], test_lib.all_scenario_config)
    test_util.test_logger("wait for 20 seconds to see if management node VM starts on another host")
    time.sleep(20)

    new_mn_host_ip = test_stub.get_host_by_consul_leader(test_lib.all_scenario_config, test_lib.scenario_file)
    if new_mn_host_ip == "" or new_mn_host_ip == mn_host[0].ip_:
        test_util.test_fail("management node VM not run correctly on [%s] after its former host [%s] down for 20s" % (new_mn_host_ip, mn_host[0].ip_))

    count = 60
    while count > 0:
        new_mn_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file)
        if len(new_mn_host) == 1:
            test_util.test_logger("management node VM run after its former host down for 30s")
            break
        elif len(new_mn_host) > 1:
            test_util.test_fail("management node VM runs on more than one host after its former host down")
        time.sleep(5)
        count -= 1

    if len(new_mn_host) == 0:
        test_util.test_fail("management node VM does not run after its former host down for 30s")
    elif len(new_mn_host) > 1:
        test_util.test_fail("management node VM runs on more than one host after its former host down")

    test_util.test_logger("wait for 5 minutes to see if management node starts again")
    try:
        #node_ops.wait_for_management_server_start(300)
        test_stub.wrapper_of_wait_for_management_server_start(600)
    except:
        test_util.test_fail("management node does not recover after its former host's consul down")

    test_stub.ensure_hosts_connected()
    test_stub.ensure_pss_connected()
    test_stub.ensure_bss_connected()

    test_stub.return_pass_ahead_if_3sites("TEST PASS")
    vm = test_stub.create_basic_vm()
    vm.check()
    vm.destroy()

    test_util.test_pass('Create VM Test Success')
def test():
    global vm
    global mn_host
    mn_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file)
    if len(mn_host) != 1:
        test_util.test_fail('MN VM is running on %d host(s)' % len(mn_host))
    test_util.test_logger("stop consul for host [%s] that mn vm is running on" % (mn_host[0].ip_))
    test_stub.stop_consul(mn_host[0], test_lib.all_scenario_config)
    test_util.test_logger("wait for 20 seconds to see if management node VM starts on another host")
    time.sleep(20)

    new_mn_host_ip = test_stub.get_host_by_consul_leader(test_lib.all_scenario_config, test_lib.scenario_file)
    if new_mn_host_ip == "" or new_mn_host_ip == mn_host[0].ip_:
        test_util.test_fail("management node VM not run correctly on [%s] after its former host [%s] down for 20s" % (new_mn_host_ip, mn_host[0].ip_))

    count = 60
    while count > 0:
        new_mn_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file)
        if len(new_mn_host) == 1:
            test_util.test_logger("management node VM run after its former host down for 30s")
            break
        elif len(new_mn_host) > 1:
            test_util.test_fail("management node VM runs on more than one host after its former host down")
        time.sleep(5)
        count -= 1

    if len(new_mn_host) == 0:
        test_util.test_fail("management node VM does not run after its former host down for 30s")
    elif len(new_mn_host) > 1:
        test_util.test_fail("management node VM runs on more than one host after its former host down")

    test_util.test_logger("wait for 5 minutes to see if management node starts again")
    try:
        node_ops.wait_for_management_server_start(300)
    except:
        test_util.test_fail("management node does not recover after its former host's consul down")

    test_stub.ensure_hosts_connected()
    test_stub.ensure_pss_connected()
    test_stub.ensure_bss_connected()

    vm = test_stub.create_basic_vm()
    vm.check()
    vm.destroy()

    test_util.test_pass('Create VM Test Success')