Skip to content

Commit a8bc7c1

Browse files
authored
bumped libbuildpack-dynatrace to v1.5.0 (#532)
* bumped libbuildpack-dynatrace to v1.5.0 updated fake dynatrace api and integration test to take care of the OneAgent config update functionality * fixed missing path creation for fake ruxitagentproc.conf file
1 parent 9ac826b commit a8bc7c1

File tree

9 files changed

+245
-9
lines changed

9 files changed

+245
-9
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"revision":1234567890,
3+
"properties":
4+
[
5+
{
6+
"section":"fakesection",
7+
"key":"fakekey",
8+
"value":"fakevalue"
9+
}
10+
]
11+
}

fixtures/fake_dynatrace_api/install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ function main() {
88
echo "dir -> ${dir}"
99

1010
mkdir -p "${dir}/dynatrace/oneagent/agent/lib64"
11+
mkdir -p "${dir}/dynatrace/oneagent/agent/conf"
1112

1213
curl -s --fail "http://{{.URI}}/manifest.json" > "${dir}/dynatrace/oneagent/manifest.json"
1314
curl -s --fail "http://{{.URI}}/dynatrace-env.sh" > "${dir}/dynatrace/oneagent/dynatrace-env.sh"
1415
curl -s --fail "http://{{.URI}}/liboneagentproc.so" > "${dir}/dynatrace/oneagent/agent/lib64/liboneagentproc.so"
16+
curl -s --fail "http://{{.URI}}/ruxitagentproc.conf" > "${dir}/dynatrace/oneagent/agent/conf/ruxitagentproc.conf"
1517
}
1618

1719
main "${@}"

fixtures/fake_dynatrace_api/main.go

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@ func main() {
2222
}
2323

2424
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
25-
switch req.URL.Path {
25+
var withoutAgentPath bool
26+
path := req.URL.Path
27+
28+
uri := application.ApplicationURIs[0]
29+
30+
if strings.HasPrefix(path, "/without-agent-path") {
31+
uri = fmt.Sprintf("%s/without-agent-path", uri)
32+
path = strings.TrimPrefix(path, "/without-agent-path")
33+
withoutAgentPath = true
34+
}
35+
36+
switch path {
2637
case "/v1/deployment/installer/agent/unix/paas-sh/latest":
27-
context := struct{ URI string }{URI: application.ApplicationURIs[0]}
38+
context := struct{ URI string }{URI: uri}
2839
t := template.Must(template.New("install.sh").ParseFiles("install.sh"))
2940
err := t.Execute(w, context)
3041
if err != nil {
@@ -33,7 +44,7 @@ func main() {
3344
return
3445
}
3546

36-
case "/manifest.json", "/dynatrace-env.sh", "/liboneagentproc.so":
47+
case "/dynatrace-env.sh", "/liboneagentproc.so", "/ruxitagentproc.conf":
3748
contents, err := ioutil.ReadFile(strings.TrimPrefix(req.URL.Path, "/"))
3849
if err != nil {
3950
w.WriteHeader(http.StatusInternalServerError)
@@ -42,6 +53,42 @@ func main() {
4253
}
4354
w.Write(contents)
4455

56+
case "/manifest.json":
57+
var payload map[string]interface{}
58+
file, err := os.Open("manifest.json")
59+
if err != nil {
60+
w.WriteHeader(http.StatusInternalServerError)
61+
w.Write([]byte(err.Error()))
62+
return
63+
}
64+
65+
err = json.NewDecoder(file).Decode(&payload)
66+
if err != nil {
67+
w.WriteHeader(http.StatusInternalServerError)
68+
w.Write([]byte(err.Error()))
69+
return
70+
}
71+
72+
if withoutAgentPath {
73+
payload["technologies"] = map[string]interface{}{
74+
"process": map[string]interface{}{
75+
"linux-x86-64": []struct{}{},
76+
},
77+
}
78+
}
79+
80+
json.NewEncoder(w).Encode(payload)
81+
82+
case "/v1/deployment/installer/agent/processmoduleconfig":
83+
fakeConfig, err := ioutil.ReadFile("fake_config.json")
84+
if err != nil {
85+
w.WriteHeader(http.StatusInternalServerError)
86+
w.Write([]byte(err.Error()))
87+
return
88+
}
89+
w.Write(fakeConfig)
90+
91+
4592
default:
4693
w.WriteHeader(http.StatusNotFound)
4794
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# some comment
2+
[testsection]
3+
testkey testvalue

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.4.2
4+
github.com/Dynatrace/libbuildpack-dynatrace v1.5.0
55
github.com/blang/semver v3.5.1+incompatible
66
github.com/cloudfoundry/libbuildpack v0.0.0-20220509111721-05ef1d6ca1f1
77
github.com/elazarl/goproxy v0.0.0-20191011121108-aa519ddbe484 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ code.cloudfoundry.org/lager v2.0.0+incompatible h1:WZwDKDB2PLd/oL+USK4b4aEjUymIe
22
code.cloudfoundry.org/lager v2.0.0+incompatible/go.mod h1:O2sS7gKP3HM2iemG+EnwvyNQK7pTSC6Foi4QiMp9sSk=
33
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
44
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
5-
github.com/Dynatrace/libbuildpack-dynatrace v1.4.2 h1:sGmRK5owrhyryDSDkX6PjxUTPj+RAxyD5W1rMLX3S1A=
6-
github.com/Dynatrace/libbuildpack-dynatrace v1.4.2/go.mod h1:TojYXsxk1r+TaVOTUOWKyX2hAOzbvb+BsQGxUZ8Cb2s=
5+
github.com/Dynatrace/libbuildpack-dynatrace v1.5.0 h1:EZ2fSooBGd179dFbM673l1RE7zGfKuyVUujl/plWsnU=
6+
github.com/Dynatrace/libbuildpack-dynatrace v1.5.0/go.mod h1:TojYXsxk1r+TaVOTUOWKyX2hAOzbvb+BsQGxUZ8Cb2s=
77
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
88
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
99
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=

src/python/integration/deploy_python_app_with_dynatrace_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,26 @@ var _ = Describe("CF Python Buildpack", func() {
244244
Expect(app.Stdout.String()).To(ContainSubstring("Dynatrace OneAgent injection is set up."))
245245
})
246246
})
247+
248+
Context("deploying a Python app with Dynatrace OneAgent with single credentials service", func() {
249+
It("checks if agent config update via API was successful", func() {
250+
serviceName := "dynatrace-" + cutlass.RandStringRunes(20) + "-service"
251+
command := exec.Command("cf", "cups", serviceName, "-p", fmt.Sprintf("'{\"apitoken\":\"secretpaastoken\",\"apiurl\":\"%s\",\"environmentid\":\"envid\"}'", dynatraceAPIURI))
252+
_, err := command.CombinedOutput()
253+
Expect(err).To(BeNil())
254+
createdServices = append(createdServices, serviceName)
255+
command = exec.Command("cf", "bind-service", app.Name, serviceName)
256+
_, err = command.CombinedOutput()
257+
Expect(err).To(BeNil())
258+
259+
command = exec.Command("cf", "restage", app.Name)
260+
_, err = command.Output()
261+
Expect(err).To(BeNil())
262+
263+
Expect(app.ConfirmBuildpack(buildpackVersion)).To(Succeed())
264+
Expect(app.Stdout.String()).To(ContainSubstring("Fetching updated OneAgent configuration from tenant..."))
265+
Expect(app.Stdout.String()).To(ContainSubstring("Finished writing updated OneAgent config back to"))
266+
})
267+
})
268+
247269
})

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

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

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# code.cloudfoundry.org/lager v2.0.0+incompatible
22
code.cloudfoundry.org/lager
3-
# github.com/Dynatrace/libbuildpack-dynatrace v1.4.2
3+
# github.com/Dynatrace/libbuildpack-dynatrace v1.5.0
44
github.com/Dynatrace/libbuildpack-dynatrace
55
# github.com/Masterminds/semver v1.5.0
66
github.com/Masterminds/semver

0 commit comments

Comments
 (0)