client = startGarden(args...)
		props = garden.Properties{"somename": "somevalue"}

		container, err = client.Create(garden.ContainerSpec{
			Properties: props,
		})
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		Expect(client.DestroyAndStop()).To(Succeed())
		Expect(os.RemoveAll(propertiesDir)).To(Succeed())
	})

	It("can get properties", func() {
		properties, err := container.Properties()
		Expect(err).NotTo(HaveOccurred())
		Expect(properties).To(HaveKeyWithValue("somename", "somevalue"))
	})

	It("can set a single property", func() {
		err := container.SetProperty("someothername", "someothervalue")
		Expect(err).NotTo(HaveOccurred())

		properties, err := container.Properties()
		Expect(err).NotTo(HaveOccurred())
		Expect(properties).To(HaveKeyWithValue("somename", "somevalue"))
		Expect(properties).To(HaveKeyWithValue("someothername", "someothervalue"))
	})

	It("can get a single property", func() {
			It("returns the error", func() {
				_, err := container.Info()
				Ω(err).Should(Equal(disaster))
			})
		})
	})

	Describe("Properties", func() {
		Context("when getting properties succeeds", func() {
			BeforeEach(func() {
				fakeConnection.PropertiesReturns(garden.Properties{"Foo": "bar"}, nil)
			})

			It("returns the properties map", func() {
				result, err := container.Properties()
				Ω(err).ShouldNot(HaveOccurred())
				Ω(result).Should(Equal(garden.Properties{"Foo": "bar"}))
			})
		})

		Context("when getting properties fails", func() {
			disaster := errors.New("oh no!")

			BeforeEach(func() {
				fakeConnection.PropertiesReturns(nil, disaster)
			})

			It("returns the error", func() {
				_, err := container.Properties()
				Ω(err).Should(Equal(disaster))
Exemple #3
0
func hostIfName(container garden.Container) string {
	properties, err := container.Properties()
	Expect(err).NotTo(HaveOccurred())
	return properties["kawasaki.host-interface"]
}
Exemple #4
0
			_, err := client.Create(garden.ContainerSpec{
				Handle:     "handlecake",
				Properties: garden.Properties{"somename": "somevalue"},
			})
			Expect(err).NotTo(HaveOccurred())
		}()

		var lookupContainer garden.Container
		Eventually(func() error {
			var err error
			lookupContainer, err = client.Lookup("handlecake")
			return err
		}, time.Second*10).ShouldNot(HaveOccurred())

		// Properties used to be set after containers were available from lookup
		Expect(lookupContainer.Properties()).To(HaveKeyWithValue("somename", "somevalue"))
	})

	Context("create more containers than the maxkeyring limit", func() {
		BeforeEach(func() {
			Expect(ioutil.WriteFile("/proc/sys/kernel/keys/maxkeys", []byte("10"), 0644)).To(Succeed())
		})

		AfterEach(func() {
			Expect(ioutil.WriteFile("/proc/sys/kernel/keys/maxkeys", []byte("200"), 0644)).To(Succeed())
		})

		It("works", func() {
			containers := make([]garden.Container, 11)
			for i := 0; i < 11; i++ {
				c, err := client.Create(garden.ContainerSpec{})
Exemple #5
0
func containerIP(container garden.Container) string {
	properties, err := container.Properties()
	Expect(err).NotTo(HaveOccurred())
	return properties[gardener.ContainerIPKey]
}