def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm global image imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) cond = res_ops.gen_query_conditions('type', '=', 'SharedMountPoint') local_pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) if len(local_pss) == 0: test_util.test_skip('Required smp ps to test') ps_uuid = local_pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24 * 60 * 60 - 60) * 1000 elif agent_action == 2: agent_time = 360 * 1000 image_uuid = str(uuid.uuid4()).replace('-', '') if agent_url == CREATE_TEMPLATE_FROM_VOLUME_PATH: rsp = dep_ops.json_post( "http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({ "key": vm.get_vm().rootVolumeUuid, "value": '{"%s":%s}' % (agent_url, agent_action) })) else: rsp = dep_ops.json_post( "http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({ "key": image_uuid, "value": '{"%s":%s}' % (agent_url, agent_action) })) image_creation_option = test_util.ImageOption() bss = res_ops.query_resource(res_ops.SFTP_BACKUP_STORAGE, []) if len(bss) == 0: test_util.test_skip('Required sftp bs to test') bs_uuid = bss[0].uuid image_creation_option.set_uuid(image_uuid) image_creation_option.set_backup_storage_uuid_list([bs_uuid]) image_creation_option.set_root_volume_uuid(vm.vm.rootVolumeUuid) image_creation_option.set_name('test_create_root_volume_template_timeout') image_creation_option.set_timeout(24 * 60 * 60 * 1000) image = zstack_image_header.ZstackTestImage() image.set_creation_option(image_creation_option) start = time.time() image.create() end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm global image imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) cond = res_ops.gen_query_conditions('type', '=', 'SharedMountPoint') local_pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) if len(local_pss) == 0: test_util.test_skip('Required smp ps to test') ps_uuid = local_pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24*60*60-60)*1000 elif agent_action == 2: agent_time = 360 * 1000 image_uuid = str(uuid.uuid4()).replace('-', '') if agent_url == CREATE_TEMPLATE_FROM_VOLUME_PATH: rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": vm.get_vm().rootVolumeUuid, "value": '{"%s":%s}' % (agent_url, agent_action)})) else: rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": image_uuid, "value": '{"%s":%s}' % (agent_url, agent_action)})) image_creation_option = test_util.ImageOption() bss = res_ops.query_resource(res_ops.SFTP_BACKUP_STORAGE, []) if len(bss) == 0: test_util.test_skip('Required sftp bs to test') bs_uuid = bss[0].uuid image_creation_option.set_uuid(image_uuid) image_creation_option.set_backup_storage_uuid_list([bs_uuid]) image_creation_option.set_root_volume_uuid(vm.vm.rootVolumeUuid) image_creation_option.set_name('test_create_root_volume_template_timeout') image_creation_option.set_timeout(24*60*60*1000) image = zstack_image_header.ZstackTestImage() image.set_creation_option(image_creation_option) start = time.time() image.create() end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global image agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24*60*60-60)*1000 elif agent_action == 2: agent_time = 360 * 1000 image_uuid = str(uuid.uuid4()).replace('-', '') rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": image_uuid, "value": '{"%s":%s}' % (agent_url, agent_action)})) image_creation_option = test_util.ImageOption() imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') bs_uuid = imagestore.uuid image_option = test_util.ImageOption() image_option.set_uuid(image_uuid) image_option.set_name('fake_image') image_option.set_description('fake image') image_option.set_format('raw') image_option.set_mediaType('RootVolumeTemplate') image_option.set_backup_storage_uuid_list([bs_uuid]) image_option.url = "http://fake/fake.raw" image_option.set_timeout(24*60*60*1000) start = time.time() image = img_ops.add_image(image_option) end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) cond = res_ops.gen_query_conditions('type', '=', 'LocalStorage') local_pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) if len(local_pss) == 0: test_util.test_skip('Required ceph ps to test') ps_uuid = local_pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) vm.stop() target_host = test_lib.lib_find_random_host(vm.vm) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24 * 60 * 60 - 60) * 1000 elif agent_action == 2: agent_time = 360 * 1000 rsp = dep_ops.json_post( "http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({ "key": vm.get_vm().rootVolumeUuid, "value": '{"%s":%s}' % (agent_url, agent_action) })) start = time.time() vol_ops.migrate_volume(vm.get_vm().rootVolumeUuid, target_host.uuid) end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) cond = res_ops.gen_query_conditions('type', '=', 'LocalStorage') local_pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) if len(local_pss) == 0: test_util.test_skip('Required ceph ps to test') ps_uuid = local_pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) vm.stop() target_host = test_lib.lib_find_random_host(vm.vm) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24*60*60-60)*1000 elif agent_action == 2: agent_time = 360 * 1000 rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": vm.get_vm().rootVolumeUuid, "value": '{"%s":%s}' % (agent_url, agent_action)})) start = time.time() vol_ops.migrate_volume(vm.get_vm().rootVolumeUuid, target_host.uuid) end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm global image imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) ceph_pss = res_ops.query_resource(res_ops.CEPH_PRIMARY_STORAGE, []) if len(ceph_pss) == 0: test_util.test_skip('Required ceph ps to test') ps_uuid = ceph_pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24 * 60 * 60 - 60) * 1000 elif agent_action == 2: agent_time = 360 * 1000 rsp = dep_ops.json_post( "http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({ "key": vm.get_vm().rootVolumeUuid, "value": '{"%s":%s}' % (agent_url, agent_action) })) image_creation_option = test_util.ImageOption() bss = res_ops.query_resource(res_ops.CEPH_BACKUP_STORAGE, []) if len(bss) == 0: test_util.test_skip('Required ceph bs to test') bs_uuid = bss[0].uuid image_creation_option.set_backup_storage_uuid_list([bs_uuid]) image_creation_option.set_root_volume_uuid(vm.vm.rootVolumeUuid) image_creation_option.set_name('test_create_root_volume_template_timeout') image_creation_option.set_timeout(24 * 60 * 60 * 1000) image = zstack_image_header.ZstackTestImage() image.set_creation_option(image_creation_option) start = time.time() image.create() end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global image agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24 * 60 * 60 - 60) * 1000 elif agent_action == 2: agent_time = 360 * 1000 image_uuid = str(uuid.uuid4()).replace('-', '') rsp = dep_ops.json_post( "http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({ "key": image_uuid, "value": '{"%s":%s}' % (agent_url, agent_action) })) image_creation_option = test_util.ImageOption() bss = res_ops.query_resource(res_ops.CEPH_BACKUP_STORAGE, []) if len(bss) == 0: test_util.test_skip('Required ceph bs to test') bs_uuid = bss[0].uuid image_option = test_util.ImageOption() image_option.set_uuid(image_uuid) image_option.set_name('fake_image') image_option.set_description('fake image') image_option.set_format('raw') image_option.set_mediaType('RootVolumeTemplate') image_option.set_backup_storage_uuid_list([bs_uuid]) image_option.url = "http://fake/fake.raw" image_option.set_timeout(24 * 60 * 60 * 1000) start = time.time() image = img_ops.add_image(image_option) end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm global image imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) ceph_pss = res_ops.query_resource(res_ops.CEPH_PRIMARY_STORAGE, []) if len(ceph_pss) == 0: test_util.test_skip('Required ceph ps to test') ps_uuid = ceph_pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24*60*60-60)*1000 elif agent_action == 2: agent_time = 360 * 1000 rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": vm.get_vm().rootVolumeUuid, "value": '{"%s":%s}' % (agent_url, agent_action)})) image_creation_option = test_util.ImageOption() bss = res_ops.query_resource(res_ops.CEPH_BACKUP_STORAGE, []) if len(bss) == 0: test_util.test_skip('Required ceph bs to test') bs_uuid = bss[0].uuid image_creation_option.set_backup_storage_uuid_list([bs_uuid]) image_creation_option.set_root_volume_uuid(vm.vm.rootVolumeUuid) image_creation_option.set_name('test_create_root_volume_template_timeout') image_creation_option.set_timeout(24*60*60*1000) image = zstack_image_header.ZstackTestImage() image.set_creation_option(image_creation_option) start = time.time() image.create() end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm global live_migration ps_type = flavor['ps'] if ps_type == "Local": live_migration = config_ops.get_global_config_value('localStoragePrimaryStorage', 'liveMigrationWithStorage.allow') config_ops.change_global_config('localStoragePrimaryStorage', 'liveMigrationWithStorage.allow', 'true') imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) cond = res_ops.gen_query_conditions('type', '=', ps_type) pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) if len(pss) == 0: test_util.test_skip('Required %s ps to test' % (ps_type)) ps_uuid = pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24*60*60-60)*1000 elif agent_action == 2: agent_time = 360 * 1000 rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": vm.get_vm().uuid, "value": '{"%s":%s}' % (agent_url, agent_action)})) candidate_hosts = vm_ops.get_vm_migration_candidate_hosts(vm.get_vm().uuid) start = time.time() if candidate_hosts != None and test_lib.lib_check_vm_live_migration_cap(vm.get_vm()): vm_ops.migrate_vm(vm.get_vm().uuid, candidate_hosts.inventories[0].uuid) else: test_util.test_skip('Required migratable host to test') end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))