예제 #1
0
				Expect(consulInstanceGroup.Name).To(Equal("consul"))
			})

			Context("failure cases", func() {
				It("errors out when it cannot find the instance group", func() {
					_, err := manifest.GetInstanceGroup("non-existing-job")
					Expect(err).To(MatchError(`instance group "non-existing-job" does not exist`))
				})
			})
		})
	})

	Context("Manifest V1", func() {
		Describe("SetConsulJobInstanceCount", func() {
			var (
				manifest consul.Manifest
			)

			BeforeEach(func() {
				var err error
				manifest, err = consul.NewManifest(consul.Config{
					Networks: []consul.ConfigNetwork{
						{
							IPRange: "10.244.4.0/24",
							Nodes:   1,
						},
					},
				}, iaas.NewWardenConfig())
				Expect(err).NotTo(HaveOccurred())
			})
						},
					},
				}, iaas.NewWardenConfig())
				Expect(err).To(MatchError("can't allocate 9 ips from 8 available ips"))
			})
		})
	})

	Describe("ConsulMembers", func() {
		Context("when there is a single job with a single instance", func() {
			It("returns a list of members in the cluster", func() {
				manifest := consul.Manifest{
					Jobs: []core.Job{
						{
							Instances: 1,
							Networks: []core.JobNetwork{{
								StaticIPs: []string{"10.244.4.2"},
							}},
						},
					},
				}

				members := manifest.ConsulMembers()
				Expect(members).To(Equal([]consul.ConsulMember{{
					Address: "10.244.4.2",
				}}))
			})
		})

		Context("when there are multiple jobs with multiple instances", func() {
			It("returns a list of members in the cluster", func() {
				manifest := consul.Manifest{