本文整理匯總了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/generator.RandomName函數的典型用法代碼示例。如果您正苦於以下問題:Golang RandomName函數的具體用法?Golang RandomName怎麽用?Golang RandomName使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了RandomName函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newCfApp
func newCfApp(appNamePrefix string, maxFailedCurls int) *cfApp {
appName := appNamePrefix + "-" + generator.RandomName()
rawUrl := fmt.Sprintf(AppRoutePattern, appName, config.OverrideDomain)
appUrl, err := url.Parse(rawUrl)
if err != nil {
panic(err)
}
return &cfApp{
appName: appName,
appRoute: *appUrl,
orgName: "org-" + generator.RandomName(),
spaceName: "space-" + generator.RandomName(),
maxFailedCurls: maxFailedCurls,
}
}
示例2: AuthenticateUser
func AuthenticateUser(authorizationEndpoint string, username string, password string) (cookie string) {
loginCsrfUri := fmt.Sprintf("%v/login", authorizationEndpoint)
cookieFile, err := ioutil.TempFile("", "cats-csrf-cookie"+generator.RandomName())
Expect(err).ToNot(HaveOccurred())
cookiePath := cookieFile.Name()
defer func() {
cookieFile.Close()
os.Remove(cookiePath)
}()
curl := runner.Curl(loginCsrfUri, `--insecure`, `-i`, `-v`, `-c`, cookiePath).Wait(DEFAULT_TIMEOUT)
apiResponse := string(curl.Out.Contents())
csrfRegEx, _ := regexp.Compile(`name="X-Uaa-Csrf" value="(.*)"`)
csrfToken := csrfRegEx.FindStringSubmatch(apiResponse)[1]
loginUri := fmt.Sprintf("%v/login.do", authorizationEndpoint)
usernameEncoded := url.QueryEscape(username)
passwordEncoded := url.QueryEscape(password)
csrfTokenEncoded := url.QueryEscape(csrfToken)
loginCredentials := fmt.Sprintf("username=%v&password=%v&X-Uaa-Csrf=%v", usernameEncoded, passwordEncoded, csrfTokenEncoded)
curl = runner.Curl(loginUri, `--data`, loginCredentials, `--insecure`, `-i`, `-v`, `-b`, cookiePath).Wait(DEFAULT_TIMEOUT)
Expect(curl).To(Exit(0))
apiResponse = string(curl.Out.Contents())
jsessionRegEx, _ := regexp.Compile(`JSESSIONID([^;]*)`)
vcapidRegEx, _ := regexp.Compile(`__VCAP_ID__([^;]*)`)
sessionId := jsessionRegEx.FindString(apiResponse)
vcapId := vcapidRegEx.FindString(apiResponse)
cookie = fmt.Sprintf("%v;%v", sessionId, vcapId)
return
}
示例3: TestApplications
func TestApplications(t *testing.T) {
RegisterFailHandler(Fail)
SetDefaultEventuallyTimeout(time.Minute)
SetDefaultEventuallyPollingInterval(time.Second)
config := helpers.LoadConfig()
context = helpers.NewContext(config)
environment := helpers.NewEnvironment(context)
BeforeSuite(func() {
environment.Setup()
})
AfterSuite(func() {
environment.Teardown()
})
BeforeEach(func() {
appName = generator.RandomName()
})
componentName := "Diego"
rs := []Reporter{}
if config.ArtifactsDirectory != "" {
helpers.EnableCFTrace(config, componentName)
rs = append(rs, helpers.NewJUnitReporter(config, componentName))
}
RunSpecsWithDefaultAndCustomReporters(t, componentName, rs)
}
示例4: testThatDrainIsReachable
func testThatDrainIsReachable(syslogDrainAddress string, drainListener *syslogDrainListener) {
conn, err := net.Dial("tcp", syslogDrainAddress)
Expect(err).ToNot(HaveOccurred())
defer conn.Close()
randomMessage := "random-message-" + generator.RandomName()
_, err = conn.Write([]byte(randomMessage))
Expect(err).ToNot(HaveOccurred())
Eventually(func() bool {
return drainListener.DidReceive(randomMessage)
}).Should(BeTrue())
}
示例5: NewServiceBroker
func NewServiceBroker(name string, path string, context helpers.SuiteContext) ServiceBroker {
b := ServiceBroker{}
b.Path = path
b.Name = name
b.Service.Name = generator.RandomName()
b.Service.ID = generator.RandomName()
b.Plan.Name = generator.RandomName()
b.Plan.ID = generator.RandomName()
b.Service.DashboardClient.ID = generator.RandomName()
b.Service.DashboardClient.Secret = generator.RandomName()
b.Service.DashboardClient.RedirectUri = generator.RandomName()
b.context = context
return b
}
示例6: NewServiceBroker
func NewServiceBroker(name string, path string, context helpers.SuiteContext, includeSSOClient bool) ServiceBroker {
b := ServiceBroker{}
b.Path = path
b.Name = name
b.Service.Name = generator.RandomName()
b.Service.ID = generator.RandomName()
b.SyncPlans = []Plan{
{Name: generator.RandomName(), ID: generator.RandomName()},
{Name: generator.RandomName(), ID: generator.RandomName()},
}
b.AsyncPlans = []Plan{
{Name: generator.RandomName(), ID: generator.RandomName()},
{Name: generator.RandomName(), ID: generator.RandomName()},
}
b.SsoPlans = []Plan{
{
Name: generator.RandomName(), ID: generator.RandomName(), DashboardClient: DashboardClient{
ID: generator.RandomName(),
Secret: generator.RandomName(),
},
},
}
if includeSSOClient {
b.Service.DashboardClient.Key = "dashboard_client"
} else {
b.Service.DashboardClient.Key = "dashboard_client-deactivated"
}
b.Service.DashboardClient.ID = generator.RandomName()
b.Service.DashboardClient.Secret = generator.RandomName()
b.Service.DashboardClient.RedirectUri = generator.RandomName()
b.context = context
return b
}
示例7:
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
. "github.com/cloudfoundry/cf-acceptance-tests/helpers/services"
)
var _ = Describe("Service Broker Lifecycle", func() {
var broker ServiceBroker
Describe("public brokers", func() {
var acls *Session
var output []byte
var oldServiceName string
var oldPlanName string
BeforeEach(func() {
broker = NewServiceBroker(generator.RandomName(), assets.NewAssets().ServiceBroker, context, false)
cf.TargetSpace(context.RegularUserContext(), context.ShortTimeout())
broker.Push()
broker.Configure()
cf.AsUser(context.AdminUserContext(), context.ShortTimeout(), func() {
broker.Create()
})
})
Describe("Updating the catalog", func() {
BeforeEach(func() {
broker.PublicizePlans()
})
示例8:
}, ASYNC_OPERATION_TIMEOUT, ASYNC_OPERATION_POLL_INTERVAL).Should(Say("not found"))
}
waitForAsyncOperationToComplete := func(broker ServiceBroker, instanceName string) {
Eventually(func() *Session {
serviceDetails := cf.Cf("service", instanceName).Wait(DEFAULT_TIMEOUT)
Expect(serviceDetails).To(Exit(0), "failed getting service instance details")
return serviceDetails
}, ASYNC_OPERATION_TIMEOUT, ASYNC_OPERATION_POLL_INTERVAL).Should(Say("succeeded"))
}
type Params struct{ Param1 string }
Context("Synchronous operations", func() {
BeforeEach(func() {
broker = NewServiceBroker(generator.RandomName(), assets.NewAssets().ServiceBroker, context, true)
broker.Push()
broker.Configure()
broker.Create()
broker.PublicizePlans()
})
AfterEach(func() {
broker.Destroy()
})
Context("just service instances", func() {
It("can create a service instance", func() {
tags := "['tag1', 'tag2']"
type Params struct{ Param1 string }
params, _ := json.Marshal(Params{Param1: "value"})
示例9: TestTurbulence
"testing"
)
func TestTurbulence(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Turbulence Suite")
}
var (
goPath string
config helpers.Config
bosh *helpers.Bosh
turbulenceManifest *helpers.Manifest
etcdRelease = fmt.Sprintf("etcd-%s", generator.RandomName())
etcdDeployment = etcdRelease
turbulenceDeployment = fmt.Sprintf("turb-%s", generator.RandomName())
directorUUIDStub, etcdNameOverrideStub, turbulenceNameOverrideStub string
turbulenceManifestGeneration string
etcdManifestGeneration string
)
var _ = BeforeSuite(func() {
goPath = helpers.SetupGoPath()
gemfilePath := helpers.SetupFastBosh()
config = helpers.LoadConfig()
boshOperationTimeout := helpers.GetBoshOperationTimeout(config)
bosh = helpers.NewBosh(gemfilePath, goPath, config.BoshTarget, boshOperationTimeout)
示例10:
appLogsSession := cf.Cf("logs", "--recent", appName)
Expect(appLogsSession.Wait(DEFAULT_TIMEOUT)).To(Exit(0))
return appLogsSession
}, DEFAULT_TIMEOUT).Should(Say("Muahaha"))
})
})
Context("firehose data", func() {
It("shows logs and metrics", func() {
config := helpers.LoadConfig()
noaaConnection := noaa.NewConsumer(getDopplerEndpoint(), &tls.Config{InsecureSkipVerify: config.SkipSSLValidation}, nil)
msgChan := make(chan *events.Envelope, 100000)
errorChan := make(chan error)
stopchan := make(chan struct{})
go noaaConnection.Firehose(generator.RandomName(), getAdminUserAccessToken(), msgChan, errorChan, stopchan)
defer close(stopchan)
Eventually(func() string {
return helpers.CurlApp(appName, fmt.Sprintf("/log/sleep/%d", hundredthOfOneSecond))
}, DEFAULT_TIMEOUT).Should(ContainSubstring("Muahaha"))
timeout := time.After(5 * time.Second)
messages := make([]*events.Envelope, 0, 100000)
for {
select {
case <-timeout:
return
case msg := <-msgChan:
messages = append(messages, msg)
示例11:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"github.com/cloudfoundry/cf-acceptance-tests/helpers"
shelpers "github.com/cloudfoundry/cf-acceptance-tests/services/helpers"
)
var _ = Describe("Purging service offerings", func() {
var broker shelpers.ServiceBroker
BeforeEach(func() {
broker = shelpers.NewServiceBroker(generator.RandomName(), helpers.NewAssets().ServiceBroker, context)
broker.Push()
broker.Configure()
broker.Create()
broker.PublicizePlans()
})
AfterEach(func() {
broker.Destroy()
})
It("removes all instances and plans of the service, then removes the service offering", func() {
instanceName := "purge-offering-instance"
marketplace := cf.Cf("marketplace").Wait(DEFAULT_TIMEOUT)
Expect(marketplace).To(Exit(0))
示例12:
})
It("Applies correct environment variables while running apps", func() {
cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
Expect(cf.Cf("set-running-environment-variable-group", `{"CATS_RUNNING_TEST_VAR":"running_env_value"}`).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
Expect(cf.Cf("push", appName, "-m", "128M", "-p", assets.NewAssets().Dora, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
env := helpers.CurlApp(appName, "/env")
Expect(env).To(ContainSubstring("running_env_value"))
})
It("Applies environment variables while staging apps", func() {
buildpackName = generator.RandomName()
buildpackZip := createBuildpack()
cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
Expect(cf.Cf("set-staging-environment-variable-group", `{"CATS_STAGING_TEST_VAR":"staging_env_value"}`).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
Expect(cf.Cf("create-buildpack", buildpackName, buildpackZip, "999").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
Expect(cf.Cf("push", appName, "-m", "128M", "-b", buildpackName, "-p", assets.NewAssets().HelloWorld, "-d", config.AppsDomain).Wait(CF_PUSH_TIMEOUT)).To(Exit(1))
Eventually(func() *Session {
appLogsSession := cf.Cf("logs", "--recent", appName)
Expect(appLogsSession.Wait(DEFAULT_TIMEOUT)).To(Exit(0))
return appLogsSession
}, DEFAULT_TIMEOUT).Should(Say("staging_env_value"))
})
示例13:
app_helpers.SetBackend(appName)
Expect(cf.Cf("start", appName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
Eventually(func() string {
return helpers.CurlAppRoot(appName)
}, DEFAULT_TIMEOUT).Should(ContainSubstring("Hi, I'm Dora!"))
})
AfterEach(func() {
app_helpers.AppReport(appName, DEFAULT_TIMEOUT)
Expect(cf.Cf("delete", appName, "-f", "-r").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
})
Describe("Removing the route", func() {
It("Should be able to remove and delete the route", func() {
secondHost := generator.RandomName()
By("adding a route")
Eventually(cf.Cf("map-route", appName, helpers.LoadConfig().AppsDomain, "-n", secondHost), DEFAULT_TIMEOUT).Should(Exit(0))
Eventually(helpers.CurlingAppRoot(appName), DEFAULT_TIMEOUT).Should(ContainSubstring("Hi, I'm Dora!"))
Eventually(helpers.CurlingAppRoot(secondHost), DEFAULT_TIMEOUT).Should(ContainSubstring("Hi, I'm Dora!"))
By("removing a route")
Eventually(cf.Cf("unmap-route", appName, helpers.LoadConfig().AppsDomain, "-n", secondHost), DEFAULT_TIMEOUT).Should(Exit(0))
Eventually(helpers.CurlingAppRoot(secondHost), DEFAULT_TIMEOUT).Should(ContainSubstring("404"))
Eventually(helpers.CurlingAppRoot(appName), DEFAULT_TIMEOUT).Should(ContainSubstring("Hi, I'm Dora!"))
By("deleting the original route")
Expect(cf.Cf("delete-route", helpers.LoadConfig().AppsDomain, "-n", appName, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0))
Eventually(helpers.CurlingAppRoot(appName), DEFAULT_TIMEOUT).Should(ContainSubstring("404"))
})
示例14: TestDeploy
func TestDeploy(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Deploy Suite")
}
var (
goPath string
config helpers.Config
bosh *helpers.Bosh
consulManifestGeneration string
directorUUIDStub string
consulRelease = fmt.Sprintf("consul-%s", generator.RandomName())
consulDeployment = consulRelease
consulNameOverrideStub string
)
var _ = BeforeSuite(func() {
goPath = helpers.SetupGoPath()
gemfilePath := helpers.SetupFastBosh()
config = helpers.LoadConfig()
boshOperationTimeout := helpers.GetBoshOperationTimeout(config)
bosh = helpers.NewBosh(gemfilePath, goPath, config.BoshTarget, boshOperationTimeout)
consulManifestGeneration = filepath.Join(goPath, "src", "acceptance-tests", "scripts", "generate-consul-deployment-manifest")
err := os.Chdir(goPath)
Expect(err).ToNot(HaveOccurred())
示例15:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
. "github.com/cloudfoundry/cf-acceptance-tests/helpers/services"
)
var _ = Describe("Purging service offerings", func() {
var broker ServiceBroker
BeforeEach(func() {
broker = NewServiceBroker(generator.RandomName(), assets.NewAssets().ServiceBroker, context)
broker.Push()
broker.Configure()
cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
broker.Create()
broker.PublicizePlans()
})
})
AfterEach(func() {
broker.Destroy()
})
Context("when there are several existing service entities", func() {
var appName, instanceName string