forked from cloudfoundry/cf-acceptance-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changing_start_command.go
107 lines (83 loc) · 3.15 KB
/
changing_start_command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package apps
import (
"encoding/json"
"fmt"
"strings"
. "github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
"github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/app_helpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/random_name"
)
var _ = AppsDescribe("Changing an app's start command", func() {
var appName string
BeforeEach(func() {
appName = random_name.CATSRandomName("APP")
})
AfterEach(func() {
app_helpers.AppReport(appName)
Expect(cf.Cf("delete", appName, "-f", "-r").Wait()).To(Exit(0))
})
Context("by using the command flag", func() {
var expectedNullResponse string
BeforeEach(func() {
appUrl := "https://" + appName + "." + Config.GetAppsDomain()
nullSession := helpers.CurlSkipSSL(Config.GetSkipSSLValidation(), appUrl).Wait()
expectedNullResponse = string(nullSession.Buffer().Contents())
Expect(cf.Cf(
"push", appName,
"-b", Config.GetBinaryBuildpackName(),
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().Catnip,
"-d", Config.GetAppsDomain(),
"-c", "FOO=foo ./catnip",
).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")
}).Should(ContainSubstring("foo"))
guid := cf.Cf("app", appName, "--guid").Wait().Out.Contents()
appGuid := strings.TrimSpace(string(guid))
workflowhelpers.ApiRequest(
"PUT",
"/v2/apps/"+appGuid,
nil,
Config.DefaultTimeoutDuration(),
`{"command":"FOO=bar ./catnip"}`,
)
Expect(cf.Cf("stop", appName).Wait()).To(Exit(0))
Eventually(func() string {
return helpers.CurlApp(Config, appName, "/env/FOO")
}).Should(ContainSubstring(expectedNullResponse))
Expect(cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
Eventually(func() string {
return helpers.CurlApp(Config, appName, "/env/FOO")
}).Should(ContainSubstring("bar"))
})
})
Context("by using a Procfile", func() {
type AppResource struct {
Entity struct {
DetectedStartCommand string `json:"detected_start_command"`
} `json:"entity"`
}
type AppsResponse struct {
Resources []AppResource `json:"resources"`
}
BeforeEach(func() {
Expect(cf.Cf("push", appName, "-b", Config.GetNodejsBuildpackName(), "-m", DEFAULT_MEMORY_LIMIT, "-p", assets.NewAssets().NodeWithProcfile, "-d", Config.GetAppsDomain()).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
})
It("detects the use of the start command in the 'web' process type", func() {
var appsResponse AppsResponse
cfResponse := cf.Cf("curl", fmt.Sprintf("/v2/apps?q=name:%s", appName)).Wait().Out.Contents()
json.Unmarshal(cfResponse, &appsResponse)
Expect(appsResponse.Resources[0].Entity.DetectedStartCommand).To(Equal("node app.js"))
})
})
})