Пример #1
0
		BeforeEach(func() {
			var err error
			manifest, err = consul.NewManifestV2(consul.ConfigV2{
				AZs: []consul.ConfigAZ{
					{
						IPRange: "10.244.4.0/24",
						Nodes:   1,
						Name:    "z1",
					},
				},
			}, iaas.NewWardenConfig())
			Expect(err).NotTo(HaveOccurred())
		})
		Describe("SetInstanceCount", func() {
			It("updates the instance count", func() {
				newManifest, err := manifest.SetInstanceCount("consul", 3)
				Expect(err).NotTo(HaveOccurred())

				consulInstanceGroup, err := newManifest.GetInstanceGroup("consul")
				Expect(err).NotTo(HaveOccurred())

				Expect(consulInstanceGroup.Instances).To(Equal(3))
				Expect(len(consulInstanceGroup.Networks[0].StaticIPs)).To(Equal(3))
			})

			It("updates static ips to empty slice if instance count is 0", func() {
				newManifest, err := manifest.SetInstanceCount("consul", 0)
				Expect(err).NotTo(HaveOccurred())

				consulInstanceGroup, err := newManifest.GetInstanceGroup("consul")
				Expect(err).NotTo(HaveOccurred())
		}, "1m", "10s").Should(ConsistOf(helpers.GetVMsFromManifest(manifest)))

		tcClient = testconsumerclient.New(fmt.Sprintf("http://%s:6769", manifest.InstanceGroups[1].Networks[0].StaticIPs[0]))
	})

	AfterEach(func() {
		if !CurrentGinkgoTestDescription().Failed {
			err := boshClient.DeleteDeployment(manifest.Name)
			Expect(err).NotTo(HaveOccurred())
		}
	})

	Context("with an operator defined check script", func() {
		It("deregisters a service if the health check fails", func() {
			By("registering a service", func() {
				manifest, err := manifest.SetInstanceCount("test_consumer", 3)
				Expect(err).NotTo(HaveOccurred())
				manifest.InstanceGroups[0].Properties.Consul.Agent.Services = core.JobPropertiesConsulAgentServices{
					"some-service": core.JobPropertiesConsulAgentService{
						Name: "some-service-name",
						Check: &core.JobPropertiesConsulAgentServiceCheck{
							Name:     "some-service-check",
							Script:   fmt.Sprintf("curl -f %s", fmt.Sprintf("http://%s:6769/health_check", manifest.InstanceGroups[1].Networks[0].StaticIPs[0])),
							Interval: "10s",
						},
						Tags: []string{"some-service-tag"},
					},
				}
			})

			By("deploying", func() {