當前位置: 首頁>>代碼示例>>Golang>>正文


Golang runner.NewCmdRunner函數代碼示例

本文整理匯總了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()
		}
	})
}
開發者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


注:本文中的github.com/cloudfoundry-incubator/cf-test-helpers/runner.NewCmdRunner函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。