Exemple #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,
		})
	}
}
}

func (fakeProcessKiller *fakeProcessKiller) Kill(pid int) error {
	fakeProcessKiller.lastPidKilled = pid
	fakeProcessKiller.killed = true
	return nil
}

type fakeInstanceInformer struct{}

func (*fakeInstanceInformer) InstancePid(instanceId string) (int, error) {
	return 123, nil
}

var _ = Describe("Redis Process Controller", func() {
	var processController *redis.OSProcessController
	var instance *redis.Instance = &redis.Instance{}
	var instanceInformer *fakeInstanceInformer
	var logger *lagertest.TestLogger
	var fakeProcessChecker *fakeProcessChecker = &fakeProcessChecker{}
	var fakeProcessKiller *fakeProcessKiller = &fakeProcessKiller{}
	var commandRunner *system.FakeCommandRunner
	var connectionTimeoutErr error

	BeforeEach(func() {
		connectionTimeoutErr = nil
		instanceInformer = &fakeInstanceInformer{}
		logger = lagertest.NewTestLogger("process-controller")
		commandRunner = &system.FakeCommandRunner{}
	})