)

var _ = Describe("restarting processes", func() {
	Context("when an instance is provisioned, bound, and has data written to it", func() {
		var instanceID string
		var host string
		var port uint
		var password string
		var client redisclient.Conn

		processMonitorPath := helpers.BuildExecutable("github.com/pivotal-cf/cf-redis-broker/cmd/processmonitor")

		configCommand := "CONFIG"

		BeforeEach(func() {
			monitorSession = integration.LaunchProcessWithBrokerConfig(processMonitorPath, "broker.yml")

			instanceID = uuid.NewRandom().String()
			statusCode, _ := brokerClient.ProvisionInstance(instanceID, "shared")
			Ω(statusCode).To(Equal(201))

			bindingID := uuid.NewRandom().String()
			statusCode, body := brokerClient.BindInstance(instanceID, bindingID)
			Ω(statusCode).To(Equal(201))

			var parsedJSON map[string]interface{}
			json.Unmarshal(body, &parsedJSON)

			credentials := parsedJSON["credentials"].(map[string]interface{})
			port = uint(credentials["port"].(float64))
			host = credentials["host"].(string)
func relaunchProcessMonitorWithConfig(processMonitorPath, brokerConfigName string) {
	helpers.KillProcess(monitorSession)
	monitorSession = integration.LaunchProcessWithBrokerConfig(processMonitorPath, brokerConfigName)
}
Пример #3
0
package brokerintegration_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
	"github.com/pivotal-cf/cf-redis-broker/integration"
)

var _ = Describe("broker cmd", func() {
	It("fails with non zero status code if unable to bind to required port", func() {
		newBrokerSession := integration.LaunchProcessWithBrokerConfig(brokerExecutablePath, "broker.yml")
		Eventually(newBrokerSession).Should(gexec.Exit())
		Expect(newBrokerSession.ExitCode()).NotTo(Equal(0))
	})

	It("logs a useful error message if unable to bind to require port", func() {
		newBrokerSession := integration.LaunchProcessWithBrokerConfig(brokerExecutablePath, "broker.yml")
		Eventually(newBrokerSession).Should(gexec.Exit())
		Eventually(newBrokerSession.Err).Should(gbytes.Say("bind: address already in use"))
	})
})
Пример #4
0
package brokerintegration_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
	"github.com/pivotal-cf/cf-redis-broker/integration"
	"github.com/pivotal-cf/cf-redis-broker/integration/helpers"
)

var _ = Describe("Broker Integration", func() {
	var broker *gexec.Session

	BeforeEach(func() {
		broker = integration.LaunchProcessWithBrokerConfig(brokerExecutablePath, "broker.yml-colocated")
		Eventually(broker.Out).Should(gbytes.Say("shared Redis instance"))
	})

	AfterEach(func() {
		helpers.KillProcess(broker)
	})

	JustBeforeEach(func() {
		helpers.KillProcess(broker)
	})

	Context("when the Redis broker is shutdown", func() {
		It("logs a shutdown preparation message", func() {
			Expect(broker.Out).To(gbytes.Say("Starting Redis Broker shutdown"))
		})
	"github.com/onsi/gomega/gexec"
	"github.com/pborman/uuid"
	"github.com/pivotal-cf/cf-redis-broker/integration"
	"github.com/pivotal-cf/cf-redis-broker/integration/helpers"
)

var sourcePath = "github.com/pivotal-cf/cf-redis-broker/cmd/processmonitor"

var _ = Describe("processmonitor cmd", func() {
	Describe("Log output", func() {
		var monitorSession *gexec.Session
		processMonitorPath := helpers.BuildExecutable(sourcePath)

		Context("When there are no Redis instances provisioned", func() {
			BeforeEach(func() {
				monitorSession = integration.LaunchProcessWithBrokerConfig(processMonitorPath, "broker.yml")
			})

			AfterEach(func() {
				helpers.KillProcess(monitorSession)
			})

			It("logs 0 instances found", func() {
				Eventually(monitorSession.Buffer()).Should(gbytes.Say("0 shared Redis instances found"))
			})
		})

		Context("When there is a single Redis instance provisioned", func() {
			instanceUuid := uuid.NewRandom().String()

			BeforeEach(func() {
Пример #6
0
	var instanceID string

	BeforeEach(func() {
		instanceID = uuid.NewRandom().String()
		brokerClient.ProvisionInstance(instanceID, "dedicated")
	})

	AfterEach(func() {
		brokerClient.DeprovisionInstance(instanceID)
	})

	Context("when the broker is restarted", func() {
		BeforeEach(func() {
			helpers.KillProcess(brokerSession)
			brokerSession = integration.LaunchProcessWithBrokerConfig(brokerExecutablePath, "broker.yml")
			Ω(helpers.ServiceAvailable(brokerPort)).Should(BeTrue())
		})

		It("retains state", func() {
			debugInfo := getDebugInfo()

			Ω(debugInfo.Allocated.Count).Should(Equal(1))
			Ω(len(debugInfo.Allocated.Clusters)).Should(Equal(1))

			host := debugInfo.Allocated.Clusters[0].Hosts[0]
			Ω(host).Should(MatchRegexp("server[1-3]\\.127\\.0\\.0\\.1\\.xip\\.io"))

			Ω(debugInfo.Pool.Clusters).ShouldNot(ContainElement([]string{host}))
		})
	})
Пример #7
0
func switchBroker(config string) {
	helpers.KillProcess(brokerSession)
	helpers.ResetTestDirs()
	brokerSession = integration.LaunchProcessWithBrokerConfig(brokerExecutablePath, config)
	Ω(helpers.ServiceAvailable(brokerPort)).Should(BeTrue())
}