本文整理汇总了Golang中github.com/openshift/origin/test/extended/util.FetchURL函数的典型用法代码示例。如果您正苦于以下问题:Golang FetchURL函数的具体用法?Golang FetchURL怎么用?Golang FetchURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FetchURL函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewSampleRepoTest
// NewSampleRepoTest creates a function for a new ginkgo test case that will instantiate a template
// from a url, kick off the buildconfig defined in that template, wait for the build/deploy,
// and then confirm the application is serving an expected string value.
func NewSampleRepoTest(c SampleRepoConfig) func() {
return func() {
defer g.GinkgoRecover()
var oc = exutil.NewCLI(c.repoName+"-repo-test", exutil.KubeConfigPath())
g.JustBeforeEach(func() {
g.By("Waiting for builder service account")
err := exutil.WaitForBuilderAccount(oc.KubeREST().ServiceAccounts(oc.Namespace()))
o.Expect(err).NotTo(o.HaveOccurred())
})
g.Describe("Building "+c.repoName+" app from new-app", func() {
g.It(fmt.Sprintf("should build a "+c.repoName+" image and run it in a pod"), func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
exutil.CheckOpenShiftNamespaceImageStreams(oc)
g.By(fmt.Sprintf("calling oc new-app with the " + c.repoName + " example template"))
err := oc.Run("new-app").Args("-f", c.templateURL).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
// all the templates automatically start a build.
buildName := c.buildConfigName + "-1"
g.By("expecting the build is in the Complete phase")
err = exutil.WaitForABuild(oc.REST().Builds(oc.Namespace()), buildName, exutil.CheckBuildSuccessFn, exutil.CheckBuildFailedFn)
if err != nil {
exutil.DumpBuildLogs(c.buildConfigName, oc)
}
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting the app deployment to be complete")
err = exutil.WaitForADeploymentToComplete(oc.KubeREST().ReplicationControllers(oc.Namespace()), c.deploymentConfigName, oc)
o.Expect(err).NotTo(o.HaveOccurred())
if len(c.dbDeploymentConfigName) > 0 {
g.By("expecting the db deployment to be complete")
err = exutil.WaitForADeploymentToComplete(oc.KubeREST().ReplicationControllers(oc.Namespace()), c.dbDeploymentConfigName, oc)
o.Expect(err).NotTo(o.HaveOccurred())
}
g.By("expecting the service is available")
serviceIP, err := oc.Run("get").Args("service", c.serviceName).Template("{{ .spec.clusterIP }}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(serviceIP).ShouldNot(o.Equal(""))
g.By("expecting an endpoint is available")
err = oc.KubeFramework().WaitForAnEndpoint(c.serviceName)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("verifying string from app request")
response, err := exutil.FetchURL("http://"+serviceIP+":8080"+c.appPath, time.Duration(30*time.Second))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(response).Should(o.ContainSubstring(c.expectedString))
})
})
}
}
示例2: CheckPageContains
// CheckPageContains makes a http request for an example application and checks
// that the result contains given string
func CheckPageContains(oc *exutil.CLI, endpoint, path, contents string) (bool, error) {
address, err := exutil.GetEndpointAddress(oc, endpoint)
if err != nil {
return false, err
}
response, err := exutil.FetchURL(fmt.Sprintf("http://%s/%s", address, path), 3*time.Minute)
if err != nil {
return false, err
}
return strings.Contains(response, contents), nil
}