本文整理汇总了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/runner.NewCmdRunner函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCmdRunner函数的具体用法?Golang NewCmdRunner怎么用?Golang NewCmdRunner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCmdRunner函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
})
}
示例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()
}
}
}
示例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()
}
示例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())
}
示例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
}
示例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)
}
示例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()
}
})
}
示例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())
}
示例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()
示例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")
})
})
示例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")
示例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())
}
}
示例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())
}
示例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")
示例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()
})
})