github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/container/containerv2/worker_pool_test.go (about) 1 package containerv2 2 3 import ( 4 "log" 5 "net/http" 6 7 bluemix "github.com/IBM-Cloud/bluemix-go" 8 "github.com/IBM-Cloud/bluemix-go/client" 9 bluemixHttp "github.com/IBM-Cloud/bluemix-go/http" 10 "github.com/IBM-Cloud/bluemix-go/session" 11 "github.com/onsi/gomega/ghttp" 12 13 . "github.com/onsi/ginkgo" 14 . "github.com/onsi/gomega" 15 ) 16 17 var _ = Describe("workerpools", func() { 18 var server *ghttp.Server 19 AfterEach(func() { 20 server.Close() 21 }) 22 23 //Create 24 Describe("Create", func() { 25 Context("When creating workerpool is successful", func() { 26 BeforeEach(func() { 27 server = ghttp.NewServer() 28 server.AppendHandlers( 29 ghttp.CombineHandlers( 30 ghttp.VerifyRequest(http.MethodPost, "/v2/vpc/createWorkerPool"), 31 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","flavor":"b2.4x16", "hostPool":"hostpoolid1", "name":"mywork211","vpcID":"6015365a-9d93-4bb4-8248-79ae0db2dc26","workerCount":1,"zones":[], "entitlement":""}`), 32 ghttp.RespondWith(http.StatusCreated, `{ 33 "workerPoolID":"string" 34 }`), 35 ), 36 ) 37 }) 38 39 It("should create Workerpool in a cluster", func() { 40 target := ClusterTargetHeader{} 41 params := WorkerPoolRequest{ 42 Cluster: "bm64u3ed02o93vv36hb0", 43 HostPoolID: "hostpoolid1", 44 CommonWorkerPoolConfig: CommonWorkerPoolConfig{ 45 Flavor: "b2.4x16", 46 Name: "mywork211", 47 VpcID: "6015365a-9d93-4bb4-8248-79ae0db2dc26", 48 WorkerCount: 1, 49 Zones: []Zone{}, 50 Entitlement: "", 51 }, 52 } 53 _, err := newWorkerPool(server.URL()).CreateWorkerPool(params, target) 54 Expect(err).NotTo(HaveOccurred()) 55 }) 56 }) 57 Context("When creating workerpool is successful with OS", func() { 58 BeforeEach(func() { 59 server = ghttp.NewServer() 60 server.AppendHandlers( 61 ghttp.CombineHandlers( 62 ghttp.VerifyRequest(http.MethodPost, "/v2/vpc/createWorkerPool"), 63 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","flavor":"b2.4x16", "hostPool":"hostpoolid1", "name":"mywork211","vpcID":"6015365a-9d93-4bb4-8248-79ae0db2dc26","workerCount":1,"zones":[], "entitlement":"", "operatingSystem":"REDHAT_7_64"}`), 64 ghttp.RespondWith(http.StatusCreated, `{ 65 "workerPoolID":"string" 66 }`), 67 ), 68 ) 69 }) 70 71 It("should create Workerpool in a cluster", func() { 72 target := ClusterTargetHeader{} 73 params := WorkerPoolRequest{ 74 Cluster: "bm64u3ed02o93vv36hb0", 75 HostPoolID: "hostpoolid1", 76 CommonWorkerPoolConfig: CommonWorkerPoolConfig{ 77 Flavor: "b2.4x16", 78 Name: "mywork211", 79 VpcID: "6015365a-9d93-4bb4-8248-79ae0db2dc26", 80 WorkerCount: 1, 81 Zones: []Zone{}, 82 Entitlement: "", 83 OperatingSystem: "REDHAT_7_64", 84 }, 85 } 86 _, err := newWorkerPool(server.URL()).CreateWorkerPool(params, target) 87 Expect(err).NotTo(HaveOccurred()) 88 }) 89 }) 90 Context("When creating workerpool is successful with kms enabled and provided by different account", func() { 91 BeforeEach(func() { 92 server = ghttp.NewServer() 93 server.AppendHandlers( 94 ghttp.CombineHandlers( 95 ghttp.VerifyRequest(http.MethodPost, "/v2/vpc/createWorkerPool"), 96 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","flavor":"b2.4x16", "hostPool":"hostpoolid1", "name":"mywork211","vpcID":"6015365a-9d93-4bb4-8248-79ae0db2dc26","workerCount":1,"zones":[], "entitlement":"", "workerVolumeEncryption": {"kmsInstanceID": "kmsid", "workerVolumeCRKID": "rootkeyid", "kmsAccountID":"OtherAccountID"}}`), 97 ghttp.RespondWith(http.StatusCreated, `{ 98 "workerPoolID":"string" 99 }`), 100 ), 101 ) 102 }) 103 104 It("should create Workerpool in a cluster", func() { 105 target := ClusterTargetHeader{} 106 params := WorkerPoolRequest{ 107 Cluster: "bm64u3ed02o93vv36hb0", 108 HostPoolID: "hostpoolid1", 109 CommonWorkerPoolConfig: CommonWorkerPoolConfig{ 110 Flavor: "b2.4x16", 111 Name: "mywork211", 112 VpcID: "6015365a-9d93-4bb4-8248-79ae0db2dc26", 113 WorkerCount: 1, 114 Zones: []Zone{}, 115 Entitlement: "", 116 WorkerVolumeEncryption: &WorkerVolumeEncryption{ 117 KmsInstanceID: "kmsid", 118 WorkerVolumeCRKID: "rootkeyid", 119 KMSAccountID: "OtherAccountID", 120 }, 121 }, 122 } 123 _, err := newWorkerPool(server.URL()).CreateWorkerPool(params, target) 124 Expect(err).NotTo(HaveOccurred()) 125 }) 126 }) 127 Context("When creating workerpool is successful with kms enabled and provided by different account", func() { 128 BeforeEach(func() { 129 server = ghttp.NewServer() 130 server.AppendHandlers( 131 ghttp.CombineHandlers( 132 ghttp.VerifyRequest(http.MethodPost, "/v2/vpc/createWorkerPool"), 133 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","flavor":"b2.4x16", "hostPool":"hostpoolid1", "name":"mywork211","vpcID":"6015365a-9d93-4bb4-8248-79ae0db2dc26","workerCount":1,"zones":[], "entitlement":"", "workerVolumeEncryption": {"kmsInstanceID": "kmsid", "workerVolumeCRKID": "rootkeyid", "kmsAccountID":"OtherAccountID"}}`), 134 ghttp.RespondWith(http.StatusCreated, `{ 135 "workerPoolID":"string" 136 }`), 137 ), 138 ) 139 }) 140 141 It("should create Workerpool in a cluster", func() { 142 target := ClusterTargetHeader{} 143 params := WorkerPoolRequest{ 144 Cluster: "bm64u3ed02o93vv36hb0", 145 HostPoolID: "hostpoolid1", 146 CommonWorkerPoolConfig: CommonWorkerPoolConfig{ 147 Flavor: "b2.4x16", 148 Name: "mywork211", 149 VpcID: "6015365a-9d93-4bb4-8248-79ae0db2dc26", 150 WorkerCount: 1, 151 Zones: []Zone{}, 152 Entitlement: "", 153 WorkerVolumeEncryption: &WorkerVolumeEncryption{ 154 KmsInstanceID: "kmsid", 155 WorkerVolumeCRKID: "rootkeyid", 156 KMSAccountID: "OtherAccountID", 157 }, 158 }, 159 } 160 _, err := newWorkerPool(server.URL()).CreateWorkerPool(params, target) 161 Expect(err).NotTo(HaveOccurred()) 162 }) 163 }) 164 Context("When creating workerpool is successful with SecondaryStorageOption", func() { 165 BeforeEach(func() { 166 server = ghttp.NewServer() 167 server.AppendHandlers( 168 ghttp.CombineHandlers( 169 ghttp.VerifyRequest(http.MethodPost, "/v2/vpc/createWorkerPool"), 170 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","flavor":"b2.4x16", "hostPool":"hostpoolid1", "name":"mywork211","vpcID":"6015365a-9d93-4bb4-8248-79ae0db2dc26","workerCount":1,"zones":[], "entitlement":"", "secondaryStorageOption": "secondarystoragename1"}`), 171 ghttp.RespondWith(http.StatusCreated, `{ 172 "workerPoolID":"string" 173 }`), 174 ), 175 ) 176 }) 177 178 It("should create Workerpool in a cluster", func() { 179 target := ClusterTargetHeader{} 180 params := WorkerPoolRequest{ 181 Cluster: "bm64u3ed02o93vv36hb0", 182 HostPoolID: "hostpoolid1", 183 CommonWorkerPoolConfig: CommonWorkerPoolConfig{ 184 Flavor: "b2.4x16", 185 Name: "mywork211", 186 VpcID: "6015365a-9d93-4bb4-8248-79ae0db2dc26", 187 WorkerCount: 1, 188 Zones: []Zone{}, 189 Entitlement: "", 190 SecondaryStorageOption: "secondarystoragename1", 191 }, 192 } 193 _, err := newWorkerPool(server.URL()).CreateWorkerPool(params, target) 194 Expect(err).NotTo(HaveOccurred()) 195 }) 196 }) 197 Context("When creating workerpool is unsuccessful", func() { 198 BeforeEach(func() { 199 server = ghttp.NewServer() 200 server.SetAllowUnhandledRequests(true) 201 server.AppendHandlers( 202 ghttp.CombineHandlers( 203 ghttp.VerifyRequest(http.MethodPost, "/v2/vpc/createWorkerPool"), 204 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","flavor":"b2.4x16","name":"mywork211","vpcID":"6015365a-9d93-4bb4-8248-79ae0db2dc26","workerCount":1,"zones":[],"entitlement":""} 205 `), 206 ghttp.RespondWith(http.StatusInternalServerError, `Failed to create workerpool`), 207 ), 208 ) 209 }) 210 211 It("should return error during creating workerpool", func() { 212 params := WorkerPoolRequest{ 213 Cluster: "bm64u3ed02o93vv36hb0", 214 CommonWorkerPoolConfig: CommonWorkerPoolConfig{ 215 Flavor: "b2.4x16", 216 Name: "mywork211", 217 VpcID: "6015365a-9d93-4bb4-8248-79ae0db2dc26", 218 WorkerCount: 1, 219 Zones: []Zone{}, 220 Entitlement: "", 221 }, 222 } 223 target := ClusterTargetHeader{} 224 _, err := newWorkerPool(server.URL()).CreateWorkerPool(params, target) 225 Expect(err).To(HaveOccurred()) 226 }) 227 }) 228 }) 229 230 //getworkerpools 231 Describe("Get", func() { 232 Context("When Get workerpool is successful", func() { 233 BeforeEach(func() { 234 server = ghttp.NewServer() 235 server.AppendHandlers( 236 ghttp.CombineHandlers( 237 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPool"), 238 ghttp.RespondWith(http.StatusCreated, `{ 239 "dedicatedHostPoolId": "dedicatedhostpoolid1", 240 "flavor": "string", 241 "id": "string", 242 "isolation": "string", 243 "lifecycle": { 244 "actualState": "string", 245 "desiredState": "string" 246 }, 247 "operatingSystem": "REDHAT_7_64", 248 "poolName": "string", 249 "provider": "string", 250 "vpcID": "string", 251 "workerCount": 0, 252 "zones": [ 253 { 254 "id": "string", 255 "subnets": [ 256 { 257 "id": "string", 258 "primary": true 259 } 260 ], 261 "workerCount": 0 262 } 263 ] 264 }`), 265 ), 266 ) 267 }) 268 269 It("should get Workerpool in a cluster", func() { 270 target := ClusterTargetHeader{} 271 272 wp, err := newWorkerPool(server.URL()).GetWorkerPool("aaa", "bbb", target) 273 Expect(err).NotTo(HaveOccurred()) 274 Expect(wp.HostPoolID).To(BeIdenticalTo("dedicatedhostpoolid1")) 275 Expect(wp.OperatingSystem).To(BeIdenticalTo("REDHAT_7_64")) 276 Expect(wp.AutoscaleEnabled).To(BeFalse()) 277 }) 278 }) 279 Context("When get workerpool is unsuccessful", func() { 280 BeforeEach(func() { 281 server = ghttp.NewServer() 282 server.SetAllowUnhandledRequests(true) 283 server.AppendHandlers( 284 ghttp.CombineHandlers( 285 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPool"), 286 ghttp.RespondWith(http.StatusInternalServerError, `Failed to get workerpool`), 287 ), 288 ) 289 }) 290 291 It("should return error during get workerpool", func() { 292 target := ClusterTargetHeader{} 293 _, err := newWorkerPool(server.URL()).GetWorkerPool("aaa", "bbb", target) 294 Expect(err).To(HaveOccurred()) 295 }) 296 }) 297 Context("When Get workerpool is successful and worker volume encyiption is enabled", func() { 298 BeforeEach(func() { 299 server = ghttp.NewServer() 300 server.AppendHandlers( 301 ghttp.CombineHandlers( 302 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPool"), 303 ghttp.RespondWith(http.StatusCreated, `{ 304 "flavor": "string", 305 "id": "string", 306 "isolation": "string", 307 "lifecycle": { 308 "actualState": "string", 309 "desiredState": "string" 310 }, 311 "poolName": "string", 312 "provider": "string", 313 "vpcID": "string", 314 "workerCount": 0, 315 "zones": [ 316 { 317 "id": "string", 318 "subnets": [ 319 { 320 "id": "string", 321 "primary": true 322 } 323 ], 324 "workerCount": 0 325 } 326 ], 327 "workerVolumeEncryption": { 328 "workerVolumeCRKID": "crk", 329 "kmsInstanceID": "kmsid" 330 } 331 }`), 332 ), 333 ) 334 }) 335 336 It("should get Workerpool in a cluster", func() { 337 target := ClusterTargetHeader{} 338 339 wpresp, err := newWorkerPool(server.URL()).GetWorkerPool("aaa", "bbb", target) 340 Expect(err).NotTo(HaveOccurred()) 341 Expect(wpresp.WorkerVolumeEncryption.KmsInstanceID).Should(Equal("kmsid")) 342 Expect(wpresp.WorkerVolumeEncryption.WorkerVolumeCRKID).Should(Equal("crk")) 343 }) 344 }) 345 Context("When Get workerpool is successful and worker volume encyiption is enabled and provided by another account", func() { 346 BeforeEach(func() { 347 server = ghttp.NewServer() 348 server.AppendHandlers( 349 ghttp.CombineHandlers( 350 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPool"), 351 ghttp.RespondWith(http.StatusCreated, `{ 352 "flavor": "string", 353 "id": "string", 354 "isolation": "string", 355 "lifecycle": { 356 "actualState": "string", 357 "desiredState": "string" 358 }, 359 "poolName": "string", 360 "provider": "string", 361 "vpcID": "string", 362 "workerCount": 0, 363 "zones": [ 364 { 365 "id": "string", 366 "subnets": [ 367 { 368 "id": "string", 369 "primary": true 370 } 371 ], 372 "workerCount": 0 373 } 374 ], 375 "workerVolumeEncryption": { 376 "workerVolumeCRKID": "crk", 377 "kmsInstanceID": "kmsid", 378 "kmsAccountID":"OtherAccountID" 379 } 380 }`), 381 ), 382 ) 383 }) 384 385 It("should get Workerpool in a cluster with KMSAccountID present in WorkerVolumeEncryption", func() { 386 target := ClusterTargetHeader{} 387 388 wpresp, err := newWorkerPool(server.URL()).GetWorkerPool("aaa", "bbb", target) 389 Expect(err).NotTo(HaveOccurred()) 390 Expect(wpresp.WorkerVolumeEncryption.KmsInstanceID).Should(Equal("kmsid")) 391 Expect(wpresp.WorkerVolumeEncryption.WorkerVolumeCRKID).Should(Equal("crk")) 392 Expect(wpresp.WorkerVolumeEncryption.KMSAccountID).Should(Equal("OtherAccountID")) 393 }) 394 }) 395 Context("When Get workerpool is successful with UserDefinedSecondaryDisk", func() { 396 BeforeEach(func() { 397 server = ghttp.NewServer() 398 server.AppendHandlers( 399 ghttp.CombineHandlers( 400 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPool"), 401 ghttp.RespondWith(http.StatusCreated, `{ 402 "flavor": "flavor1", 403 "id": "id1", 404 "lifecycle": { 405 "actualState": "actual", 406 "desiredState": "desired" 407 }, 408 "operatingSystem": "REDHAT_7_64", 409 "poolName": "name1", 410 "provider": "provider1", 411 "vpcID": "vpcid1", 412 "workerCount": 0, 413 "secondaryStorageOption": { 414 "Count": 1, 415 "DeviceType": "devtype1", 416 "RAIDConfiguration": "config1", 417 "Size": 2, 418 "name": "name3", 419 "profile": "profile3" 420 } 421 }`), 422 ), 423 ) 424 }) 425 426 It("should get Workerpool in a cluster", func() { 427 target := ClusterTargetHeader{} 428 429 wp, err := newWorkerPool(server.URL()).GetWorkerPool("aaa", "bbb", target) 430 Expect(err).NotTo(HaveOccurred()) 431 storage := DiskConfigResp{ 432 Count: 1, 433 DeviceType: "devtype1", 434 RAIDConfiguration: "config1", 435 Size: 2, 436 Name: "name3", 437 Profile: "profile3", 438 } 439 Expect(*wp.SecondaryStorageOption).To(BeIdenticalTo(storage)) 440 }) 441 }) 442 Context("When Get workerpool is successful with AutoscaleEnabled", func() { 443 BeforeEach(func() { 444 server = ghttp.NewServer() 445 server.AppendHandlers( 446 ghttp.CombineHandlers( 447 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPool"), 448 ghttp.RespondWith(http.StatusCreated, `{ 449 "flavor": "flavor1", 450 "id": "id1", 451 "lifecycle": { 452 "actualState": "actual", 453 "desiredState": "desired" 454 }, 455 "poolName": "name1", 456 "provider": "provider1", 457 "vpcID": "vpcid1", 458 "workerCount": 0, 459 "autoscaleEnabled" : true 460 }`), 461 ), 462 ) 463 }) 464 465 It("should get Workerpool in a cluster", func() { 466 target := ClusterTargetHeader{} 467 468 wp, err := newWorkerPool(server.URL()).GetWorkerPool("aaa", "bbb", target) 469 Expect(err).NotTo(HaveOccurred()) 470 Expect(wp.AutoscaleEnabled).To(BeTrue()) 471 }) 472 }) 473 }) 474 475 //List 476 //getworkerpools 477 Describe("List", func() { 478 Context("When list workerpool is successful", func() { 479 BeforeEach(func() { 480 server = ghttp.NewServer() 481 server.AppendHandlers( 482 ghttp.CombineHandlers( 483 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPools"), 484 ghttp.RespondWith(http.StatusCreated, `[{ 485 "flavor": "string", 486 "id": "string", 487 "isolation": "string", 488 "lifecycle": { 489 "actualState": "string", 490 "desiredState": "string" 491 }, 492 "poolName": "string", 493 "provider": "string", 494 "vpcID": "string", 495 "workerCount": 0, 496 "zones": [ 497 { 498 "id": "string", 499 "subnets": [ 500 { 501 "id": "string", 502 "primary": true 503 } 504 ], 505 "workerCount": 0 506 } 507 ] 508 }]`), 509 ), 510 ) 511 }) 512 513 It("should list Workerpools in a cluster", func() { 514 target := ClusterTargetHeader{} 515 516 _, err := newWorkerPool(server.URL()).ListWorkerPools("aaa", target) 517 Expect(err).NotTo(HaveOccurred()) 518 }) 519 }) 520 Context("When list workerpool is unsuccessful", func() { 521 BeforeEach(func() { 522 server = ghttp.NewServer() 523 server.SetAllowUnhandledRequests(true) 524 server.AppendHandlers( 525 ghttp.CombineHandlers( 526 ghttp.VerifyRequest(http.MethodGet, "/v2/vpc/getWorkerPools"), 527 ghttp.RespondWith(http.StatusInternalServerError, `Failed to list workerpool`), 528 ), 529 ) 530 }) 531 532 It("should return error during get workerpools", func() { 533 target := ClusterTargetHeader{} 534 _, err := newWorkerPool(server.URL()).ListWorkerPools("aaa", target) 535 Expect(err).To(HaveOccurred()) 536 }) 537 }) 538 }) 539 540 //Delete 541 Describe("Delete", func() { 542 Context("When delete of worker is successful", func() { 543 BeforeEach(func() { 544 server = ghttp.NewServer() 545 server.AppendHandlers( 546 ghttp.CombineHandlers( 547 ghttp.VerifyRequest(http.MethodDelete, "/v1/clusters/test/workerpools/abc-123-def-ghi"), 548 ghttp.RespondWith(http.StatusOK, `{ 549 }`), 550 ), 551 ) 552 }) 553 554 It("should delete workerpool", func() { 555 target := ClusterTargetHeader{} 556 err := newWorkerPool(server.URL()).DeleteWorkerPool("test", "abc-123-def-ghi", target) 557 Expect(err).NotTo(HaveOccurred()) 558 }) 559 }) 560 Context("When cluster delete is failed", func() { 561 BeforeEach(func() { 562 server = ghttp.NewServer() 563 server.SetAllowUnhandledRequests(true) 564 server.AppendHandlers( 565 ghttp.CombineHandlers( 566 ghttp.VerifyRequest(http.MethodDelete, "/v1/clusters/test/workerpools/abc-123-def-ghi"), 567 ghttp.RespondWith(http.StatusInternalServerError, `Failed to delete worker`), 568 ), 569 ) 570 }) 571 572 It("should return error service key delete", func() { 573 target := ClusterTargetHeader{} 574 err := newWorkerPool(server.URL()).DeleteWorkerPool("test", "abc-123-def-ghi", target) 575 Expect(err).To(HaveOccurred()) 576 }) 577 }) 578 579 //Resize 580 Describe("Resize", func() { 581 Context("When resizing workerpool is successful", func() { 582 BeforeEach(func() { 583 server = ghttp.NewServer() 584 server.AppendHandlers( 585 ghttp.CombineHandlers( 586 ghttp.VerifyRequest(http.MethodPost, "/v2/resizeWorkerPool"), 587 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","workerpool":"mywork211","size":5}`), 588 ), 589 ) 590 }) 591 It("should resize Workerpool in a cluster", func() { 592 target := ClusterTargetHeader{} 593 params := ResizeWorkerPoolReq{ 594 Cluster: "bm64u3ed02o93vv36hb0", 595 Workerpool: "mywork211", 596 Size: 5, 597 } 598 err := newWorkerPool(server.URL()).ResizeWorkerPool(params, target) 599 Expect(err).NotTo(HaveOccurred()) 600 }) 601 }) 602 Context("When resizing workerpool is unsuccessful", func() { 603 BeforeEach(func() { 604 server = ghttp.NewServer() 605 server.SetAllowUnhandledRequests(true) 606 server.AppendHandlers( 607 ghttp.CombineHandlers( 608 ghttp.VerifyRequest(http.MethodPost, "/v2/resizeWorkerPool"), 609 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","workerpool":"mywork211","size":5}`), 610 ghttp.RespondWith(http.StatusInternalServerError, `Failed to resize workerpool`), 611 ), 612 ) 613 }) 614 615 It("should return error during resizing workerpool", func() { 616 params := ResizeWorkerPoolReq{ 617 Cluster: "bm64u3ed02o93vv36hb0", 618 Workerpool: "mywork211", 619 Size: 5, 620 } 621 target := ClusterTargetHeader{} 622 err := newWorkerPool(server.URL()).ResizeWorkerPool(params, target) 623 Expect(err).To(HaveOccurred()) 624 }) 625 }) 626 }) 627 628 // UpdateWorkerPoolLabels 629 Describe("UpdateWorkerPoolLabels", func() { 630 Context("When updateing workerpool labels successful", func() { 631 BeforeEach(func() { 632 server = ghttp.NewServer() 633 server.SetAllowUnhandledRequests(true) 634 server.AppendHandlers( 635 ghttp.CombineHandlers( 636 ghttp.VerifyRequest(http.MethodPost, "/v2/setWorkerPoolLabels"), 637 ghttp.VerifyJSON(`{"cluster":"bm64u3ed02o93vv36hb0","workerpool":"mywork211","labels": {"a": "apple","b": "banana"}}`), 638 ), 639 ) 640 }) 641 642 It("should update labels in the workerpool", func() { 643 params := SetWorkerPoolLabelsRequest{ 644 Cluster: "bm64u3ed02o93vv36hb0", 645 WorkerPool: "mywork211", 646 Labels: map[string]string{ 647 "a": "apple", 648 "b": "banana", 649 }, 650 } 651 target := ClusterTargetHeader{} 652 err := newWorkerPool(server.URL()).UpdateWorkerPoolLabels(params, target) 653 Expect(err).ToNot(HaveOccurred()) 654 }) 655 }) 656 }) 657 }) 658 }) 659 660 func newWorkerPool(url string) WorkerPool { 661 662 sess, err := session.New() 663 if err != nil { 664 log.Fatal(err) 665 } 666 conf := sess.Config.Copy() 667 conf.HTTPClient = bluemixHttp.NewHTTPClient(conf) 668 conf.Endpoint = &url 669 670 client := client.Client{ 671 Config: conf, 672 ServiceName: bluemix.VpcContainerService, 673 } 674 return newWorkerPoolAPI(&client) 675 }