Ejemplo n.º 1
0
func ensureRunning(instance *redis.Instance, repo *redis.LocalRepository, processController *redis.OSProcessController, logger lager.Logger) {
	configPath := repo.InstanceConfigPath(instance.ID)
	instanceDataDir := repo.InstanceDataDir(instance.ID)
	pidfilePath := repo.InstancePidFilePath(instance.ID)
	logfilePath := repo.InstanceLogFilePath(instance.ID)

	err := processController.EnsureRunning(instance, configPath, instanceDataDir, pidfilePath, logfilePath)
	if err != nil {
		logger.Fatal("Error starting instance", err, lager.Data{
			"instance": instance.ID,
		})
	}
}
			JustBeforeEach(func() {
				controller = processController
				log = gbytes.NewBuffer()
				controller.Logger.RegisterSink(lager.NewWriterSink(log, lager.DEBUG))
			})

			Context("and is a redis server", func() {
				Context("and is the correct redis instance", func() {
					var err error

					JustBeforeEach(func() {
						processController.PingFunc = func(instance *redis.Instance) error {
							return nil
						}
						err = controller.EnsureRunning(instance, "", "", "", "")
					})

					It("does not return an error", func() {
						Expect(err).NotTo(HaveOccurred())
					})

					It("logs success", func() {
						Eventually(log).Should(gbytes.Say("redis instance already running"))
					})
				})

				Context("and is not the correct redis instance", func() {
					var err error
					var file *os.File