func startAgent() *gexec.Session { config := &agentconfig.Config{ DefaultConfPath: helpers.AssetPath("redis.conf.default"), ConfPath: redisConfPath, MonitExecutablePath: helpers.AssetPath("fake_monit"), Port: "9876", AuthConfiguration: agentconfig.AuthConfiguration{ Username: "******", Password: "******", }, } configFile, err := ioutil.TempFile("", "config.yml") Expect(err).ToNot(HaveOccurred()) encoder := candiedyaml.NewEncoder(configFile) err = encoder.Encode(config) Ω(err).ShouldNot(HaveOccurred()) configFile.Close() agentPath, err := gexec.Build("github.com/pivotal-cf/cf-redis-broker/cmd/agent") Ω(err).ShouldNot(HaveOccurred()) session, err := gexec.Start( exec.Command(agentPath, fmt.Sprintf("-agentConfig=%s", configFile.Name())), GinkgoWriter, GinkgoWriter, ) Ω(err).ShouldNot(HaveOccurred()) Expect(helpers.ServiceAvailable(9876)).To(BeTrue()) return session }
func LoadBrokerConfig(brokerFilename string) brokerconfig.Config { brokerConfigPath := helpers.AssetPath(brokerFilename) brokerConfig, err := brokerconfig.ParseConfig(brokerConfigPath) Ω(err).NotTo(HaveOccurred()) return brokerConfig }
func launchProcessWithBrokerConfig(executablePath string, brokerConfigName string) *gexec.Session { brokerConfigFile := helpers.AssetPath(brokerConfigName) os.Setenv("BROKER_CONFIG_PATH", brokerConfigFile) processCmd := exec.Command(executablePath) processCmd.Stdout = GinkgoWriter processCmd.Stderr = GinkgoWriter return runCommand(processCmd) }
func getRedisProcessCount() int { scriptPath := helpers.AssetPath("redis_process_count.sh") output, cmdErr := exec.Command(scriptPath).Output() Ω(cmdErr).NotTo(HaveOccurred()) result, numberParseErr := strconv.Atoi(strings.TrimSpace(string(output))) Ω(numberParseErr).NotTo(HaveOccurred()) return result }
"path/filepath" "time" goamz "github.com/goamz/goamz/s3" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-cf/cf-redis-broker/integration" "github.com/pivotal-cf/cf-redis-broker/integration/helpers" "github.com/pivotal-cf/cf-redis-broker/s3" "github.com/pivotal-golang/lager" ) var _ = Describe("backups", func() { Context("when config is invalid", func() { It("exits with status code 78", func() { configFile := helpers.AssetPath("invalid-backup.yml") backupExitCode := runBackup(configFile) Expect(backupExitCode).Should(Equal(78)) }) }) Context("when S3 is not configured", func() { It("exits with status code 0", func() { configFile := helpers.AssetPath("empty-backup.yml") backupExitCode := runBackup(configFile) Expect(backupExitCode).Should(Equal(0)) }) }) Context("when S3 is configured correctly", func() { var (
func copyOverFromAssets(fileName, dir string) { assetPath := helpers.AssetPath(fileName) data, _ := ioutil.ReadFile(assetPath) ioutil.WriteFile(path.Join(dir, fileName), data, 0644) }