func initiateBrokerConfig(serviceBrokerAppName string) string {
	brokerConfigJson := helpers.CurlApp(serviceBrokerAppName, "/config")

	var brokerConfigMap customMap

	err := json.Unmarshal([]byte(brokerConfigJson), &brokerConfigMap)
	Expect(err).NotTo(HaveOccurred())

	dashboardClientId := generator.PrefixedRandomName("RATS-DASHBOARD-ID-")
	serviceName := generator.PrefixedRandomName("RATS-SERVICE-")
	serviceId := generator.PrefixedRandomName("RATS-SERVICE-ID-")

	services := brokerConfigMap.key("behaviors").key("catalog").key("body")["services"].([]interface{})
	service := services[0].(map[string]interface{})
	service["dashboard_client"].(map[string]interface{})["id"] = dashboardClientId
	service["name"] = serviceName
	service["id"] = serviceId

	plans := service["plans"].([]interface{})

	for i, plan := range plans {
		servicePlanId := generator.PrefixedRandomName(fmt.Sprintf("RATS-SERVICE-PLAN-ID-%d-", i))
		plan.(map[string]interface{})["id"] = servicePlanId
	}

	changedJson, err := json.Marshal(brokerConfigMap)
	Expect(err).NotTo(HaveOccurred())

	helpers.CurlApp(serviceBrokerAppName, "/config", "-X", "POST", "-d", string(changedJson))

	return serviceName
}
Пример #2
0
func NewRegularTestSpace(cfg spaceConfig, quotaLimit string) *TestSpace {
	return NewBaseTestSpace(
		generator.PrefixedRandomName(cfg.GetNamePrefix(), "SPACE"),
		generator.PrefixedRandomName(cfg.GetNamePrefix(), "ORG"),
		generator.PrefixedRandomName(cfg.GetNamePrefix(), "QUOTA"),
		quotaLimit,
		false,
		cfg.GetScaledTimeout(1*time.Minute),
		commandstarter.NewCommandStarter(),
	)
}
Пример #3
0
func pushApp() string {
	appName := generator.PrefixedRandomName("LATS-App-")
	appPush := cf.Cf("push", appName, "-p", "assets/dora").Wait(60 * time.Second)
	Expect(appPush).To(gexec.Exit(0))

	return appName
}
func createServiceInstance(serviceName string) string {
	serviceInstanceName := generator.PrefixedRandomName("RATS-SERVICE-")

	session := cf.Cf("create-service", serviceName, "fake-plan", serviceInstanceName)
	Expect(session.Wait(DEFAULT_TIMEOUT)).To(Exit(0))

	return serviceInstanceName
}
func NewBaseTestSuiteSetup(config testSuiteConfig, testSpace, testUser remoteResource, regularUserContext, adminUserContext UserContext) *ReproducibleTestSuiteSetup {
	shortTimeout := config.GetScaledTimeout(1 * time.Minute)

	return &ReproducibleTestSuiteSetup{
		shortTimeout: shortTimeout,
		longTimeout:  config.GetScaledTimeout(5 * time.Minute),

		organizationName: generator.PrefixedRandomName(config.GetNamePrefix(), "ORG"),
		spaceName:        generator.PrefixedRandomName(config.GetNamePrefix(), "SPACE"),

		regularUserContext: regularUserContext,
		adminUserContext:   adminUserContext,

		isPersistent: false,
		TestSpace:    testSpace,
		TestUser:     testUser,
	}
}
func createServiceBroker() (string, string, string) {
	serviceBrokerAsset := assets.NewAssets().ServiceBroker
	serviceBrokerAppName := PushApp(serviceBrokerAsset, config.RubyBuildpackName)

	serviceName := initiateBrokerConfig(serviceBrokerAppName)

	brokerName := generator.PrefixedRandomName("RATS-BROKER-")
	brokerUrl := helpers.AppUri(serviceBrokerAppName, "")

	config = helpers.LoadConfig()
	context := helpers.NewContext(config)
	cf.AsUser(context.AdminUserContext(), context.ShortTimeout(), func() {
		session := cf.Cf("create-service-broker", brokerName, "user", "password", brokerUrl)
		Expect(session.Wait(DEFAULT_TIMEOUT)).To(Exit(0))

		session = cf.Cf("enable-service-access", serviceName)
		Expect(session.Wait(DEFAULT_TIMEOUT)).To(Exit(0))

	})

	return brokerName, serviceBrokerAppName, serviceName
}
Пример #7
0
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gbytes"
	. "github.com/onsi/gomega/gexec"
)

var _ = Describe("package features", func() {
	var (
		appName            string
		appGuid            string
		packageGuid        string
		spaceGuid          string
		destinationAppGuid string
	)

	BeforeEach(func() {
		appName = generator.PrefixedRandomName("CATS-APP-")
		spaceGuid = GetSpaceGuidFromName(context.RegularUserContext().Space)
		appGuid = CreateApp(appName, spaceGuid, "{}")
		packageGuid = CreatePackage(appGuid)
		token := GetAuthToken()
		uploadUrl := fmt.Sprintf("%s/v3/packages/%s/upload", config.ApiEndpoint, packageGuid)
		UploadPackage(uploadUrl, assets.NewAssets().DoraZip, token)
		WaitForPackageToBeReady(packageGuid)
	})

	AfterEach(func() {
		app_helpers.AppReport(appName, DEFAULT_TIMEOUT)
		DeleteApp(appGuid)
		if destinationAppGuid != "" {
			DeleteApp(destinationAppGuid)
		}
	"github.com/cloudfoundry-incubator/cf-test-helpers/runner"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Recursive Delete", func() {
	var broker ServiceBroker
	var orgName string
	var quotaName string

	BeforeEach(func() {
		broker = NewServiceBroker(
			generator.PrefixedRandomName("rec-del"),
			assets.NewAssets().ServiceBroker,
			context,
		)
		broker.Push()
		broker.Configure()
		broker.Create()
		broker.PublicizePlans()

		orgName = generator.PrefixedRandomName("rec-del")
		quotaName = generator.PrefixedRandomName("rec-del")
		spaceName := generator.PrefixedRandomName("rec-del")
		appName := generator.PrefixedRandomName("rec-del")
		instanceName := generator.PrefixedRandomName("rec-del")

		cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
		runner.NewCmdRunner(curlCmd, DEFAULT_TIMEOUT).Run()
		Expect(string(curlCmd.Err.Contents())).To(HaveLen(0))
		return string(curlCmd.Out.Contents())
	}

	BeforeEach(func() {
		orgName = context.RegularUserContext().Org
		spaceName = context.RegularUserContext().Space

		domainName = generator.RandomName() + "." + helpers.LoadConfig().AppsDomain
		cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
			Expect(cf.Cf("create-shared-domain", domainName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
		})

		appNameDora = generator.PrefixedRandomName("CATS-APP-")
		Expect(cf.Cf("push", appNameDora, "-m", "128M", "-p", assets.NewAssets().Dora, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))

		appNameSimple = generator.PrefixedRandomName("CATS-APP-")
		Expect(cf.Cf("push", appNameSimple, "-m", "128M", "-p", assets.NewAssets().HelloWorld, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
	})

	AfterEach(func() {
		cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
			Expect(cf.Cf("target", "-o", orgName).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
			Expect(cf.Cf("delete-shared-domain", domainName, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		})

		Expect(cf.Cf("delete", appNameDora, "-f", "-r").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		Expect(cf.Cf("delete", appNameSimple, "-f", "-r").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
	})
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
	. "github.com/cloudfoundry/cf-acceptance-tests/helpers/services"
)

var _ = Describe("Service Broker Lifecycle", func() {
	var broker ServiceBroker

	Describe("public brokers", func() {
		var acls *Session
		var output []byte
		var oldServiceName string
		var oldPlanName string

		BeforeEach(func() {
			broker = NewServiceBroker(
				generator.PrefixedRandomName("pblc-brkr-"),
				assets.NewAssets().ServiceBroker,
				context,
			)
			cf.TargetSpace(context.RegularUserContext(), context.ShortTimeout())
			broker.Push()
			broker.Configure()

			cf.AsUser(context.AdminUserContext(), context.ShortTimeout(), func() {
				broker.Create()
			})
		})

		Describe("Updating the catalog", func() {

			BeforeEach(func() {
package verification_test

import (
	. "github.com/cloudfoundry-incubator/bits-service-migration-tests/helpers"
	"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
	"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Buildpacks", func() {
	var appName string

	BeforeEach(func() {
		appName = generator.PrefixedRandomName("BSMT-APP-")
	})

	AfterEach(func() {
		Expect(cf.Cf("delete", appName, "-f", "-r").Wait(defaultTimeout)).To(Exit(0))
	})

	It("uses a previously uploaded buildpack", func() {
		Expect(cf.Cf("push", appName, "--no-start", "-b", BuildpackName, "-p", TestAppPath, "-d", config.AppsDomain).Wait(defaultTimeout)).To(Exit(0))
		SetBackend(appName)
		Expect(cf.Cf("start", appName).Wait(cfPushTimeout)).To(Exit(0))
	})
})
	. "github.com/onsi/gomega/gexec"

	"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
	"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
	"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
)

var _ = Describe("The Elasticsearch service", func() {

	Describe("adding elasticsearch to an app", func() {
		var (
			appName string
		)

		BeforeEach(func() {
			appName = generator.PrefixedRandomName("CATS-APP-")
			Expect(cf.Cf(
				"push", appName,
				"--no-start",
				"-b", config.GoBuildpackName,
				"-p", "../example_apps/es_test_app",
				"-d", config.AppsDomain,
			).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		})

		It("can be added to an app", func() {
			instanceName := generator.PrefixedRandomName("ES-SERVICE-")

			Expect(cf.Cf("create-service", "elasticsearch13", "free", instanceName).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
			Expect(cf.Cf("bind-service", appName, instanceName).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
			Expect(cf.Cf("start", appName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
Пример #13
0
		Expect(plans.Out.Contents()).To(ContainSubstring("M-HA-dedicated-9.5"))
		Expect(plans.Out.Contents()).To(ContainSubstring("L-dedicated-9.5"))
		Expect(plans.Out.Contents()).To(ContainSubstring("L-HA-dedicated-9.5"))
	})

	Context("creating a database instance", func() {
		// Avoid creating additional tests in this block because this setup and teardown is
		// slow (several minutes).

		var (
			appName         string
			dbInstanceName  string
			rdsInstanceName string
		)
		BeforeEach(func() {
			appName = generator.PrefixedRandomName("CATS-APP-")
			dbInstanceName = generator.PrefixedRandomName("test-db-")
			Expect(cf.Cf("create-service", serviceName, testPlanName, dbInstanceName).Wait(DEFAULT_TIMEOUT)).To(Exit(0))

			pollForRDSCreationCompletion(dbInstanceName)

			rdsInstanceName = getRDSInstanceName(dbInstanceName)
			fmt.Fprintf(GinkgoWriter, "Created RDS instance: %s\n", rdsInstanceName)

			Expect(cf.Cf(
				"push", appName,
				"--no-start",
				"-b", config.GoBuildpackName,
				"-p", "../../example-apps/healthcheck",
				"-f", "../../example-apps/healthcheck/manifest.yml",
				"-d", config.AppsDomain,
func PushAppNoStart(asset, buildpackName string) string {
	app := generator.PrefixedRandomName("RATS-APP-")
	Expect(cf.Cf("push", app, "-b", buildpackName, "--no-start", "-m", DEFAULT_MEMORY_LIMIT, "-p", asset, "-d", config.AppsDomain).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
	return app
}
	}

	waitForAsyncOperationToComplete := func(broker ServiceBroker, instanceName string) {
		Eventually(func() *Session {
			serviceDetails := cf.Cf("service", instanceName).Wait(DEFAULT_TIMEOUT)
			Expect(serviceDetails).To(Exit(0), "failed getting service instance details")
			return serviceDetails
		}, ASYNC_OPERATION_TIMEOUT, ASYNC_OPERATION_POLL_INTERVAL).Should(Say("succeeded"))
	}

	type Params struct{ Param1 string }

	Context("Synchronous operations", func() {
		BeforeEach(func() {
			broker = NewServiceBroker(
				generator.PrefixedRandomName("pblc-brkr-"),
				assets.NewAssets().ServiceBroker,
				context,
			)
			broker.Push()
			broker.Configure()
			broker.Create()
			broker.PublicizePlans()
		})

		AfterEach(func() {
			app_helpers.AppReport(broker.Name, DEFAULT_TIMEOUT)

			broker.Destroy()
		})
Пример #16
0
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gexec"
)

var _ = Describe("User services", func() {
	var testConfig = helpers.LoadConfig()
	var appName string

	Describe("When a user-defined service is bound", func() {
		var serviceName string

		BeforeEach(func() {
			appName = generator.PrefixedRandomName("CATS-APP-")
			serviceName = generator.PrefixedRandomName("CUPS-")

			Eventually(cf.Cf(
				"push",
				appName,
				"--no-start",
				"-b", testConfig.RubyBuildpackName,
				"-m", DEFAULT_MEMORY_LIMIT,
				"-p", assets.NewAssets().RubySimple,
				"-d", testConfig.AppsDomain), DEFAULT_TIMEOUT).Should(Exit(0), "Failed to push app")

			app_helpers.SetBackend(appName)
			Expect(cf.Cf("start", appName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))

			Eventually(cf.Cf("cups", serviceName, "-l", "does this matter"), DEFAULT_TIMEOUT).Should(Exit(0), "Failed to create syslog drain service")
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gexec"

	"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
	"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
	"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
)

var _ = Describe("Copy app bits", func() {
	var golangAppName string
	var helloWorldAppName string

	BeforeEach(func() {
		golangAppName = generator.PrefixedRandomName("CATS-APP-")
		helloWorldAppName = generator.PrefixedRandomName("CATS-APP-")

		Expect(cf.Cf("push", golangAppName, "-p", assets.NewAssets().Golang, "--no-start").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		Expect(cf.Cf("push", helloWorldAppName, "-p", assets.NewAssets().HelloWorld, "--no-start").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
	})

	AfterEach(func() {
		Expect(cf.Cf("delete", golangAppName, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		Expect(cf.Cf("delete", helloWorldAppName, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
	})

	It("Copies over the package from the source app to the destination app", func() {
		Expect(cf.Cf("copy-source", helloWorldAppName, golangAppName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))

		Eventually(func() string {
			})

			Context("when arbitrary parameters are sent", func() {
				var (
					brokerName          string
					brokerAppName       string
					serviceInstanceName string
					domain              string
					hostname            string
				)

				BeforeEach(func() {
					var serviceName string
					domain = config.AppsDomain
					spacename := context.RegularUserContext().Space
					hostname = generator.PrefixedRandomName("RATS-HOSTNAME-")

					brokerName, brokerAppName, serviceName = createServiceBroker()
					serviceInstanceName = createServiceInstance(serviceName)

					createRoute(hostname, "", spacename, domain)

					configureBroker(brokerAppName, "")
				})

				AfterEach(func() {
					unbindRouteFromService(hostname, serviceInstanceName)
					deleteServiceInstance(serviceInstanceName)
					deleteServiceBroker(brokerName)
					DeleteRoute(hostname, "", domain)
				})
Пример #19
0
func pushApp(asset string) string {
	app := generator.PrefixedRandomName("RATS-APP-")
	Expect(cf.Cf("push", app, "-p", asset).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
	return app
}
func PushApp(asset string) string {
	app := generator.PrefixedRandomName("RATS-APP-")
	Expect(cf.Cf("push", app, "-m", "128M", "-p", asset, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
	return app
}
Пример #21
0
func CATSRandomName(resource string) string {
	return generator.PrefixedRandomName("CATS", resource)
}
	. "github.com/onsi/gomega/gbytes"
	. "github.com/onsi/gomega/gexec"

	"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
	"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/app_helpers"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
	. "github.com/cloudfoundry/cf-acceptance-tests/helpers/services"
)

var _ = Describe("Purging service offerings", func() {
	var broker ServiceBroker

	BeforeEach(func() {
		broker = NewServiceBroker(
			generator.PrefixedRandomName("ps-"),
			assets.NewAssets().ServiceBroker,
			context,
		)
		broker.Push()
		broker.Configure()
		cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
			broker.Create()
			broker.PublicizePlans()
		})
	})

	AfterEach(func() {
		app_helpers.AppReport(broker.Name, DEFAULT_TIMEOUT)

		broker.Destroy()
			Port int
		}
	}
	type StatsResponse map[string]Stat

	type DoraCurlResponse struct {
		Stdout     string
		Stderr     string
		ReturnCode int `json:"return_code"`
	}

	var serverAppName, securityGroupName, privateHost string
	var privatePort int

	BeforeEach(func() {
		serverAppName = generator.PrefixedRandomName("CATS-APP-")
		Expect(cf.Cf("push", serverAppName, "-m", "128M", "-p", assets.NewAssets().Dora, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))

		// gather app url
		var appsResponse AppsResponse
		cfResponse := cf.Cf("curl", fmt.Sprintf("/v2/apps?q=name:%s", serverAppName)).Wait(DEFAULT_TIMEOUT).Out.Contents()
		json.Unmarshal(cfResponse, &appsResponse)
		serverAppUrl := appsResponse.Resources[0].Metadata.Url

		// gather app stats for dea ip and app port
		var statsResponse StatsResponse
		cfResponse = cf.Cf("curl", fmt.Sprintf("%s/stats", serverAppUrl)).Wait(DEFAULT_TIMEOUT).Out.Contents()
		json.Unmarshal(cfResponse, &statsResponse)

		privateHost = statsResponse["0"].Stats.Host
		privatePort = statsResponse["0"].Stats.Port
	. "github.com/onsi/gomega/gexec"
	archive_helpers "github.com/pivotal-golang/archiver/extractor/test_helper"
)

var _ = Describe("buildpack", func() {
	var (
		appName       string
		appGuid       string
		buildpackName string
		packageGuid   string
		spaceGuid     string
		token         string
	)

	BeforeEach(func() {
		appName = generator.PrefixedRandomName("CATS-APP-")
		spaceGuid = GetSpaceGuidFromName(context.RegularUserContext().Space)
		appGuid = CreateApp(appName, spaceGuid, "{}")
		packageGuid = CreatePackage(appGuid)
		token = GetAuthToken()
		uploadUrl := fmt.Sprintf("%s/v3/packages/%s/upload", config.ApiEndpoint, packageGuid)
		UploadPackage(uploadUrl, assets.NewAssets().DoraZip, token)
		WaitForPackageToBeReady(packageGuid)

		buildpackName = generator.PrefixedRandomName("CATS-BP-")
		buildpackZip := createBuildpack()

		cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
			Expect(cf.Cf("create-buildpack", buildpackName, buildpackZip, "999").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		})
	})
Пример #25
0
	})

	for _, event := range response.Resources {
		if event.Entity.AppName == appName && event.Entity.State == state {
			return true, event
		}
	}

	return false, AppUsageEvent{}
}

var _ = Describe("Application Lifecycle", func() {
	var appName string

	BeforeEach(func() {
		appName = generator.PrefixedRandomName("CATS-APP-")

		Expect(cf.Cf("push", appName, "--no-start", "-b", config.RubyBuildpackName, "-m", DEFAULT_MEMORY_LIMIT, "-p", assets.NewAssets().Dora, "-d", config.AppsDomain).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		app_helpers.SetBackend(appName)
		Expect(cf.Cf("start", appName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
	})

	AfterEach(func() {
		app_helpers.AppReport(appName, DEFAULT_TIMEOUT)

		Expect(cf.Cf("delete", appName, "-f", "-r").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
	})

	Describe("pushing", func() {
		It("makes the app reachable via its bound route", func() {
			Eventually(func() string {
	"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/app_helpers"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
	. "github.com/cloudfoundry/cf-acceptance-tests/helpers/services"
)

var _ = Describe("SSO Lifecycle", func() {
	var broker ServiceBroker
	var config OAuthConfig
	var apiEndpoint = helpers.LoadConfig().ApiEndpoint

	redirectUri := `http://example.com`

	BeforeEach(func() {
		broker = NewServiceBroker(
			generator.PrefixedRandomName("sso-lifecycle-"),
			assets.NewAssets().ServiceBroker,
			context,
		)
		broker.Push()
		broker.Service.DashboardClient.RedirectUri = redirectUri
		broker.Configure()

		config = OAuthConfig{}
		config.ClientId = broker.Service.DashboardClient.ID
		config.ClientSecret = broker.Service.DashboardClient.Secret
		config.RedirectUri = redirectUri
		config.RequestedScopes = `openid,cloud_controller_service_permissions.read`

		SetOauthEndpoints(apiEndpoint, &config)