var config restoreconfig.Config

	BeforeEach(func() {
		instanceID = "test_instance"
		sourceRdbPath = filepath.Join("assets", "dump.rdb")
		err := copyFile(filepath.Join("..", "brokerintegration", "assets", "redis.conf"), "/tmp/redis.conf")
		Ω(err).ShouldNot(HaveOccurred())
		err = copyFile(filepath.Join("assets", "monit"), "/tmp/monit")
		Ω(err).ShouldNot(HaveOccurred())
		err = os.Chmod("/tmp/monit", 0755)
		Ω(err).ShouldNot(HaveOccurred())
		monitLogFile = setupMonitLogFile()
	})

	AfterEach(func() {
		pid, err := config.InstancePid(instanceID)
		if err == nil {
			syscall.Kill(pid, syscall.SIGKILL)
		}

		Eventually(redisSession, "20s").Should(gexec.Exit(0))
	})

	Describe("common to plans", func() {
		BeforeEach(func() {
			config = loadRestoreConfig(sharedPlan)
			redisSession = startRedisSession(config, instanceID, sharedPlan)
			restoreCommand = buildRestoreCommand(sourceRdbPath, monitLogFile, instanceID, sharedPlan)
		})

		It("exits with a non zero status if no arguments are provided", func() {
Esempio n. 2
0
				Expect(err).NotTo(HaveOccurred())

				pidfilePath = path.Join(restoreConfig.PidfileDirectory, "instance-id.pid")
				err = ioutil.WriteFile(pidfilePath, []byte("1234"), 0777)
				Expect(err).ToNot(HaveOccurred())
			})

			AfterEach(func() {
				if pidfilePath == "" {
					err := os.Remove(pidfilePath)
					Expect(err).NotTo(HaveOccurred())
				}
			})

			It("Returns instance PID", func() {
				Expect(restoreConfig.InstancePid("instance-id")).To(Equal(1234))
			})
		})

		Describe("#InstancePidFilePath", func() {
			It("Returns the instance PID file path", func() {
				expected := "/tmp/pidfiles/instance-id.pid"
				Expect(restoreConfig.InstancePidFilePath("instance-id")).To(Equal(expected))
			})
		})

		Describe("#InstanceDataDir", func() {
			It("Returns the instance data directory", func() {
				Expect(restoreConfig.InstanceDataDir("instance-id")).To(Equal("/tmp/redis/data/instance-id/db"))
			})
		})