forked from DataDog/dd-trace-go
-
Notifications
You must be signed in to change notification settings - Fork 0
326 lines (303 loc) · 11.3 KB
/
unit-integration-tests.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: Unit and Integration Tests
on:
workflow_call:
inputs:
go-version:
required: true
type: string
ref:
description: 'The branch to run the workflow on'
required: true
type: string
env:
DD_APPSEC_WAF_TIMEOUT: 1m # Increase time WAF time budget to reduce CI flakiness
jobs:
copyright:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.ref }}
- name: Copyright
run: |
go run checkcopyright.go
lint:
runs-on:
group: "APM Larger Runners"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.ref }}
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
go_version: ${{ inputs.go-version }}
golangci_lint_version: v1.52.2
fail_on_error: true
reporter: github-pr-review
test-contrib:
runs-on:
group: "APM Larger Runners"
env:
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
INTEGRATION: true
services:
datadog-agent:
image: datadog/agent:latest
env:
DD_HOSTNAME: "github-actions-worker"
DD_APM_ENABLED: true
DD_BIND_HOST: "0.0.0.0"
DD_API_KEY: "invalid_key_but_this_is_fine"
DD_TEST_AGENT_HOST: "localhost"
DD_TEST_AGENT_PORT: 9126
# We need to specify a custom health-check. By default, this container will remain "unhealthy" since
# we don't fully configure it with a valid API key (and possibly other reasons)
# This command just checks for our ability to connect to port 8126
options: >-
--health-cmd "bash -c '</dev/tcp/127.0.0.1/8126'"
ports:
- 8125:8125/udp
- 8126:8126
testagent:
image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.11.0
ports:
- 9126:9126
env:
LOG_LEVEL: DEBUG
TRACE_LANGUAGE: golang
ENABLED_CHECKS: trace_stall,trace_count_header,trace_peer_service,trace_dd_service
PORT: 9126
DD_SUPPRESS_TRACE_PARSE_ERRORS: true
DD_POOL_TRACE_CHECK_FAILURES: true
DD_DISABLE_ERROR_RESPONSES: true
cassandra:
image: cassandra:3.7
env:
JVM_OPTS: "-Xms750m -Xmx750m"
ports:
- 9042:9042
mysql:
image: circleci/mysql:5.7
env:
MYSQL_ROOT_PASSWORD: admin
MYSQL_PASSWORD: test
MYSQL_USER: test
MYSQL_DATABASE: test
ports:
- 3306:3306
postgres:
image: circleci/postgres:9.5
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
SA_PASSWORD: myPassw0rd
ACCEPT_EULA: Y
ports:
- 1433:1433
consul:
image: consul:1.6.0
ports:
- 8500:8500
redis:
image: redis:3.2
ports:
- 6379:6379
elasticsearch2:
image: elasticsearch:2
env:
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
ports:
- 9200:9200
elasticsearch5:
image: elasticsearch:5
env:
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
ports:
- 9201:9200
elasticsearch6:
image: elasticsearch:6.8.13
env:
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
ports:
- 9202:9200
elasticsearch7:
image: elasticsearch:7.14.1
env:
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
discovery.type: single-node
ports:
- 9203:9200
elasticsearch8:
image: elasticsearch:8.6.2
env:
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
discovery.type: single-node
xpack.security.enabled: false
ports:
- 9204:9200
mongo:
image: circleci/mongo:latest-ram
ports:
- 27017:27017
memcached:
image: memcached:1.5.9
ports:
- 11211:11211
zookeeper:
image: bitnami/zookeeper:latest
env:
ALLOW_ANONYMOUS_LOGIN: "yes"
ports:
- 2181:2181
kafka:
image: wurstmeister/kafka:2.13-2.8.1
env:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_CREATE_TOPICS: gotest:1:1,gosegtest:1:1
KAFKA_BROKER_ID: 1
ports:
- 9092:9092
localstack:
image: localstack/localstack:latest
ports:
- 4566:4566
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.ref }}
- name: Setup Go
uses: ./.github/actions/setup-go
with:
go-version: ${{ inputs.go-version }}
- name: Test Contrib
run: |
mkdir -p $TEST_RESULTS
PACKAGE_NAMES=$(go list ./contrib/... | grep -v -e grpc.v12 -e google.golang.org/api)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v -race -coverprofile=coverage.txt -covermode=atomic
- name: Upload the results to Datadog CI App
if: always()
continue-on-error: true
uses: ./.github/actions/dd-ci-upload
with:
dd-api-key: ${{ secrets.DD_CI_API_KEY }}
files: ${{ env.TEST_RESULTS }}/gotestsum-report*.xml
tags: go:${{ inputs.go-version }},arch:${{ runner.arch }},os:${{ runner.os }},distribution:${{ runner.distribution }}
- name: Upload Coverage
if: always()
continue-on-error: true
shell: bash
run: bash <(curl -s https://codecov.io/bash)
- name: Get Datadog APM Test Agent Logs
if: always()
shell: bash
run: docker logs ${{ job.services.testagent.id }}
- name: Get Datadog APM Test Agent Trace Check Summary Results
if: always()
shell: bash
run: |
RESPONSE=$(curl -s -w "\n%{http_code}" -o response.txt "http://127.0.0.1:9126/test/trace_check/failures?return_all=true")
RESPONSE_CODE=$(echo "$RESPONSE" | awk 'END {print $NF}')
SUMMARY_RESPONSE=$(curl -s -w "\n%{http_code}" -o summary_response.txt "http://127.0.0.1:9126/test/trace_check/summary?return_all=true")
SUMMARY_RESPONSE_CODE=$(echo "$SUMMARY_RESPONSE" | awk 'END {print $NF}')
if [[ $RESPONSE_CODE -eq 200 ]]; then
echo " "
cat response.txt
echo " - All APM Test Agent Check Traces returned successful!"
echo "APM Test Agent Check Traces Summary Results:"
cat summary_response.txt | jq "."
else
echo "APM Test Agent Check Traces failed with response code: $RESPONSE_CODE"
echo "Failures:"
cat response.txt
echo "APM Test Agent Check Traces Summary Results:"
cat summary_response.txt | jq "."
exit 1
fi
- name: Testing outlier google.golang.org/api
run: |
go get google.golang.org/[email protected] # version used to generate code
go mod tidy # Go1.16 doesn't update the sum file correctly after the go get, this tidy fixes it
go test -v ./contrib/google.golang.org/api/...
- name: Testing outlier gRPC v1.2
run: |
# This hacky approach is necessary because running the tests regularly
# do not allow using [email protected] alongside [email protected].
# [email protected] is no longer possible to test because internal/datastreams/propagator.go
# expects sketches-go to have the package `github.com/DataDog/sketches-go/ddsketch/encoding` which
# is only present from v1.1.0 onwards.
go mod vendor
# Checkout [email protected]
cd vendor/google.golang.org && rm -rf grpc
git clone https://github.com/grpc/grpc-go grpc && cd grpc
git fetch origin && git checkout v1.2.0 && cd ../../..
# Checkout [email protected]
cd vendor/github.com/DataDog && rm -rf sketches-go
git clone https://github.com/DataDog/sketches-go && cd sketches-go
git fetch origin && git checkout v1.1.0 && cd ../../../..
# Revert to old metadata functions as FromIncomingContext and NewOutgoingContext are not present in v1.2.0.
# These functions were updated to current versions to avoid compilation errors in the development environments.
sed -i 's/metadata\.FromIncomingContext/metadata.FromContext/g' ./contrib/google.golang.org/grpc.v12/*
sed -i 's/metadata\.NewOutgoingContext/metadata.NewContext/g' ./contrib/google.golang.org/grpc.v12/*
go test -mod=vendor -v ./contrib/google.golang.org/grpc.v12/...
test-core:
runs-on:
group: "APM Larger Runners"
env:
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
INTEGRATION: true
services:
datadog-agent:
image: datadog/agent:latest
env:
DD_HOSTNAME: "github-actions-worker"
DD_APM_ENABLED: true
DD_BIND_HOST: "0.0.0.0"
DD_API_KEY: "invalid_key_but_this_is_fine"
# We need to specify a custom health-check. By default, this container will remain "unhealthy" since
# we don't fully configure it with a valid API key (and possibly other reasons)
# This command just checks for our ability to connect to port 8126
options: >-
--health-cmd "bash -c '</dev/tcp/127.0.0.1/8126'"
ports:
- 8125:8125/udp
- 8126:8126
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.ref }}
- name: Setup Go
uses: ./.github/actions/setup-go
with:
go-version: ${{ inputs.go-version }}
- name: Test Core
env:
DD_APPSEC_WAF_TIMEOUT: 1h
run: |
mkdir -p $TEST_RESULTS
PACKAGE_NAMES=$(go list ./... | grep -v /contrib/)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v -race -coverprofile=coverage.txt -covermode=atomic
- name: Upload the results to Datadog CI App
if: always()
continue-on-error: true
uses: ./.github/actions/dd-ci-upload
with:
dd-api-key: ${{ secrets.DD_CI_API_KEY }}
files: ${{ env.TEST_RESULTS }}/gotestsum-report.xml
tags: go:${{ inputs.go-version }}},arch:${{ runner.arch }},os:${{ runner.os }},distribution:${{ runner.distribution }}
- name: Upload Coverage
if: always()
shell: bash
run: bash <(curl -s https://codecov.io/bash)