Best Gauge code snippet using validation.Scenario
scenario_3252_test.go
Source:scenario_3252_test.go
...7 "github.com/ucloud/ucloud-sdk-go/ucloud/utest/driver"8 "github.com/ucloud/ucloud-sdk-go/ucloud/utest/utils"9 "github.com/ucloud/ucloud-sdk-go/ucloud/utest/validation"10)11func TestScenario3252(t *testing.T) {12 spec.ParallelTest(t, &driver.Scenario{13 PreCheck: func() {14 testAccPreCheck(t)15 },16 Id: "3252",17 Vars: func(scenario *driver.Scenario) map[string]interface{} {18 return map[string]interface{}{19 "GroupName": "CreateIgName1",20 "Password": "Z3VhbmxpeXVhbm1pbWExMjMhQCM=",21 "ChargeType": "Month",22 "CreateCPU": 1,23 "CreateMem": 1024,24 "NewPassword": "Z3VhbmxpeXVhbm1pbWExMjMhQCM=",25 "Name": "uhost-ig-api-N-æ®éæ¬å°ç",26 "BootSize": 20,27 "BootType": "LOCAL_NORMAL",28 "DiskSize": 20,29 "DiskType": "LOCAL_NORMAL",30 "BootBackup": "NONE",31 "DiskBackup": "NONE",32 "MinimalCpuPlatform": "Intel/Auto",33 "MachineType": "N",34 "Region": "cn-bj2",35 "Zone": "cn-bj2-05",36 }37 },38 Owners: []string{"maggie.an@ucloud.cn"},39 Title: "ä¼ å
¥ç¡¬ä»¶é离ç»id-Auto-N-LOCAL_NORMAL-LOCAL_NORMAL-硬件é离ç»",40 Steps: []*driver.Step{41 testStep3252DescribeImage01,42 testStep3252CreateIsolationGroup02,43 testStep3252DescribeIsolationGroup03,44 testStep3252DescribeUHostInstance04,45 testStep3252CreateUHostInstance05,46 testStep3252DescribeUHostInstance06,47 testStep3252CreateUHostInstance07,48 testStep3252CreateUHostInstance08,49 testStep3252CreateUHostInstance09,50 testStep3252CreateUHostInstance10,51 testStep3252CreateUHostInstance11,52 testStep3252CreateUHostInstance12,53 testStep3252CreateUHostInstance13,54 testStep3252DescribeUHostInstance14,55 testStep3252LeaveIsolationGroup15,56 testStep3252DescribeUHostInstance16,57 testStep3252DescribeUHostInstance17,58 testStep3252DescribeIsolationGroup18,59 testStep3252CreateUHostInstance19,60 testStep3252DescribeIsolationGroup20,61 testStep3252DescribeUHostInstance21,62 testStep3252DeleteIsolationGroup22,63 testStep3252DescribeUHostInstance23,64 testStep3252DescribeUHostInstance24,65 testStep3252StopUHostInstance25,66 testStep3252StopUHostInstance26,67 testStep3252StopUHostInstance27,68 testStep3252StopUHostInstance28,69 testStep3252StopUHostInstance29,70 testStep3252StopUHostInstance30,71 testStep3252StopUHostInstance31,72 testStep3252StopUHostInstance32,73 testStep3252DescribeUHostInstance33,74 testStep3252TerminateUHostInstance34,75 testStep3252TerminateUHostInstance35,76 testStep3252TerminateUHostInstance36,77 testStep3252TerminateUHostInstance37,78 testStep3252TerminateUHostInstance38,79 testStep3252TerminateUHostInstance39,80 testStep3252TerminateUHostInstance40,81 testStep3252TerminateUHostInstance41,82 },83 })84}85var testStep3252DescribeImage01 = &driver.Step{86 Invoker: func(step *driver.Step) (interface{}, error) {87 c, err := step.LoadFixture("UHost")88 if err != nil {89 return nil, err90 }91 client := c.(*uhost.UHostClient)92 req := client.NewDescribeImageRequest()93 err = utils.SetRequest(req, map[string]interface{}{94 "Zone": step.Scenario.GetVar("Zone"),95 "Region": step.Scenario.GetVar("Region"),96 "OsType": "Linux",97 "ImageType": "Base",98 })99 if err != nil {100 return nil, err101 }102 resp, err := client.DescribeImage(req)103 if err != nil {104 return resp, err105 }106 step.Scenario.SetVar("ImageID", step.Must(utils.GetValue(resp, "ImageSet.0.ImageId")))107 return resp, nil108 },109 Validators: func(step *driver.Step) []driver.TestValidator {110 return []driver.TestValidator{111 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),112 validation.Builtins.NewValidator("Action", "DescribeImageResponse", "str_eq"),113 }114 },115 StartupDelay: time.Duration(0) * time.Second,116 MaxRetries: 3,117 RetryInterval: 1 * time.Second,118 Title: "è·åéåå表",119 FastFail: true,120}121var testStep3252CreateIsolationGroup02 = &driver.Step{122 Invoker: func(step *driver.Step) (interface{}, error) {123 c, err := step.LoadFixture("UHost")124 if err != nil {125 return nil, err126 }127 client := c.(*uhost.UHostClient)128 req := client.NewCreateIsolationGroupRequest()129 err = utils.SetRequest(req, map[string]interface{}{130 "Region": step.Scenario.GetVar("Region"),131 "GroupName": step.Scenario.GetVar("GroupName"),132 })133 if err != nil {134 return nil, err135 }136 resp, err := client.CreateIsolationGroup(req)137 if err != nil {138 return resp, err139 }140 step.Scenario.SetVar("GroupId", step.Must(utils.GetValue(resp, "GroupId")))141 return resp, nil142 },143 Validators: func(step *driver.Step) []driver.TestValidator {144 return []driver.TestValidator{145 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),146 validation.Builtins.NewValidator("Action", "CreateIsolationGroupResponse", "str_eq"),147 }148 },149 StartupDelay: time.Duration(0) * time.Second,150 MaxRetries: 3,151 RetryInterval: 1 * time.Second,152 Title: "å建硬件é离ç»",153 FastFail: true,154}155var testStep3252DescribeIsolationGroup03 = &driver.Step{156 Invoker: func(step *driver.Step) (interface{}, error) {157 c, err := step.LoadFixture("UHost")158 if err != nil {159 return nil, err160 }161 client := c.(*uhost.UHostClient)162 req := client.NewDescribeIsolationGroupRequest()163 err = utils.SetRequest(req, map[string]interface{}{164 "Region": step.Scenario.GetVar("Region"),165 "GroupId": step.Scenario.GetVar("GroupId"),166 })167 if err != nil {168 return nil, err169 }170 resp, err := client.DescribeIsolationGroup(req)171 if err != nil {172 return resp, err173 }174 return resp, nil175 },176 Validators: func(step *driver.Step) []driver.TestValidator {177 return []driver.TestValidator{178 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),179 validation.Builtins.NewValidator("Action", "DescribeIsolationGroupResponse", "str_eq"),180 validation.Builtins.NewValidator("IsolationGroupSet.0.GroupName", step.Scenario.GetVar("GroupName"), "str_eq"),181 validation.Builtins.NewValidator("IsolationGroupSet.0.GroupId", step.Scenario.GetVar("GroupId"), "str_eq"),182 }183 },184 StartupDelay: time.Duration(10) * time.Second,185 MaxRetries: 3,186 RetryInterval: 1 * time.Second,187 Title: "æ述硬件é离ç»",188 FastFail: true,189}190var testStep3252DescribeUHostInstance04 = &driver.Step{191 Invoker: func(step *driver.Step) (interface{}, error) {192 c, err := step.LoadFixture("UHost")193 if err != nil {194 return nil, err195 }196 client := c.(*uhost.UHostClient)197 req := client.NewDescribeUHostInstanceRequest()198 err = utils.SetRequest(req, map[string]interface{}{199 "Zone": step.Scenario.GetVar("Zone"),200 "Region": step.Scenario.GetVar("Region"),201 "IsolationGroup": step.Scenario.GetVar("GroupId"),202 })203 if err != nil {204 return nil, err205 }206 resp, err := client.DescribeUHostInstance(req)207 if err != nil {208 return resp, err209 }210 return resp, nil211 },212 Validators: func(step *driver.Step) []driver.TestValidator {213 return []driver.TestValidator{214 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),215 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),216 }217 },218 StartupDelay: time.Duration(10) * time.Second,219 MaxRetries: 3,220 RetryInterval: 30 * time.Second,221 Title: "è·å主æºä¿¡æ¯",222 FastFail: true,223}224var testStep3252CreateUHostInstance05 = &driver.Step{225 Invoker: func(step *driver.Step) (interface{}, error) {226 c, err := step.LoadFixture("UHost")227 if err != nil {228 return nil, err229 }230 client := c.(*uhost.UHostClient)231 req := client.NewCreateUHostInstanceRequest()232 err = utils.SetRequest(req, map[string]interface{}{233 "Zone": step.Scenario.GetVar("Zone"),234 "TimemachineFeature": "No",235 "Tag": "Default",236 "Region": step.Scenario.GetVar("Region"),237 "Quantity": 1,238 "Password": step.Scenario.GetVar("Password"),239 "Name": step.Scenario.GetVar("Name"),240 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),241 "Memory": step.Scenario.GetVar("CreateMem"),242 "MachineType": step.Scenario.GetVar("MachineType"),243 "LoginMode": "Password",244 "IsolationGroup": step.Scenario.GetVar("GroupId"),245 "ImageId": step.Scenario.GetVar("ImageID"),246 "HotplugFeature": "false",247 "Disks": []map[string]interface{}{248 {249 "BackupType": step.Scenario.GetVar("BootBackup"),250 "IsBoot": "True",251 "Size": step.Scenario.GetVar("BootSize"),252 "Type": step.Scenario.GetVar("BootType"),253 },254 {255 "BackupType": step.Scenario.GetVar("DiskBackup"),256 "IsBoot": "False",257 "Size": step.Scenario.GetVar("DiskSize"),258 "Type": step.Scenario.GetVar("DiskType"),259 },260 },261 "ChargeType": step.Scenario.GetVar("ChargeType"),262 "CPU": step.Scenario.GetVar("CreateCPU"),263 })264 if err != nil {265 return nil, err266 }267 resp, err := client.CreateUHostInstance(req)268 if err != nil {269 return resp, err270 }271 step.Scenario.SetVar("hostId1", step.Must(utils.GetValue(resp, "UHostIds.0")))272 return resp, nil273 },274 Validators: func(step *driver.Step) []driver.TestValidator {275 return []driver.TestValidator{276 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),277 validation.Builtins.NewValidator("Action", "CreateUHostInstanceResponse", "str_eq"),278 }279 },280 StartupDelay: time.Duration(0) * time.Second,281 MaxRetries: 3,282 RetryInterval: 1 * time.Second,283 Title: "å建äºä¸»æº",284 FastFail: false,285}286var testStep3252DescribeUHostInstance06 = &driver.Step{287 Invoker: func(step *driver.Step) (interface{}, error) {288 c, err := step.LoadFixture("UHost")289 if err != nil {290 return nil, err291 }292 client := c.(*uhost.UHostClient)293 req := client.NewDescribeUHostInstanceRequest()294 err = utils.SetRequest(req, map[string]interface{}{295 "Zone": step.Scenario.GetVar("Zone"),296 "Region": step.Scenario.GetVar("Region"),297 "IsolationGroup": step.Scenario.GetVar("GroupId"),298 })299 if err != nil {300 return nil, err301 }302 resp, err := client.DescribeUHostInstance(req)303 if err != nil {304 return resp, err305 }306 return resp, nil307 },308 Validators: func(step *driver.Step) []driver.TestValidator {309 return []driver.TestValidator{310 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),311 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),312 }313 },314 StartupDelay: time.Duration(0) * time.Second,315 MaxRetries: 3,316 RetryInterval: 1 * time.Second,317 Title: "è·å主æºä¿¡æ¯",318 FastFail: false,319}320var testStep3252CreateUHostInstance07 = &driver.Step{321 Invoker: func(step *driver.Step) (interface{}, error) {322 c, err := step.LoadFixture("UHost")323 if err != nil {324 return nil, err325 }326 client := c.(*uhost.UHostClient)327 req := client.NewCreateUHostInstanceRequest()328 err = utils.SetRequest(req, map[string]interface{}{329 "Zone": step.Scenario.GetVar("Zone"),330 "TimemachineFeature": "No",331 "Tag": "Default",332 "Region": step.Scenario.GetVar("Region"),333 "Quantity": 1,334 "Password": step.Scenario.GetVar("Password"),335 "Name": step.Scenario.GetVar("Name"),336 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),337 "Memory": step.Scenario.GetVar("CreateMem"),338 "MachineType": step.Scenario.GetVar("MachineType"),339 "LoginMode": "Password",340 "IsolationGroup": step.Scenario.GetVar("GroupId"),341 "ImageId": step.Scenario.GetVar("ImageID"),342 "HotplugFeature": "false",343 "Disks": []map[string]interface{}{344 {345 "BackupType": step.Scenario.GetVar("BootBackup"),346 "IsBoot": "True",347 "Size": step.Scenario.GetVar("BootSize"),348 "Type": step.Scenario.GetVar("BootType"),349 },350 {351 "BackupType": step.Scenario.GetVar("DiskBackup"),352 "IsBoot": "False",353 "Size": step.Scenario.GetVar("DiskSize"),354 "Type": step.Scenario.GetVar("DiskType"),355 },356 },357 "ChargeType": step.Scenario.GetVar("ChargeType"),358 "CPU": step.Scenario.GetVar("CreateCPU"),359 })360 if err != nil {361 return nil, err362 }363 resp, err := client.CreateUHostInstance(req)364 if err != nil {365 return resp, err366 }367 step.Scenario.SetVar("hostId2", step.Must(utils.GetValue(resp, "UHostIds.0")))368 return resp, nil369 },370 Validators: func(step *driver.Step) []driver.TestValidator {371 return []driver.TestValidator{372 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),373 validation.Builtins.NewValidator("Action", "CreateUHostInstanceResponse", "str_eq"),374 }375 },376 StartupDelay: time.Duration(0) * time.Second,377 MaxRetries: 3,378 RetryInterval: 1 * time.Second,379 Title: "å建äºä¸»æº",380 FastFail: true,381}382var testStep3252CreateUHostInstance08 = &driver.Step{383 Invoker: func(step *driver.Step) (interface{}, error) {384 c, err := step.LoadFixture("UHost")385 if err != nil {386 return nil, err387 }388 client := c.(*uhost.UHostClient)389 req := client.NewCreateUHostInstanceRequest()390 err = utils.SetRequest(req, map[string]interface{}{391 "Zone": step.Scenario.GetVar("Zone"),392 "TimemachineFeature": "No",393 "Tag": "Default",394 "Region": step.Scenario.GetVar("Region"),395 "Quantity": 1,396 "Password": step.Scenario.GetVar("Password"),397 "Name": step.Scenario.GetVar("Name"),398 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),399 "Memory": step.Scenario.GetVar("CreateMem"),400 "MachineType": step.Scenario.GetVar("MachineType"),401 "LoginMode": "Password",402 "IsolationGroup": step.Scenario.GetVar("GroupId"),403 "ImageId": step.Scenario.GetVar("ImageID"),404 "HotplugFeature": "false",405 "Disks": []map[string]interface{}{406 {407 "BackupType": step.Scenario.GetVar("BootBackup"),408 "IsBoot": "True",409 "Size": step.Scenario.GetVar("BootSize"),410 "Type": step.Scenario.GetVar("BootType"),411 },412 {413 "BackupType": step.Scenario.GetVar("DiskBackup"),414 "IsBoot": "False",415 "Size": step.Scenario.GetVar("DiskSize"),416 "Type": step.Scenario.GetVar("DiskType"),417 },418 },419 "ChargeType": step.Scenario.GetVar("ChargeType"),420 "CPU": step.Scenario.GetVar("CreateCPU"),421 })422 if err != nil {423 return nil, err424 }425 resp, err := client.CreateUHostInstance(req)426 if err != nil {427 return resp, err428 }429 step.Scenario.SetVar("hostId3", step.Must(utils.GetValue(resp, "UHostIds.0")))430 return resp, nil431 },432 Validators: func(step *driver.Step) []driver.TestValidator {433 return []driver.TestValidator{434 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),435 validation.Builtins.NewValidator("Action", "CreateUHostInstanceResponse", "str_eq"),436 }437 },438 StartupDelay: time.Duration(0) * time.Second,439 MaxRetries: 3,440 RetryInterval: 1 * time.Second,441 Title: "å建äºä¸»æº",442 FastFail: true,443}444var testStep3252CreateUHostInstance09 = &driver.Step{445 Invoker: func(step *driver.Step) (interface{}, error) {446 c, err := step.LoadFixture("UHost")447 if err != nil {448 return nil, err449 }450 client := c.(*uhost.UHostClient)451 req := client.NewCreateUHostInstanceRequest()452 err = utils.SetRequest(req, map[string]interface{}{453 "Zone": step.Scenario.GetVar("Zone"),454 "TimemachineFeature": "No",455 "Tag": "Default",456 "Region": step.Scenario.GetVar("Region"),457 "Quantity": 1,458 "Password": step.Scenario.GetVar("Password"),459 "Name": step.Scenario.GetVar("Name"),460 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),461 "Memory": step.Scenario.GetVar("CreateMem"),462 "MachineType": step.Scenario.GetVar("MachineType"),463 "LoginMode": "Password",464 "IsolationGroup": step.Scenario.GetVar("GroupId"),465 "ImageId": step.Scenario.GetVar("ImageID"),466 "HotplugFeature": "false",467 "Disks": []map[string]interface{}{468 {469 "BackupType": step.Scenario.GetVar("BootBackup"),470 "IsBoot": "True",471 "Size": step.Scenario.GetVar("BootSize"),472 "Type": step.Scenario.GetVar("BootType"),473 },474 {475 "BackupType": step.Scenario.GetVar("DiskBackup"),476 "IsBoot": "False",477 "Size": step.Scenario.GetVar("DiskSize"),478 "Type": step.Scenario.GetVar("DiskType"),479 },480 },481 "ChargeType": step.Scenario.GetVar("ChargeType"),482 "CPU": step.Scenario.GetVar("CreateCPU"),483 })484 if err != nil {485 return nil, err486 }487 resp, err := client.CreateUHostInstance(req)488 if err != nil {489 return resp, err490 }491 step.Scenario.SetVar("hostId4", step.Must(utils.GetValue(resp, "UHostIds.0")))492 return resp, nil493 },494 Validators: func(step *driver.Step) []driver.TestValidator {495 return []driver.TestValidator{496 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),497 validation.Builtins.NewValidator("Action", "CreateUHostInstanceResponse", "str_eq"),498 }499 },500 StartupDelay: time.Duration(0) * time.Second,501 MaxRetries: 3,502 RetryInterval: 1 * time.Second,503 Title: "å建äºä¸»æº",504 FastFail: true,505}506var testStep3252CreateUHostInstance10 = &driver.Step{507 Invoker: func(step *driver.Step) (interface{}, error) {508 c, err := step.LoadFixture("UHost")509 if err != nil {510 return nil, err511 }512 client := c.(*uhost.UHostClient)513 req := client.NewCreateUHostInstanceRequest()514 err = utils.SetRequest(req, map[string]interface{}{515 "Zone": step.Scenario.GetVar("Zone"),516 "TimemachineFeature": "No",517 "Tag": "Default",518 "Region": step.Scenario.GetVar("Region"),519 "Quantity": 1,520 "Password": step.Scenario.GetVar("Password"),521 "Name": step.Scenario.GetVar("Name"),522 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),523 "Memory": step.Scenario.GetVar("CreateMem"),524 "MachineType": step.Scenario.GetVar("MachineType"),525 "LoginMode": "Password",526 "IsolationGroup": step.Scenario.GetVar("GroupId"),527 "ImageId": step.Scenario.GetVar("ImageID"),528 "HotplugFeature": "false",529 "Disks": []map[string]interface{}{530 {531 "BackupType": step.Scenario.GetVar("BootBackup"),532 "IsBoot": "True",533 "Size": step.Scenario.GetVar("BootSize"),534 "Type": step.Scenario.GetVar("BootType"),535 },536 {537 "BackupType": step.Scenario.GetVar("DiskBackup"),538 "IsBoot": "False",539 "Size": step.Scenario.GetVar("DiskSize"),540 "Type": step.Scenario.GetVar("DiskType"),541 },542 },543 "ChargeType": step.Scenario.GetVar("ChargeType"),544 "CPU": step.Scenario.GetVar("CreateCPU"),545 })546 if err != nil {547 return nil, err548 }549 resp, err := client.CreateUHostInstance(req)550 if err != nil {551 return resp, err552 }553 step.Scenario.SetVar("hostId5", step.Must(utils.GetValue(resp, "UHostIds.0")))554 return resp, nil555 },556 Validators: func(step *driver.Step) []driver.TestValidator {557 return []driver.TestValidator{558 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),559 validation.Builtins.NewValidator("Action", "CreateUHostInstanceResponse", "str_eq"),560 }561 },562 StartupDelay: time.Duration(0) * time.Second,563 MaxRetries: 3,564 RetryInterval: 1 * time.Second,565 Title: "å建äºä¸»æº",566 FastFail: true,567}568var testStep3252CreateUHostInstance11 = &driver.Step{569 Invoker: func(step *driver.Step) (interface{}, error) {570 c, err := step.LoadFixture("UHost")571 if err != nil {572 return nil, err573 }574 client := c.(*uhost.UHostClient)575 req := client.NewCreateUHostInstanceRequest()576 err = utils.SetRequest(req, map[string]interface{}{577 "Zone": step.Scenario.GetVar("Zone"),578 "TimemachineFeature": "No",579 "Tag": "Default",580 "Region": step.Scenario.GetVar("Region"),581 "Quantity": 1,582 "Password": step.Scenario.GetVar("Password"),583 "Name": step.Scenario.GetVar("Name"),584 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),585 "Memory": step.Scenario.GetVar("CreateMem"),586 "MachineType": step.Scenario.GetVar("MachineType"),587 "LoginMode": "Password",588 "IsolationGroup": step.Scenario.GetVar("GroupId"),589 "ImageId": step.Scenario.GetVar("ImageID"),590 "HotplugFeature": "false",591 "Disks": []map[string]interface{}{592 {593 "BackupType": step.Scenario.GetVar("BootBackup"),594 "IsBoot": "True",595 "Size": step.Scenario.GetVar("BootSize"),596 "Type": step.Scenario.GetVar("BootType"),597 },598 {599 "BackupType": step.Scenario.GetVar("DiskBackup"),600 "IsBoot": "False",601 "Size": step.Scenario.GetVar("DiskSize"),602 "Type": step.Scenario.GetVar("DiskType"),603 },604 },605 "ChargeType": step.Scenario.GetVar("ChargeType"),606 "CPU": step.Scenario.GetVar("CreateCPU"),607 })608 if err != nil {609 return nil, err610 }611 resp, err := client.CreateUHostInstance(req)612 if err != nil {613 return resp, err614 }615 step.Scenario.SetVar("hostId6", step.Must(utils.GetValue(resp, "UHostIds.0")))616 return resp, nil617 },618 Validators: func(step *driver.Step) []driver.TestValidator {619 return []driver.TestValidator{620 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),621 validation.Builtins.NewValidator("Action", "CreateUHostInstanceResponse", "str_eq"),622 }623 },624 StartupDelay: time.Duration(0) * time.Second,625 MaxRetries: 3,626 RetryInterval: 1 * time.Second,627 Title: "å建äºä¸»æº",628 FastFail: true,629}630var testStep3252CreateUHostInstance12 = &driver.Step{631 Invoker: func(step *driver.Step) (interface{}, error) {632 c, err := step.LoadFixture("UHost")633 if err != nil {634 return nil, err635 }636 client := c.(*uhost.UHostClient)637 req := client.NewCreateUHostInstanceRequest()638 err = utils.SetRequest(req, map[string]interface{}{639 "Zone": step.Scenario.GetVar("Zone"),640 "TimemachineFeature": "No",641 "Tag": "Default",642 "Region": step.Scenario.GetVar("Region"),643 "Quantity": 1,644 "Password": step.Scenario.GetVar("Password"),645 "Name": step.Scenario.GetVar("Name"),646 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),647 "Memory": step.Scenario.GetVar("CreateMem"),648 "MachineType": step.Scenario.GetVar("MachineType"),649 "LoginMode": "Password",650 "IsolationGroup": step.Scenario.GetVar("GroupId"),651 "ImageId": step.Scenario.GetVar("ImageID"),652 "HotplugFeature": "false",653 "Disks": []map[string]interface{}{654 {655 "BackupType": step.Scenario.GetVar("BootBackup"),656 "IsBoot": "True",657 "Size": step.Scenario.GetVar("BootSize"),658 "Type": step.Scenario.GetVar("BootType"),659 },660 {661 "BackupType": step.Scenario.GetVar("DiskBackup"),662 "IsBoot": "False",663 "Size": step.Scenario.GetVar("DiskSize"),664 "Type": step.Scenario.GetVar("DiskType"),665 },666 },667 "ChargeType": step.Scenario.GetVar("ChargeType"),668 "CPU": step.Scenario.GetVar("CreateCPU"),669 })670 if err != nil {671 return nil, err672 }673 resp, err := client.CreateUHostInstance(req)674 if err != nil {675 return resp, err676 }677 step.Scenario.SetVar("hostId7", step.Must(utils.GetValue(resp, "UHostIds.0")))678 return resp, nil679 },680 Validators: func(step *driver.Step) []driver.TestValidator {681 return []driver.TestValidator{682 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),683 validation.Builtins.NewValidator("Action", "CreateUHostInstanceResponse", "str_eq"),684 }685 },686 StartupDelay: time.Duration(0) * time.Second,687 MaxRetries: 3,688 RetryInterval: 1 * time.Second,689 Title: "å建äºä¸»æº",690 FastFail: true,691}692var testStep3252CreateUHostInstance13 = &driver.Step{693 Invoker: func(step *driver.Step) (interface{}, error) {694 c, err := step.LoadFixture("UHost")695 if err != nil {696 return nil, err697 }698 client := c.(*uhost.UHostClient)699 req := client.NewCreateUHostInstanceRequest()700 err = utils.SetRequest(req, map[string]interface{}{701 "Zone": step.Scenario.GetVar("Zone"),702 "TimemachineFeature": "No",703 "Tag": "Default",704 "Region": step.Scenario.GetVar("Region"),705 "Quantity": 1,706 "Password": step.Scenario.GetVar("Password"),707 "Name": step.Scenario.GetVar("Name"),708 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),709 "Memory": step.Scenario.GetVar("CreateMem"),710 "MachineType": step.Scenario.GetVar("MachineType"),711 "LoginMode": "Password",712 "IsolationGroup": step.Scenario.GetVar("GroupId"),713 "ImageId": step.Scenario.GetVar("ImageID"),714 "HotplugFeature": "false",715 "Disks": []map[string]interface{}{716 {717 "BackupType": step.Scenario.GetVar("BootBackup"),718 "IsBoot": "True",719 "Size": step.Scenario.GetVar("BootSize"),720 "Type": step.Scenario.GetVar("BootType"),721 },722 {723 "BackupType": step.Scenario.GetVar("DiskBackup"),724 "IsBoot": "False",725 "Size": step.Scenario.GetVar("DiskSize"),726 "Type": step.Scenario.GetVar("DiskType"),727 },728 },729 "ChargeType": step.Scenario.GetVar("ChargeType"),730 "CPU": step.Scenario.GetVar("CreateCPU"),731 })732 if err != nil {733 return nil, err734 }735 resp, err := client.CreateUHostInstance(req)736 if err != nil {737 return resp, err738 }739 return resp, nil740 },741 Validators: func(step *driver.Step) []driver.TestValidator {742 return []driver.TestValidator{743 validation.Builtins.NewValidator("RetCode", 0, "ne"),744 }745 },746 StartupDelay: time.Duration(0) * time.Second,747 MaxRetries: 3,748 RetryInterval: 1 * time.Second,749 Title: "å建äºä¸»æº",750 FastFail: true,751}752var testStep3252DescribeUHostInstance14 = &driver.Step{753 Invoker: func(step *driver.Step) (interface{}, error) {754 c, err := step.LoadFixture("UHost")755 if err != nil {756 return nil, err757 }758 client := c.(*uhost.UHostClient)759 req := client.NewDescribeUHostInstanceRequest()760 err = utils.SetRequest(req, map[string]interface{}{761 "Zone": step.Scenario.GetVar("Zone"),762 "UHostIds": []interface{}{763 step.Scenario.GetVar("hostId1"),764 step.Scenario.GetVar("hostId2"),765 step.Scenario.GetVar("hostId3"),766 step.Scenario.GetVar("hostId4"),767 step.Scenario.GetVar("hostId5"),768 step.Scenario.GetVar("hostId6"),769 step.Scenario.GetVar("hostId7"),770 },771 "Region": step.Scenario.GetVar("Region"),772 })773 if err != nil {774 return nil, err775 }776 resp, err := client.DescribeUHostInstance(req)777 if err != nil {778 return resp, err779 }780 return resp, nil781 },782 Validators: func(step *driver.Step) []driver.TestValidator {783 return []driver.TestValidator{784 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),785 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),786 validation.Builtins.NewValidator("UHostSet.0.CPU", step.Scenario.GetVar("CreateCPU"), "str_eq"),787 validation.Builtins.NewValidator("UHostSet.0.Memory", step.Scenario.GetVar("CreateMem"), "str_eq"),788 validation.Builtins.NewValidator("UHostSet.0.BasicImageId", step.Scenario.GetVar("ImageID"), "str_eq"),789 validation.Builtins.NewValidator("UHostSet.0.State", "Running", "str_eq"),790 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.IsBoot", "True", "str_eq"),791 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.IsBoot", "False", "str_eq"),792 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.DiskType", step.Scenario.GetVar("BootType"), "str_eq"),793 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.DiskType", step.Scenario.GetVar("DiskType"), "str_eq"),794 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.Size", step.Scenario.GetVar("BootSize"), "str_eq"),795 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.Size", step.Scenario.GetVar("DiskSize"), "str_eq"),796 validation.Builtins.NewValidator("UHostSet.0.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),797 validation.Builtins.NewValidator("UHostSet.1.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),798 validation.Builtins.NewValidator("UHostSet.2.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),799 validation.Builtins.NewValidator("UHostSet.3.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),800 validation.Builtins.NewValidator("UHostSet.4.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),801 validation.Builtins.NewValidator("UHostSet.5.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),802 validation.Builtins.NewValidator("UHostSet.6.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),803 validation.Builtins.NewValidator("UHostSet.1.State", "Running", "str_eq"),804 validation.Builtins.NewValidator("UHostSet.2.State", "Running", "str_eq"),805 validation.Builtins.NewValidator("UHostSet.3.State", "Running", "str_eq"),806 validation.Builtins.NewValidator("UHostSet.4.State", "Running", "str_eq"),807 validation.Builtins.NewValidator("UHostSet.5.State", "Running", "str_eq"),808 validation.Builtins.NewValidator("UHostSet.6.State", "Running", "str_eq"),809 validation.Builtins.NewValidator("UHostSet.0.MachineType", step.Scenario.GetVar("MachineType"), "str_eq"),810 }811 },812 StartupDelay: time.Duration(10) * time.Second,813 MaxRetries: 60,814 RetryInterval: 30 * time.Second,815 Title: "è·å主æºä¿¡æ¯",816 FastFail: true,817}818var testStep3252LeaveIsolationGroup15 = &driver.Step{819 Invoker: func(step *driver.Step) (interface{}, error) {820 c, err := step.LoadFixture("UHost")821 if err != nil {822 return nil, err823 }824 client := c.(*uhost.UHostClient)825 req := client.NewLeaveIsolationGroupRequest()826 err = utils.SetRequest(req, map[string]interface{}{827 "Zone": step.Scenario.GetVar("Zone"),828 "UHostId": step.Scenario.GetVar("hostId1"),829 "Region": step.Scenario.GetVar("Region"),830 "GroupId": step.Scenario.GetVar("GroupId"),831 })832 if err != nil {833 return nil, err834 }835 resp, err := client.LeaveIsolationGroup(req)836 if err != nil {837 return resp, err838 }839 return resp, nil840 },841 Validators: func(step *driver.Step) []driver.TestValidator {842 return []driver.TestValidator{843 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),844 validation.Builtins.NewValidator("Action", "LeaveIsolationGroupResponse", "str_eq"),845 validation.Builtins.NewValidator("UHostId", step.Scenario.GetVar("hostId1"), "str_eq"),846 }847 },848 StartupDelay: time.Duration(0) * time.Second,849 MaxRetries: 3,850 RetryInterval: 1 * time.Second,851 Title: "移é¤ç¡¬ä»¶é离ç»",852 FastFail: true,853}854var testStep3252DescribeUHostInstance16 = &driver.Step{855 Invoker: func(step *driver.Step) (interface{}, error) {856 c, err := step.LoadFixture("UHost")857 if err != nil {858 return nil, err859 }860 client := c.(*uhost.UHostClient)861 req := client.NewDescribeUHostInstanceRequest()862 err = utils.SetRequest(req, map[string]interface{}{863 "Zone": step.Scenario.GetVar("Zone"),864 "UHostIds": []interface{}{865 step.Scenario.GetVar("hostId1"),866 },867 "Region": step.Scenario.GetVar("Region"),868 })869 if err != nil {870 return nil, err871 }872 resp, err := client.DescribeUHostInstance(req)873 if err != nil {874 return resp, err875 }876 return resp, nil877 },878 Validators: func(step *driver.Step) []driver.TestValidator {879 return []driver.TestValidator{880 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),881 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),882 validation.Builtins.NewValidator("UHostSet.0.CPU", step.Scenario.GetVar("CreateCPU"), "str_eq"),883 validation.Builtins.NewValidator("UHostSet.0.Memory", step.Scenario.GetVar("CreateMem"), "str_eq"),884 validation.Builtins.NewValidator("UHostSet.0.UHostId", step.Scenario.GetVar("hostId1"), "str_eq"),885 validation.Builtins.NewValidator("UHostSet.0.BasicImageId", step.Scenario.GetVar("ImageID"), "str_eq"),886 validation.Builtins.NewValidator("UHostSet.0.State", "Running", "str_eq"),887 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.IsBoot", "True", "str_eq"),888 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.IsBoot", "False", "str_eq"),889 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.DiskType", step.Scenario.GetVar("BootType"), "str_eq"),890 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.DiskType", step.Scenario.GetVar("DiskType"), "str_eq"),891 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.Size", step.Scenario.GetVar("BootSize"), "str_eq"),892 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.Size", step.Scenario.GetVar("DiskSize"), "str_eq"),893 validation.Builtins.NewValidator("UHostSet.0.IsolationGroup", 0, "len_eq"),894 validation.Builtins.NewValidator("UHostSet.0.MachineType", step.Scenario.GetVar("MachineType"), "str_eq"),895 }896 },897 StartupDelay: time.Duration(0) * time.Second,898 MaxRetries: 3,899 RetryInterval: 1 * time.Second,900 Title: "è·å主æºä¿¡æ¯",901 FastFail: false,902}903var testStep3252DescribeUHostInstance17 = &driver.Step{904 Invoker: func(step *driver.Step) (interface{}, error) {905 c, err := step.LoadFixture("UHost")906 if err != nil {907 return nil, err908 }909 client := c.(*uhost.UHostClient)910 req := client.NewDescribeUHostInstanceRequest()911 err = utils.SetRequest(req, map[string]interface{}{912 "Zone": step.Scenario.GetVar("Zone"),913 "UHostIds": []interface{}{914 step.Scenario.GetVar("hostId2"),915 step.Scenario.GetVar("hostId3"),916 step.Scenario.GetVar("hostId4"),917 step.Scenario.GetVar("hostId5"),918 step.Scenario.GetVar("hostId6"),919 step.Scenario.GetVar("hostId7"),920 },921 "Region": step.Scenario.GetVar("Region"),922 })923 if err != nil {924 return nil, err925 }926 resp, err := client.DescribeUHostInstance(req)927 if err != nil {928 return resp, err929 }930 return resp, nil931 },932 Validators: func(step *driver.Step) []driver.TestValidator {933 return []driver.TestValidator{934 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),935 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),936 validation.Builtins.NewValidator("UHostSet.0.CPU", step.Scenario.GetVar("CreateCPU"), "str_eq"),937 validation.Builtins.NewValidator("UHostSet.0.Memory", step.Scenario.GetVar("CreateMem"), "str_eq"),938 validation.Builtins.NewValidator("UHostSet.0.BasicImageId", step.Scenario.GetVar("ImageID"), "str_eq"),939 validation.Builtins.NewValidator("UHostSet.0.State", "Running", "str_eq"),940 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.IsBoot", "True", "str_eq"),941 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.IsBoot", "False", "str_eq"),942 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.DiskType", step.Scenario.GetVar("BootType"), "str_eq"),943 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.DiskType", step.Scenario.GetVar("DiskType"), "str_eq"),944 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.Size", step.Scenario.GetVar("BootSize"), "str_eq"),945 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.Size", step.Scenario.GetVar("DiskSize"), "str_eq"),946 validation.Builtins.NewValidator("UHostSet.0.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),947 validation.Builtins.NewValidator("UHostSet.1.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),948 validation.Builtins.NewValidator("UHostSet.2.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),949 validation.Builtins.NewValidator("UHostSet.3.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),950 validation.Builtins.NewValidator("UHostSet.4.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),951 validation.Builtins.NewValidator("UHostSet.5.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),952 validation.Builtins.NewValidator("UHostSet.0.MachineType", step.Scenario.GetVar("MachineType"), "str_eq"),953 }954 },955 StartupDelay: time.Duration(0) * time.Second,956 MaxRetries: 3,957 RetryInterval: 1 * time.Second,958 Title: "è·å主æºä¿¡æ¯",959 FastFail: true,960}961var testStep3252DescribeIsolationGroup18 = &driver.Step{962 Invoker: func(step *driver.Step) (interface{}, error) {963 c, err := step.LoadFixture("UHost")964 if err != nil {965 return nil, err966 }967 client := c.(*uhost.UHostClient)968 req := client.NewDescribeIsolationGroupRequest()969 err = utils.SetRequest(req, map[string]interface{}{970 "Region": step.Scenario.GetVar("Region"),971 "GroupId": step.Scenario.GetVar("GroupId"),972 })973 if err != nil {974 return nil, err975 }976 resp, err := client.DescribeIsolationGroup(req)977 if err != nil {978 return resp, err979 }980 return resp, nil981 },982 Validators: func(step *driver.Step) []driver.TestValidator {983 return []driver.TestValidator{984 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),985 validation.Builtins.NewValidator("Action", "DescribeIsolationGroupResponse", "str_eq"),986 validation.Builtins.NewValidator("IsolationGroupSet.0.GroupName", step.Scenario.GetVar("GroupName"), "str_eq"),987 validation.Builtins.NewValidator("IsolationGroupSet.0.GroupId", step.Scenario.GetVar("GroupId"), "str_eq"),988 validation.Builtins.NewValidator("IsolationGroupSet.0.SpreadInfoSet.0.UHostCount", 6, "str_eq"),989 }990 },991 StartupDelay: time.Duration(0) * time.Second,992 MaxRetries: 3,993 RetryInterval: 1 * time.Second,994 Title: "æ述硬件é离ç»",995 FastFail: true,996}997var testStep3252CreateUHostInstance19 = &driver.Step{998 Invoker: func(step *driver.Step) (interface{}, error) {999 c, err := step.LoadFixture("UHost")1000 if err != nil {1001 return nil, err1002 }1003 client := c.(*uhost.UHostClient)1004 req := client.NewCreateUHostInstanceRequest()1005 err = utils.SetRequest(req, map[string]interface{}{1006 "Zone": step.Scenario.GetVar("Zone"),1007 "TimemachineFeature": "No",1008 "Tag": "Default",1009 "Region": step.Scenario.GetVar("Region"),1010 "Quantity": 1,1011 "Password": step.Scenario.GetVar("Password"),1012 "NetCapability": "Normal",1013 "Name": step.Scenario.GetVar("Name"),1014 "MinimalCpuPlatform": step.Scenario.GetVar("MinimalCpuPlatform"),1015 "Memory": step.Scenario.GetVar("CreateMem"),1016 "MachineType": step.Scenario.GetVar("MachineType"),1017 "LoginMode": "Password",1018 "IsolationGroup": step.Scenario.GetVar("GroupId"),1019 "ImageId": step.Scenario.GetVar("ImageID"),1020 "HotplugFeature": "false",1021 "Disks": []map[string]interface{}{1022 {1023 "BackupType": step.Scenario.GetVar("BootBackup"),1024 "IsBoot": "True",1025 "Size": step.Scenario.GetVar("BootSize"),1026 "Type": step.Scenario.GetVar("BootType"),1027 },1028 {1029 "BackupType": step.Scenario.GetVar("DiskBackup"),1030 "IsBoot": "False",1031 "Size": step.Scenario.GetVar("DiskSize"),1032 "Type": step.Scenario.GetVar("DiskType"),1033 },1034 },1035 "ChargeType": step.Scenario.GetVar("ChargeType"),1036 "CPU": step.Scenario.GetVar("CreateCPU"),1037 })1038 if err != nil {1039 return nil, err1040 }1041 resp, err := client.CreateUHostInstance(req)1042 if err != nil {1043 return resp, err1044 }1045 step.Scenario.SetVar("hostId8", step.Must(utils.GetValue(resp, "UHostIds.0")))1046 return resp, nil1047 },1048 Validators: func(step *driver.Step) []driver.TestValidator {1049 return []driver.TestValidator{1050 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1051 }1052 },1053 StartupDelay: time.Duration(0) * time.Second,1054 MaxRetries: 3,1055 RetryInterval: 1 * time.Second,1056 Title: "å建äºä¸»æº",1057 FastFail: true,1058}1059var testStep3252DescribeIsolationGroup20 = &driver.Step{1060 Invoker: func(step *driver.Step) (interface{}, error) {1061 c, err := step.LoadFixture("UHost")1062 if err != nil {1063 return nil, err1064 }1065 client := c.(*uhost.UHostClient)1066 req := client.NewDescribeIsolationGroupRequest()1067 err = utils.SetRequest(req, map[string]interface{}{1068 "Region": step.Scenario.GetVar("Region"),1069 "GroupId": step.Scenario.GetVar("GroupId"),1070 })1071 if err != nil {1072 return nil, err1073 }1074 resp, err := client.DescribeIsolationGroup(req)1075 if err != nil {1076 return resp, err1077 }1078 return resp, nil1079 },1080 Validators: func(step *driver.Step) []driver.TestValidator {1081 return []driver.TestValidator{1082 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1083 validation.Builtins.NewValidator("Action", "DescribeIsolationGroupResponse", "str_eq"),1084 validation.Builtins.NewValidator("IsolationGroupSet.0.GroupName", step.Scenario.GetVar("GroupName"), "str_eq"),1085 validation.Builtins.NewValidator("IsolationGroupSet.0.GroupId", step.Scenario.GetVar("GroupId"), "str_eq"),1086 validation.Builtins.NewValidator("IsolationGroupSet.0.SpreadInfoSet.0.UHostCount", 7, "str_eq"),1087 }1088 },1089 StartupDelay: time.Duration(0) * time.Second,1090 MaxRetries: 3,1091 RetryInterval: 1 * time.Second,1092 Title: "æ述硬件é离ç»",1093 FastFail: true,1094}1095var testStep3252DescribeUHostInstance21 = &driver.Step{1096 Invoker: func(step *driver.Step) (interface{}, error) {1097 c, err := step.LoadFixture("UHost")1098 if err != nil {1099 return nil, err1100 }1101 client := c.(*uhost.UHostClient)1102 req := client.NewDescribeUHostInstanceRequest()1103 err = utils.SetRequest(req, map[string]interface{}{1104 "Zone": step.Scenario.GetVar("Zone"),1105 "UHostIds": []interface{}{1106 step.Scenario.GetVar("hostId8"),1107 },1108 "Region": step.Scenario.GetVar("Region"),1109 })1110 if err != nil {1111 return nil, err1112 }1113 resp, err := client.DescribeUHostInstance(req)1114 if err != nil {1115 return resp, err1116 }1117 return resp, nil1118 },1119 Validators: func(step *driver.Step) []driver.TestValidator {1120 return []driver.TestValidator{1121 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1122 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),1123 validation.Builtins.NewValidator("UHostSet.0.CPU", step.Scenario.GetVar("CreateCPU"), "str_eq"),1124 validation.Builtins.NewValidator("UHostSet.0.Memory", step.Scenario.GetVar("CreateMem"), "str_eq"),1125 validation.Builtins.NewValidator("UHostSet.0.BasicImageId", step.Scenario.GetVar("ImageID"), "str_eq"),1126 validation.Builtins.NewValidator("UHostSet.0.State", "Running", "str_eq"),1127 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.IsBoot", "True", "str_eq"),1128 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.IsBoot", "False", "str_eq"),1129 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.DiskType", step.Scenario.GetVar("BootType"), "str_eq"),1130 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.DiskType", step.Scenario.GetVar("DiskType"), "str_eq"),1131 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.Size", step.Scenario.GetVar("BootSize"), "str_eq"),1132 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.Size", step.Scenario.GetVar("DiskSize"), "str_eq"),1133 validation.Builtins.NewValidator("UHostSet.0.IsolationGroup", step.Scenario.GetVar("GroupId"), "str_eq"),1134 }1135 },1136 StartupDelay: time.Duration(0) * time.Second,1137 MaxRetries: 30,1138 RetryInterval: 10 * time.Second,1139 Title: "è·å主æºä¿¡æ¯",1140 FastFail: true,1141}1142var testStep3252DeleteIsolationGroup22 = &driver.Step{1143 Invoker: func(step *driver.Step) (interface{}, error) {1144 c, err := step.LoadFixture("UHost")1145 if err != nil {1146 return nil, err1147 }1148 client := c.(*uhost.UHostClient)1149 req := client.NewDeleteIsolationGroupRequest()1150 err = utils.SetRequest(req, map[string]interface{}{1151 "Region": step.Scenario.GetVar("Region"),1152 "GroupId": step.Scenario.GetVar("GroupId"),1153 })1154 if err != nil {1155 return nil, err1156 }1157 resp, err := client.DeleteIsolationGroup(req)1158 if err != nil {1159 return resp, err1160 }1161 return resp, nil1162 },1163 Validators: func(step *driver.Step) []driver.TestValidator {1164 return []driver.TestValidator{1165 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1166 validation.Builtins.NewValidator("Action", "DeleteIsolationGroupResponse", "str_eq"),1167 validation.Builtins.NewValidator("GroupId", step.Scenario.GetVar("GroupId"), "str_eq"),1168 }1169 },1170 StartupDelay: time.Duration(0) * time.Second,1171 MaxRetries: 3,1172 RetryInterval: 1 * time.Second,1173 Title: "å é¤ç¡¬ä»¶é离ç»",1174 FastFail: true,1175}1176var testStep3252DescribeUHostInstance23 = &driver.Step{1177 Invoker: func(step *driver.Step) (interface{}, error) {1178 c, err := step.LoadFixture("UHost")1179 if err != nil {1180 return nil, err1181 }1182 client := c.(*uhost.UHostClient)1183 req := client.NewDescribeUHostInstanceRequest()1184 err = utils.SetRequest(req, map[string]interface{}{1185 "Zone": step.Scenario.GetVar("Zone"),1186 "UHostIds": []interface{}{1187 step.Scenario.GetVar("hostId1"),1188 step.Scenario.GetVar("hostId2"),1189 step.Scenario.GetVar("hostId3"),1190 step.Scenario.GetVar("hostId4"),1191 step.Scenario.GetVar("hostId5"),1192 step.Scenario.GetVar("hostId6"),1193 step.Scenario.GetVar("hostId7"),1194 step.Scenario.GetVar("hostId8"),1195 },1196 "Region": step.Scenario.GetVar("Region"),1197 })1198 if err != nil {1199 return nil, err1200 }1201 resp, err := client.DescribeUHostInstance(req)1202 if err != nil {1203 return resp, err1204 }1205 return resp, nil1206 },1207 Validators: func(step *driver.Step) []driver.TestValidator {1208 return []driver.TestValidator{1209 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1210 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),1211 validation.Builtins.NewValidator("UHostSet.0.CPU", step.Scenario.GetVar("CreateCPU"), "str_eq"),1212 validation.Builtins.NewValidator("UHostSet.0.Memory", step.Scenario.GetVar("CreateMem"), "str_eq"),1213 validation.Builtins.NewValidator("UHostSet.0.BasicImageId", step.Scenario.GetVar("ImageID"), "str_eq"),1214 validation.Builtins.NewValidator("UHostSet.0.State", "Running", "str_eq"),1215 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.IsBoot", "True", "str_eq"),1216 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.IsBoot", "False", "str_eq"),1217 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.DiskType", step.Scenario.GetVar("BootType"), "str_eq"),1218 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.DiskType", step.Scenario.GetVar("DiskType"), "str_eq"),1219 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.Size", step.Scenario.GetVar("BootSize"), "str_eq"),1220 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.Size", step.Scenario.GetVar("DiskSize"), "str_eq"),1221 validation.Builtins.NewValidator("UHostSet.0.IsolationGroup", 0, "len_eq"),1222 validation.Builtins.NewValidator("UHostSet.1.IsolationGroup", 0, "len_eq"),1223 validation.Builtins.NewValidator("UHostSet.2.IsolationGroup", 0, "len_eq"),1224 validation.Builtins.NewValidator("UHostSet.3.IsolationGroup", 0, "len_eq"),1225 validation.Builtins.NewValidator("UHostSet.4.IsolationGroup", 0, "len_eq"),1226 validation.Builtins.NewValidator("UHostSet.5.IsolationGroup", 0, "len_eq"),1227 validation.Builtins.NewValidator("UHostSet.6.IsolationGroup", 0, "len_eq"),1228 validation.Builtins.NewValidator("UHostSet.7.IsolationGroup", 0, "len_eq"),1229 }1230 },1231 StartupDelay: time.Duration(0) * time.Second,1232 MaxRetries: 3,1233 RetryInterval: 1 * time.Second,1234 Title: "è·å主æºä¿¡æ¯",1235 FastFail: true,1236}1237var testStep3252DescribeUHostInstance24 = &driver.Step{1238 Invoker: func(step *driver.Step) (interface{}, error) {1239 c, err := step.LoadFixture("UHost")1240 if err != nil {1241 return nil, err1242 }1243 client := c.(*uhost.UHostClient)1244 req := client.NewDescribeUHostInstanceRequest()1245 err = utils.SetRequest(req, map[string]interface{}{1246 "Zone": step.Scenario.GetVar("Zone"),1247 "UHostIds": []interface{}{1248 step.Scenario.GetVar("hostId1"),1249 step.Scenario.GetVar("hostId2"),1250 step.Scenario.GetVar("hostId3"),1251 step.Scenario.GetVar("hostId4"),1252 step.Scenario.GetVar("hostId5"),1253 step.Scenario.GetVar("hostId6"),1254 step.Scenario.GetVar("hostId7"),1255 step.Scenario.GetVar("hostId8"),1256 },1257 "Region": step.Scenario.GetVar("Region"),1258 })1259 if err != nil {1260 return nil, err1261 }1262 resp, err := client.DescribeUHostInstance(req)1263 if err != nil {1264 return resp, err1265 }1266 return resp, nil1267 },1268 Validators: func(step *driver.Step) []driver.TestValidator {1269 return []driver.TestValidator{1270 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1271 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),1272 validation.Builtins.NewValidator("UHostSet.0.CPU", step.Scenario.GetVar("CreateCPU"), "str_eq"),1273 validation.Builtins.NewValidator("UHostSet.0.Memory", step.Scenario.GetVar("CreateMem"), "str_eq"),1274 validation.Builtins.NewValidator("UHostSet.0.BasicImageId", step.Scenario.GetVar("ImageID"), "str_eq"),1275 validation.Builtins.NewValidator("UHostSet.0.State", "Running", "str_eq"),1276 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.IsBoot", "True", "str_eq"),1277 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.IsBoot", "False", "str_eq"),1278 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.DiskType", step.Scenario.GetVar("BootType"), "str_eq"),1279 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.DiskType", step.Scenario.GetVar("DiskType"), "str_eq"),1280 validation.Builtins.NewValidator("UHostSet.0.DiskSet.0.Size", step.Scenario.GetVar("BootSize"), "str_eq"),1281 validation.Builtins.NewValidator("UHostSet.0.DiskSet.1.Size", step.Scenario.GetVar("DiskSize"), "str_eq"),1282 validation.Builtins.NewValidator("UHostSet.0.State", "Running", "str_eq"),1283 validation.Builtins.NewValidator("UHostSet.1.State", "Running", "str_eq"),1284 validation.Builtins.NewValidator("UHostSet.2.State", "Running", "str_eq"),1285 validation.Builtins.NewValidator("UHostSet.3.State", "Running", "str_eq"),1286 validation.Builtins.NewValidator("UHostSet.4.State", "Running", "str_eq"),1287 validation.Builtins.NewValidator("UHostSet.5.State", "Running", "str_eq"),1288 validation.Builtins.NewValidator("UHostSet.6.State", "Running", "str_eq"),1289 validation.Builtins.NewValidator("UHostSet.7.State", "Running", "str_eq"),1290 }1291 },1292 StartupDelay: time.Duration(0) * time.Second,1293 MaxRetries: 30,1294 RetryInterval: 10 * time.Second,1295 Title: "è·å主æºä¿¡æ¯",1296 FastFail: true,1297}1298var testStep3252StopUHostInstance25 = &driver.Step{1299 Invoker: func(step *driver.Step) (interface{}, error) {1300 c, err := step.LoadFixture("UHost")1301 if err != nil {1302 return nil, err1303 }1304 client := c.(*uhost.UHostClient)1305 req := client.NewStopUHostInstanceRequest()1306 err = utils.SetRequest(req, map[string]interface{}{1307 "Zone": step.Scenario.GetVar("Zone"),1308 "UHostId": step.Scenario.GetVar("hostId1"),1309 "Region": step.Scenario.GetVar("Region"),1310 })1311 if err != nil {1312 return nil, err1313 }1314 resp, err := client.StopUHostInstance(req)1315 if err != nil {1316 return resp, err1317 }1318 return resp, nil1319 },1320 Validators: func(step *driver.Step) []driver.TestValidator {1321 return []driver.TestValidator{1322 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1323 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1324 }1325 },1326 StartupDelay: time.Duration(0) * time.Second,1327 MaxRetries: 3,1328 RetryInterval: 1 * time.Second,1329 Title: "å
³é主æº",1330 FastFail: true,1331}1332var testStep3252StopUHostInstance26 = &driver.Step{1333 Invoker: func(step *driver.Step) (interface{}, error) {1334 c, err := step.LoadFixture("UHost")1335 if err != nil {1336 return nil, err1337 }1338 client := c.(*uhost.UHostClient)1339 req := client.NewStopUHostInstanceRequest()1340 err = utils.SetRequest(req, map[string]interface{}{1341 "Zone": step.Scenario.GetVar("Zone"),1342 "UHostId": step.Scenario.GetVar("hostId2"),1343 "Region": step.Scenario.GetVar("Region"),1344 })1345 if err != nil {1346 return nil, err1347 }1348 resp, err := client.StopUHostInstance(req)1349 if err != nil {1350 return resp, err1351 }1352 return resp, nil1353 },1354 Validators: func(step *driver.Step) []driver.TestValidator {1355 return []driver.TestValidator{1356 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1357 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1358 }1359 },1360 StartupDelay: time.Duration(0) * time.Second,1361 MaxRetries: 3,1362 RetryInterval: 1 * time.Second,1363 Title: "å
³é主æº",1364 FastFail: true,1365}1366var testStep3252StopUHostInstance27 = &driver.Step{1367 Invoker: func(step *driver.Step) (interface{}, error) {1368 c, err := step.LoadFixture("UHost")1369 if err != nil {1370 return nil, err1371 }1372 client := c.(*uhost.UHostClient)1373 req := client.NewStopUHostInstanceRequest()1374 err = utils.SetRequest(req, map[string]interface{}{1375 "Zone": step.Scenario.GetVar("Zone"),1376 "UHostId": step.Scenario.GetVar("hostId3"),1377 "Region": step.Scenario.GetVar("Region"),1378 })1379 if err != nil {1380 return nil, err1381 }1382 resp, err := client.StopUHostInstance(req)1383 if err != nil {1384 return resp, err1385 }1386 return resp, nil1387 },1388 Validators: func(step *driver.Step) []driver.TestValidator {1389 return []driver.TestValidator{1390 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1391 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1392 }1393 },1394 StartupDelay: time.Duration(0) * time.Second,1395 MaxRetries: 3,1396 RetryInterval: 1 * time.Second,1397 Title: "å
³é主æº",1398 FastFail: true,1399}1400var testStep3252StopUHostInstance28 = &driver.Step{1401 Invoker: func(step *driver.Step) (interface{}, error) {1402 c, err := step.LoadFixture("UHost")1403 if err != nil {1404 return nil, err1405 }1406 client := c.(*uhost.UHostClient)1407 req := client.NewStopUHostInstanceRequest()1408 err = utils.SetRequest(req, map[string]interface{}{1409 "Zone": step.Scenario.GetVar("Zone"),1410 "UHostId": step.Scenario.GetVar("hostId4"),1411 "Region": step.Scenario.GetVar("Region"),1412 })1413 if err != nil {1414 return nil, err1415 }1416 resp, err := client.StopUHostInstance(req)1417 if err != nil {1418 return resp, err1419 }1420 return resp, nil1421 },1422 Validators: func(step *driver.Step) []driver.TestValidator {1423 return []driver.TestValidator{1424 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1425 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1426 }1427 },1428 StartupDelay: time.Duration(0) * time.Second,1429 MaxRetries: 3,1430 RetryInterval: 1 * time.Second,1431 Title: "å
³é主æº",1432 FastFail: true,1433}1434var testStep3252StopUHostInstance29 = &driver.Step{1435 Invoker: func(step *driver.Step) (interface{}, error) {1436 c, err := step.LoadFixture("UHost")1437 if err != nil {1438 return nil, err1439 }1440 client := c.(*uhost.UHostClient)1441 req := client.NewStopUHostInstanceRequest()1442 err = utils.SetRequest(req, map[string]interface{}{1443 "Zone": step.Scenario.GetVar("Zone"),1444 "UHostId": step.Scenario.GetVar("hostId5"),1445 "Region": step.Scenario.GetVar("Region"),1446 })1447 if err != nil {1448 return nil, err1449 }1450 resp, err := client.StopUHostInstance(req)1451 if err != nil {1452 return resp, err1453 }1454 return resp, nil1455 },1456 Validators: func(step *driver.Step) []driver.TestValidator {1457 return []driver.TestValidator{1458 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1459 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1460 }1461 },1462 StartupDelay: time.Duration(0) * time.Second,1463 MaxRetries: 3,1464 RetryInterval: 1 * time.Second,1465 Title: "å
³é主æº",1466 FastFail: true,1467}1468var testStep3252StopUHostInstance30 = &driver.Step{1469 Invoker: func(step *driver.Step) (interface{}, error) {1470 c, err := step.LoadFixture("UHost")1471 if err != nil {1472 return nil, err1473 }1474 client := c.(*uhost.UHostClient)1475 req := client.NewStopUHostInstanceRequest()1476 err = utils.SetRequest(req, map[string]interface{}{1477 "Zone": step.Scenario.GetVar("Zone"),1478 "UHostId": step.Scenario.GetVar("hostId6"),1479 "Region": step.Scenario.GetVar("Region"),1480 })1481 if err != nil {1482 return nil, err1483 }1484 resp, err := client.StopUHostInstance(req)1485 if err != nil {1486 return resp, err1487 }1488 return resp, nil1489 },1490 Validators: func(step *driver.Step) []driver.TestValidator {1491 return []driver.TestValidator{1492 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1493 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1494 }1495 },1496 StartupDelay: time.Duration(0) * time.Second,1497 MaxRetries: 3,1498 RetryInterval: 1 * time.Second,1499 Title: "å
³é主æº",1500 FastFail: true,1501}1502var testStep3252StopUHostInstance31 = &driver.Step{1503 Invoker: func(step *driver.Step) (interface{}, error) {1504 c, err := step.LoadFixture("UHost")1505 if err != nil {1506 return nil, err1507 }1508 client := c.(*uhost.UHostClient)1509 req := client.NewStopUHostInstanceRequest()1510 err = utils.SetRequest(req, map[string]interface{}{1511 "Zone": step.Scenario.GetVar("Zone"),1512 "UHostId": step.Scenario.GetVar("hostId7"),1513 "Region": step.Scenario.GetVar("Region"),1514 })1515 if err != nil {1516 return nil, err1517 }1518 resp, err := client.StopUHostInstance(req)1519 if err != nil {1520 return resp, err1521 }1522 return resp, nil1523 },1524 Validators: func(step *driver.Step) []driver.TestValidator {1525 return []driver.TestValidator{1526 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1527 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1528 }1529 },1530 StartupDelay: time.Duration(0) * time.Second,1531 MaxRetries: 3,1532 RetryInterval: 1 * time.Second,1533 Title: "å
³é主æº",1534 FastFail: true,1535}1536var testStep3252StopUHostInstance32 = &driver.Step{1537 Invoker: func(step *driver.Step) (interface{}, error) {1538 c, err := step.LoadFixture("UHost")1539 if err != nil {1540 return nil, err1541 }1542 client := c.(*uhost.UHostClient)1543 req := client.NewStopUHostInstanceRequest()1544 err = utils.SetRequest(req, map[string]interface{}{1545 "Zone": step.Scenario.GetVar("Zone"),1546 "UHostId": step.Scenario.GetVar("hostId8"),1547 "Region": step.Scenario.GetVar("Region"),1548 })1549 if err != nil {1550 return nil, err1551 }1552 resp, err := client.StopUHostInstance(req)1553 if err != nil {1554 return resp, err1555 }1556 return resp, nil1557 },1558 Validators: func(step *driver.Step) []driver.TestValidator {1559 return []driver.TestValidator{1560 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1561 validation.Builtins.NewValidator("Action", "StopUHostInstanceResponse", "str_eq"),1562 }1563 },1564 StartupDelay: time.Duration(0) * time.Second,1565 MaxRetries: 3,1566 RetryInterval: 1 * time.Second,1567 Title: "å
³é主æº",1568 FastFail: true,1569}1570var testStep3252DescribeUHostInstance33 = &driver.Step{1571 Invoker: func(step *driver.Step) (interface{}, error) {1572 c, err := step.LoadFixture("UHost")1573 if err != nil {1574 return nil, err1575 }1576 client := c.(*uhost.UHostClient)1577 req := client.NewDescribeUHostInstanceRequest()1578 err = utils.SetRequest(req, map[string]interface{}{1579 "Zone": step.Scenario.GetVar("Zone"),1580 "UHostIds": []interface{}{1581 step.Scenario.GetVar("hostId1"),1582 step.Scenario.GetVar("hostId2"),1583 step.Scenario.GetVar("hostId3"),1584 step.Scenario.GetVar("hostId4"),1585 step.Scenario.GetVar("hostId5"),1586 step.Scenario.GetVar("hostId6"),1587 step.Scenario.GetVar("hostId7"),1588 step.Scenario.GetVar("hostId8"),1589 },1590 "Region": step.Scenario.GetVar("Region"),1591 })1592 if err != nil {1593 return nil, err1594 }1595 resp, err := client.DescribeUHostInstance(req)1596 if err != nil {1597 return resp, err1598 }1599 return resp, nil1600 },1601 Validators: func(step *driver.Step) []driver.TestValidator {1602 return []driver.TestValidator{1603 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1604 validation.Builtins.NewValidator("Action", "DescribeUHostInstanceResponse", "str_eq"),1605 validation.Builtins.NewValidator("UHostSet.0.State", "Stopped", "str_eq"),1606 validation.Builtins.NewValidator("UHostSet.1.State", "Stopped", "str_eq"),1607 validation.Builtins.NewValidator("UHostSet.2.State", "Stopped", "str_eq"),1608 validation.Builtins.NewValidator("UHostSet.3.State", "Stopped", "str_eq"),1609 validation.Builtins.NewValidator("UHostSet.4.State", "Stopped", "str_eq"),1610 validation.Builtins.NewValidator("UHostSet.5.State", "Stopped", "str_eq"),1611 validation.Builtins.NewValidator("UHostSet.6.State", "Stopped", "str_eq"),1612 validation.Builtins.NewValidator("UHostSet.7.State", "Stopped", "str_eq"),1613 }1614 },1615 StartupDelay: time.Duration(10) * time.Second,1616 MaxRetries: 30,1617 RetryInterval: 10 * time.Second,1618 Title: "è·å主æºä¿¡æ¯",1619 FastFail: true,1620}1621var testStep3252TerminateUHostInstance34 = &driver.Step{1622 Invoker: func(step *driver.Step) (interface{}, error) {1623 c, err := step.LoadFixture("UHost")1624 if err != nil {1625 return nil, err1626 }1627 client := c.(*uhost.UHostClient)1628 req := client.NewTerminateUHostInstanceRequest()1629 err = utils.SetRequest(req, map[string]interface{}{1630 "Zone": step.Scenario.GetVar("Zone"),1631 "UHostId": step.Scenario.GetVar("hostId1"),1632 "ReleaseUDisk": "true",1633 "Region": step.Scenario.GetVar("Region"),1634 })1635 if err != nil {1636 return nil, err1637 }1638 resp, err := client.TerminateUHostInstance(req)1639 if err != nil {1640 return resp, err1641 }1642 return resp, nil1643 },1644 Validators: func(step *driver.Step) []driver.TestValidator {1645 return []driver.TestValidator{1646 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1647 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),1648 }1649 },1650 StartupDelay: time.Duration(10) * time.Second,1651 MaxRetries: 3,1652 RetryInterval: 1 * time.Second,1653 Title: "å é¤äºä¸»æº",1654 FastFail: true,1655}1656var testStep3252TerminateUHostInstance35 = &driver.Step{1657 Invoker: func(step *driver.Step) (interface{}, error) {1658 c, err := step.LoadFixture("UHost")1659 if err != nil {1660 return nil, err1661 }1662 client := c.(*uhost.UHostClient)1663 req := client.NewTerminateUHostInstanceRequest()1664 err = utils.SetRequest(req, map[string]interface{}{1665 "Zone": step.Scenario.GetVar("Zone"),1666 "UHostId": step.Scenario.GetVar("hostId2"),1667 "ReleaseUDisk": "true",1668 "Region": step.Scenario.GetVar("Region"),1669 })1670 if err != nil {1671 return nil, err1672 }1673 resp, err := client.TerminateUHostInstance(req)1674 if err != nil {1675 return resp, err1676 }1677 return resp, nil1678 },1679 Validators: func(step *driver.Step) []driver.TestValidator {1680 return []driver.TestValidator{1681 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1682 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),1683 }1684 },1685 StartupDelay: time.Duration(0) * time.Second,1686 MaxRetries: 3,1687 RetryInterval: 1 * time.Second,1688 Title: "å é¤äºä¸»æº",1689 FastFail: false,1690}1691var testStep3252TerminateUHostInstance36 = &driver.Step{1692 Invoker: func(step *driver.Step) (interface{}, error) {1693 c, err := step.LoadFixture("UHost")1694 if err != nil {1695 return nil, err1696 }1697 client := c.(*uhost.UHostClient)1698 req := client.NewTerminateUHostInstanceRequest()1699 err = utils.SetRequest(req, map[string]interface{}{1700 "Zone": step.Scenario.GetVar("Zone"),1701 "UHostId": step.Scenario.GetVar("hostId3"),1702 "ReleaseUDisk": "true",1703 "Region": step.Scenario.GetVar("Region"),1704 })1705 if err != nil {1706 return nil, err1707 }1708 resp, err := client.TerminateUHostInstance(req)1709 if err != nil {1710 return resp, err1711 }1712 return resp, nil1713 },1714 Validators: func(step *driver.Step) []driver.TestValidator {1715 return []driver.TestValidator{1716 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1717 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),1718 }1719 },1720 StartupDelay: time.Duration(0) * time.Second,1721 MaxRetries: 3,1722 RetryInterval: 1 * time.Second,1723 Title: "å é¤äºä¸»æº",1724 FastFail: false,1725}1726var testStep3252TerminateUHostInstance37 = &driver.Step{1727 Invoker: func(step *driver.Step) (interface{}, error) {1728 c, err := step.LoadFixture("UHost")1729 if err != nil {1730 return nil, err1731 }1732 client := c.(*uhost.UHostClient)1733 req := client.NewTerminateUHostInstanceRequest()1734 err = utils.SetRequest(req, map[string]interface{}{1735 "Zone": step.Scenario.GetVar("Zone"),1736 "UHostId": step.Scenario.GetVar("hostId4"),1737 "ReleaseUDisk": "true",1738 "Region": step.Scenario.GetVar("Region"),1739 })1740 if err != nil {1741 return nil, err1742 }1743 resp, err := client.TerminateUHostInstance(req)1744 if err != nil {1745 return resp, err1746 }1747 return resp, nil1748 },1749 Validators: func(step *driver.Step) []driver.TestValidator {1750 return []driver.TestValidator{1751 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1752 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),1753 }1754 },1755 StartupDelay: time.Duration(0) * time.Second,1756 MaxRetries: 3,1757 RetryInterval: 1 * time.Second,1758 Title: "å é¤äºä¸»æº",1759 FastFail: false,1760}1761var testStep3252TerminateUHostInstance38 = &driver.Step{1762 Invoker: func(step *driver.Step) (interface{}, error) {1763 c, err := step.LoadFixture("UHost")1764 if err != nil {1765 return nil, err1766 }1767 client := c.(*uhost.UHostClient)1768 req := client.NewTerminateUHostInstanceRequest()1769 err = utils.SetRequest(req, map[string]interface{}{1770 "Zone": step.Scenario.GetVar("Zone"),1771 "UHostId": step.Scenario.GetVar("hostId5"),1772 "ReleaseUDisk": "true",1773 "Region": step.Scenario.GetVar("Region"),1774 })1775 if err != nil {1776 return nil, err1777 }1778 resp, err := client.TerminateUHostInstance(req)1779 if err != nil {1780 return resp, err1781 }1782 return resp, nil1783 },1784 Validators: func(step *driver.Step) []driver.TestValidator {1785 return []driver.TestValidator{1786 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1787 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),1788 }1789 },1790 StartupDelay: time.Duration(0) * time.Second,1791 MaxRetries: 3,1792 RetryInterval: 1 * time.Second,1793 Title: "å é¤äºä¸»æº",1794 FastFail: false,1795}1796var testStep3252TerminateUHostInstance39 = &driver.Step{1797 Invoker: func(step *driver.Step) (interface{}, error) {1798 c, err := step.LoadFixture("UHost")1799 if err != nil {1800 return nil, err1801 }1802 client := c.(*uhost.UHostClient)1803 req := client.NewTerminateUHostInstanceRequest()1804 err = utils.SetRequest(req, map[string]interface{}{1805 "Zone": step.Scenario.GetVar("Zone"),1806 "UHostId": step.Scenario.GetVar("hostId6"),1807 "ReleaseUDisk": "true",1808 "Region": step.Scenario.GetVar("Region"),1809 })1810 if err != nil {1811 return nil, err1812 }1813 resp, err := client.TerminateUHostInstance(req)1814 if err != nil {1815 return resp, err1816 }1817 return resp, nil1818 },1819 Validators: func(step *driver.Step) []driver.TestValidator {1820 return []driver.TestValidator{1821 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1822 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),1823 }1824 },1825 StartupDelay: time.Duration(0) * time.Second,1826 MaxRetries: 3,1827 RetryInterval: 1 * time.Second,1828 Title: "å é¤äºä¸»æº",1829 FastFail: false,1830}1831var testStep3252TerminateUHostInstance40 = &driver.Step{1832 Invoker: func(step *driver.Step) (interface{}, error) {1833 c, err := step.LoadFixture("UHost")1834 if err != nil {1835 return nil, err1836 }1837 client := c.(*uhost.UHostClient)1838 req := client.NewTerminateUHostInstanceRequest()1839 err = utils.SetRequest(req, map[string]interface{}{1840 "Zone": step.Scenario.GetVar("Zone"),1841 "UHostId": step.Scenario.GetVar("hostId7"),1842 "ReleaseUDisk": "true",1843 "Region": step.Scenario.GetVar("Region"),1844 })1845 if err != nil {1846 return nil, err1847 }1848 resp, err := client.TerminateUHostInstance(req)1849 if err != nil {1850 return resp, err1851 }1852 return resp, nil1853 },1854 Validators: func(step *driver.Step) []driver.TestValidator {1855 return []driver.TestValidator{1856 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1857 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),1858 }1859 },1860 StartupDelay: time.Duration(0) * time.Second,1861 MaxRetries: 3,1862 RetryInterval: 1 * time.Second,1863 Title: "å é¤äºä¸»æº",1864 FastFail: false,1865}1866var testStep3252TerminateUHostInstance41 = &driver.Step{1867 Invoker: func(step *driver.Step) (interface{}, error) {1868 c, err := step.LoadFixture("UHost")1869 if err != nil {1870 return nil, err1871 }1872 client := c.(*uhost.UHostClient)1873 req := client.NewTerminateUHostInstanceRequest()1874 err = utils.SetRequest(req, map[string]interface{}{1875 "Zone": step.Scenario.GetVar("Zone"),1876 "UHostId": step.Scenario.GetVar("hostId8"),1877 "ReleaseUDisk": "true",1878 "Region": step.Scenario.GetVar("Region"),1879 })1880 if err != nil {1881 return nil, err1882 }1883 resp, err := client.TerminateUHostInstance(req)1884 if err != nil {1885 return resp, err1886 }1887 return resp, nil1888 },1889 Validators: func(step *driver.Step) []driver.TestValidator {1890 return []driver.TestValidator{1891 validation.Builtins.NewValidator("RetCode", 0, "str_eq"),1892 validation.Builtins.NewValidator("Action", "TerminateUHostInstanceResponse", "str_eq"),...
scenario_runner.go
Source:scenario_runner.go
...22const (23 OpSearch OpType = "search"24 OpIndex = "index"25)26type runningScenario struct {27 *models.Scenario28 exerciseCancelFunc context.CancelFunc29 validationCancelFunc context.CancelFunc30 usageConn *usage.Connection31 stateConn *es.Client32 goldenConn *es.Client33}34type ScenarioRunner struct {35 cfg *config.Config36 scenarios map[string]runningScenario37 usageConn *usage.Connection38 stateConn *es.Client39 essConn *api.API40}41func NewScenarioRunner(cfg *config.Config) (*ScenarioRunner, error) {42 sr := new(ScenarioRunner)43 sr.cfg = cfg44 sr.scenarios = map[string]runningScenario{}45 usageConn, err := sr.initUsageClusterConnection()46 if err != nil {47 return nil, err48 }49 stateConn, err := es.NewClient(es.Config{50 Addresses: []string{cfg.StateCluster.Url},51 Username: cfg.StateCluster.Username,52 Password: cfg.StateCluster.Password,53 })54 if err != nil {55 return nil, err56 }57 essConn, err := api.NewAPI(api.Config{58 Host: cfg.API.Url,59 Client: new(http.Client),60 AuthWriter: auth.APIKey(cfg.API.Key),61 })62 if err != nil {63 return nil, fmt.Errorf("unable to connect to Elastic Cloud API at [%s]: %w", cfg.API.Url, err)64 }65 sr.usageConn = usageConn66 sr.stateConn = stateConn67 sr.essConn = essConn68 return sr, nil69}70func (sr *ScenarioRunner) Start(s *models.Scenario) error {71 logging.Logger.Info("starting scenario runner...")72 deploymentName := s.GetDeploymentName()73 exists, err := deployment.CheckIfDeploymentExists(sr.essConn, deploymentName)74 if err != nil {75 return fmt.Errorf("unable to check if deployment [%s] exists: %w", deploymentName, err)76 }77 if !exists {78 // Create deployment79 deploymentConfigDAO := dao.NewDeploymentConfiguration(sr.stateConn)80 deploymentConfig, err := deploymentConfigDAO.Get(s.DeploymentConfiguration.ID)81 if err != nil {82 return err83 }84 if deploymentConfig == nil {85 return fmt.Errorf("deployment configuration [%s] specified in scenario [%s] does not exist", s.DeploymentConfiguration.ID, s.ID)86 }87 req, err := deploymentConfig.ToDeploymentCreateRequest(s.DeploymentConfiguration.Variables)88 if err != nil {89 return fmt.Errorf("unable to create deployment create request from configuration [%s]: %w", deploymentConfig.ID, err)90 }91 logging.Logger.Info("creating deployment from config...",92 zap.String("deployment", deploymentName),93 zap.String("config", deploymentConfig.ID),94 )95 out, err := deployment.CreateDeployment(sr.essConn, deploymentName, req)96 if err != nil {97 return err98 }99 s.ClusterIDs = out.ClusterIDs100 s.DeploymentCredentials = out.DeploymentCredentials101 }102 goldenConn, err := es.NewClient(es.Config{103 CloudID: s.DeploymentCredentials.CloudID,104 Username: s.DeploymentCredentials.Username,105 Password: s.DeploymentCredentials.Password,106 })107 if err != nil {108 return fmt.Errorf("unable to create connection to golden deployment: %w", err)109 }110 exerciseCtx, exerciseCancelFunc := context.WithCancel(context.Background())111 validationCtx, validationCancelFunc := context.WithCancel(context.Background())112 rs := runningScenario{113 Scenario: s,114 exerciseCancelFunc: exerciseCancelFunc,115 validationCancelFunc: validationCancelFunc,116 usageConn: sr.usageConn,117 stateConn: sr.stateConn,118 goldenConn: goldenConn,119 }120 sr.scenarios[s.ID] = rs121 if s.StartedOn == nil {122 scenarioDAO := dao.NewScenario(sr.stateConn)123 if err := scenarioDAO.Save(s); err != nil {124 return err125 }126 now := time.Now()127 s.StartedOn = &now128 }129 rs.start(exerciseCtx, validationCtx)130 return nil131}132func (sr *ScenarioRunner) Stop(scenarioID string) {133 rs := sr.scenarios[scenarioID]134 rs.validationCancelFunc()135 rs.exerciseCancelFunc()136 delete(sr.scenarios, scenarioID)137}138func (sr *ScenarioRunner) StopAll() {139 for _, scenario := range sr.scenarios {140 sr.Stop(scenario.ID)141 }142}143func (rs *runningScenario) start(exerciseCtx, validationCtx context.Context) {144 rs.startExerciseLoop(exerciseCtx)145 rs.startValidationLoop(validationCtx)146}147func (rs *runningScenario) startExerciseLoop(ctx context.Context) {148 loggingParam := zap.String("scenario", rs.ID)149 logging.Logger.Info("starting exercise loop", loggingParam)150 // TODO: consider start time + offset, if it has already passed, start now!151 startOffset := time.Duration(rs.Workload.StartOffsetSeconds) * time.Second152 now := time.Now()153 startTime := now.Add(startOffset)154 ticker := time.NewTicker(1 * time.Second)155 go func() {156 for {157 select {158 case <-ctx.Done():159 logging.Logger.Info("exercise loop done for scenario", loggingParam)160 ticker.Stop()161 return162 case t := <-ticker.C:163 if t.Before(startTime) {164 logging.Logger.Debug("not yet time to start exercising scenario", loggingParam)165 continue166 }167 numRequestsToFire := rand.Intn(rs.Workload.MaxRequestsPerSecond + 1)168 logging.Logger.Debug("firing requests now...", loggingParam, zap.Int("requests", numRequestsToFire))169 var err error170 for i := 0; i < numRequestsToFire; i++ {171 op := randOp(rs.Workload.IndexToSearchRatio)172 switch op {173 case OpSearch:174 logging.Logger.Debug("firing search request", loggingParam)175 err = doSearch(rs.goldenConn, "foo*")176 case OpIndex:177 logging.Logger.Debug("firing index request", loggingParam)178 err = doIndex(rs.goldenConn, "foo", randIndexBody())179 }180 }181 if err != nil {182 logging.Logger.Error(err.Error(), loggingParam)183 }184 }185 }186 }()187}188func (rs *runningScenario) startValidationLoop(ctx context.Context) {189 validationFrequency := rs.GetValidationFrequency()190 startAfter := waitFor(*rs.StartedOn, validationFrequency)191 loggingParam := zap.String("scenario", rs.ID)192 logging.Logger.Info("starting validation loop", loggingParam, zap.Duration("delay", startAfter))193 var timer *time.Timer194 timer = time.AfterFunc(startAfter, func() {195 rs.validate()196 ticker := time.NewTicker(validationFrequency)197 for {198 select {199 case <-ctx.Done():200 logging.Logger.Info("stopping validation loop", loggingParam)201 ticker.Stop()202 timer.Stop()203 return204 case <-ticker.C:205 rs.validate()206 }207 }208 })209}210func (rs *runningScenario) validate() {211 loggingParam := zap.String("scenario", rs.ID)212 logging.Logger.Info("running validations...", loggingParam)213 result := rs.Scenario.Validate(rs.usageConn)214 validationResultDAO := dao.NewValidationResult(rs.stateConn)215 if err := validationResultDAO.Save(result); err != nil {216 logging.Logger.Error("error saving validation result", loggingParam, zap.Error(err))217 }218}219func waitFor(start time.Time, interval time.Duration) time.Duration {220 next := start221 for next.Before(time.Now()) {222 next = next.Add(interval)223 }224 return next.Sub(time.Now())225}226func (sr *ScenarioRunner) initUsageClusterConnection() (*usage.Connection, error) {227 return usage.NewConnection(228 sr.cfg.UsageCluster.Url,229 sr.cfg.UsageCluster.Username,230 sr.cfg.UsageCluster.Password,231 )232}233func randOp(indexToSearchRatio int) OpType {234 ops := make([]OpType, 1+indexToSearchRatio)235 ops[0] = OpSearch236 for i := 1; i < len(ops); i++ {237 ops[i] = OpIndex238 }239 randIdx := rand.Intn(len(ops))240 return ops[randIdx]...
default_validation_test.go
Source:default_validation_test.go
...47 }48 capabilities.On("V2_0Validation").Return(false)49 capabilities.On("V1_3Validation").Return(false)50 capabilities.On("V1_2Validation").Return(true)51 // Scenario I: An error that isn't *commonerrors.ExecutionFailureError or *commonerrors.VSCCEndorsementPolicyError52 // should cause a panic53 validator.On("Validate", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.New("bla bla")).Once()54 require.Panics(t, func() {55 validation.Validate(block, "", 0, 0, plugin.SerializedPolicy("policy"))56 })57 // Scenario II: Non execution errors are returned as is58 validator.On("Validate", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&commonerrors.VSCCEndorsementPolicyError{Err: errors.New("foo")}).Once()59 err := validation.Validate(block, "", 0, 0, plugin.SerializedPolicy("policy"))60 require.Equal(t, (&commonerrors.VSCCEndorsementPolicyError{Err: errors.New("foo")}).Error(), err.Error())61 // Scenario III: Execution errors are converted to the plugin error type62 validator.On("Validate", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&commonerrors.VSCCExecutionFailureError{Err: errors.New("bar")}).Once()63 err = validation.Validate(block, "", 0, 0, plugin.SerializedPolicy("policy"))64 require.Equal(t, &ExecutionFailureError{Reason: "bar"}, err)65 // Scenario IV: No errors are forwarded66 validator.On("Validate", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()67 require.NoError(t, validation.Validate(block, "", 0, 0, plugin.SerializedPolicy("policy")))68}69func TestValidateBadInput(t *testing.T) {70 validator := &vmocks.TransactionValidator{}71 validation := &DefaultValidation{72 TxValidatorV1_2: validator,73 }74 // Scenario I: Nil block75 validator.On("Validate", mock.Anything, mock.Anything).Return(nil).Once()76 err := validation.Validate(nil, "", 0, 0, plugin.SerializedPolicy("policy"))77 require.Equal(t, "empty block", err.Error())78 block := &common.Block{79 Header: &common.BlockHeader{},80 Data: &common.BlockData{81 Data: [][]byte{{}},82 },83 }84 // Scenario II: Block with 1 transaction, but position is at 1 also85 validator.On("Validate", mock.Anything, mock.Anything).Return(nil).Once()86 err = validation.Validate(block, "", 1, 0, plugin.SerializedPolicy("policy"))87 require.Equal(t, "block has only 1 transactions, but requested tx at position 1", err.Error())88 // Scenario III: Block without header89 validator.On("Validate", mock.Anything, mock.Anything).Return(nil).Once()90 err = validation.Validate(&common.Block{91 Data: &common.BlockData{92 Data: [][]byte{{}},93 },94 }, "", 0, 0, plugin.SerializedPolicy("policy"))95 require.Equal(t, "no block header", err.Error())96 // Scenario IV: No serialized policy passed97 require.Panics(t, func() {98 validator.On("Validate", mock.Anything, mock.Anything).Return(nil).Once()99 err = validation.Validate(&common.Block{100 Header: &common.BlockHeader{},101 Data: &common.BlockData{102 Data: [][]byte{{}},103 },104 }, "", 0, 0)105 })106 // Scenario V: Policy passed isn't a serialized policy107 require.Panics(t, func() {108 validator.On("Validate", mock.Anything, mock.Anything).Return(nil).Once()109 err = validation.Validate(&common.Block{110 Header: &common.BlockHeader{},111 Data: &common.BlockData{112 Data: [][]byte{{}},113 },114 }, "", 0, 0, []byte("policy"))115 })116}...
Scenario
Using AI Code Generation
1import (2type User struct {3 Name string `valid:"Required; MaxSize(50)"`4 Phone string `valid:"Required; Phone"`5}6func main() {7 user := User{Name: "slene", Phone: "123456"}8 valid := validation.Validation{}9 b, err := valid.Valid(&user)10 if err != nil {11 fmt.Println(err)12 }13 if !b {14 fmt.Println(valid.Errors)15 }16}17import (18type User struct {19 Name string `valid:"Required; MaxSize(50)"`20 Phone string `valid:"Required; Phone"`21}22func main() {23 user := User{Name: "slene", Phone: "123456"}24 valid := validation.Validation{}25 b, err := valid.Valid(&user)26 if err != nil {27 fmt.Println(err)28 }29 if !b {30 fmt.Println(valid.Errors)31 }32}33import (34type User struct {35 Name string `valid:"Required; MaxSize(50)"`36 Phone string `valid:"Required; Phone"`37}38func main() {39 user := User{Name: "slene", Phone: "123456"}40 valid := validation.Validation{}41 b, err := valid.Valid(&user)42 if err != nil {43 fmt.Println(err)44 }45 if !b {46 fmt.Println(valid.Errors)47 }48}49import (50type User struct {51 Name string `valid:"Required; MaxSize(50)"`52 Phone string `valid:"Required; Phone"`53}54func main() {55 user := User{Name: "
Scenario
Using AI Code Generation
1import (2func main() {3 result, err := gojsonschema.Validate(schemaLoader, documentLoader)4 if err != nil {5 panic(err)6 }7 if result.Valid() {8 fmt.Printf("The document is valid9 } else {10 fmt.Printf("The document is not valid. see errors :11 for _, desc := range result.Errors() {12 fmt.Printf("- %s13 }14 }15}16import (17func main() {18 result, err := gojsonschema.Validate(schemaLoader, documentLoader)19 if err != nil {20 panic(err)21 }22 if result.Valid() {23 fmt.Printf("The document is valid24 } else {25 fmt.Printf("The document is not valid. see errors :26 for _, desc := range result.Errors() {27 fmt.Printf("- %s28 }29 }30}31import (32func main() {
Scenario
Using AI Code Generation
1import (2func main() {3 fmt.Println("Enter a number")4 fmt.Scanln(&input)5 inputInt, err := strconv.Atoi(input)6 if err != nil {7 fmt.Println("Please enter a valid number")8 } else {9 fmt.Println("You entered", inputInt)10 }11 fmt.Println("Enter a string")12 fmt.Scanln(&input)13 if strings.Contains(input, " ") {14 fmt.Println("Please enter a valid string")15 } else {16 fmt.Println("You entered", input)17 }18}19import (
Scenario
Using AI Code Generation
1 v := validation.Validation{}2 v.Field("test", "test").Required()3 if !v.Validate() {4 fmt.Println("Validation failed")5 fmt.Println(v.Errors)6 } else {7 fmt.Println("Validation passed")8 }9 fmt.Println("Scenario 2: Validating multiple fields")10 fmt.Println("
Scenario
Using AI Code Generation
1 v = validation.Validation{}2 v.Field("test", "test").Required()3 v.Field("test2", "test2").Required()4 if !v.Validate() {5 fmt.Println("Validation failed")6 fmt.Println(v.Errors)7 } else {8 fmt.Println("Validation passed")9 }10 fmt.Println("Scenario 3: Validating a field with a custom error message")11 fmt.Println("
Scenario
Using AI Code Generation
1 v = validation.Validation{}2 v.Field("test", "test").Required().Message("This field is required")3 if !v.Validate() {4 fmt.Println("Validation failed")5 fmt.Println(v.Errors)6 } else {7 fmt.Println("Validation passed")8 }9 fmt.Println("Scenario 4: Validating a field with a custom error message")10 fmt.Println("
Scenario
Using AI Code Generation
1 v = validation.Validation{}2 v.Field("test", "test").Required().Message("This field is required")3 if !v.Validate() {4 fmt.Println("Validation failed")5 fmt.Println(v.Errors)6 } else {7 fmt.Println("Validation passed")8 }
Scenario
Using AI Code Generation
1var validation = new Validation();2var scenario = validation.Scenario("scenario1");3var result = scenario.Validate(new {Name = "test", Age = 20});4var validation = new Validation();5var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});6var validation = new Validation();7var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});8var scenario2 = validation.Scenario("scenario2");9var result2 = scenario2.Validate(new {Name = "test", Age = 20});10var validation = new Validation();11var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});12var result2 = validation.Scenario("scenario2").Validate(new {Name = "test", Age = 20});13var validation = new Validation();14var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});15var result2 = validation.Scenario("scenario2").Validate(new {Name = "test", Age = 20});16var result3 = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});17var validation = new Validation();18var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});19var result2 = validation.Scenario("scenario2").Validate(new {Name = "test", Age = 20});20var result3 = validation.Scenario("scenario3").Validate(new {Name = "test", Age = 20});21var result4 = validation.Scenario("scenario4").Validate(new {Name = "test", Age = 20});22var validation = new Validation();23var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});24var result2 = validation.Scenario("scenario2").Validate(new {Name
Scenario
Using AI Code Generation
1var validation = new Validation();2var scenario = validation.Scenario("scenario1");3var result = scenario.Validate(new {Name = "test", Age = 20});4var validation = new Validation();5var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});6var validation = new Validation();7var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});8var scenario2 = validation.Scenario("scenario2");9var result2 = scenario2.Validate(new {Name = "test", Age = 20});10var validation = new Validation();11var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});12var result2 = validation.Scenario("scenario2").Validate(new {Name = "test", Age = 20});13var validation = new Validation();14var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});15var result2 = validation.Scenario("scenario2").Validate(new {Name = "test", Age = 20});16var result3 = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});17var validation = new Validation();18var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});19var result2 = validation.Scenario("scenario2").Validate(new {Name = "test", Age = 20});20var result3 = validation.Scenario("scenario3").Validate(new {Name = "test", Age = 20});21var result4 = validation.Scenario("scenario4").Validate(new {Name = "test", Age = 20});22var validation = new Validation();23var result = validation.Scenario("scenario1").Validate(new {Name = "test", Age = 20});24var result2 = validation.Scenario("scenario2").Validate(new {Name{25 fmt.Println("Please enter a valid number")26 } else {27 fmt.Println("You entered", inputInt)28 }29 fmt.Println("Enter a string")30 fmt.Scanln(&input)31 if strings.Contains(input, " ") {32 fmt.Println("Please enter a valid string")33 } else {34 fmt.Println("You entered", input)35 }36}37import (
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!