log.Println("outputBytes=" + string(outputBytes)) Expect(err).ToNot(HaveOccurred()) err = json.Unmarshal(outputBytes, &resultOutput) Expect(err).ToNot(HaveOccurred()) Expect(resultOutput["error"]).To(BeNil()) id := resultOutput["result"].(string) vmId, err = strconv.Atoi(id) Expect(err).ToNot(HaveOccurred()) Expect(vmId).ToNot(BeNil()) log.Println("---> created vm ", vmId) testhelpers.WaitForVirtualGuestToBeRunning(vmId) testhelpers.WaitForVirtualGuestToHaveNoActiveTransactions(vmId) vm, err := virtualGuestService.GetObject(vmId) Expect(err).ToNot(HaveOccurred()) disk = testhelpers.CreateDisk(20, strconv.Itoa(vm.Datacenter.Id)) strVGID = strconv.Itoa(vmId) strDID = strconv.Itoa(disk.Id) replacementMap = map[string]string{ "VMID": strVGID, "DiskID": strDID, } }) AfterEach(func() { testhelpers.DeleteVirtualGuest(vmId)
Expect(err.Error()).To(ContainSubstring("Domain")) Expect(err.Error()).To(ContainSubstring("StartCpus")) Expect(err.Error()).To(ContainSubstring("MaxMemory")) Expect(err.Error()).To(ContainSubstring("Datacenter")) }) }) Context("#GetObject", func() { BeforeEach(func() { virtualGuest.Id = 1234567 fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Guest_Service_getObject.json") Expect(err).ToNot(HaveOccurred()) }) It("sucessfully retrieves SoftLayer_Virtual_Guest instance", func() { vg, err := virtualGuestService.GetObject(virtualGuest.Id) Expect(err).ToNot(HaveOccurred()) Expect(vg.Id).To(Equal(virtualGuest.Id)) Expect(vg.AccountId).To(Equal(278444)) Expect(vg.CreateDate).ToNot(BeNil()) Expect(vg.DedicatedAccountHostOnlyFlag).To(BeFalse()) Expect(vg.Domain).To(Equal("softlayer.com")) Expect(vg.FullyQualifiedDomainName).To(Equal("bosh-ecpi1.softlayer.com")) Expect(vg.Hostname).To(Equal("bosh-ecpi1")) Expect(vg.Id).To(Equal(1234567)) Expect(vg.LastPowerStateId).To(Equal(0)) Expect(vg.LastVerifiedDate).To(BeNil()) Expect(vg.MaxCpu).To(Equal(1)) Expect(vg.MaxCpuUnits).To(Equal("CORE")) Expect(vg.MaxMemory).To(Equal(1024)) Expect(vg.MetricPollDate).To(BeNil())
testhelpers.WaitForVirtualGuestToBeRunning(virtualGuest.Id) testhelpers.WaitForVirtualGuestToHaveNoActiveTransactions(virtualGuest.Id) virtualGuestService, err := testhelpers.CreateVirtualGuestService() Expect(err).ToNot(HaveOccurred()) fmt.Printf("----> will attempt to upgrade virtual guest `%d`: [CPUs --> 2; RAM --> 2Gb; Network speed --> 1000]\n", virtualGuest.Id) _, err = virtualGuestService.UpgradeObject(virtualGuest.Id, &softlayer.UpgradeOptions{ Cpus: 2, MemoryInGB: 2, NicSpeed: 1000, }) Expect(err).ToNot(HaveOccurred()) fmt.Printf("----> verifying that upgrade successfully completed for virtual guest `%d`\n", virtualGuest.Id) testhelpers.WaitForVirtualGuestTransactionWithStatus(virtualGuest.Id, "UPGRADE") testhelpers.WaitForVirtualGuestToHaveNoActiveTransactions(virtualGuest.Id) fmt.Printf("----> verify that cpu, ram and memory of virtual guest `%d` are upgraded\n", virtualGuest.Id) upgradedVirtualGuest, err := virtualGuestService.GetObject(virtualGuest.Id) Expect(err).ToNot(HaveOccurred()) Expect(upgradedVirtualGuest.MaxMemory).To(Equal(2048)) Expect(upgradedVirtualGuest.NetworkComponents[0].MaxSpeed).To(Equal(1000)) Expect(upgradedVirtualGuest.StartCpus).To(Equal(2)) fmt.Printf("----> successfully upgraded virtual guest `%d`\n", virtualGuest.Id) }) }) })
fs = fakesys.NewFakeFileSystem() testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Virtual_Guest_Service_getObject.json") }) Describe("Upload", func() { It("file contents into /var/vcap/file.ext", func() { expectedCmdResults := []string{ "", } testhelpers.SetTestFixturesForFakeSSHClient(sshClient, expectedCmdResults, nil) var virtualGuestService softlayer.SoftLayer_Virtual_Guest_Service virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service() Expect(err).ToNot(HaveOccurred()) virtualGuest, err := virtualGuestService.GetObject(1234567) Expect(err).ToNot(HaveOccurred()) softlayerFileService = NewSoftlayerFileService(sshClient, virtualGuest, logger, uuidGenerator, fs) err = softlayerFileService.Upload("/var/vcap/file.ext", []byte("fake-contents")) Expect(err).ToNot(HaveOccurred()) }) }) Describe("Download", func() { It("copies agent env into temporary location", func() { expectedCmdResults := []string{ "", } testhelpers.SetTestFixturesForFakeSSHClient(sshClient, expectedCmdResults, nil)