Exemple #1
0
func newControllerFromEnv() controller.Controller {
	const atlasBaseURL = "https://atlas.hashicorp.com"
	const boxName = "cloudfoundry/bosh-lite"

	awsRegion := loadOrFail("AWS_DEFAULT_REGION")
	templateBody, err := json.Marshal(templates.DefaultTemplate)
	say.ExitIfError("internal error: unable to marshal CloudFormation template", err)

	webClient := &client.WebClient{}
	jsonClient := client.JSONClient{BaseURL: atlasBaseURL}
	atlasClient := &client.AtlasClient{&jsonClient}
	awsClient, err := aws.New(aws.Config{
		AccessKey:  loadOrFail("AWS_ACCESS_KEY_ID"),
		SecretKey:  loadOrFail("AWS_SECRET_ACCESS_KEY"),
		RegionName: awsRegion,
	})
	say.ExitIfError("internal error: unable to create AWS client", err)
	parallelRunner := &shell.ParallelRunner{Runner: &shell.Runner{}}

	controller := controller.Controller{
		AtlasClient:    atlasClient,
		AWSClient:      awsClient,
		Log:            &CliLogger{},
		WebClient:      webClient,
		ParallelRunner: parallelRunner,

		VagrantBoxName: boxName,
		Region:         awsRegion,
		Template:       string(templateBody),
		SSHPort:        22,
		SSHUser:        "******",
	}

	return controller
}
Exemple #2
0
func TestProctor(t *testing.T) {
	if os.Getenv("SKIP_AWS_TESTS") == "true" {
		say.Println(0, say.Yellow("WARNING: Skipping AWS integration suite"))
		return
	}
	rand.Seed(config.GinkgoConfig.RandomSeed)
	RegisterFailHandler(Fail)
	RunSpecs(t, "AWS Integration Suite")
}

var awsClient *aws.Client

var _ = BeforeSuite(func() {
	var err error
	awsClient, err = aws.New(aws.Config{
		AccessKey:  loadOrFail("AWS_ACCESS_KEY_ID"),
		SecretKey:  loadOrFail("AWS_SECRET_ACCESS_KEY"),
		RegionName: loadOrFail("AWS_DEFAULT_REGION"),
	})
	Expect(err).NotTo(HaveOccurred())
})

func loadOrFail(varName string) string {
	value := os.Getenv(varName)
	if value == "" {
		Fail(fmt.Sprintf("missing value for environment variable '%s'", varName))
	}
	return value
}