Exemplo n.º 1
0
func BuildRedisClientFromConf(conf redisconf.Conf) redis.Conn {
	port, err := strconv.Atoi(conf.Get("port"))
	Ω(err).NotTo(HaveOccurred())

	password := conf.Get("requirepass")

	return BuildRedisClient(uint(port), "localhost", password)
}
func moveDataFor(propertyName, fileName, redisConfFilePath string) error {
	var fileContents []byte
	var redisConf redisconf.Conf
	var err error

	if redisConf, err = redisconf.Load(redisConfFilePath); err != nil {
		return err
	}
	if redisConf.Get(propertyName) != "" {
		os.Remove(fileName)
		return nil
	}

	if fileContents, err = ioutil.ReadFile(fileName); err != nil {
		return err
	}

	redisConf.Set(propertyName, string(fileContents))
	if err = redisConf.Save(redisConfFilePath); err != nil {
		return err
	}
	os.Remove(fileName)
	return nil
}
Exemplo n.º 3
0
			Fail("Test timed out after 10 seconds")
		}

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

		redisConn = helpers.BuildRedisClientFromConf(conf)
	})

	AfterEach(func() {
		stopAgent(agentSession)
		stopRedisAndDeleteData(redisConn, aofPath)
	})

	It("no longer uses the original password", func() {
		password := originalRedisConf.Get("requirepass")
		port := originalRedisConf.Get("port")
		uri := fmt.Sprintf("127.0.0.1:%s", port)
		redisConn, err := redis.Dial("tcp", uri)
		Ω(err).ShouldNot(HaveOccurred())

		_, err = redisConn.Do("AUTH", password)
		Ω(err).Should(MatchError("ERR invalid password"))
	})

	It("resets the configuration", func() {
		config, err := redis.Strings(redisConn.Do("CONFIG", "GET", "maxmemory-policy"))

		Ω(err).ShouldNot(HaveOccurred())
		Ω(config[1]).Should(Equal("noeviction"))
	})
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/pivotal-cf/cf-redis-broker/redisconf"
)

var _ = Describe("redisconf", func() {
	Describe("InitForDedicatedNode", func() {
		var conf redisconf.Conf

		BeforeEach(func() {
			path, err := filepath.Abs(path.Join("assets", "redis.conf"))
			Expect(err).ToNot(HaveOccurred())
			conf, err = redisconf.Load(path)
			Expect(err).ToNot(HaveOccurred())
			Expect(conf.Get("maxmemory")).To(BeEmpty())
			Expect(conf.Password()).To(BeEmpty())
		})

		It("sets the max memory parameter", func() {
			err := conf.InitForDedicatedNode()
			Expect(err).ToNot(HaveOccurred())

			maxmemory := conf.Get("maxmemory")
			Expect(maxmemory).ToNot(BeEmpty())

			_, err = strconv.Atoi(maxmemory)
			Expect(err).ToNot(HaveOccurred())
		})

		Context("called without password", func() {