コード例 #1
0
				"Tag_compiling":  "buildpack_python",
				"Tag_deployment": "metadata_deployment",
			}
		})

		AfterEach(func() {
			testhelpers.DeleteVirtualGuest(virtualGuest.Id)
			testhelpers.DeleteSshKey(createdSshKey.Id)
		})

		It("issues set_vm_metadata to cpi", func() {
			pwd, err := os.Getwd()
			Expect(err).ToNot(HaveOccurred())
			rootTemplatePath := filepath.Join(pwd, "..", "..")

			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("set_vm_metadata", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			tmpConfigPath, err := testhelperscpi.CreateTmpConfigPath(rootTemplatePath, configPath, username, apiKey)
			Expect(err).ToNot(HaveOccurred())

			_, err = testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			Expect(err).ToNot(HaveOccurred())

			err = os.RemoveAll(tmpConfigPath)
			Expect(err).ToNot(HaveOccurred())

			tagReferences, err := virtualGuestService.GetTagReferences(virtualGuest.Id)
			Expect(err).ToNot(HaveOccurred())

			tagReferencesJSON, err := json.Marshal(tagReferences)
コード例 #2
0
			Expect(err).ToNot(HaveOccurred())
		})
	})

	Context("#GenerateCpiJsonPayload", func() {
		Context("set_vm_metadata CPI method", func() {
			BeforeEach(func() {
				cpiTemplate = testhelpers.CpiTemplate{
					ID:           "fake-id",
					DirectorUuid: "fake-director-uuid",
					Tags:         "fake, tags",
				}
			})

			It("verifies the generated payload", func() {
				payload, err := testhelpers.GenerateCpiJsonPayload("set_vm_metadata", rootTemplatePath, replacementMap)
				Expect(err).ToNot(HaveOccurred())
				Expect(payload).To(MatchJSON(`
					{
						"method": "set_vm_metadata",
						"arguments": [
							"some ID",
							{
								"director": "BOSH Director",
								"deployment": "softlayer",
								"tags": "some, tags"
							}
						],
						"context": {
							"director_uuid": "some director UUID"
						}
コード例 #3
0
	AfterEach(func() {
		err = os.RemoveAll(tmpConfigPath)
		Expect(err).ToNot(HaveOccurred())
	})

	Context("attach_disk in SoftLayer with invalid virtual guest id and disk id", func() {
		BeforeEach(func() {
			replacementMap = map[string]string{
				"VMID":   "123456",
				"DiskID": "123",
			}
		})

		It("returns error", func() {
			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("attach_disk", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			log.Println("outputBytes=" + string(outputBytes))
			Expect(err).ToNot(HaveOccurred())
			err = json.Unmarshal(outputBytes, &resultOutput)
			Expect(err).ToNot(HaveOccurred())
			Expect(resultOutput["error"]).ToNot(BeNil())
		})
	})

	Context("attach_disk in SoftLayer with valid virtual guest id(with multipath installed) and disk id", func() {
		BeforeEach(func() {
			err = testhelpers.FindAndDeleteTestSshKeys()
			Expect(err).ToNot(HaveOccurred())
コード例 #4
0
			strVGID = strconv.Itoa(virtualGuest.Id)

			replacementMap = map[string]string{
				"ID":           strVGID,
				"DirectorUuid": "fake-director-uuid",
			}
		})

		AfterEach(func() {
			testhelpers.DeleteVirtualGuest(virtualGuest.Id)
			testhelpers.DeleteSshKey(createdSshKey.Id)
		})

		It("returns true because vm exists", func() {
			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("has_vm", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			Expect(err).ToNot(HaveOccurred())

			err = json.Unmarshal(outputBytes, &output)
			Expect(err).ToNot(HaveOccurred())
			Expect(output["result"]).To(BeTrue())
		})
	})

	Context("has_vm without valid vm id", func() {
		BeforeEach(func() {
			replacementMap = map[string]string{
				"ID":           "123456",
コード例 #5
0
			testhelpers.TIMEOUT = 35 * time.Minute
			testhelpers.POLLING_INTERVAL = 10 * time.Second
			testhelpers.WaitForVirtualGuestBlockTemplateGroupToHaveNoActiveTransactions(vgbdtGroup.Id)
		})

		AfterEach(func() {
			_, err := vgbdtgService.DeleteObject(virtual_disk_image_id)
			Expect(err).ToNot(HaveOccurred())
		})

		It("returns true because valid parameters", func() {
			replacementMap = map[string]string{
				"ID":         strconv.Itoa(virtual_disk_image_id),
				"Datacenter": testhelpers.GetDatacenter(),
			}
			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("create_stemcell", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			log.Println("outputBytes=" + string(outputBytes))
			Expect(err).ToNot(HaveOccurred())

			err = json.Unmarshal(outputBytes, &output)
			Expect(err).ToNot(HaveOccurred())
			Expect(output["result"]).ToNot(BeNil())
			Expect(output["error"]).To(BeNil())

			vmId, err = strconv.ParseFloat(output["result"].(string), 64)
			Expect(err).ToNot(HaveOccurred())
			Expect(vmId).ToNot(BeZero())
		})
コード例 #6
0
	})

	Context("True path of OS Reload", func() {

		BeforeEach(func() {
			os.Setenv("SQLITE_DB_FILE", "vm_pool.sqlite.right")
		})

		AfterEach(func() {
			err = os.Remove("/tmp/vm_pool.sqlite.right")
			Expect(err).ToNot(HaveOccurred())
		})

		It("returns true if the VM creation procedure is correct", func() {

			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("create_vm", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			log.Println("outputBytes of vm creation: " + string(outputBytes))
			Expect(err).ToNot(HaveOccurred())

			err = json.Unmarshal(outputBytes, &output)
			Expect(err).ToNot(HaveOccurred())
			Expect(output["result"]).ToNot(BeNil())
			Expect(output["error"]).To(BeNil())

			id := output["result"].(string)
			vmId, err = strconv.Atoi(id)
			log.Println(fmt.Sprintf("Create a new VM with ID: %d", vmId))