func LastPageUsageEvents(TestSetup *workflowhelpers.ReproducibleTestSuiteSetup) []AppUsageEvent { var response AppUsageEvents workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() { workflowhelpers.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1", &response, Config.DefaultTimeoutDuration()) }) return response.Resources }
func lastAppUsageEvent(appName string, state string) (bool, AppUsageEvent) { var response AppUsageEvents workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() { workflowhelpers.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1&results-per-page=150", &response, Config.DefaultTimeoutDuration()) }) for _, event := range response.Resources { if event.Entity.AppName == appName && event.Entity.State == state { return true, event } } return false, AppUsageEvent{} }
app_helpers.SetBackend(appName) Expect(cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())).To(Exit(0)) }) It("takes effect after a restart, not requiring a push", func() { Eventually(func() string { return helpers.CurlApp(Config, appName, "/env/FOO") }, Config.DefaultTimeoutDuration()).Should(ContainSubstring("foo")) guid := cf.Cf("app", appName, "--guid").Wait(Config.DefaultTimeoutDuration()).Out.Contents() appGuid := strings.TrimSpace(string(guid)) workflowhelpers.ApiRequest( "PUT", "/v2/apps/"+appGuid, nil, Config.DefaultTimeoutDuration(), `{"command":"FOO=bar bundle exec rackup config.ru -p $PORT"}`, ) Expect(cf.Cf("stop", appName).Wait(Config.DefaultTimeoutDuration())).To(Exit(0)) Eventually(func() string { return helpers.CurlApp(Config, appName, "/env/FOO") }, Config.DefaultTimeoutDuration()).Should(ContainSubstring("404")) Expect(cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())).To(Exit(0)) Eventually(func() string { return helpers.CurlApp(Config, appName, "/env/FOO") }, Config.DefaultTimeoutDuration()).Should(ContainSubstring("bar"))