Example #1
0
func startRedis(confPath string) (*gexec.Session, redis.Conn) {
	redisSession, err := gexec.Start(exec.Command("redis-server", confPath), GinkgoWriter, GinkgoWriter)
	Ω(err).ShouldNot(HaveOccurred())

	conf, err := redisconf.Load(confPath)
	Ω(err).ShouldNot(HaveOccurred())

	port, err := strconv.Atoi(conf.Get("port"))
	Ω(err).ShouldNot(HaveOccurred())

	Expect(helpers.ServiceAvailable(uint(port))).To(BeTrue())
	return redisSession, helpers.BuildRedisClient(uint(port), "localhost", conf.Get("requirepass"))
}
			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)
			password = credentials["password"].(string)

			client = helpers.BuildRedisClient(port, host, password)
		})

		AfterEach(func() {
			helpers.KillProcess(monitorSession)
			client.Close()
			brokerClient.DeprovisionInstance(instanceID)
		})

		It("is restarted", func() {
			_, err := client.Do("SET", "foo", "bar")
			Ω(err).ShouldNot(HaveOccurred())

			helpers.KillRedisProcess(instanceID, brokerConfig)

			Ω(helpers.ServiceAvailable(port)).Should(BeTrue())