-
Notifications
You must be signed in to change notification settings - Fork 9
251 lines (222 loc) · 10.2 KB
/
run-lib-injection.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Lib-injection tests
on:
workflow_call:
inputs:
build_lib_injection_app_images:
description: "Shall we build python base images for tests on python tracer"
default: false
required: false
type: boolean
library:
description: "Library to test"
required: true
type: string
version:
description: "Version of the image to test"
required: true
type: string
env:
REGISTRY: ghcr.io
jobs:
compute-matrix:
name: Get weblogs for Lib-Injection tests
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.compute-matrix.outputs.matrix }}
matrix_supported_langs: ${{ steps.compute-matrix.outputs.matrix_supported_langs }}
matrix_profiling_supported: ${{ steps.compute-matrix.outputs.matrix_profiling_supported }}
init_image: ${{ steps.compute-matrix.outputs.init_image }}
steps:
- name: Compute matrix
id: compute-matrix
shell: python
run: |
import json
import os
weblogs={
"cpp": [],
"dotnet": [{"name":"dd-lib-dotnet-init-test-app","supported":"true"}],
"golang": [],
"java": [{"name":"dd-lib-java-init-test-app","supported":"true"},{"name":"jdk7-app","supported":"false"}],
"nodejs": [{"name":"sample-app","supported":"true"},{"name":"sample-app-node13","supported":"false"}],
"php": [],
"python": [{"name":"dd-lib-python-init-test-django","supported":"true"},
{"name":"dd-lib-python-init-test-django-gunicorn", "supported":"true"},
{"name":"dd-lib-python-init-test-django-gunicorn-alpine","supported":"true"},
{"name":"dd-lib-python-init-test-django-preinstalled","supported":"true","skip-profiling":"true"},
{"name":"dd-lib-python-init-test-django-unsupported-package-force","supported":"true"},
{"name":"dd-lib-python-init-test-django-uvicorn","supported":"true"},
{"name":"dd-lib-python-init-test-protobuf-old","supported":"true"}],
"ruby": [{"name":"dd-lib-ruby-init-test-rails","supported":"true"}, {"name":"dd-lib-ruby-init-test-rails-explicit","supported":"true"}, {"name":"dd-lib-ruby-init-test-rails-gemsrb","supported":"true"}]
}
prod_init_images={
"cpp": [],
"dotnet": ["gcr.io/datadoghq/dd-lib-dotnet-init:latest"],
"golang": [],
"java": ["gcr.io/datadoghq/dd-lib-java-init:latest"],
"nodejs": ["gcr.io/datadoghq/dd-lib-js-init:latest"],
"php": [],
"python": ["gcr.io/datadoghq/dd-lib-python-init:latest"],
"ruby": ["gcr.io/datadoghq/dd-lib-ruby-init:latest"],
}
dev_init_images={
"cpp": [],
"dotnet": ["ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:latest_snapshot"],
"golang": [],
"java": ["ghcr.io/datadog/dd-trace-java/dd-lib-java-init:latest_snapshot"],
"nodejs": ["ghcr.io/datadog/dd-trace-js/dd-lib-js-init:latest_snapshot"],
"php": [],
"python": ["ghcr.io/datadog/dd-trace-py/dd-lib-python-init:latest_snapshot"],
"ruby": ["ghcr.io/datadog/dd-trace-rb/dd-lib-ruby-init:latest_snapshot"],
}
#All weblog variants
result = weblogs["${{ inputs.library }}"]
#Only supported weblog variants
results_supported_langs = []
results_profiling_supported = []
for weblog in weblogs["${{ inputs.library }}"]:
if weblog["supported"] == "true":
results_supported_langs.append(weblog["name"])
if "skip-profiling" not in weblog or weblog["skip-profiling"] != "true":
results_profiling_supported.append(weblog["name"])
#Use the latest init image for prod version, latest_snapshot init image for dev version
if "${{ inputs.version }}" == 'prod':
result_init_image = prod_init_images["${{ inputs.library }}"]
else:
result_init_image = dev_init_images["${{ inputs.library }}"]
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(f'matrix={json.dumps(result)}', file=fh)
print(f'init_image={json.dumps(result_init_image)}', file=fh)
print(f'matrix_supported_langs={json.dumps(results_supported_langs)}', file=fh)
print(f'matrix_profiling_supported={json.dumps(results_profiling_supported)}', file=fh)
print(json.dumps(result, indent=2))
print(json.dumps(result_init_image, indent=2))
print(json.dumps(results_supported_langs, indent=2))
print(json.dumps(results_profiling_supported, indent=2))
lib-injection-init-image-validator:
if: inputs.library == 'dotnet' || inputs.library == 'java' || inputs.library == 'python' || inputs.library == 'ruby' || inputs.library == 'nodejs'
runs-on:
group: "APM Larger Runners"
permissions:
contents: read
packages: read
needs:
- compute-matrix
strategy:
matrix:
weblog: ${{ fromJson(needs.compute-matrix.outputs.matrix) }}
lib_init_image: ${{ fromJson(needs.compute-matrix.outputs.init_image) }}
fail-fast: false
env:
TEST_LIBRARY: ${{ inputs.library }}
LIB_INIT_IMAGE: ${{ matrix.lib_init_image }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'DataDog/system-tests'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/#-action@343f7c4344506bcbf9b4de18042ae17996df046d # 3.0.0
with:
registry: ghcr.io/datadog
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build weblog init image validator
run: lib-injection/build/build_lib_injection_weblog.sh -w ${{ matrix.weblog.name }} -l ${{ inputs.library }}
- name: Install runner
uses: ./.github/actions/install_runner
- name: Perform lib injection
if: matrix.weblog.supported == 'true'
run: |
echo "Testing lib injection init image: $LIB_INIT_IMAGE"
./run.sh LIB_INJECTION_VALIDATION
- name: Perform lib injection for not supported lang
if: matrix.weblog.supported == 'false'
run: |
echo "Testing lib injection init image: $LIB_INIT_IMAGE"
./run.sh LIB_INJECTION_VALIDATION_UNSUPPORTED_LANG
- name: Compress logs
id: compress_logs
if: always()
run: tar -czvf artifact.tar.gz $(ls | grep logs)
- name: Upload artifact
if: always() && steps.compress_logs.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: logs_lib-injection_validation_${{ inputs.library}}_${{matrix.weblog.name}}_${{ endsWith(matrix.lib_init_image, 'latest_snapshot') == true && 'latest_snapshot' || 'latest'}}
path: artifact.tar.gz
k8s-lib-injection-tests:
if: inputs.library == 'dotnet' || inputs.library == 'java' || inputs.library == 'python' || inputs.library == 'ruby' || inputs.library == 'nodejs'
runs-on:
group: "APM Larger Runners"
permissions:
contents: read
packages: write
needs:
- compute-matrix
strategy:
matrix:
weblog: ${{ fromJson(needs.compute-matrix.outputs.matrix_supported_langs) }}
lib_init_image: ${{ fromJson(needs.compute-matrix.outputs.init_image) }}
cluster_agent_version: ['7.56.2', '7.57.0']
fail-fast: false
env:
TEST_LIBRARY: ${{ inputs.library }}
WEBLOG_VARIANT: ${{ matrix.weblog }}
LIB_INIT_IMAGE: ${{ matrix.lib_init_image }}
SYSTEM_TESTS_REPORT_ENVIRONMENT: dev
SYSTEM_TESTS_REPORT_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
LIBRARY_INJECTION_TEST_APP_IMAGE: ghcr.io/datadog/system-tests/${{ matrix.weblog }}:${{ inputs.build_lib_injection_app_images != true && 'latest' || github.sha }}
CLUSTER_AGENT_VERSION: ${{ matrix.cluster_agent_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'DataDog/system-tests'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.12.1 # 0.13.0 is causing the builds to fail
install: true
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 1
- name: Log in to the Container registry
uses: docker/#-action@343f7c4344506bcbf9b4de18042ae17996df046d # 3.0.0
with:
registry: ghcr.io/datadog
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install runner
uses: ./.github/actions/install_runner
- name: Build weblog base images (PR)
id: build
if: inputs.build_lib_injection_app_images
run: |
#Build multiplatform
lib-injection/build/build_lib_injection_weblog.sh -w ${{ matrix.weblog }} -l ${{ inputs.library }} --push-tag ${{ env.LIBRARY_INJECTION_TEST_APP_IMAGE }} --docker-platform linux/arm64,linux/amd64
- name: Kubernetes lib-injection tests
id: k8s-lib-injection-tests
run: ./run.sh K8S_LIBRARY_INJECTION_BASIC
- name: Kubernetes lib-injection profiling tests
id: k8s-lib-injection-tests-profiling
if: ${{ contains(fromJson(needs.compute-matrix.outputs.matrix_profiling_supported), matrix.weblog) }}
run: ./run.sh K8S_LIBRARY_INJECTION_PROFILING
- name: Compress logs
id: compress_logs
if: always() && steps.build.outcome == 'success'
run: tar -czvf artifact.tar.gz $(ls | grep logs)
- name: Upload artifact
if: always() && steps.compress_logs.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: logs_k8s-lib-injection_${{ inputs.library}}_${{matrix.weblog}}_${{matrix.cluster_agent_version}}_${{ endsWith(matrix.lib_init_image, 'latest_snapshot') == true && 'dev' || 'prod'}}
path: artifact.tar.gz