Skip to content

Commit a8f26b4

Browse files
committed
Resolves merge conflicts
2 parents 15c2be6 + 122692d commit a8f26b4

File tree

10 files changed

+938
-0
lines changed

10 files changed

+938
-0
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/cloudfoundry/python-buildpack
22

33
require (
4+
github.com/Dynatrace/libbuildpack-dynatrace v1.2.1
45
github.com/blang/semver v3.5.1+incompatible
56
github.com/cloudfoundry/libbuildpack v0.0.0-20191216200928-f551f3c60d86
67
github.com/elazarl/goproxy v0.0.0-20191011121108-aa519ddbe484 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ code.cloudfoundry.org/lager v2.0.0+incompatible/go.mod h1:O2sS7gKP3HM2iemG+Enwvy
33
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
44
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
55
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
6+
github.com/Dynatrace/libbuildpack-dynatrace v1.2.1 h1:XJ+mmQSAOoaeVip6kAIV/tWd2gQQWUeowU/bEGFil2c=
7+
github.com/Dynatrace/libbuildpack-dynatrace v1.2.1/go.mod h1:TojYXsxk1r+TaVOTUOWKyX2hAOzbvb+BsQGxUZ8Cb2s=
68
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
79
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
810
github.com/cheggaaa/pb v2.0.7+incompatible/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=

src/python/hooks/dynatrace.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package hooks
2+
3+
import (
4+
"github.com/Dynatrace/libbuildpack-dynatrace"
5+
"github.com/cloudfoundry/libbuildpack"
6+
)
7+
8+
func init() {
9+
libbuildpack.AddHook(dynatrace.NewHook("sdk", "process"))
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
package integration_test
2+
3+
import (
4+
"os/exec"
5+
"path/filepath"
6+
7+
"github.com/cloudfoundry/libbuildpack/cutlass"
8+
9+
. "github.com/onsi/ginkgo"
10+
. "github.com/onsi/gomega"
11+
)
12+
13+
var _ = Describe("CF Python Buildpack", func() {
14+
var app *cutlass.App
15+
var createdServices []string
16+
17+
BeforeEach(func() {
18+
//app = cutlass.New(Fixtures("flask"))
19+
app = cutlass.New(filepath.Join(bpDir, "fixtures", "flask"))
20+
app.SetEnv("BP_DEBUG", "true")
21+
PushAppAndConfirm(app)
22+
23+
createdServices = make([]string, 0)
24+
})
25+
26+
AfterEach(func() {
27+
if app != nil {
28+
app.Destroy()
29+
}
30+
app = nil
31+
32+
for _, service := range createdServices {
33+
command := exec.Command("cf", "delete-service", "-f", service)
34+
_, err := command.Output()
35+
Expect(err).To(BeNil())
36+
}
37+
})
38+
39+
Context("deploying a Python app with Dynatrace agent with single credentials service", func() {
40+
It("checks if Dynatrace injection was successful", func() {
41+
serviceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
42+
command := exec.Command("cf", "cups", serviceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paas/manifest\",\"environmentid\":\"envid\"}'")
43+
_, err := command.CombinedOutput()
44+
Expect(err).To(BeNil())
45+
createdServices = append(createdServices, serviceName)
46+
47+
command = exec.Command("cf", "bind-service", app.Name, serviceName)
48+
_, err = command.CombinedOutput()
49+
Expect(err).To(BeNil())
50+
command = exec.Command("cf", "restage", app.Name)
51+
_, err = command.Output()
52+
Expect(err).To(BeNil())
53+
54+
Expect(app.ConfirmBuildpack(buildpackVersion)).To(Succeed())
55+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace service credentials found. Setting up Dynatrace PaaS agent."))
56+
Expect(app.Stdout.String()).To(ContainSubstring("Starting Dynatrace PaaS agent installer"))
57+
Expect(app.Stdout.String()).To(ContainSubstring("Copy dynatrace-env.sh"))
58+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent installed."))
59+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent injection is set up."))
60+
})
61+
})
62+
63+
Context("deploying a Python app with Dynatrace agent with two credentials services", func() {
64+
It("checks if detection of second service with credentials works", func() {
65+
CredentialsServiceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
66+
command := exec.Command("cf", "cups", CredentialsServiceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paas/manifest\",\"environmentid\":\"envid\"}'")
67+
_, err := command.CombinedOutput()
68+
Expect(err).To(BeNil())
69+
createdServices = append(createdServices, CredentialsServiceName)
70+
71+
duplicateCredentialsServiceName := "dynatrace-dupe-" + cutlass.RandStringRunes(20) + "-service"
72+
command = exec.Command("cf", "cups", duplicateCredentialsServiceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paas/manifest\",\"environmentid\":\"envid\"}'")
73+
_, err = command.CombinedOutput()
74+
Expect(err).To(BeNil())
75+
createdServices = append(createdServices, duplicateCredentialsServiceName)
76+
77+
command = exec.Command("cf", "bind-service", app.Name, CredentialsServiceName)
78+
_, err = command.CombinedOutput()
79+
Expect(err).To(BeNil())
80+
command = exec.Command("cf", "bind-service", app.Name, duplicateCredentialsServiceName)
81+
_, err = command.CombinedOutput()
82+
Expect(err).To(BeNil())
83+
84+
command = exec.Command("cf", "restage", app.Name)
85+
_, err = command.Output()
86+
Expect(err).To(BeNil())
87+
88+
Expect(app.Stdout.String()).To(ContainSubstring("More than one matching service found!"))
89+
})
90+
})
91+
92+
Context("deploying a Python app with Dynatrace agent with failing agent download and ignoring errors", func() {
93+
It("checks if skipping download errors works", func() {
94+
CredentialsServiceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
95+
command := exec.Command("cf", "cups", CredentialsServiceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paasFAILING/manifest\",\"environmentid\":\"envid\",\"skiperrors\":\"true\"}'")
96+
_, err := command.CombinedOutput()
97+
Expect(err).To(BeNil())
98+
createdServices = append(createdServices, CredentialsServiceName)
99+
100+
command = exec.Command("cf", "bind-service", app.Name, CredentialsServiceName)
101+
_, err = command.CombinedOutput()
102+
Expect(err).To(BeNil())
103+
104+
command = exec.Command("cf", "restage", app.Name)
105+
_, err = command.Output()
106+
Expect(err).To(BeNil())
107+
108+
Expect(app.Stdout.String()).To(ContainSubstring("Download returned with status 404"))
109+
Expect(app.Stdout.String()).To(ContainSubstring("Error during installer download, skipping installation"))
110+
})
111+
})
112+
113+
Context("deploying a Python app with Dynatrace agent with two dynatrace services", func() {
114+
It("check if service detection isn't disturbed by a service with tags", func() {
115+
CredentialsServiceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
116+
command := exec.Command("cf", "cups", CredentialsServiceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paas/manifest\",\"environmentid\":\"envid\"}'")
117+
_, err := command.CombinedOutput()
118+
Expect(err).To(BeNil())
119+
createdServices = append(createdServices, CredentialsServiceName)
120+
121+
tagsServiceName := "dynatrace-tags-" + cutlass.RandStringRunes(20) + "-service"
122+
command = exec.Command("cf", "cups", tagsServiceName, "-p", "'{\"tag:dttest\":\"dynatrace_test\"}'")
123+
_, err = command.CombinedOutput()
124+
Expect(err).To(BeNil())
125+
createdServices = append(createdServices, tagsServiceName)
126+
127+
command = exec.Command("cf", "bind-service", app.Name, CredentialsServiceName)
128+
_, err = command.CombinedOutput()
129+
Expect(err).To(BeNil())
130+
command = exec.Command("cf", "bind-service", app.Name, tagsServiceName)
131+
_, err = command.CombinedOutput()
132+
Expect(err).To(BeNil())
133+
134+
command = exec.Command("cf", "restage", app.Name)
135+
_, err = command.Output()
136+
Expect(err).To(BeNil())
137+
138+
Expect(app.ConfirmBuildpack(buildpackVersion)).To(Succeed())
139+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace service credentials found. Setting up Dynatrace PaaS agent."))
140+
Expect(app.Stdout.String()).To(ContainSubstring("Starting Dynatrace PaaS agent installer"))
141+
Expect(app.Stdout.String()).To(ContainSubstring("Copy dynatrace-env.sh"))
142+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent installed."))
143+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent injection is set up."))
144+
})
145+
})
146+
147+
Context("deploying a Python app with Dynatrace agent with single credentials service and without manifest.json", func() {
148+
It("checks if Dynatrace injection was successful", func() {
149+
serviceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
150+
command := exec.Command("cf", "cups", serviceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paas\",\"environmentid\":\"envid\"}'")
151+
_, err := command.CombinedOutput()
152+
Expect(err).To(BeNil())
153+
createdServices = append(createdServices, serviceName)
154+
155+
command = exec.Command("cf", "bind-service", app.Name, serviceName)
156+
_, err = command.CombinedOutput()
157+
Expect(err).To(BeNil())
158+
command = exec.Command("cf", "restage", app.Name)
159+
_, err = command.Output()
160+
Expect(err).To(BeNil())
161+
162+
Expect(app.ConfirmBuildpack(buildpackVersion)).To(Succeed())
163+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace service credentials found. Setting up Dynatrace PaaS agent."))
164+
Expect(app.Stdout.String()).To(ContainSubstring("Starting Dynatrace PaaS agent installer"))
165+
Expect(app.Stdout.String()).To(ContainSubstring("Copy dynatrace-env.sh"))
166+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent installed."))
167+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent injection is set up."))
168+
})
169+
})
170+
171+
Context("deploying a Python app with Dynatrace agent with failing agent download and checking retry", func() {
172+
It("checks if retrying downloads works", func() {
173+
CredentialsServiceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
174+
command := exec.Command("cf", "cups", CredentialsServiceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paasFAILING/manifest\",\"environmentid\":\"envid\"}'")
175+
_, err := command.CombinedOutput()
176+
Expect(err).To(BeNil())
177+
createdServices = append(createdServices, CredentialsServiceName)
178+
179+
command = exec.Command("cf", "bind-service", app.Name, CredentialsServiceName)
180+
_, err = command.CombinedOutput()
181+
Expect(err).To(BeNil())
182+
183+
command = exec.Command("cf", "restage", app.Name)
184+
_, err = command.CombinedOutput()
185+
186+
Eventually(app.Stdout.String).Should(ContainSubstring("Error during installer download, retrying in 4s"))
187+
Eventually(app.Stdout.String).Should(ContainSubstring("Error during installer download, retrying in 5s"))
188+
Eventually(app.Stdout.String).Should(ContainSubstring("Error during installer download, retrying in 7s"))
189+
Eventually(app.Stdout.String).Should(ContainSubstring("Download returned with status 404"))
190+
191+
Eventually(app.Stdout.String).Should(ContainSubstring("Failed to compile droplet"))
192+
})
193+
})
194+
195+
Context("deploying a Python app with Dynatrace agent with single credentials service and a redis service", func() {
196+
It("checks if Dynatrace injection was successful", func() {
197+
serviceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
198+
command := exec.Command("cf", "cups", serviceName, "-p", "'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"https://s3.amazonaws.com/dt-paas/manifest\",\"environmentid\":\"envid\"}'")
199+
_, err := command.CombinedOutput()
200+
Expect(err).To(BeNil())
201+
createdServices = append(createdServices, serviceName)
202+
command = exec.Command("cf", "bind-service", app.Name, serviceName)
203+
_, err = command.CombinedOutput()
204+
Expect(err).To(BeNil())
205+
206+
redisServiceName := "redis-" + cutlass.RandStringRunes(20) + "-service"
207+
command = exec.Command("cf", "cups", redisServiceName, "-p", "'{\"name\":\"redis\", \"credentials\":{\"db_type\":\"redis\", \"instance_administration_api\":{\"deployment_id\":\"12345asdf\", \"instance_id\":\"12345asdf\", \"root\":\"https://doesnotexi.st\"}}}'")
208+
_, err = command.CombinedOutput()
209+
Expect(err).To(BeNil())
210+
createdServices = append(createdServices, redisServiceName)
211+
command = exec.Command("cf", "bind-service", app.Name, redisServiceName)
212+
_, err = command.CombinedOutput()
213+
Expect(err).To(BeNil())
214+
215+
command = exec.Command("cf", "restage", app.Name)
216+
_, err = command.Output()
217+
Expect(err).To(BeNil())
218+
219+
Expect(app.ConfirmBuildpack(buildpackVersion)).To(Succeed())
220+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace service credentials found. Setting up Dynatrace PaaS agent."))
221+
Expect(app.Stdout.String()).To(ContainSubstring("Starting Dynatrace PaaS agent installer"))
222+
Expect(app.Stdout.String()).To(ContainSubstring("Copy dynatrace-env.sh"))
223+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent installed."))
224+
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace PaaS agent injection is set up."))
225+
})
226+
})
227+
})

vendor/github.com/Dynatrace/libbuildpack-dynatrace/.gitignore

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)