Skip to content

Commit a437b0e

Browse files
rbambergerSophie Wigmore
andauthored
Bump github.com/Dynatrace/libbuildpack-dynatrace to v1.5.2 (#701)
* Bump github.com/Dynatrace/libbuildpack-dynatrace to v1.5.2 * Integration tests updated * comment removed --------- Co-authored-by: Sophie Wigmore <[email protected]>
1 parent 44d7f4c commit a437b0e

File tree

6 files changed

+164
-47
lines changed

6 files changed

+164
-47
lines changed

fixtures/fake_dynatrace_api/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ func main() {
7979
json.NewEncoder(w).Encode(payload)
8080

8181
case "/v1/deployment/installer/agent/processmoduleconfig":
82+
if os.Getenv("API_CONNECTION_FAIL") == "true" {
83+
w.WriteHeader(http.StatusInternalServerError)
84+
w.Write([]byte(err.Error()))
85+
return
86+
}
87+
8288
fakeConfig, err := os.ReadFile("fake_config.json")
8389
if err != nil {
8490
w.WriteHeader(http.StatusInternalServerError)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/cloudfoundry/python-buildpack
22

33
require (
4-
github.com/Dynatrace/libbuildpack-dynatrace v1.5.0
4+
github.com/Dynatrace/libbuildpack-dynatrace v1.5.2
55
github.com/blang/semver v3.5.1+incompatible
66
github.com/cloudfoundry/libbuildpack v0.0.0-20230209225346-0e58f7be61d4
77
github.com/golang/mock v1.6.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
44
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
55
github.com/Dynatrace/libbuildpack-dynatrace v1.5.0 h1:EZ2fSooBGd179dFbM673l1RE7zGfKuyVUujl/plWsnU=
66
github.com/Dynatrace/libbuildpack-dynatrace v1.5.0/go.mod h1:TojYXsxk1r+TaVOTUOWKyX2hAOzbvb+BsQGxUZ8Cb2s=
7+
github.com/Dynatrace/libbuildpack-dynatrace v1.5.2 h1:yiF8yuJ4762ocmZEM+/K8auciKFQ3XfQb/0Qt7VL+rU=
8+
github.com/Dynatrace/libbuildpack-dynatrace v1.5.2/go.mod h1:Uu9aa5UFAk1Ua+zZXnvzo+avDXuEi+GtegeOyja9xg4=
79
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
810
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
911
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=

src/python/integration/deploy_python_app_with_dynatrace_test.go

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ import (
1515

1616
var _ = Describe("CF Python Buildpack", func() {
1717
var (
18-
app *cutlass.App
19-
createdServices []string
20-
dynatraceAPI *cutlass.App
21-
dynatraceAPIURI string
18+
app *cutlass.App
19+
createdServices []string
20+
dynatraceAPI *cutlass.App
21+
dynatraceAPIURI string
22+
dynatraceBrokenAPI *cutlass.App
23+
dynatraceBrokenAPIURI string
2224
)
2325

2426
BeforeEach(func() {
2527
if isSerialTest {
2628
Skip("Skipping parallel tests")
2729
}
2830

31+
//API mocking App
2932
dynatraceAPI = cutlass.New(Fixtures("fake_dynatrace_api"))
3033
// TODO: remove this once go-buildpack runs on cflinuxfs4
3134
// This is done to have the dynatrace broker app written in go up and running
@@ -41,6 +44,23 @@ var _ = Describe("CF Python Buildpack", func() {
4144
dynatraceAPIURI, err = dynatraceAPI.GetUrl("")
4245
Expect(err).NotTo(HaveOccurred())
4346

47+
//API mocking App with broken processmoduleconfig Endpoint
48+
dynatraceBrokenAPI = cutlass.New(Fixtures("fake_dynatrace_api"))
49+
50+
// TODO: remove this once go-buildpack runs on cflinuxfs4
51+
// This is done to have the dynatrace broker app written in go up and running
52+
if os.Getenv("CF_STACK") == "cflinuxfs4" {
53+
dynatraceBrokenAPI.Stack = "cflinuxfs3"
54+
}
55+
dynatraceBrokenAPI.SetEnv("BP_DEBUG", "true")
56+
dynatraceBrokenAPI.SetEnv("API_CONNECTION_FAIL", "true")
57+
58+
Expect(dynatraceBrokenAPI.Push()).To(Succeed())
59+
Eventually(func() ([]string, error) { return dynatraceBrokenAPI.InstanceStates() }, 60*time.Second).Should(Equal([]string{"RUNNING"}))
60+
61+
dynatraceBrokenAPIURI, err = dynatraceBrokenAPI.GetUrl("")
62+
Expect(err).NotTo(HaveOccurred())
63+
4464
app = cutlass.New(filepath.Join(bpDir, "fixtures", "flask"))
4565
app.SetEnv("BP_DEBUG", "true")
4666
PushAppAndConfirm(app)
@@ -59,6 +79,16 @@ var _ = Describe("CF Python Buildpack", func() {
5979
_, err := command.Output()
6080
Expect(err).To(BeNil())
6181
}
82+
83+
if dynatraceAPI != nil {
84+
dynatraceAPI.Destroy()
85+
}
86+
dynatraceAPI = nil
87+
88+
if dynatraceBrokenAPI != nil {
89+
dynatraceBrokenAPI.Destroy()
90+
}
91+
dynatraceBrokenAPI = nil
6292
})
6393

6494
Context("deploying a Python app with Dynatrace agent with single credentials service", func() {
@@ -271,4 +301,46 @@ var _ = Describe("CF Python Buildpack", func() {
271301
})
272302
})
273303

304+
Context("deploying a Python app with Dynatrace OneAgent being able to contact the API to fetch the updated OneAgent config", func() {
305+
It("checks if agent config update via API was successful", func() {
306+
serviceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
307+
command := exec.Command("cf", "cups", serviceName, "-p", fmt.Sprintf("'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"%s\",\"environmentid\":\"envid\"}'", dynatraceAPIURI))
308+
_, err := command.CombinedOutput()
309+
Expect(err).To(BeNil())
310+
createdServices = append(createdServices, serviceName)
311+
command = exec.Command("cf", "bind-service", app.Name, serviceName)
312+
_, err = command.CombinedOutput()
313+
Expect(err).To(BeNil())
314+
315+
command = exec.Command("cf", "restage", app.Name)
316+
_, err = command.Output()
317+
Expect(err).To(BeNil())
318+
319+
Expect(app.ConfirmBuildpack(buildpackVersion)).To(Succeed())
320+
Expect(app.Stdout.String()).To(ContainSubstring("Fetching updated OneAgent configuration from tenant..."))
321+
Expect(app.Stdout.String()).To(ContainSubstring("Successfully fetched updated OneAgent config from the API"))
322+
})
323+
})
324+
325+
Context("deploying a Python app with Dynatrace OneAgent not being able to contact the API to fetch the updated OneAgent config", func() {
326+
It("checks if agent config update via API fails soft", func() {
327+
serviceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
328+
329+
command := exec.Command("cf", "cups", serviceName, "-p", fmt.Sprintf("'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"%s\",\"environmentid\":\"envid\"}'", dynatraceBrokenAPIURI))
330+
_, err := command.CombinedOutput()
331+
Expect(err).To(BeNil())
332+
createdServices = append(createdServices, serviceName)
333+
command = exec.Command("cf", "bind-service", app.Name, serviceName)
334+
_, err = command.CombinedOutput()
335+
Expect(err).To(BeNil())
336+
337+
command = exec.Command("cf", "restage", app.Name)
338+
_, err = command.Output()
339+
Expect(err).To(BeNil())
340+
341+
Expect(app.ConfirmBuildpack(buildpackVersion)).To(Succeed())
342+
Expect(app.Stdout.String()).To(ContainSubstring("Fetching updated OneAgent configuration from tenant..."))
343+
Expect(app.Stdout.String()).To(ContainSubstring("Failed to fetch updated OneAgent config from the API"))
344+
})
345+
})
274346
})

vendor/github.com/Dynatrace/libbuildpack-dynatrace/hook.go

Lines changed: 77 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# code.cloudfoundry.org/lager v2.0.0+incompatible
22
## explicit
33
code.cloudfoundry.org/lager
4-
# github.com/Dynatrace/libbuildpack-dynatrace v1.5.0
5-
## explicit
4+
# github.com/Dynatrace/libbuildpack-dynatrace v1.5.2
5+
## explicit; go 1.19
66
github.com/Dynatrace/libbuildpack-dynatrace
77
# github.com/Masterminds/semver v1.5.0
88
## explicit

0 commit comments

Comments
 (0)