})

	AfterEach(func() {
		By("deleting consul deployment", func() {
			if !CurrentGinkgoTestDescription().Failed {
				Eventually(func() ([]string, error) {
					return lockedDeployments()
				}, "10m", "30s").ShouldNot(ContainElement(consulManifest.Name))

				err := boshClient.DeleteDeployment(consulManifest.Name)
				Expect(err).NotTo(HaveOccurred())
			}
		})
	})

	It("does not error out", func() {
		addresses, err := testConsumerClient.DNS("large-dns-response.fake.local")
		Expect(err).NotTo(HaveOccurred())
		Expect(addresses).To(Equal([]string{
			"1.2.3.0", "1.2.3.0",
			"1.2.3.1", "1.2.3.1",
			"1.2.3.2", "1.2.3.2",
			"1.2.3.3", "1.2.3.3",
			"1.2.3.0", "1.2.3.0",
			"1.2.3.1", "1.2.3.1",
			"1.2.3.2", "1.2.3.2",
			"1.2.3.3", "1.2.3.3",
		}))
	})
})
				},
			}
		})

		By("deploying", func() {
			yaml, err := manifest.ToYAML()
			Expect(err).NotTo(HaveOccurred())

			yaml, err = boshClient.ResolveManifestVersions(yaml)
			Expect(err).NotTo(HaveOccurred())

			_, err = boshClient.Deploy(yaml)
			Expect(err).NotTo(HaveOccurred())

			Eventually(func() ([]bosh.VM, error) {
				return helpers.DeploymentVMs(boshClient, manifest.Name)
			}, "1m", "10s").Should(ConsistOf(helpers.GetVMsFromManifest(manifest)))
		})

		By("resolving service addresses", func() {
			Eventually(func() ([]string, error) {
				return tcClient.DNS("consul-test-consumer.service.cf.internal")
			}, "1m", "10s").Should(ConsistOf(manifest.InstanceGroups[1].Networks[0].StaticIPs))

			Eventually(func() ([]string, error) {
				return tcClient.DNS("some-service.service.cf.internal")
			}, "1m", "10s").Should(ConsistOf(manifest.InstanceGroups[1].Networks[0].StaticIPs))
		})
	})
})
	AfterEach(func() {
		By("deleting consul deployment", func() {
			if !CurrentGinkgoTestDescription().Failed {
				Eventually(func() string {
					incidentResp, err := turbulenceClient.Incident(delayIncidentID)
					Expect(err).NotTo(HaveOccurred())

					return incidentResp.ExecutionCompletedAt
				}, TIMEOUT.String(), "10s").ShouldNot(BeEmpty())

				// Turbulence API might say that the incident is finished, but it might not be - sanity check
				Eventually(func() (int64, error) {
					var err error
					dnsStartTime := time.Now()
					_, err = tcClient.DNS("my-fake-server.fake.local")
					if err != nil {
						return 0, err
					}
					dnsElapsedTime := time.Since(dnsStartTime)
					return dnsElapsedTime.Nanoseconds(), nil
				}, TIMEOUT.String(), "100ms").Should(BeNumerically("<", 1*time.Second))

				Eventually(func() ([]string, error) {
					return lockedDeployments()
				}, "10m", "30s").ShouldNot(ContainElement(consulManifest.Name))

				err := boshClient.DeleteDeployment(consulManifest.Name)
				Expect(err).NotTo(HaveOccurred())
			}
		})
			Expect(err).NotTo(HaveOccurred())

			yaml, err = boshClient.ResolveManifestVersions(yaml)
			Expect(err).NotTo(HaveOccurred())

			_, err = boshClient.Deploy(yaml)
			Expect(err).NotTo(HaveOccurred())

			Eventually(func() ([]bosh.VM, error) {
				return helpers.DeploymentVMs(boshClient, manifest.Name)
			}, "1m", "10s").Should(ConsistOf(helpers.GetVMsFromManifest(manifest)))
		})

		By("resolving service addresses", func() {
			Eventually(func() ([]string, error) {
				return tcClient.DNS("some-service.service.cf.internal")
			}, "2m", "10s").Should(ConsistOf(manifest.InstanceGroups[0].Networks[0].StaticIPs))

			Eventually(func() ([]string, error) {
				return tcClient.DNS("consul-0.some-service.service.cf.internal")
			}, "2m", "10s").Should(ConsistOf(manifest.InstanceGroups[0].Networks[0].StaticIPs[0]))

			Eventually(func() ([]string, error) {
				return tcClient.DNS("consul-1.some-service.service.cf.internal")
			}, "2m", "10s").Should(ConsistOf(manifest.InstanceGroups[0].Networks[0].StaticIPs[1]))

			Eventually(func() ([]string, error) {
				return tcClient.DNS("consul-2.some-service.service.cf.internal")
			}, "2m", "10s").Should(ConsistOf(manifest.InstanceGroups[0].Networks[0].StaticIPs[2]))

			Eventually(func() ([]string, error) {
				Expect(err).NotTo(HaveOccurred())

				yaml, err = boshClient.ResolveManifestVersions(yaml)
				Expect(err).NotTo(HaveOccurred())

				_, err = boshClient.Deploy(yaml)
				Expect(err).NotTo(HaveOccurred())

				Eventually(func() ([]bosh.VM, error) {
					return helpers.DeploymentVMs(boshClient, manifest.Name)
				}, "1m", "10s").Should(ConsistOf(helpers.GetVMsFromManifest(manifest)))
			})

			By("resolving the service address", func() {
				Eventually(func() ([]string, error) {
					return tcClient.DNS("some-service-name.service.cf.internal")
				}, "1m", "10s").Should(ConsistOf(manifest.InstanceGroups[0].Networks[0].StaticIPs))
			})

			By("causing the health check to fail", func() {
				err := tcClient.SetHealthCheck(false)
				Expect(err).NotTo(HaveOccurred())
			})

			By("the service should be deregistered", func() {
				Eventually(func() ([]string, error) {
					return tcClient.DNS("some-service-name.service.cf.internal")
				}, "1m", "10s").Should(BeEmpty())
			})

			By("causing the health check to succeed", func() {