本文整理匯總了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/helpers.CurlApp函數的典型用法代碼示例。如果您正苦於以下問題:Golang CurlApp函數的具體用法?Golang CurlApp怎麽用?Golang CurlApp使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CurlApp函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: configureBroker
func configureBroker(serviceBrokerAppName, routeServiceName string) {
brokerConfigJson := helpers.CurlApp(serviceBrokerAppName, "/config")
var brokerConfigMap customMap
err := json.Unmarshal([]byte(brokerConfigJson), &brokerConfigMap)
Expect(err).NotTo(HaveOccurred())
if routeServiceName != "" {
routeServiceUrl := helpers.AppUri(routeServiceName, "/")
url, err := url.Parse(routeServiceUrl)
Expect(err).NotTo(HaveOccurred())
url.Scheme = "https"
routeServiceUrl = url.String()
brokerConfigMap.key("behaviors").key("bind").key("default").key("body")["route_service_url"] = routeServiceUrl
} else {
body := brokerConfigMap.key("behaviors").key("bind").key("default").key("body")
delete(body, "route_service_url")
}
changedJson, err := json.Marshal(brokerConfigMap)
Expect(err).NotTo(HaveOccurred())
helpers.CurlApp(serviceBrokerAppName, "/config", "-X", "POST", "-d", string(changedJson))
}
示例2: initiateBrokerConfig
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
}
示例3: getAppContainerIpAndPort
func getAppContainerIpAndPort(appName string) (string, int) {
curlResponse := helpers.CurlApp(Config, appName, "/myip")
containerIp := strings.TrimSpace(curlResponse)
curlResponse = helpers.CurlApp(Config, appName, "/env/VCAP_APPLICATION")
var env map[string]interface{}
err := json.Unmarshal([]byte(curlResponse), &env)
Expect(err).NotTo(HaveOccurred())
containerPort := int(env["port"].(float64))
return containerIp, containerPort
}
示例4: curlAppHeaders
func curlAppHeaders(appName, path string, args ...string) textproto.MIMEHeader {
curlResponse := helpers.CurlApp(appName, path, append(args, "-I")...)
reader := textproto.NewReader(bufio.NewReader(bytes.NewBufferString(curlResponse)))
reader.ReadLine()
m, err := reader.ReadMIMEHeader()
Expect(err).ShouldNot(HaveOccurred())
return m
}
示例5:
Expect(cf.Cf(
"push", appName,
"--no-start",
"-b", config.RubyBuildpackName,
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().Dora,
"-d", helpers.LoadConfig().AppsDomain,
"-c", "FOO=foo bundle exec rackup config.ru -p $PORT",
).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
app_helpers.SetBackend(appName)
Expect(cf.Cf("start", appName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
})
It("takes effect after a restart, not requiring a push", func() {
Eventually(func() string {
return helpers.CurlApp(appName, "/env/FOO")
}, DEFAULT_TIMEOUT).Should(ContainSubstring("foo"))
var response cf.QueryResponse
cf.ApiRequest("GET", "/v2/apps?q=name:"+appName, &response, DEFAULT_TIMEOUT)
Expect(response.Resources).To(HaveLen(1))
appGuid := response.Resources[0].Metadata.Guid
cf.ApiRequest(
"PUT",
"/v2/apps/"+appGuid,
nil,
DEFAULT_TIMEOUT,
示例6:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe(deaUnsupportedTag+"Docker Application Lifecycle", func() {
var appName string
JustBeforeEach(func() {
app_helpers.SetBackend(appName)
By("downloading from dockerhub (starting the app)")
Eventually(cf.Cf("start", appName), CF_PUSH_TIMEOUT).Should(Exit(0))
Eventually(func() string {
return helpers.CurlApp(appName, "/env/INSTANCE_INDEX")
}, DEFAULT_TIMEOUT).Should(Equal("0"))
})
AfterEach(func() {
app_helpers.AppReport(appName, DEFAULT_TIMEOUT)
Eventually(cf.Cf("delete", appName, "-f"), DEFAULT_TIMEOUT).Should(Exit(0))
})
Describe("running a docker app with a start command", func() {
BeforeEach(func() {
appName = generator.PrefixedRandomName("CATS-APP-")
Eventually(cf.Cf(
"push", appName,
"--no-start",
// app is defined by cloudfoundry-incubator/diego-dockerfiles
示例7:
package wats
import (
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Application Lifecycle", func() {
Describe("An app staged on Diego and running on Diego", func() {
It("exercises the app through its lifecycle", func() {
By("pushing it")
Eventually(pushNoraWithOptions(appName, 1, "256m"), CF_PUSH_TIMEOUT).Should(Succeed())
By("staging and running it on Diego")
enableDiego(appName)
Eventually(runCf("start", appName), CF_PUSH_TIMEOUT).Should(Succeed())
By("attempting to leak more memory than allowed")
// leak 300mb
response := helpers.CurlApp(appName, "/leakmemory/300")
Expect(response).To(ContainSubstring("Insufficient memory"))
})
})
})
示例8:
AfterEach(func() {
Expect(cf.Cf("delete", serverAppName, "-f").Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
})
// this test assumes the default running security groups block access to the DEAs
// the test takes advantage of the fact that the DEA ip address and internal container ip address
// are discoverable via the cc api and dora's myip endpoint
It("allows previously-blocked ip traffic after applying a security group, and re-blocks it when the group is removed", func() {
clientAppName := generator.PrefixedRandomName("CATS-APP-")
Expect(cf.Cf("push", clientAppName, "-m", "128M", "-p", assets.NewAssets().Dora, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
defer func() { cf.Cf("delete", clientAppName, "-f").Wait(CF_PUSH_TIMEOUT) }()
By("Gathering container ip")
curlResponse := helpers.CurlApp(serverAppName, "/myip")
containerIp := strings.TrimSpace(curlResponse)
By("Testing app egress rules")
var doraCurlResponse DoraCurlResponse
curlResponse = helpers.CurlApp(clientAppName, fmt.Sprintf("/curl/%s/%d", privateHost, privatePort))
json.Unmarshal([]byte(curlResponse), &doraCurlResponse)
Expect(doraCurlResponse.ReturnCode).ToNot(Equal(0))
By("Applying security group")
rules := fmt.Sprintf(
`[{"destination":"%s","ports":"%d","protocol":"tcp"},
{"destination":"%s","ports":"%d","protocol":"tcp"}]`,
privateHost, privatePort, containerIp, privatePort)
file, _ := ioutil.TempFile(os.TempDir(), "CATS-sg-rules")
示例9:
if process.Type == "web" {
webProcess = process
} else if process.Type == "worker" {
workerProcess = process
}
}
CreateAndMapRoute(appGuid, context.RegularUserContext().Space, helpers.LoadConfig().AppsDomain, webProcess.Name)
StartApp(appGuid)
Eventually(func() string {
return helpers.CurlAppRoot(webProcess.Name)
}, DEFAULT_TIMEOUT).Should(ContainSubstring("Hi, I'm Dora!"))
output := helpers.CurlApp(webProcess.Name, "/env")
Expect(output).To(ContainSubstring(fmt.Sprintf("application_name\\\":\\\"%s", appName)))
Expect(output).To(ContainSubstring(appCreationEnvironmentVariables))
Expect(cf.Cf("apps").Wait(DEFAULT_TIMEOUT)).To(Say(fmt.Sprintf("%s\\s+started", webProcess.Name)))
Expect(cf.Cf("apps").Wait(DEFAULT_TIMEOUT)).To(Say(fmt.Sprintf("%s\\s+started", workerProcess.Name)))
usageEvents := lastPageUsageEvents(appName)
event1 := AppUsageEvent{Entity{ProcessType: webProcess.Type, AppGuid: webProcess.Guid, State: "STARTED", ParentAppGuid: appGuid, ParentAppName: appName}}
event2 := AppUsageEvent{Entity{ProcessType: workerProcess.Type, AppGuid: workerProcess.Guid, State: "STARTED", ParentAppGuid: appGuid, ParentAppName: appName}}
Expect(eventsInclude(usageEvents, event1)).To(BeTrue())
Expect(eventsInclude(usageEvents, event2)).To(BeTrue())
StopApp(appGuid)
示例10:
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)).Should(Exit(0))
})
It("doesn't die when printing 32MB", func() {
beforeId := helpers.CurlApp(appName, "/id")
Expect(helpers.CurlAppWithTimeout(appName, "/logspew/32000", LONG_CURL_TIMEOUT)).
To(ContainSubstring("Just wrote 32000 kbytes to the log"))
// Give time for components (i.e. Warden) to react to the output
// and potentially make bad decisions (like killing the app)
time.Sleep(10 * time.Second)
afterId := helpers.CurlApp(appName, "/id")
Expect(beforeId).To(Equal(afterId))
})
})
示例11:
package wats
import (
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("A running application", func() {
BeforeEach(func() {
pushAndStartNora(appName)
})
AfterEach(func() {
Eventually(cf.Cf("logs", appName, "--recent")).Should(gexec.Exit())
Eventually(cf.Cf("delete", appName, "-f")).Should(gexec.Exit(0))
})
It("can show crash events", func() {
helpers.CurlApp(appName, "/exit")
Eventually(func() string {
return string(cf.Cf("events", appName).Wait(CF_PUSH_TIMEOUT).Out.Contents())
}, CF_PUSH_TIMEOUT).Should(ContainSubstring("Exited"))
})
})
示例12:
BeforeEach(func() {
appName = generator.PrefixedRandomName("CATS-APP-")
Expect(cf.Cf("push", appName, "-p", assets.NewAssets().Java, "--no-start", "-m", "512M").Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
Expect(cf.Cf("set-env", appName, "JAVA_OPTS", "-Djava.security.egd=file:///dev/urandom").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
Expect(cf.Cf("start", appName).Wait(CF_JAVA_TIMEOUT)).To(Exit(0))
})
AfterEach(func() {
Expect(cf.Cf("delete", appName, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
It("Does not corrupt UTF-8 characters in filenames", func() {
var curlResponse string
Eventually(func() string {
curlResponse = helpers.CurlApp(appName, "/omega")
return curlResponse
}, DEFAULT_TIMEOUT).Should(ContainSubstring("It's Ω!"))
Expect(curlResponse).To(ContainSubstring("File encoding is UTF-8"))
})
Describe("Routing", func() {
It("Supports URLs with percent-encoded characters", func() {
var curlResponse string
Eventually(func() string {
curlResponse = helpers.CurlApp(appName, "/requesturi/%21%7E%5E%24%20%27%28%29?foo=bar+baz%20bing")
return curlResponse
}, DEFAULT_TIMEOUT).Should(ContainSubstring("You requested some information about rio rancho properties"))
Expect(curlResponse).To(ContainSubstring("/requesturi/%21%7E%5E%24%20%27%28%29"))
Expect(curlResponse).To(ContainSubstring("Query String is [foo=bar+baz%20bing]"))
})
示例13:
MapRouteToApp(domain, app2Path, app2)
MapRouteToApp(domain, app3Path, app3)
})
AfterEach(func() {
app_helpers.AppReport(app1, DEFAULT_TIMEOUT)
app_helpers.AppReport(app2, DEFAULT_TIMEOUT)
app_helpers.AppReport(app3, DEFAULT_TIMEOUT)
DeleteApp(app1)
DeleteApp(app2)
DeleteApp(app3)
})
Context("when another app has a route with a context path", func() {
It("routes to app with context path", func() {
Eventually(func() string {
return helpers.CurlAppRoot(domain)
}, DEFAULT_TIMEOUT).Should(ContainSubstring(app1))
Eventually(func() string {
return helpers.CurlApp(domain, app2Path)
}, DEFAULT_TIMEOUT).Should(ContainSubstring(app2))
Eventually(func() string {
return helpers.CurlApp(domain, app3Path)
}, DEFAULT_TIMEOUT).Should(ContainSubstring(app3))
})
})
})
示例14:
appName = random_name.CATSRandomName("APP")
envVarName = fmt.Sprintf("CATS_RUNNING_TEST_VAR_%s", strconv.Itoa(int(time.Now().UnixNano())))
})
AfterEach(func() {
app_helpers.AppReport(appName, Config.DefaultTimeoutDuration())
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
revertExtendedEnv("running", envVarName)
})
Expect(cf.Cf("delete", appName, "-f", "-r").Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
})
It("Applies correct environment variables while running apps", func() {
envVarValue := fmt.Sprintf("running_env_value_%s", strconv.Itoa(int(time.Now().UnixNano())))
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
extendEnv("running", envVarName, envVarValue)
})
Expect(cf.Cf("push", appName, "--no-start", "-b", Config.GetRubyBuildpackName(), "-m", DEFAULT_MEMORY_LIMIT, "-p", assets.NewAssets().Dora, "-d", Config.GetAppsDomain()).Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
app_helpers.SetBackend(appName)
Expect(cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
env := helpers.CurlApp(Config, appName, "/env")
Expect(env).To(ContainSubstring(envVarValue))
})
})
})
示例15: createEnvBuildpack
return session
}, 1*time.Minute, 10*time.Second).Should(Say("my-service"))
})
})
// TODO Unpend this test once v3 service bindings can be deleted (especially recursively through org delete)
PIt("exposes them during running", func() {
dropletGuid := StagePackage(packageGuid, "{}")
WaitForDropletToStage(dropletGuid)
AssignDropletToApp(appGuid, dropletGuid)
CreateAndMapRoute(appGuid, context.RegularUserContext().Space, config.AppsDomain, appName)
StartApp(appGuid)
Eventually(func() string {
return helpers.CurlApp(appName, "/env")
}, DEFAULT_TIMEOUT).Should(ContainSubstring("my-service"))
})
})
func createEnvBuildpack() string {
tmpPath, err := ioutil.TempDir("", "buildpack-cats")
Expect(err).ToNot(HaveOccurred())
buildpackArchivePath := path.Join(tmpPath, "buildpack.zip")
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash