def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]

    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    for host in hosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
Exemple #2
0
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth("eth0", 10)
    linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    
    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]
    for host in hosts:
        cmd.ethname = 'eth0'
        cmd.vlan = 10
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        cmd.vlan = 11
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth("eth0", 10)
    linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = 'eth0'
    cmd.vlan = 10

    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = 'eth0'
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd)
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
Exemple #5
0
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(
            test_lib.all_scenario_config, test_lib.scenario_file,
            test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    if os.environ.get('ZSTACK_SIMULATOR') == "yes":
        deploy_operations.deploy_simulator_database(
            test_lib.deploy_config, test_lib.all_scenario_config,
            test_lib.scenario_file)
    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]

    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in hosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    if os.environ.get('ZSTACK_SIMULATOR') == "yes":
        if os.environ.get('WOODPECKER_PARALLEL') != None and os.environ.get('WOODPECKER_PARALLEL') == '0':
            destroy_initial_database()
            deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
        else:
            test_util.test_logger('Skip case setup since parallel testing')
Exemple #8
0
def test():
    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
def test():
    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = nic_name
    cmd.vlan = 10
    
    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = nic_name
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    test_util.test_pass('Suite Setup Success')
Exemple #10
0
def test():
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    mevoco1_ip = os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP']
    mevoco2_ip = os.environ['serverIp2']

    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco1_ip
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.lib_set_provision_storage_rate(6)
    test_lib.lib_set_provision_memory_rate(3)

    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco2_ip
    test_lib.setup_plan.deploy_test_agent()
    #test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    #deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.lib_set_provision_storage_rate(6)
    test_lib.lib_set_provision_memory_rate(3)

    test_util.test_pass('Suite Setup Success')
def test():
    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth("eth0", 10)
    linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    
    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]
    for host in hosts:
        cmd.ethname = 'eth0'
        cmd.vlan = 10
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        cmd.vlan = 11
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    test_util.test_pass('Suite Setup Success')
def test():
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    mevoco1_ip = os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP']
    mevoco2_ip = os.environ['serverIp2']

    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco1_ip
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.lib_set_provision_storage_rate(6)
    test_lib.lib_set_provision_memory_rate(3)

    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco2_ip
    test_lib.setup_plan.deploy_test_agent()
    #test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    #deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.lib_set_provision_storage_rate(6)
    test_lib.lib_set_provision_memory_rate(3)

    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
	test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
Exemple #15
0
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    shell.call('yum --disablerepo=epel install -y libvirt-devel')
    shell.call('pip install virtualbmc')
    shell.call('cp %s/integrationtest/vm/baremetal/vbmc.py \
               /var/lib/zstack/virtualenv/woodpecker/lib/python2.7/site-packages/virtualbmc/vbmc.py -fr' \
               % os.environ.get('woodpecker_root_path'))
    test_util.test_logger('Virtualbmc has been deployed on Host')

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    ##If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    #setup = setup_actions.SetupAction()
    #setup.plan = test_lib.all_config
    #setup.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_vcenter(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    test_stub.check_deployed_vcenter(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)

    image_name = os.environ['vcenterDefaultmplate']
    cond = res_ops.gen_query_conditions('name', '=', image_name)
    image_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid
    img_ops.update_image_platform(image_uuid, 'Linux')

    test_util.test_pass('Suite Setup Success')
Exemple #17
0
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    ##If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    #setup = setup_actions.SetupAction()
    #setup.plan = test_lib.all_config
    #setup.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(
            test_lib.all_scenario_config, test_lib.scenario_file,
            test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_vcenter(test_lib.deploy_config,
                                             test_lib.all_scenario_config,
                                             test_lib.scenario_file)
    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)

    test_util.test_pass('Suite Setup Success')
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('ZStack Installation Suite Setup Success')
def test():
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_db_without_reinstall_zstack()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    test_util.test_pass('Suite Setup Success')
def test():
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    test_util.test_pass('Suite Setup Success')
def test():
    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
def test():
    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
def test():
    test_lib.setup_plan.execute_plan_ha()
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    #linux.create_vlan_eth(nic_name, 10)
    #linux.create_vlan_eth(nic_name, 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    #cmd = host_plugin.CreateVlanDeviceCmd()
    #cmd.ethname = nic_name
    #cmd.vlan = 10
    
    #cmd2 = host_plugin.CreateVlanDeviceCmd()
    #cmd2.ethname = nic_name
    #cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    #for host in testHosts:
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s' %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips, 'disaster-recovery'))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s '' '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, 'disaster-recovery'))

    dicts = {}
    for host in testHosts:
        cmd = 'virsh --version'
        dicts[host.managementIp_] = test_lib.lib_execute_ssh_cmd(host.managementIp_, host.username_, host.password_, cmd, 180)
    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))
        version = test_lib.lib_execute_ssh_cmd(host.managementIp_, host.username_, host.password_, cmd, 180)
        # Some host are installed in expert mode without virsh
        if dicts[host.managementIp_]:
            assert version == dicts[host.managementIp_]

    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"
    public_l2_vlan = int(os.getenv('l2PublicVlan'))
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)
    linux.create_vlan_eth(nic_name, public_l2_vlan)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    
    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]
    for host in hosts:
        cmd.ethname = nic_name
        cmd.vlan = 10
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        cmd.vlan = 11
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        cmd.vlan = public_l2_vlan
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)

    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)

    bss = res_ops.query_resource(res_ops.BACKUP_STORAGE)
    bs = bss[0]
    test_util.test_pass('Suite Setup Success')
def test():
    test_lib.setup_plan.execute_plan_ha()

    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_util.test_pass('Suite Setup Success')
Exemple #27
0
def test():
    global test_obj_dict
    global origin_ip
    global test_config_des
    global deploy_tmpt_src
    global deploy_tmpt_des

    origin_ip = os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP']

    test_util.test_dsc(
        'Create test vm to test zstack all installation in CentOS7.')
    #    image_name = os.environ.get('imageName_i_c7')
    #    image_name = "zstack_iso_centos7_141"
    image_name = os.environ.get('imageName_i_offline')
    vm = test_stub.create_vlan_vm(image_name)
    test_obj_dict.add_vm(vm)
    if os.environ.get('zstackManagementIp') == None:
        vm.check()
    else:
        time.sleep(60)

    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip
    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    test_stub.execute_all_install(ssh_cmd, target_file, tmp_file)

    #    test_stub.check_installation(ssh_cmd, tmp_file, vm_inv)

    test_util.test_dsc("Prepare Config Files")
    cmd = "cp %s %s" % (deploy_tmpt_src, deploy_tmpt_des)
    os.system(cmd)
    cmd = "sed -i \"s/templateIP/%s/g\" %s" % (vm_ip, deploy_tmpt_des)
    os.system(cmd)

    test_config_obj = test_util.TestConfig(test_config_des)
    test_config = test_config_obj.get_test_config()
    all_config = test_config_obj.get_deploy_config()
    deploy_config = all_config.deployerConfig
    cmd = "vconfig add eth0 213"
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
    cmd = "vconfig add eth0 212"
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)

    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = vm_ip
    deploy_operations.deploy_initial_database(deploy_config)

    test_util.test_dsc("Clean up")
    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = origin_ip
    os.system('rm -f %s' % deploy_tmpt_des)
    os.system('rm -f %s' % tmp_file)
    vm.destroy()
    test_obj_dict.rm_vm(vm)
    test_util.test_pass('ZStack installation Test Success')
def test():
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_util.test_pass('Suite Setup Success')
def test():
    global test_obj_dict
    global origin_ip
    global test_config_des
    global deploy_tmpt_src
    global deploy_tmpt_des

    origin_ip = os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP']

    test_util.test_dsc('Create test vm to test zstack all installation in CentOS7.')
#    image_name = os.environ.get('imageName_i_c7')
#    image_name = "zstack_iso_centos7_141"
    image_name = os.environ.get('imageName_i_offline')
    vm = test_stub.create_vlan_vm(image_name)
    test_obj_dict.add_vm(vm)
    if os.environ.get('zstackManagementIp') == None:
        vm.check()
    else:
        time.sleep(60)

    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip
    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    test_stub.execute_all_install(ssh_cmd, target_file, tmp_file)

#    test_stub.check_installation(ssh_cmd, tmp_file, vm_inv)

    test_util.test_dsc("Prepare Config Files")
    cmd = "cp %s %s" % (deploy_tmpt_src, deploy_tmpt_des)
    os.system(cmd)
    cmd = "sed -i \"s/templateIP/%s/g\" %s" % (vm_ip, deploy_tmpt_des)
    os.system(cmd)

    test_config_obj = test_util.TestConfig(test_config_des)
    test_config = test_config_obj.get_test_config()
    all_config = test_config_obj.get_deploy_config()
    deploy_config = all_config.deployerConfig
    cmd = "vconfig add eth0 213"
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)
    cmd = "vconfig add eth0 212"
    rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180)

    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = vm_ip
    deploy_operations.deploy_initial_database(deploy_config)

    test_util.test_dsc("Clean up")
    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = origin_ip
    os.system('rm -f %s' % deploy_tmpt_des) 
    os.system('rm -f %s' % tmp_file)
    vm.destroy()
    test_obj_dict.rm_vm(vm)
    test_util.test_pass('ZStack installation Test Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = nic_name
    cmd.vlan = 10
    
    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = nic_name
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    if test_lib.ver_ge_zstack_2_0(mn_ip):
        test_lib.lib_set_allow_live_migration_local_storage('true')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.ensure_recover_script_l2_correct()

    if test_lib.lib_is_storage_network_separate():
        add_ps_network_gateway_sys_tag()

    test_util.test_pass('Suite Setup Success')
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    test_util.test_pass('ZStack Installation Suite Setup Success')
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
Exemple #33
0
def test():
    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    test_util.test_pass('Suite Setup Success')
Exemple #34
0
def test():
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth("eth0", 10)
    linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = 'eth0'
    cmd.vlan = 10

    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = 'eth0'
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd)
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
Exemple #36
0
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    if os.environ.get('zstackManagementIp') == None:
        test_lib.setup_plan.deploy_test_agent()
        test_lib.setup_plan.execute_plan_without_deploy_test_agent()
        deploy_operations.deploy_initial_database(test_lib.deploy_config)

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    test_util.test_pass('ZStack Installation Suite Setup Success')
def test():
    if test_lib.scenario_config == None or test_lib.scenario_file ==None:
        test_util.test_fail('Suite Setup Fail without scenario')

    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth("eth0", 10)
    linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = 'eth0'
    cmd.vlan = 10
    
    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = 'eth0'
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)

    config_json = os.environ.get('configJson')
    ha_deploy_tool = os.environ.get('zstackHaInstaller')
    mn_img = os.environ.get('mnImage')
    test_stub.deploy_ha_env(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config,config_json, ha_deploy_tool, mn_img)

    node_operations.wait_for_management_server_start(300)
    ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", os.environ.get('zstackHaVip'), 'root', 'password')
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.lib_set_reserved_memory('8G')
    test_util.test_pass('Suite Setup Success')
Exemple #38
0
def test():
    try:
        test_lib.setup_plan.deploy_test_agent()
    except:
        pass
    if os.path.exists(EXTRA_ARM_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_ARM_SETUP_SCRIPT)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()

    test_lib.setup_plan.deploy_test_agent()

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('Suite Setup Success')
Exemple #40
0
def test():
    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_util.test_pass('Suite Setup Success')
def test():
    setup = setup_actions.SetupAction()
    setup.plan = test_lib.all_config
    setup.run()

    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
	test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_util.test_pass('Suite Setup Success')
Exemple #42
0
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    ##If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    #setup = setup_actions.SetupAction()
    #setup.plan = test_lib.all_config
    #setup.run()
    test_lib.setup_plan.deploy_test_agent()
    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(
            test_lib.all_scenario_config, test_lib.scenario_file,
            test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_vcenter(test_lib.deploy_config,
                                             test_lib.all_scenario_config,
                                             test_lib.scenario_file)
    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    test_stub.check_deployed_vcenter(test_lib.deploy_config,
                                     test_lib.all_scenario_config,
                                     test_lib.scenario_file)

    image_name = os.environ['vcenterDefaultmplate']
    cond = res_ops.gen_query_conditions('name', '=', image_name)
    image_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid
    img_ops.update_image_platform(image_uuid, 'Linux')

    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth("eth0", 10)
    linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = 'eth0'
    cmd.vlan = 10
    
    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = 'eth0'
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
Exemple #44
0
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    test_lib.setup_plan.deploy_test_agent()

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(
            test_lib.all_scenario_config, test_lib.scenario_file,
            test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s' %s" %
                      (EXTRA_SUITE_SETUP_SCRIPT, mn_ips, 'baremetal'))
            deploy_vbmc(mn_ips)
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, 'baremetal'))
        deploy_vbmc()

    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    print "print deploy test agent"
    test_lib.setup_plan.deploy_test_agent()
    print "print deploy test agent done"

    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = 'bond0'
    cmd.vlan = 10
    
    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = 'bond0'
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)

    #test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 10)
    #linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    #cmd = host_plugin.CreateVlanDeviceCmd()
    
    #hosts = test_lib.lib_get_all_hosts_from_plan()
    #if type(hosts) != type([]):
    #    hosts = [hosts]
    #for host in hosts:
    #    cmd.ethname = 'eth0'
    #    cmd.vlan = 10
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
    #    cmd.vlan = 11
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('ZStack stress Test Suite Setup Success')
Exemple #47
0
def test():
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 10)
    #linux.create_vlan_eth("eth0", 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    #cmd = host_plugin.CreateVlanDeviceCmd()

    #hosts = test_lib.lib_get_all_hosts_from_plan()
    #if type(hosts) != type([]):
    #    hosts = [hosts]
    #for host in hosts:
    #    cmd.ethname = 'eth0'
    #    cmd.vlan = 10
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
    #    cmd.vlan = 11
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    deploy_operations.deploy_initial_database(test_lib.deploy_config)
    test_util.test_pass('ZStack stress Test Suite Setup Success')
def test():
    if os.environ.get('ZSTACK_SIMULATOR') == "yes":
        os.system('pkill -f ./test_rest_server.py')
        process = subprocess.Popen("./test_rest_server.py", cwd=os.environ.get('woodpecker_root_path')+'/dailytest/', universal_newlines=True, preexec_fn=os.setsid)
        test_lib.setup_plan.execute_plan_without_deploy_test_agent()
        deploy_operations.deploy_simulator_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
        deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    
        agent_url = CP_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = CREATE_SNAPSHOT_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                volume_uuid = entity_body_json["volumeUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = UPLOAD_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = NFS_CREATE_TEMPLATE_FROM_VOLUME_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                src_path = entity_body_json["rootVolumePath"].split('vol-')[1].split('/')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = SMP_CREATE_TEMPLATE_FROM_VOLUME_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                src_path = entity_body_json["volumePath"].split('vol-')[1].split('/')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = NFS_COMMIT_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = SMP_COMMIT_BITS_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        
        agent_url = NFS_UPLOAD_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = SMP_UPLOAD_BITS_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = LOCAL_CREATE_TEMPLATE_FROM_VOLUME
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                volume_uuid = entity_body_json["volumePath"].split('vol-')[1].split('/')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = LOCAL_COMMIT_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        
        agent_url = LOCAL_UPLOAD_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = KVM_TAKE_VOLUME_SNAPSHOT_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                volume_uuid = entity_body_json["volumeUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = LOCAL_UPLOAD_BIT_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = NFS_UPLOAD_TO_SFTP_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = SMP_UPLOAD_BITS_TO_SFTP_BACKUPSTORAGE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = SBLK_CREATE_TEMPLATE_FROM_VOLUME_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                volume_uuid = entity_body_json["volumePath"].split('/')[3]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = SBLK_COMMIT_BITS_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        
        agent_url = SBLK_UPLOAD_BITS_TO_IMAGESTORE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = CEPH_DOWNLOAD_IMAGE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = IMAGESTORE_IMPORT
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageuuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = SFTP_DOWNLOAD_IMAGE_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                image_uuid = entity_body_json["imageUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = KVM_MIGRATE_VM_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                vm_uuid = entity_body_json["vmUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+vm_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = GET_MD5_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                volume_uuid = entity_body_json["volumeUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = CHECK_MD5_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                volume_uuid = entity_body_json["volumeUuid"]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        
        agent_url = COPY_TO_REMOTE_BITS_PATH
        script = '''
        { entity -> 
        	slurper = new groovy.json.JsonSlurper();
        	entity_body_json = slurper.parseText(entity.body);
                volume_uuid = entity_body_json["paths"][0].split('vol-')[1].split('/')[0]
        	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
        	get.setRequestMethod("GET");
        	def getRC = get.getResponseCode();
        	if (!getRC.equals(200)) {
        		return;
        		//throw new Exception("shuang")
        	}; 
        	reply = get.getInputStream().getText();
                reply_json = slurper.parseText(reply);
                try {
        	        item = reply_json['result']
                	item_json = slurper.parseText(item);
        		action = item_json['%s']
                } catch(Exception ex) {
        		return
        	}
        	if (action == 1) {
        		sleep((24*60*60-60)*1000)
        	} else if (action == 2) {
        		sleep(360*1000)
        	}
        }
        ''' % (agent_url)
        deploy_operations.remove_simulator_agent_script(agent_url)
        deploy_operations.deploy_simulator_agent_script(agent_url, script)
        deploy_operations.install_mini_server()
    else:
        if test_lib.scenario_config == None or test_lib.scenario_file ==None:
            test_util.test_fail('Suite Setup Fail without scenario')
    
        if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
            scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
            test_util.test_skip('Suite Setup Success')
        if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
            scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)
    
        nic_name = "eth0"
        if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
            nic_name = "zsn0"
    
        #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
        #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
        linux.create_vlan_eth(nic_name, 10)
        linux.create_vlan_eth(nic_name, 11)
    
        #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
        test_lib.setup_plan.deploy_test_agent()
        cmd = host_plugin.CreateVlanDeviceCmd()
        cmd.ethname = nic_name
        cmd.vlan = 10
        
        cmd2 = host_plugin.CreateVlanDeviceCmd()
        cmd2.ethname = nic_name
        cmd2.vlan = 11
        testHosts = test_lib.lib_get_all_hosts_from_plan()
        if type(testHosts) != type([]):
            testHosts = [testHosts]
        for host in testHosts:
            http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
            http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)
    
    
        test_stub.deploy_2ha(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        mn_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 0).ip_
        mn_ip2 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 1).ip_
    
        if not xmlobject.has_element(test_lib.deploy_config, 'backupStorages.miniBackupStorage'):
            host_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 2).ip_
            test_stub.recover_vlan_in_host(host_ip1, test_lib.all_scenario_config, test_lib.deploy_config)
    
        test_stub.wrapper_of_wait_for_management_server_start(600, EXTRA_SUITE_SETUP_SCRIPT)
        test_util.test_logger("@@@DEBUG->suite_setup@@@ os\.environ\[\'ZSTACK_BUILT_IN_HTTP_SERVER_IP\'\]=%s; os\.environ\[\'zstackHaVip\'\]=%s"    \
                              %(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], os.environ['zstackHaVip']) )
        ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip1, 'root', 'password')
        ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip2, 'root', 'password')
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip1))
            os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip2))
    
        deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
        for host in testHosts:
            os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))
    
        test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
        #test_lib.lib_set_reserved_memory('1G')
    
        if test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-local-ps.xml"], ["scenario-config-upgrade-3.1.1.xml"]):
            cmd = r"sed -i '$a\172.20.198.8 rsync.repo.zstack.io' /etc/hosts"
            ssh.execute(cmd, mn_ip1, "root", "password", False, 22)
            ssh.execute(cmd, mn_ip2, "root", "password", False, 22)

    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        nic_name = "zsn0"
    public_l2_vlan = int(os.getenv('l2PublicVlan'))
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)
    linux.create_vlan_eth(nic_name, public_l2_vlan)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()

    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]
    for host in hosts:
        cmd.ethname = nic_name
        cmd.vlan = 10
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd)
        cmd.vlan = 11
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd)
        cmd.vlan = public_l2_vlan
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(
            test_lib.all_scenario_config, test_lib.scenario_file,
            test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT))

    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)

    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
        test_lib.lib_set_ha_selffencer_maxattempts('60')
        test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)

    bss = res_ops.query_resource(res_ops.BACKUP_STORAGE)
    bs = bss[0]
    test_util.test_pass('Suite Setup Success')
def test():
    os.system('pkill -f ./test_rest_server.py')
    process = subprocess.Popen("./test_rest_server.py",
                               cwd=os.environ.get('woodpecker_root_path') +
                               '/dailytest/',
                               universal_newlines=True,
                               preexec_fn=os.setsid)
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(
            test_lib.all_scenario_config, test_lib.scenario_file,
            test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s' %s" %
                      (EXTRA_SUITE_SETUP_SCRIPT, mn_ips, 'project-management'))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s '' '%s'" %
                  (EXTRA_SUITE_SETUP_SCRIPT, 'project-management'))

    if os.environ.get('ZSTACK_SIMULATOR') == "yes":
        deploy_operations.deploy_simulator_database(
            test_lib.deploy_config, test_lib.all_scenario_config,
            test_lib.scenario_file)
    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)

    agent_url = CP_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = CREATE_SNAPSHOT_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = UPLOAD_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = NFS_CREATE_TEMPLATE_FROM_VOLUME_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["rootVolumePath"].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_CREATE_TEMPLATE_FROM_VOLUME_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["volumePath"].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = NFS_COMMIT_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_COMMIT_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = NFS_UPLOAD_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_UPLOAD_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = LOCAL_CREATE_TEMPLATE_FROM_VOLUME
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumePath"].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = LOCAL_COMMIT_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = LOCAL_UPLOAD_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = KVM_TAKE_VOLUME_SNAPSHOT_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = LOCAL_UPLOAD_BIT_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = NFS_UPLOAD_TO_SFTP_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_UPLOAD_BITS_TO_SFTP_BACKUPSTORAGE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SBLK_CREATE_TEMPLATE_FROM_VOLUME_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumePath"].split('/')[3]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SBLK_COMMIT_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SBLK_UPLOAD_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = CEPH_DOWNLOAD_IMAGE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = IMAGESTORE_IMPORT
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageuuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SFTP_DOWNLOAD_IMAGE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = KVM_MIGRATE_VM_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        vm_uuid = entity_body_json["vmUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+vm_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = GET_MD5_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = CHECK_MD5_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = COPY_TO_REMOTE_BITS_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["paths"][0].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config,
                                            test_lib.scenario_file,
                                            test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config,
                                             test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        nic_name = "zsn0"

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine.
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = nic_name
    cmd.vlan = 10

    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = nic_name
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd)
        http.json_dump_post(
            testagent.build_http_path(host.managementIp_,
                                      host_plugin.CREATE_VLAN_DEVICE_PATH),
            cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(
            test_lib.all_scenario_config, test_lib.scenario_file,
            test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s' %s" %
                      (EXTRA_SUITE_SETUP_SCRIPT, mn_ips, 'disaster-recovery'))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s '' '%s'" %
                  (EXTRA_SUITE_SETUP_SCRIPT, 'disaster-recovery'))

    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(
            test_lib.scenario_file):
        host_ips = scenario_operations.dump_scenario_file_ips(
            test_lib.scenario_file)
    else:
        host_ips = testHosts
    #for host in host_ips:
    #    if host.managementIp_ != mn_ip:
    #        cmd = "echo 'export LANG=\"zh_CN.GB18030\"' >> /etc/profile && sudo ls /root && source /etc/profile"
    #        os.system('sshpass -p password ssh root@%s "%s"' %(host.managementIp_,cmd))

    deploy_operations.deploy_initial_database(test_lib.deploy_config,
                                              test_lib.all_scenario_config,
                                              test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    if test_lib.ver_ge_zstack_2_0(mn_ip):
        test_lib.lib_set_allow_live_migration_local_storage('true')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.ensure_recover_script_l2_correct()

    if test_lib.lib_is_storage_network_separate():
        add_ps_network_gateway_sys_tag()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
            test_lib.scenario_file):
        scenario_operations.replace_env_params_if_scenario()
    else:
        pass

    test_util.test_pass('Suite Setup Success')
def test():
    os.system('pkill -f ./test_rest_server.py')
    process = subprocess.Popen("./test_rest_server.py", cwd=os.environ.get('woodpecker_root_path')+'/dailytest/', universal_newlines=True, preexec_fn=os.setsid)
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s' %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips,'project-management'))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s '' '%s'" % (EXTRA_SUITE_SETUP_SCRIPT,'project-management'))

    if os.environ.get('ZSTACK_SIMULATOR') == "yes":
        deploy_operations.deploy_simulator_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)

    agent_url = CP_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = CREATE_SNAPSHOT_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = UPLOAD_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = NFS_CREATE_TEMPLATE_FROM_VOLUME_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["rootVolumePath"].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_CREATE_TEMPLATE_FROM_VOLUME_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["volumePath"].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = NFS_COMMIT_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_COMMIT_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)


    agent_url = NFS_UPLOAD_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_UPLOAD_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = LOCAL_CREATE_TEMPLATE_FROM_VOLUME
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumePath"].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = LOCAL_COMMIT_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)


    agent_url = LOCAL_UPLOAD_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = KVM_TAKE_VOLUME_SNAPSHOT_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = LOCAL_UPLOAD_BIT_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = NFS_UPLOAD_TO_SFTP_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SMP_UPLOAD_BITS_TO_SFTP_BACKUPSTORAGE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SBLK_CREATE_TEMPLATE_FROM_VOLUME_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumePath"].split('/')[3]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SBLK_COMMIT_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)


    agent_url = SBLK_UPLOAD_BITS_TO_IMAGESTORE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)

    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = CEPH_DOWNLOAD_IMAGE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = IMAGESTORE_IMPORT
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageuuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = SFTP_DOWNLOAD_IMAGE_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        image_uuid = entity_body_json["imageUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = KVM_MIGRATE_VM_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        vm_uuid = entity_body_json["vmUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+vm_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = GET_MD5_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = CHECK_MD5_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["volumeUuid"]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    agent_url = COPY_TO_REMOTE_BITS_PATH
    script = '''
{ entity -> 
	slurper = new groovy.json.JsonSlurper();
	entity_body_json = slurper.parseText(entity.body);
        volume_uuid = entity_body_json["paths"][0].split('vol-')[1].split('/')[0]
	def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); 
	get.setRequestMethod("GET");
	def getRC = get.getResponseCode();
	if (!getRC.equals(200)) {
		return;
		//throw new Exception("shuang")
	}; 
	reply = get.getInputStream().getText();
        reply_json = slurper.parseText(reply);
        try {
	        item = reply_json['result']
        	item_json = slurper.parseText(item);
		action = item_json['%s']
        } catch(Exception ex) {
		return
	}
	if (action == 1) {
		sleep((24*60*60-60)*1000)
	} else if (action == 2) {
		sleep(360*1000)
	}
}
''' % (agent_url)
    deploy_operations.remove_simulator_agent_script(agent_url)
    deploy_operations.deploy_simulator_agent_script(agent_url, script)

    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"
        linux.create_vlan_eth(nic_name, 1010)
        linux.create_vlan_eth(nic_name, 1011)
    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0")
    #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0")
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)
    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    
    hosts = test_lib.lib_get_all_hosts_from_plan()
    if type(hosts) != type([]):
        hosts = [hosts]
    for host in hosts:
        cmd.ethname = nic_name
        cmd.vlan = 10
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        cmd.vlan = 11
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    conf_ops.change_global_config("applianceVm", "agent.deployOnStart", 'true')
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT)
    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in hosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))
    
    test_util.test_dsc("create vpc vrouter")
    vr = test_stub.create_vpc_vrouter()
    test_util.test_dsc("Try to create one vm in random L3 not attached")
    with test_lib.expected_failure("create one vm in random L3 not attached", Exception):
        test_stub.create_vm_with_random_offering(vm_name='vpc_vm1', l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST))
    test_util.test_dsc("attach vpc l3 to vpc vrouter")
    test_stub.attach_l3_to_vpc_vr(vr, test_stub.L3_SYSTEM_NAME_LIST)

    test_util.test_dsc("create cloud router")
    vm1 = test_stub.create_vlan_vm(os.environ.get('l3NoVlanNetworkName2'))
    test_obj_dict.add_vm(vm1)
    vm1.clean()

    test_util.test_dsc("create load balance")
    l3_public_name = os.environ.get('l3PublicNetworkName')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_public_name).uuid

    vip = test_stub.create_vip('vip_for_lb_test', l3_net_uuid)
    test_obj_dict.add_vip(vip)

    lb = zstack_lb_header.ZstackTestLoadBalancer()
    lb.create('autoscaling lb test', vip.get_vip().uuid)
    test_obj_dict.add_load_balancer(lb)

    lb_creation_option = test_lib.lib_create_lb_listener_option('check vm http healthy','tcp',22,80)
    lbl = lb.create_listener(lb_creation_option)


    delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
    delete_policy = test_lib.lib_set_delete_policy('image', 'Direct')
#    if test_lib.lib_get_ha_selffencer_maxattempts() != None:
#        test_lib.lib_set_ha_selffencer_maxattempts('60')
#	test_lib.lib_set_ha_selffencer_storagechecker_timeout('60')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config == None or test_lib.scenario_file ==None:
        test_util.test_fail('Suite Setup Fail without scenario')

    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = nic_name
    cmd.vlan = 10
    
    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = nic_name
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)


    test_stub.deploy_2ha(test_lib.all_scenario_config, test_lib.scenario_file)
    mn_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 0).ip_
    mn_ip2 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 1).ip_

    host_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 2).ip_
    test_stub.recover_vlan_in_host(host_ip1, test_lib.all_scenario_config, test_lib.deploy_config)

    test_stub.wrapper_of_wait_for_management_server_start(600, EXTRA_SUITE_SETUP_SCRIPT)
    test_util.test_logger("@@@DEBUG->suite_setup@@@ os\.environ\[\'ZSTACK_BUILT_IN_HTTP_SERVER_IP\'\]=%s; os\.environ\[\'zstackHaVip\'\]=%s"	\
                          %(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], os.environ['zstackHaVip']) )
    ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip1, 'root', 'password')
    ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip2, 'root', 'password')
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip1))
        os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip2))

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    #test_lib.lib_set_reserved_memory('1G')
    

    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config == None or test_lib.scenario_file ==None:
        test_util.test_fail('Suite Setup Fail without scenario')

    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    linux.create_vlan_eth(nic_name, 10)
    linux.create_vlan_eth(nic_name, 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    cmd = host_plugin.CreateVlanDeviceCmd()
    cmd.ethname = nic_name
    cmd.vlan = 10
    
    cmd2 = host_plugin.CreateVlanDeviceCmd()
    cmd2.ethname = nic_name
    cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    for host in testHosts:
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
        http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)


    test_stub.deploy_2ha(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
    mn_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 0).ip_
    mn_ip2 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 1).ip_

    if not xmlobject.has_element(test_lib.deploy_config, 'backupStorages.miniBackupStorage'):
        host_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 2).ip_
        test_stub.recover_vlan_in_host(host_ip1, test_lib.all_scenario_config, test_lib.deploy_config)

    test_stub.wrapper_of_wait_for_management_server_start(600, EXTRA_SUITE_SETUP_SCRIPT)
    test_util.test_logger("@@@DEBUG->suite_setup@@@ os\.environ\[\'ZSTACK_BUILT_IN_HTTP_SERVER_IP\'\]=%s; os\.environ\[\'zstackHaVip\'\]=%s"	\
                          %(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], os.environ['zstackHaVip']) )
    ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip1, 'root', 'password')
    ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip2, 'root', 'password')
    if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip1))
        os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip2))

    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    #test_lib.lib_set_reserved_memory('1G')

    if test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-local-ps.xml"], ["scenario-config-upgrade-3.1.1.xml"]):
        cmd = r"sed -i '$a\172.20.198.8 rsync.repo.zstack.io' /etc/hosts"
        ssh.execute(cmd, mn_ip1, "root", "password", False, 22)
        ssh.execute(cmd, mn_ip2, "root", "password", False, 22)

    test_util.test_pass('Suite Setup Success')
def test():
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        test_util.test_skip('Suite Setup Success')
    if test_lib.scenario_config != None and test_lib.scenario_destroy != None:
        scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy)

    nic_name = "eth0"
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        nic_name = "zsn0"

    #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. 
    #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases.
    #linux.create_vlan_eth(nic_name, 10)
    #linux.create_vlan_eth(nic_name, 11)

    #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run()
    test_lib.setup_plan.deploy_test_agent()
    #cmd = host_plugin.CreateVlanDeviceCmd()
    #cmd.ethname = nic_name
    #cmd.vlan = 10
    
    #cmd2 = host_plugin.CreateVlanDeviceCmd()
    #cmd2.ethname = nic_name
    #cmd2.vlan = 11
    testHosts = test_lib.lib_get_all_hosts_from_plan()
    if type(testHosts) != type([]):
        testHosts = [testHosts]
    #for host in testHosts:
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd)
    #    http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2)

    test_lib.setup_plan.execute_plan_without_deploy_test_agent()
    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config)
        if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
            os.system("bash %s '%s' %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips, 'disaster-recovery'))
    elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT):
        os.system("bash %s '' '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, 'disaster-recovery'))

    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file):
        host_ips = scenario_operations.dump_scenario_file_ips(test_lib.scenario_file)
    else:
        host_ips = testHosts
    #for host in host_ips:
    #    if host.managementIp_ != mn_ip:
    #        cmd = "echo 'export LANG=\"zh_CN.GB18030\"' >> /etc/profile && sudo ls /root && source /etc/profile"
    #        os.system('sshpass -p password ssh root@%s "%s"' %(host.managementIp_,cmd))

    for host in testHosts:
        cmd = 'rpm -qa > rpm_list.txt;pip list > pip_list.txt'
        test_lib.lib_execute_ssh_cmd(host.managementIp_, 'root', 'password', cmd, 180)
    deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file)
    for host in testHosts:
        os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_))

    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    if test_lib.ver_ge_zstack_2_0(mn_ip):
        test_lib.lib_set_allow_live_migration_local_storage('true')
    test_lib.lib_set_primary_storage_imagecache_gc_interval(1)
    test_lib.ensure_recover_script_l2_correct()

    if test_lib.lib_is_storage_network_separate():
        add_ps_network_gateway_sys_tag()

    if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
        scenario_operations.replace_env_params_if_scenario()
    else:
        pass

    test_util.test_pass('Suite Setup Success')