RunSpecs(t, "Integration Suite")
}

var _ = BeforeSuite(func() {
	var err error
	pathToBinary, err = gexec.Build("github.com/pivotal-cf/redis-cpu")
	Expect(err).ToNot(HaveOccurred())

	redisRunner = new(integration.RedisRunner)

	redisRunner.Dir, err = ioutil.TempDir("", "redis")
	Expect(err).ToNot(HaveOccurred())

	redisRunner.Start([]string{
		"--bind", redisHost,
		"--port", redisPort,
		"--requirepass", redisPassword,
	})
})

var _ = AfterSuite(func() {
	gexec.CleanupBuildArtifacts()
	redisRunner.Stop()
})

func runBinary(params ...string) *gexec.Session {
	command := exec.Command(pathToBinary, params...)
	session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
	Expect(err).ToNot(HaveOccurred())
	session.Wait()
	return session
var (
	s3Server         *s3test.Server
	redisRunner      *integration.RedisRunner
	backupErr        error
	uploadedObject   []byte
	localDumpRdbPath string
	tmpDir           string
)

var _ = BeforeSuite(func() {
	redisHost := "127.0.0.1"
	redisPort := integration.RedisPort

	redisRunner = &integration.RedisRunner{}
	redisRunner.Start([]string{"--bind", redisHost, "--port", fmt.Sprintf("%d", redisPort)})

	localDumpRdbPath = filepath.Join(redisRunner.Dir, "dump.rdb")

	var err error
	s3Server, err = s3test.NewServer(&s3test.Config{
		Send409Conflict: true,
	})
	Expect(err).ToNot(HaveOccurred())

	logger := lager.NewLogger("logger")

	client, err := redis.Connect(redis.Host(redisHost), redis.Port(redisPort))
	Expect(err).ToNot(HaveOccurred())

	Expect(localDumpRdbPath).ToNot(BeAnExistingFile())
Ejemplo n.º 3
0
		Context("when the server is not running", func() {
			It("returns an error", func() {
				_, err := client.Connect(
					client.Host(host),
					client.Port(port),
				)

				// on OS X, "getsockopt:" is also present in the error message from the system
				Ω(err).Should(MatchError(MatchRegexp("dial tcp 127.0.0.1:6480: (getsockopt: )?connection refused")))
			})
		})

		Context("when the server is running", func() {
			JustBeforeEach(func() {
				redisRunner = &integration.RedisRunner{}
				redisRunner.Start(redisArgs)
			})

			AfterEach(func() {
				redisRunner.Stop()
			})

			It("connects with no error", func() {
				_, err := client.Connect(client.Host(host), client.Port(port))
				Ω(err).ShouldNot(HaveOccurred())
			})

			Context("when the server has authentication enabled", func() {
				BeforeEach(func() {
					redisArgs = append(redisArgs, "--requirepass", "hello")
				})