func NewTurbulenceClient(manifest turbulence.Manifest) turbulenceclient.Client { turbulenceUrl := fmt.Sprintf("https://*****:*****@%s:8080", manifest.Properties.TurbulenceAPI.Password, manifest.InstanceGroups[0].Networks[0].StaticIPs[0]) return turbulenceclient.NewClient(turbulenceUrl, 5*time.Minute, 2*time.Second) }
} } })) fakeServer.URL = server.URL return fakeServer } var _ = Describe("Client", func() { Describe("KillIndices", func() { var fakeServer *fakeTurbulenceServer var client turbulence.Client BeforeEach(func() { fakeServer = NewFakeTurbulenceServer() client = turbulence.NewClient(fakeServer.URL, 100*time.Millisecond, 40*time.Millisecond) }) It("makes a POST request to create an incident and then polls to wait for completion", func() { errorKillingIndices := client.KillIndices("deployment-name", "job-name", []int{0}) Expect(fakeServer.errorReadingBody).NotTo(HaveOccurred()) Expect(errorKillingIndices).NotTo(HaveOccurred()) Expect(string(fakeServer.receivedPOSTBody)).To(MatchJSON(expectedPOSTRequest)) }) It("returns a timeout error when execution does not complete", func() { fakeServer.GETResponses = []string{successfulIncompleteGETResponse} errorKillingIndices := client.KillIndices("deployment-name", "job-name", []int{0}) Expect(errorKillingIndices).NotTo(BeNil()) Expect(errorKillingIndices.Error()).To(ContainSubstring("Did not finish deleting VM in time"))
turbulenceManifest, err = destiny.FromYAML(yaml) Expect(err).NotTo(HaveOccurred()) err = client.Deploy(yaml) Expect(err).NotTo(HaveOccurred()) Eventually(func() ([]bosh.VM, error) { return client.DeploymentVMs(turbulenceManifest.Name) }, "1m", "10s").Should(ConsistOf([]bosh.VM{ {"running"}, })) }) By("preparing turbulence client", func() { turbulenceUrl := fmt.Sprintf("https://*****:*****@%s:8080", turbulenceManifest.Properties.TurbulenceAPI.Password, turbulenceManifest.Jobs[0].Networks[0].StaticIPs[0]) turbulenceClient = turbulence.NewClient(turbulenceUrl, 5*time.Minute, 2*time.Second) }) }) var _ = AfterSuite(func() { By("deleting the turbulence deployment", func() { if !CurrentGinkgoTestDescription().Failed { err := client.DeleteDeployment(turbulenceManifest.Name) Expect(err).NotTo(HaveOccurred()) } }) })