コード例 #1
0
			errorKillingIndices := client.KillIndices("deployment-name", "job-name", []int{0})
			Expect(errorKillingIndices.Error()).To(ContainSubstring("Unable to decode turbulence response."))
		})
	})

	Describe("Delay", 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 a control-network delay incident and polls for initial execution", func() {
			resp, err := client.Delay("deployment-name", "job-name", []int{0}, time.Second, 2*time.Second)
			Expect(err).NotTo(HaveOccurred())

			Expect(fakeServer.postIncidentCallCount).To(Equal(1))
			Expect(fakeServer.errorReadingBody).NotTo(HaveOccurred())
			Expect(string(fakeServer.receivedPOSTBody)).To(MatchJSON(expectedDelayPOSTRequest))
			Expect(resp).To(Equal(turbulence.Response{
				ID:                   "someID",
				ExecutionStartedAt:   "0001-01-01T00:00:00Z",
				ExecutionCompletedAt: "",
				Events: []turbulence.ResponseEvent{
					{
						Type:               "ControlNet",
						ExecutionStartedAt: "0001-01-01T00:00:00Z",
					},
				},
コード例 #2
0
	It("resolves long running DNS queries utilizing the consul recursor_timeout property", func() {
		By("making sure my-fake-server resolves", func() {
			addresses, err := tcClient.DNS("my-fake-server.fake.local")
			Expect(err).NotTo(HaveOccurred())

			// miekg/dns implementation responds with A and AAAA records regardless of the type of record requested
			// therefore we're expected 4 IPs here
			if config.WindowsClients {
				Expect(addresses).To(Equal([]string{"10.2.3.4", "10.2.3.4"}))
			} else {
				Expect(addresses).To(Equal([]string{"10.2.3.4", "10.2.3.4", "10.2.3.4", "10.2.3.4"}))
			}
		})

		By("delaying DNS queries with a network delay that is greater than the recursor timeout", func() {
			response, err := turbulenceClient.Delay(consulManifest.Name, "fake-dns-server", []int{0}, DELAY, TIMEOUT)
			Expect(err).NotTo(HaveOccurred())
			delayIncidentID = response.ID
		})

		By("making a DNS query which should timeout", func() {
			Eventually(func() ([]string, error) {
				return tcClient.DNS("my-fake-server.fake.local")
			}, "30s", "100ms").Should(BeEmpty())
		})

		By("waiting for the network delay to end", func() {
			Eventually(func() string {
				incidentResp, err := turbulenceClient.Incident(delayIncidentID)
				Expect(err).NotTo(HaveOccurred())