def step_impl(context, router, pkg_name): if pkg_name is None: pkg_name = "tests.testset.asdf" elif pkg_name == "random": pkg_name = "tests.testset." + formatdata.random_str(5) elif pkg_name == "wrong": pkg_name = "noapp.package.name" else: pass params = {"operation": "test.change.params", "custom_router": router} common.run_request(context.mock_server, "POST", params) context.scenario.current_instance = context.scenario.current_user.start_instance( pkg_name) context.scenario.instances.append(context.scenario.current_instance) if pkg_name.lower().startswith("noapp"): context.scenario.deleted_instance = context.scenario.current_instance context.scenario.deleted_instances.append( context.scenario.current_instance) context.scenario.instances.remove(context.scenario.current_instance) time.sleep(10) params = {"operation": "test.unset.params", "param": 'custom_router'} common.run_request(context.mock_server, "POST", params)
def notify_instance(self, cid, status): intervel = CUSTOM_CALLBACK_TIME if CUSTOM_CALLBACK_TIME is not None else CALL_BACK_TIME if int(intervel) == 0: return time.sleep(int(intervel) / 1000) params = clouddata.generate_comm_request(203) params.data = clouddata.generate_instance_info(cid, status) print("cid-%s %s" % (cid, params)) common.run_request("http://" + self.client_address[0] + ":8010/rest/api", method="POST", commparams=params)
def step_impl(context, action, num): """ :param context: :param action: 设置需要控制的操作类型: ["refreshSToken", "getInterface", "release", "updateResolution":,"apply"] :param num: 设置失败次数 :return: """ if action == "apply": params = { "operation": "test.change.params", "error_operations": { 'apply': int(num) } } elif action == "refreshSToken": params = { "operation": "test.change.params", "error_operations": { 'refreshSToken': int(num) } } elif action == "getInterface": params = { "operation": "test.change.params", "error_operations": { 'getInterface': int(num) } } elif action == "updateResolution": params = { "operation": "test.change.params", "error_operations": { 'updateResolution': int(num) } } elif action == "release": params = { "operation": "test.change.params", "error_operations": { 'release': int(num) } } else: pass common.run_request(context.mock_server, "POST", params)
def step_impl(context, router_id, num): num = int(num) params = { "operation": "test.change.params", "router_max_num": { router_id: num } } context.scenario.paas_request = common.run_request(context.mock_server, "POST", params)
def after_scenario(context, scenario): for inst in scenario.instances: inst.stop_instance() #make sure delete the all instance when the scenarios is over for inst in scenario.deleted_instances: inst.stop_instance() time.sleep(5) del scenario.users del scenario.instances del scenario.current_user del scenario.current_instance cloud_db = CloudDB() cloud_mongo = CloudMongo() for bid in scenario.bids: tenant_id = cloud_db.get_tenant_id_by_bid(bid) cloud_mongo.remove_config_by_tenant_id(tenant_id) del scenario.bids del scenario.deleted_instance params = {"operation": "test.unset.params", "param": "all"} common.run_request(context.mock_server, "POST", params)
def step_impl(context): params = {"operation": "test.record.operation"} common.run_request(context.mock_server, "POST", params)
def step_impl(context): params = {"operation": "test.change.params", "callback_interval": "0"} common.run_request(context.mock_server, "POST", params)
def step_impl(context, num): params = {"operation": "test.change.params", "max_num": num} common.run_request(context.mock_server, "POST", params)
def step_impl(context): params = {"operation": "test.get.operation"} _, response = common.run_request(context.mock_server, "POST", params) context.scenario.paas_request = json.loads(response)['response'] logger.info(context.scenario.paas_request)