本文整理汇总了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/runner.NewCmdRunner函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCmdRunner函数的具体用法?Golang NewCmdRunner怎么用?Golang NewCmdRunner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCmdRunner函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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()
}
})
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:29,代码来源:context.go
示例2: TargetSpace
func TargetSpace(userContext UserContext, timeout time.Duration) {
if userContext.Org != "" {
if userContext.Space != "" {
runner.NewCmdRunner(Cf("target", "-o", userContext.Org, "-s", userContext.Space), timeout).Run()
} else {
runner.NewCmdRunner(Cf("target", "-o", userContext.Org), timeout).Run()
}
}
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:9,代码来源:as_user.go
示例3: createPermissiveSecurityGroup
func (c context) createPermissiveSecurityGroup() {
rules := []map[string]string{
map[string]string{
"destination": "0.0.0.0-255.255.255.255",
"protocol": "all",
},
}
rulesFilePath, err := c.writeJSONToTempFile(rules, fmt.Sprintf("%s-rules.json", c.securityGroupName))
defer os.RemoveAll(rulesFilePath)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
runner.NewCmdRunner(cf.Cf("create-security-group", c.securityGroupName, rulesFilePath), c.shortTimeout).Run()
runner.NewCmdRunner(cf.Cf("bind-security-group", c.securityGroupName, c.organizationName, c.spaceName), c.shortTimeout).Run()
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:15,代码来源:context.go
示例4: CurlAppWithTimeout
// Curls an app's endpoint and exit successfully before the specified timeout
func CurlAppWithTimeout(appName, path string, timeout time.Duration) string {
uri := AppUri(appName, path)
curlCmd := runner.Curl(uri)
runner.NewCmdRunner(curlCmd, timeout).Run()
Expect(string(curlCmd.Err.Contents())).To(HaveLen(0))
return string(curlCmd.Out.Contents())
}
开发者ID:naheedmk,项目名称:cf-acceptance-tests,代码行数:8,代码来源:app_commands.go
示例5: InitiateUserContext
func InitiateUserContext(userContext UserContext, timeout time.Duration) (originalCfHomeDir, currentCfHomeDir string) {
originalCfHomeDir = os.Getenv("CF_HOME")
currentCfHomeDir, err := ioutil.TempDir("", fmt.Sprintf("cf_home_%d", ginkgoconfig.GinkgoConfig.ParallelNode))
if err != nil {
panic("Error: could not create temporary home directory: " + err.Error())
}
os.Setenv("CF_HOME", currentCfHomeDir)
cfSetApiArgs := []string{"api", userContext.ApiUrl}
if userContext.SkipSSLValidation {
cfSetApiArgs = append(cfSetApiArgs, "--skip-ssl-validation")
}
runner.NewCmdRunner(Cf(cfSetApiArgs...), timeout).Run()
runner.NewCmdRunner(Cf("auth", userContext.Username, userContext.Password), timeout).Run()
return
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:21,代码来源:as_user.go
示例6: Setup
func (c *context) Setup() {
cf.AsUser(c.AdminUserContext(), c.shortTimeout, func() {
runner.NewCmdRunner(cf.Cf("create-user", c.regularUserUsername, c.regularUserPassword), c.shortTimeout).Run()
if c.useExistingOrg == false {
definition := QuotaDefinition{
Name: c.quotaDefinitionName,
TotalServices: 100,
TotalRoutes: 1000,
MemoryLimit: 10240,
NonBasicServicesAllowed: true,
}
definitionPayload, err := json.Marshal(definition)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
var response cf.GenericResource
cf.ApiRequest("POST", "/v2/quota_definitions", &response, c.shortTimeout, string(definitionPayload))
c.quotaDefinitionGUID = response.Metadata.Guid
runner.NewCmdRunner(cf.Cf("create-org", c.organizationName), c.shortTimeout).Run()
runner.NewCmdRunner(cf.Cf("set-quota", c.organizationName, c.quotaDefinitionName), c.shortTimeout).Run()
}
c.setUpSpaceWithUserAccess(c.RegularUserContext())
if c.config.CreatePermissiveSecurityGroup {
c.createPermissiveSecurityGroup()
}
})
c.originalCfHomeDir, c.currentCfHomeDir = cf.InitiateUserContext(c.RegularUserContext(), c.shortTimeout)
cf.TargetSpace(c.RegularUserContext(), c.shortTimeout)
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:39,代码来源:context.go
示例7: Teardown
func (c *context) Teardown() {
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()
if !c.isPersistent {
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()
}
})
}
开发者ID:stefanschneider,项目名称:diego-windows-msi,代码行数:22,代码来源:context.go
示例8: CurlAppWithTimeout
// Curls an app's endpoint and exit successfully before the specified timeout
func CurlAppWithTimeout(appName, path string, timeout time.Duration) string {
config := LoadConfig()
uri := AppUri(appName, path)
var curlCmd *gexec.Session
if config.SkipSSLValidation {
curlCmd = runner.Curl("-k", uri)
} else {
curlCmd = runner.Curl(uri)
}
runner.NewCmdRunner(curlCmd, timeout).Run()
Expect(string(curlCmd.Err.Contents())).To(HaveLen(0))
return string(curlCmd.Out.Contents())
}
开发者ID:vito,项目名称:cf-acceptance-tests,代码行数:16,代码来源:app_commands.go
示例9:
)
const (
// The quota enforcer sleeps for one second between iterations,
// so sleeping for 20 seconds is sufficient for it have enforced all quotas
quotaEnforcerSleepTime = 20 * time.Second
)
var _ = Describe("P-MySQL Service", func() {
var sinatraPath = "../../assets/sinatra_app"
assertAppIsRunning := func(appName string) {
pingURI := helpers.TestConfig.AppURI(appName) + "/ping"
fmt.Println("\n*** Checking that the app is responding at url: ", pingURI)
runner.NewCmdRunner(runner.Curl("-k", pingURI), helpers.TestContext.ShortTimeout()).WithAttempts(3).WithOutput("OK").Run()
}
Describe("Enforcing MySQL storage and connection quota", func() {
var appName string
var serviceInstanceName string
var serviceURI string
var plan helpers.Plan
BeforeEach(func() {
appName = RandomName()
serviceInstanceName = RandomName()
plan = helpers.TestConfig.Plans[0]
serviceURI = fmt.Sprintf("%s/service/mysql/%s", helpers.TestConfig.AppURI(appName), serviceInstanceName)
runner.NewCmdRunner(Cf("push", appName, "-m", "256M", "-p", sinatraPath, "-b", "ruby_buildpack", "-no-start"), helpers.TestContext.LongTimeout()).Run()
开发者ID:pcfdev-forks,项目名称:cf-mysql-acceptance-tests,代码行数:31,代码来源:quota_test.go
示例10:
package broker_test
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
"github.com/cloudfoundry-incubator/cf-mysql-acceptance-tests/helpers"
"github.com/cloudfoundry-incubator/cf-test-helpers/runner"
)
var _ = Describe("P-MySQL Service broker", func() {
It("Registers a route", func() {
uri := fmt.Sprintf("%s://%s/v2/catalog", helpers.TestConfig.BrokerProtocol, helpers.TestConfig.BrokerHost)
fmt.Printf("\n*** Curling url: %s\n", uri)
curlCmd := runner.NewCmdRunner(runner.Curl("-k", uri), helpers.TestContext.ShortTimeout()).Run()
Expect(curlCmd).To(Say("HTTP Basic: Access denied."))
fmt.Println("Expected failure occured")
})
})
开发者ID:pcfdev-forks,项目名称:cf-mysql-acceptance-tests,代码行数:23,代码来源:broker_test.go
示例11:
BeforeEach(func() {
broker = NewServiceBroker(generator.RandomName(), assets.NewAssets().ServiceBroker, context, false)
broker.Push()
broker.Configure()
broker.Create()
broker.PublicizePlans()
orgName = generator.RandomName()
quotaName = generator.RandomName() + "-recursive-delete"
spaceName := generator.RandomName()
appName := generator.RandomName()
instanceName := generator.RandomName()
cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
runner.NewCmdRunner(cf.Cf("create-quota", quotaName, "-m", "10G", "-r", "1000", "-s", "5"), context.ShortTimeout()).Run()
createOrg := cf.Cf("create-org", orgName).Wait(DEFAULT_TIMEOUT)
Expect(createOrg).To(Exit(0), "failed to create org")
runner.NewCmdRunner(cf.Cf("set-quota", orgName, quotaName), context.ShortTimeout()).Run()
createSpace := cf.Cf("create-space", spaceName, "-o", orgName).Wait(DEFAULT_TIMEOUT)
Expect(createSpace).To(Exit(0), "failed to create space")
target := cf.Cf("target", "-o", orgName, "-s", spaceName).Wait(CF_PUSH_TIMEOUT)
Expect(target).To(Exit(0), "failed targeting")
createApp := cf.Cf("push", appName, "-p", assets.NewAssets().Dora, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)
Expect(createApp).To(Exit(0), "failed creating app")
开发者ID:vito,项目名称:cf-acceptance-tests,代码行数:30,代码来源:recursive_delete_test.go
示例12:
"github.com/cloudfoundry-incubator/cf-test-helpers/runner"
)
//var CfApiTimeout = 30 * time.Second
type GenericResource struct {
Metadata struct {
Guid string `json:"guid"`
} `json:"metadata"`
}
type QueryResponse struct {
Resources []GenericResource `struct:"resources"`
}
var ApiRequest = func(method, endpoint string, response interface{}, timeout time.Duration, data ...string) {
request := Cf(
"curl",
endpoint,
"-X", method,
"-d", strings.Join(data, ""),
)
runner.NewCmdRunner(request, timeout).Run()
if response != nil {
err := json.Unmarshal(request.Out.Contents(), response)
Expect(err).ToNot(HaveOccurred())
}
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:30,代码来源:api.go
示例13: curlAppWithCookies
func curlAppWithCookies(appName, path string, cookieStorePath string) string {
uri := helpers.AppUri(appName, path)
curlCmd := runner.Curl(uri, "-b", cookieStorePath, "-c", cookieStorePath)
runner.NewCmdRunner(curlCmd, helpers.CURL_TIMEOUT).Run()
return string(curlCmd.Out.Contents())
}
开发者ID:cwlbraa,项目名称:cf-acceptance-tests,代码行数:6,代码来源:session_affinity_test.go
示例14:
}
BeforeEach(func() {
driver = PhantomJS()
Expect(driver.Start()).To(Succeed())
var err error
page, err = driver.NewPage()
Expect(err).ToNot(HaveOccurred())
serviceInstanceName = RandomName()
planName := helpers.TestConfig.Plans[0].Name
By("Creating service")
runner.NewCmdRunner(Cf("create-service", helpers.TestConfig.ServiceName, planName, serviceInstanceName), helpers.TestContext.LongTimeout()).Run()
By("Verifing service instance exists")
var serviceInstanceInfo map[string]interface{}
serviceInfoCmd := runner.NewCmdRunner(Cf("curl", "/v2/service_instances?q=name:"+serviceInstanceName), helpers.TestContext.ShortTimeout()).Run()
err = json.Unmarshal(serviceInfoCmd.Buffer().Contents(), &serviceInstanceInfo)
Expect(err).ShouldNot(HaveOccurred())
dashboardUrl = getDashboardUrl(serviceInstanceInfo)
regularUserContext := helpers.TestContext.RegularUserContext()
username = regularUserContext.Username
password = regularUserContext.Password
})
AfterEach(func() {
By("Stopping Webdriver")
开发者ID:pcfdev-forks,项目名称:cf-mysql-acceptance-tests,代码行数:31,代码来源:dashboard_test.go
示例15:
package cf_test
import (
"os/exec"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/runner"
)
var _ = Describe("Cf", func() {
It("sends the request to current CF target", func() {
runner.CommandInterceptor = func(cmd *exec.Cmd) *exec.Cmd {
Expect(cmd.Path).To(Equal(exec.Command("cf").Path))
Expect(cmd.Args).To(Equal([]string{"cf", "apps"}))
return exec.Command("bash", "-c", `exit 42`)
}
runner.NewCmdRunner(Cf("apps"), 1*time.Second).WithExitCode(42).Run()
})
})
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:25,代码来源:cf_test.go
示例16: assertReadFromDB
func assertReadFromDB(key, value, uri string) {
curlURI := fmt.Sprintf("%s/%s", uri, key)
runner.NewCmdRunner(runner.Curl("-k", curlURI), helpers.TestContext.ShortTimeout()).WithOutput(value).Run()
}
开发者ID:pcfdev-forks,项目名称:cf-mysql-acceptance-tests,代码行数:4,代码来源:failover_test.go
示例17: RestoreUserContext
func RestoreUserContext(_ UserContext, timeout time.Duration, originalCfHomeDir, currentCfHomeDir string) {
runner.NewCmdRunner(Cf("logout"), timeout).Run()
os.Setenv("CF_HOME", originalCfHomeDir)
os.RemoveAll(currentCfHomeDir)
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:5,代码来源:as_user.go
示例18:
)
BeforeEach(func() {
appName = generator.RandomName()
appsDomain = os.Getenv("SMOKE_TESTS_APPS_DOMAIN")
Expect(appsDomain).NotTo(BeEmpty(), "must set $SMOKE_TESTS_APPS_DOMAIN")
appRoute = "http://" + appName + "." + appsDomain + "/"
})
AfterEach(func() {
Eventually(cf.Cf("logs", appName, "--recent")).Should(gexec.Exit())
Eventually(cf.Cf("delete", "-r", "-f", appName)).Should(gexec.Exit(0))
})
It("works", func() {
Eventually(cf.Cf("push", appName, "-p", "dora", "--no-start")).Should(gexec.Exit(0))
enableDiego(appName)
Eventually(cf.Cf("start", appName), 5*time.Minute).Should(gexec.Exit(0))
Eventually(cf.Cf("logs", appName, "--recent")).Should(gbytes.Say("[HEALTH/0]"))
curlAppRouteWithTimeout := func() string {
curlCmd := runner.Curl(appRoute)
runner.NewCmdRunner(curlCmd, 30*time.Second).Run()
Expect(string(curlCmd.Err.Contents())).To(HaveLen(0))
return string(curlCmd.Out.Contents())
}
Eventually(curlAppRouteWithTimeout).Should(ContainSubstring("Hi, I'm Dora!"))
})
})
开发者ID:dkoper,项目名称:diego-smoke-tests,代码行数:30,代码来源:diego_smoke_tests_test.go
示例19:
. "github.com/onsi/gomega/gbytes"
"github.com/cloudfoundry-incubator/cf-mysql-acceptance-tests/helpers"
. "github.com/cloudfoundry-incubator/cf-test-helpers/cf"
. "github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"github.com/cloudfoundry-incubator/cf-test-helpers/runner"
)
var _ = Describe("P-MySQL Lifecycle Tests", func() {
var sinatraPath = "../../assets/sinatra_app"
assertAppIsRunning := func(appName string) {
pingURI := helpers.TestConfig.AppURI(appName) + "/ping"
fmt.Println("\n*** Checking that the app is responding at url: ", pingURI)
runner.NewCmdRunner(runner.Curl("-k", pingURI), helpers.TestContext.ShortTimeout()).WithAttempts(3).WithOutput("OK").Run()
}
It("Allows users to create, bind, write to, read from, unbind, and destroy a service instance for the each plan", func() {
for _, plan := range helpers.TestConfig.Plans {
// skip if plan is private
if plan.Private {
continue
}
appName := RandomName()
pushCmd := runner.NewCmdRunner(Cf("push", appName, "-m", "256M", "-p", sinatraPath, "-b", "ruby_buildpack", "-no-start"), helpers.TestContext.LongTimeout()).Run()
Expect(pushCmd).To(Say("OK"))
serviceInstanceName := RandomName()
开发者ID:pcfdev-forks,项目名称:cf-mysql-acceptance-tests,代码行数:31,代码来源:lifecycle_test.go
示例20: SetRunawayQuota
func (context *ConfiguredContext) SetRunawayQuota() {
cf.AsUser(context.AdminUserContext(), context.shortTimeout, func() {
runner.NewCmdRunner(cf.Cf("update-quota", context.quotaDefinitionName, "-m", RUNAWAY_QUOTA_MEM_LIMIT, "-i=-1"), context.shortTimeout).Run()
})
}
开发者ID:ekcasey,项目名称:cf-test-helpers,代码行数:5,代码来源:context.go
注:本文中的github.com/cloudfoundry-incubator/cf-test-helpers/runner.NewCmdRunner函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论