def test_set_302(client, variables): scenario.initial(variables) scenario.variables["tag"] = "tag_api_test" scenario.variables["remark"] = "remark_api_test" scenario.variables["fw_name_1"] = funcs.concat( "fw_A_", funcs.get_timestamp(13), "_" ) scenario.variables["fw_rule_1_protocol"] = "TCP" scenario.variables["fw_rule_1_port"] = 1111 scenario.variables["fw_rule_1_srcip"] = "0.0.0.0/0" scenario.variables["fw_rule_1_action"] = "ACCEPT" scenario.variables["fw_rule_1_priority"] = "HIGH" scenario.variables["uhost_name_1"] = "firewall_api_test" scenario.variables["fw_rule_2_protocol"] = "UDP" scenario.variables["fw_rule_2_port"] = 2222 scenario.variables["fw_rule_2_srcip"] = "10.0.0.0/8" scenario.variables["fw_rule_2_action"] = "DROP" scenario.variables["fw_rule_2_priority"] = "LOW" scenario.variables["fw_name_2"] = funcs.concat( "fw_B_", funcs.get_timestamp(13), "_" ) scenario.variables["tag_2"] = "tag_api_test_3" scenario.variables["remark_2"] = "remark_api_test_3" scenario.variables["Image_Id"] = "#{u_get_image_resource($Region,$Zone)}" scenario.variables["recommend_web"] = "recommend web" scenario.variables["fw_rule_1"] = "TCP|1111|0.0.0.0/0|ACCEPT|HIGH" scenario.variables["fw_rule_2"] = "UDP|2222|10.0.0.0/8|DROP|LOW" scenario.run(client)
def create_udb_instance_05(client: utest.Client, variables: dict): d = { "Zone": variables.get("Zone"), "Region": variables.get("Region"), "Quantity": 0, "Port": variables.get("Port"), "ParamGroupId": funcs.search_value( variables.get("DataSet_paramGroup"), "DBTypeId", variables.get("DBTypeId"), "GroupId", ), "Name": funcs.concat( variables.get("DBName"), variables.get("DBTypeId") ), "MemoryLimit": variables.get("MemoryLimit"), "InstanceType": variables.get("InstanceType"), "InstanceMode": variables.get("InstanceMode"), "DiskSpace": variables.get("DiskSpace"), "DBTypeId": variables.get("DBTypeId"), "ChargeType": "Month", "AdminPassword": "******", } try: resp = client.udb().create_udb_instance(d) except exc.RetCodeException as e: resp = e.json() variables["DBId"] = utest.value_at_path(resp, "DBId") return resp
def prefetch_new_ucdn_domain_cache_08(client, variables): d = {"UrlList": [funcs.concat("http://", variables.get("domain"), "/")]} try: resp = client.ucdn().prefetch_new_ucdn_domain_cache(d) except exc.RetCodeException as e: resp = e.json() variables["PrefetchCache_TaskId"] = utest.value_at_path(resp, "TaskId") return resp
def test_set_4140(client: utest.Client, variables: dict): scenario.initial(variables) scenario.variables["BucketName_test"] = funcs.concat( "ucdntest-", funcs.get_timestamp(10) ) scenario.variables["time_granule_type"] = 1 scenario.run(client)
def refresh_new_ucdn_domain_cache_11(client, variables): d = { "UrlList": [funcs.concat("http://", variables.get("domain"), "/")], "Type": "file", } try: resp = client.ucdn().refresh_new_ucdn_domain_cache(d) except exc.RetCodeException as e: resp = e.json() return resp
def modify_udb_instance_name_09(client, variables): d = { "Zone": variables.get("Zone"), "Region": variables.get("Region"), "Name": funcs.concat("rename_", variables.get("DBTypeId")), "DBId": variables.get("DBId"), } try: resp = client.udb().modify_udb_instance_name(d) except exc.RetCodeException as e: resp = e.json() return resp
def rename_udisk_05(client, variables): d = { "Zone": variables.get("Zone"), "UDiskName": funcs.concat("re_", variables.get("UDiskName")), "UDiskId": variables.get("udisk_noArk_id"), "Region": variables.get("Region"), } try: resp = client.udisk().rename_udisk(d) except exc.RetCodeException as e: resp = e.json() return resp
def update_firewall_attribute_09(client, variables): d = { "Tag": variables.get("tag_2"), "Remark": variables.get("remark_2"), "Region": variables.get("Region"), "Name": funcs.concat(variables.get("fw_name_2"), variables.get("Zone")), "FWId": variables.get("fw_id1"), } try: resp = client.unet().update_firewall_attribute(d) except exc.RetCodeException as e: resp = e.json() return resp
def create_firewall_03(client, variables): d = { "Tag": variables.get("tag"), "Rule": [variables.get("fw_rule_1")], "Remark": variables.get("remark"), "Region": variables.get("Region"), "Name": funcs.concat(variables.get("fw_name_1"), variables.get("Zone")), } try: resp = client.unet().create_firewall(d) except exc.RetCodeException as e: resp = e.json() variables["fw_id1"] = utest.value_at_path(resp, "FWId") return resp
variables["DBId"] = utest.value_at_path(resp, "DBId") return resp @scenario.step( max_retries=60, retry_interval=3, startup_delay=0, fast_fail=False, validators=lambda variables: [ ("str_eq", "RetCode", 0), ( "str_eq", "DataSet.0.Name", funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), ), ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), ], action="DescribeUDBInstance", ) def describe_udb_instance_06(client: utest.Client, variables: dict): d = { "Zone": variables.get("Zone"), "Region": variables.get("Region"), "Offset": 0, "Limit": 100, "DBId": variables.get("DBId"), "ClassType": "sql", }
variables["fw_id1"] = utest.value_at_path(resp, "FWId") return resp @scenario.step( max_retries=0, retry_interval=0, startup_delay=3, fast_fail=False, validators=lambda variables: [ ("str_eq", "RetCode", 0), ("str_eq", "DataSet.0.FWId", variables.get("fw_id1")), ( "str_eq", "DataSet.0.Name", funcs.concat(variables.get("fw_name_1"), variables.get("Zone")), ), ("str_eq", "DataSet.0.Tag", variables.get("tag")), ("str_eq", "DataSet.0.Remark", variables.get("remark")), ("str_eq", "DataSet.0.ResourceCount", 0), ("str_eq", "DataSet.0.Type", "user defined"), ( "str_eq", "DataSet.0.Rule.0.ProtocolType", variables.get("fw_rule_1_protocol"), ), ("str_eq", "DataSet.0.Rule.0.DstPort", variables.get("fw_rule_1_port")), ("str_eq", "DataSet.0.Rule.0.SrcIP", variables.get("fw_rule_1_srcip")), ( "str_eq", "DataSet.0.Rule.0.RuleAction",
@scenario.step( max_retries=3, retry_interval=1, startup_delay=3, fast_fail=True, validators=lambda variables: [ ("str_eq", "RetCode", 0), ("str_eq", "Action", "DescribeUcdnDomainResponse"), ("str_eq", "DomainSet.0.ChannelType", "ucdn"), ( "str_eq", "DomainSet.0.Domain", funcs.concat( variables.get("BucketName_test"), ".ufile.ucloud.com.cn" ), ), ("str_eq", "DomainSet.0.DomainId", variables.get("domainId")), ("str_eq", "DomainSet.0.Status", "check"), ], action="DescribeUcdnDomain", ) def describe_ucdn_domain_02(client: utest.Client, variables: dict): d = {"DomainId": [variables.get("domainId")]} try: resp = client.invoke("DescribeUcdnDomain", d) except exc.RetCodeException as e: resp = e.json()
resp = e.json() return resp @scenario.step( max_retries=0, retry_interval=0, startup_delay=0, fast_fail=False, validators=lambda variables: [ ("str_eq", "RetCode", 0), ( "str_eq", "DataSet.0.Name", funcs.concat("re_", variables.get("UDiskName")), ), ], action="DescribeUDisk", ) def describe_udisk_06(client: utest.Client, variables: dict): d = { "Zone": variables.get("Zone"), "UDiskId": variables.get("udisk_noArk_id"), "Region": variables.get("Region"), "Offset": 0, "Limit": 100, } try: resp = client.udisk().describe_udisk(d)