本文整理匯總了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/cf.Cf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Cf函數的具體用法?Golang Cf怎麽用?Golang Cf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Cf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Setup
func (context *ConfiguredContext) Setup() {
cf.AsUser(context.AdminUserContext(), func() {
channel := cf.Cf("create-user", context.regularUserUsername, context.regularUserPassword)
select {
case <-channel.Out.Detect("OK"):
case <-channel.Out.Detect("scim_resource_already_exists"):
case <-time.After(ScaledTimeout(10 * time.Second)):
Fail("failed to create user")
}
definition := quotaDefinition{
Name: context.quotaDefinitionName,
TotalServices: 100,
TotalRoutes: 1000,
MemoryLimit: 10240,
NonBasicServicesAllowed: true,
}
definitionPayload, err := json.Marshal(definition)
Expect(err).ToNot(HaveOccurred())
var response cf.GenericResource
cf.ApiRequest("POST", "/v2/quota_definitions", &response, string(definitionPayload))
context.quotaDefinitionGUID = response.Metadata.Guid
Eventually(cf.Cf("create-org", context.organizationName), ScaledTimeout(60*time.Second)).Should(Exit(0))
Eventually(cf.Cf("set-quota", context.organizationName, definition.Name), ScaledTimeout(60*time.Second)).Should(Exit(0))
})
}
示例2: Destroy
func (b ServiceBroker) Destroy() {
workflowhelpers.AsUser(b.TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("purge-service-offering", b.Service.Name, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
})
b.Delete()
Expect(cf.Cf("delete", b.Name, "-f", "-r").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
}
示例3: ScaleAppInstances
func ScaleAppInstances(appName string, instances int) {
Expect(cf.Cf("scale", appName, "-i", strconv.Itoa(instances)).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
Eventually(func() string {
return string(cf.Cf("app", appName).Wait(DEFAULT_TIMEOUT).Out.Contents())
}, DEFAULT_TIMEOUT*2, 2*time.Second).
Should(ContainSubstring(fmt.Sprintf("instances: %d/%d", instances, instances)))
}
示例4: setUpSpaceWithUserAccess
func setUpSpaceWithUserAccess(uc cf.UserContext) {
spaceSetupTimeout := 10.0
Expect(cf.Cf("create-space", "-o", uc.Org, uc.Space).Wait(spaceSetupTimeout)).To(Exit(0))
Expect(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceManager").Wait(spaceSetupTimeout)).To(Exit(0))
Expect(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceDeveloper").Wait(spaceSetupTimeout)).To(Exit(0))
Expect(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceAuditor").Wait(spaceSetupTimeout)).To(Exit(0))
}
示例5: Teardown
func (c *context) Teardown() {
userOrg := c.RegularUserContext().Org
cf.RestoreUserContext(c.RegularUserContext(), c.shortTimeout, c.originalCfHomeDir, c.currentCfHomeDir)
cf.AsUser(c.AdminUserContext(), c.shortTimeout, func() {
runner.NewCmdRunner(cf.Cf("delete-user", "-f", c.regularUserUsername), c.longTimeout).Run()
// delete-space does not provide an org flag, so we must target the Org first
runner.NewCmdRunner(cf.Cf("target", "-o", userOrg), c.longTimeout).Run()
runner.NewCmdRunner(cf.Cf("delete-space", "-f", c.spaceName), c.longTimeout).Run()
if !c.useExistingOrg {
runner.NewCmdRunner(cf.Cf("delete-org", "-f", c.organizationName), c.longTimeout).Run()
cf.ApiRequest(
"DELETE",
"/v2/quota_definitions/"+c.quotaDefinitionGUID+"?recursive=true",
nil,
c.ShortTimeout(),
)
}
if c.config.CreatePermissiveSecurityGroup {
runner.NewCmdRunner(cf.Cf("delete-security-group", "-f", c.securityGroupName), c.shortTimeout).Run()
}
})
}
示例6: Destroy
func (b ServiceBroker) Destroy() {
cf.AsUser(b.context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
Expect(cf.Cf("purge-service-offering", b.Service.Name, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
b.Delete()
Expect(cf.Cf("delete", b.Name, "-f", "-r").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
}
示例7: Setup
func (context *ConfiguredContext) Setup() {
cf.AsUser(context.AdminUserContext(), func() {
definition := quotaDefinition{
Name: context.quotaDefinitionName,
TotalServices: "100",
TotalRoutes: "1000",
MemoryLimit: "10G",
NonBasicServicesAllowed: true,
}
args := []string{
"create-quota",
context.quotaDefinitionName,
"-m", definition.MemoryLimit,
"-r", definition.TotalRoutes,
"-s", definition.TotalServices,
}
if definition.NonBasicServicesAllowed {
args = append(args, "--allow-paid-service-plans")
}
Expect(cf.Cf(args...).Wait(CF_API_TIMEOUT)).To(Exit(0))
createUserSession := cf.Cf("create-user", context.regularUserUsername, context.regularUserPassword)
createUserSession.Wait(CF_API_TIMEOUT)
if createUserSession.ExitCode() != 0 {
Expect(createUserSession.Out).To(Say("scim_resource_already_exists"))
}
Expect(cf.Cf("create-org", context.organizationName).Wait(CF_API_TIMEOUT)).To(Exit(0))
Expect(cf.Cf("set-quota", context.organizationName, definition.Name).Wait(CF_API_TIMEOUT)).To(Exit(0))
})
}
示例8: runPushTests
func runPushTests(appName, appUrl string, testConfig *smoke.Config) {
if testConfig.SkipSSLValidation {
Expect(runner.Curl("-k", appUrl).Wait(CF_TIMEOUT_IN_SECONDS)).To(Say("It just needed to be restarted!"))
} else {
Expect(runner.Curl(appUrl).Wait(CF_TIMEOUT_IN_SECONDS)).To(Say("It just needed to be restarted!"))
}
instances := 2
maxAttempts := 30
ExpectAppToScale(appName, instances)
ExpectAllAppInstancesToStart(appName, instances, maxAttempts)
ExpectAllAppInstancesToBeReachable(appUrl, instances, maxAttempts)
if testConfig.Cleanup {
Expect(cf.Cf("delete", appName, "-f", "-r").Wait(CF_TIMEOUT_IN_SECONDS)).To(Exit(0))
Eventually(func() *Session {
appStatusSession := cf.Cf("app", appName)
Expect(appStatusSession.Wait(CF_TIMEOUT_IN_SECONDS)).To(Exit(1))
return appStatusSession
}, 5).Should(Say("not found"))
Eventually(func() *Session {
if testConfig.SkipSSLValidation {
return runner.Curl("-k", appUrl).Wait(CF_TIMEOUT_IN_SECONDS)
} else {
return runner.Curl(appUrl).Wait(CF_TIMEOUT_IN_SECONDS)
}
}, 5).Should(Say("404"))
}
}
示例9: EnableDiego
func EnableDiego(appName string) {
cfApp := cf.Cf("app", appName, "--guid")
Expect(cfApp.Wait()).To(Exit(0))
appGuid := strings.TrimSpace(string(cfApp.Out.Contents()))
Expect(appGuid).NotTo(Equal(""))
Eventually(cf.Cf("curl", "/v2/apps/"+appGuid, "-X", "PUT", "-d", `{"diego": true}`)).Should(Exit(0))
}
示例10: AppReport
func AppReport(appName string, timeout time.Duration) {
if appName == "" {
fmt.Println("App name was set to \"\"; skipping app report.")
return
}
Eventually(cf.Cf("app", appName, "--guid"), timeout).Should(Exit())
Eventually(cf.Cf("logs", appName, "--recent"), timeout).Should(Exit())
}
示例11: Delete
func (b ServiceBroker) Delete() {
workflowhelpers.AsUser(b.TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("delete-service-broker", b.Name, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
brokers := cf.Cf("service-brokers").Wait(Config.DefaultTimeoutDuration())
Expect(brokers).To(Exit(0))
Expect(brokers.Out.Contents()).ToNot(ContainSubstring(b.Name))
})
}
示例12: Delete
func (b ServiceBroker) Delete() {
cf.AsUser(b.context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
Expect(cf.Cf("delete-service-broker", b.Name, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
brokers := cf.Cf("service-brokers").Wait(DEFAULT_TIMEOUT)
Expect(brokers).To(Exit(0))
Expect(brokers.Out.Contents()).ToNot(ContainSubstring(b.Name))
})
}
示例13: CreateServiceInstance
func (b ServiceBroker) CreateServiceInstance(instanceName string) string {
Expect(cf.Cf("create-service", b.Service.Name, b.SyncPlans[0].Name, instanceName).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
url := fmt.Sprintf("/v2/service_instances?q=name:%s", instanceName)
serviceInstance := ServiceInstanceResponse{}
curl := cf.Cf("curl", url).Wait(DEFAULT_TIMEOUT)
Expect(curl).To(Exit(0))
json.Unmarshal(curl.Out.Contents(), &serviceInstance)
return serviceInstance.Resources[0].Metadata.Guid
}
示例14: SetBackend
func SetBackend(appName string) {
config := helpers.LoadConfig()
if config.Backend == "diego" {
guid := guidForAppName(appName)
Eventually(cf.Cf("curl", "/v2/apps/"+guid, "-X", "PUT", "-d", `{"diego": true}`), DEFAULT_TIMEOUT).Should(Exit(0))
} else if config.Backend == "dea" {
guid := guidForAppName(appName)
Eventually(cf.Cf("curl", "/v2/apps/"+guid, "-X", "PUT", "-d", `{"diego": false}`), DEFAULT_TIMEOUT).Should(Exit(0))
}
}
示例15: Teardown
func (context *ConfiguredContext) Teardown() {
cf.AsUser(context.AdminUserContext(), func() {
Expect(cf.Cf("delete-user", "-f", context.regularUserUsername).Wait(CF_API_TIMEOUT)).To(Exit(0))
if !context.isPersistent {
Expect(cf.Cf("delete-org", "-f", context.organizationName).Wait(CF_API_TIMEOUT)).To(Exit(0))
Expect(cf.Cf("delete-quota", "-f", context.quotaDefinitionName).Wait(CF_API_TIMEOUT)).To(Exit(0))
}
})
}