func startRedisAndBlockUntilUp() (*gexec.Session, string) {
	session, connection := startRedis(redisConfPath)

	_, err := connection.Do("SET", "TEST-KEY", "TEST-VALUE")
	Ω(err).ShouldNot(HaveOccurred())

	_, err = connection.Do("CONFIG", "SET", "maxmemory-policy", "allkeys-lru")
	Ω(err).ShouldNot(HaveOccurred())

	cwd, err := os.Getwd()
	Ω(err).ShouldNot(HaveOccurred())
	aofPath := filepath.Join(cwd, "appendonly.aof")

	Eventually(redisNotWritingAof(connection)).Should(BeTrue())
	Expect(helpers.FileExists(aofPath)).To(BeTrue())

	return session, aofPath
}
var _ = Describe("Startup", func() {
	var agentSession *gexec.Session

	AfterEach(func() {
		stopAgent(agentSession)
	})

	Context("when there is no redis.conf", func() {
		BeforeEach(func() {
			os.Remove(redisConfPath)
			agentSession = startAgent()
		})

		loadRedisConfFileWhenItExists := func() redisconf.Conf {
			Eventually(func() bool {
				return helpers.FileExists(redisConfPath)
			}).Should(BeTrue())
			conf, err := redisconf.Load(redisConfPath)
			Expect(err).ToNot(HaveOccurred())
			return conf
		}

		It("copies a redis.conf from the default path and adds a password", func() {
			conf := loadRedisConfFileWhenItExists()

			Expect(conf.Get("daemonize")).To(Equal("no"))
			Expect(conf.HasKey("requirepass")).To(BeTrue())
		})

		It("creates a new password each time", func() {
			initialConf := loadRedisConfFileWhenItExists()