Skip to content

Commit 9cef358

Browse files
[SVLS-8740] add e2e test trigger (#1173)
## Overview Trigger E2E test runs in this repo. This should also add E2E test runs to the release pipeline, but does not block on failure in case of flakiness. ## Testing Pipeline launches E2E tests
1 parent 977cfda commit 9cef358

5 files changed

Lines changed: 177 additions & 2 deletions

File tree

.gitlab/scripts/poll_e2e.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
# Trigger serverless-e2e-tests pipeline and poll until completion.
3+
4+
set -euo pipefail
5+
6+
if [ -z "${EXTENSION_LAYER_ARN:-}" ]; then
7+
echo "ERROR: EXTENSION_LAYER_ARN is not set or empty"
8+
exit 1
9+
fi
10+
11+
E2E_PROJECT_ENCODED="DataDog%2Fserverless-e2e-tests"
12+
E2E_REF="${E2E_REF:-main}"
13+
14+
curl -OL "binaries.ddbuild.io/dd-source/authanywhere/LATEST/authanywhere-linux-amd64" && mv authanywhere-linux-amd64 /bin/authanywhere && chmod +x /bin/authanywhere
15+
16+
BTI_CI_API_TOKEN=$(authanywhere --audience rapid-devex-ci)
17+
18+
BTI_RESPONSE=$(curl --silent --request GET \
19+
--header "$BTI_CI_API_TOKEN" \
20+
--header "Content-Type: application/vnd.api+json" \
21+
"https://bti-ci-api.us1.ddbuild.io/internal/ci/gitlab/token?owner=DataDog&repository=serverless-e2e-tests")
22+
23+
GITLAB_TOKEN=$(echo "$BTI_RESPONSE" | jq -r '.token // empty')
24+
if [ -z "$GITLAB_TOKEN" ]; then
25+
echo "ERROR: could not obtain GitLab token from BTI"
26+
exit 1
27+
fi
28+
29+
echo "Triggering DataDog/serverless-e2e-tests pipeline (ref: ${E2E_REF})..."
30+
echo " EXTENSION_LAYER_ARN=${EXTENSION_LAYER_ARN}"
31+
32+
TRIGGER_RESPONSE=$(curl --silent --request POST \
33+
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
34+
--header "Content-Type: application/json" \
35+
--data "$(jq -n \
36+
--arg ref "$E2E_REF" \
37+
--arg arn "$EXTENSION_LAYER_ARN" \
38+
'{ref: $ref, variables: [{key: "EXTENSION_VERSION", value: $arn}]}')" \
39+
"${CI_API_V4_URL}/projects/${E2E_PROJECT_ENCODED}/pipeline")
40+
41+
PIPELINE_ID=$(echo "$TRIGGER_RESPONSE" | jq -r '.id // empty')
42+
PIPELINE_URL=$(echo "$TRIGGER_RESPONSE" | jq -r '.web_url // empty')
43+
44+
if [ -z "$PIPELINE_ID" ] || [ "$PIPELINE_ID" = "null" ]; then
45+
echo "ERROR: failed to trigger downstream pipeline"
46+
echo "Response: $TRIGGER_RESPONSE"
47+
exit 1
48+
fi
49+
50+
echo "Triggered downstream pipeline: ${PIPELINE_URL} (ID: ${PIPELINE_ID})"
51+
52+
while true; do
53+
STATUS=$(curl --silent \
54+
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
55+
"${CI_API_V4_URL}/projects/${E2E_PROJECT_ENCODED}/pipelines/${PIPELINE_ID}" \
56+
| jq -r '.status // empty')
57+
58+
echo -n "E2E pipeline ${PIPELINE_ID} status: ${STATUS}, "
59+
60+
case "$STATUS" in
61+
success)
62+
echo "E2E tests passed"
63+
exit 0
64+
;;
65+
failed)
66+
echo "E2E tests failed"
67+
exit 1
68+
;;
69+
canceled|canceling)
70+
echo "E2E tests canceled"
71+
exit 1
72+
;;
73+
skipped)
74+
echo "E2E tests skipped"
75+
exit 0
76+
;;
77+
running|pending|created|waiting_for_resource|preparing)
78+
echo "still running, checking again in 2 minutes..."
79+
;;
80+
*)
81+
echo "unknown status, checking again in 2 minutes..."
82+
;;
83+
esac
84+
85+
sleep 120
86+
done

.gitlab/scripts/publish_layers.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,15 @@ while [ $latest_version -lt $VERSION ]; do
167167
done
168168

169169
printf "[$REGION] Finished publishing layers...\n"
170+
171+
if [ -n "${DOTENV:-}" ]; then
172+
printf "[$REGION] Exporting layer ARN to %s...\n" "$DOTENV"
173+
dotenv_key="${DOTENV_VAR_NAME:-EXTENSION_LAYER_ARN}"
174+
latest_arn=$(aws lambda get-layer-version \
175+
--layer-name "$LAYER_NAME" \
176+
--version-number "$VERSION" \
177+
--region "$REGION" \
178+
--query 'LayerVersionArn' --output text)
179+
echo "${dotenv_key}=${latest_arn}" >>"$DOTENV"
180+
cat "$DOTENV"
181+
fi

.gitlab/templates/pipeline.yaml.tpl

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
{{- $e2e_region := "us-west-2" -}}
2+
13
stages:
24
- test
35
- compile
46
- build
57
- integration-tests
68
- self-monitoring
9+
- e2e
710
- sign
811
- publish
912

@@ -141,6 +144,7 @@ sign layer ({{ $flavor.name }}):
141144
- .gitlab/scripts/sign_layers.sh prod
142145

143146
{{ range $environment_name, $environment := (ds "environments").environments }}
147+
{{- $dotenv := printf "%s_%s.env" $flavor.suffix $environment_name }}
144148

145149
publish layer {{ $environment_name }} ({{ $flavor.name }}):
146150
stage: publish
@@ -172,12 +176,21 @@ publish layer {{ $environment_name }} ({{ $flavor.name }}):
172176
- REGION: {{ range (ds "regions").regions }}
173177
- {{ .code }}
174178
{{- end}}
179+
{{- if eq $environment_name "sandbox" }}
180+
artifacts:
181+
reports:
182+
dotenv: {{ $dotenv }}
183+
{{- end }}
175184
variables:
176185
LAYER_NAME_BASE_SUFFIX: {{ $flavor.layer_name_base_suffix }}
177186
ARCHITECTURE: {{ $flavor.arch }}
178187
LAYER_FILE: datadog_extension-{{ $flavor.suffix }}.zip
179188
ADD_LAYER_VERSION_PERMISSIONS: {{ $environment.add_layer_version_permissions }}
180189
AUTOMATICALLY_BUMP_VERSION: {{ $environment.automatically_bump_version }}
190+
{{- if eq $environment_name "sandbox" }}
191+
LAYER_DESCRIPTION: ${CI_COMMIT_SHORT_SHA}
192+
DOTENV: {{ $dotenv }}
193+
{{- end }}
181194
before_script:
182195
- EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source .gitlab/scripts/get_secrets.sh
183196
script:
@@ -217,6 +230,67 @@ publish layer [self-monitoring] ({{ $flavor.name }}):
217230

218231
{{ end }} # end flavors
219232

233+
{{ range $f := (ds "flavors").flavors }}
234+
{{ if $f.needs_layer_publish }}
235+
{{- $dotenvE2E := printf "%s_sandbox_e2e.env" $f.suffix }}
236+
{{ with $environment := (ds "environments").environments.sandbox }}
237+
238+
publish layer e2e sandbox ({{ $f.name }}):
239+
stage: e2e
240+
tags: ["arch:amd64"]
241+
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
242+
rules:
243+
- if: '$CI_COMMIT_TAG =~ /^v.*/'
244+
when: on_success
245+
variables:
246+
LAYER_DESCRIPTION: $CI_COMMIT_TAG
247+
- when: on_success
248+
variables:
249+
LAYER_DESCRIPTION: $CI_COMMIT_SHORT_SHA
250+
needs:
251+
- layer ({{ $f.name }})
252+
{{ if and (index $f "max_layer_compressed_size_mb") (index $f "max_layer_uncompressed_size_mb") }}
253+
- check layer size ({{ $f.name }})
254+
{{ end }}
255+
dependencies:
256+
- layer ({{ $f.name }})
257+
artifacts:
258+
reports:
259+
dotenv: {{ $dotenvE2E }}
260+
variables:
261+
LAYER_NAME_BASE_SUFFIX: {{ $f.layer_name_base_suffix }}
262+
ARCHITECTURE: {{ $f.arch }}
263+
LAYER_FILE: datadog_extension-{{ $f.suffix }}.zip
264+
REGION: {{ $e2e_region }}
265+
ADD_LAYER_VERSION_PERMISSIONS: {{ $environment.add_layer_version_permissions }}
266+
AUTOMATICALLY_BUMP_VERSION: {{ $environment.automatically_bump_version }}
267+
DOTENV: {{ $dotenvE2E }}
268+
before_script:
269+
- EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source .gitlab/scripts/get_secrets.sh
270+
script:
271+
- .gitlab/scripts/publish_layers.sh
272+
273+
e2e-suite ({{ $f.name }}):
274+
stage: e2e
275+
image: registry.ddbuild.io/images/docker:20.10-py3
276+
tags: ["arch:amd64"]
277+
timeout: 3h
278+
rules:
279+
# Do not block on release, in case E2E is flaky
280+
- if: '$CI_COMMIT_TAG =~ /^v.*/'
281+
when: on_success
282+
allow_failure: true
283+
- when: on_success
284+
needs:
285+
- job: "publish layer e2e sandbox ({{ $f.name }})"
286+
artifacts: true
287+
script:
288+
- .gitlab/scripts/poll_e2e.sh
289+
290+
{{ end }}
291+
{{ end }}
292+
{{ end }}
293+
220294
{{ range $multi_arch_image_flavor := (ds "flavors").multi_arch_image_flavors }}
221295

222296
publish private images ({{ $multi_arch_image_flavor.name }}):

bottlecap/Cargo.lock

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

bottlecap/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ sha2 = { version = "0.10", default-features = false }
4040
hex = { version = "0.4", default-features = false, features = ["std"] }
4141
base64 = { version = "0.22", default-features = false }
4242
rustls = { version = "0.23.18", default-features = false, features = ["aws-lc-rs"] }
43+
# Transitive via rustls. Pinned to >=0.103.13 so cargo audit passes (RUSTSEC-2026-0098, RUSTSEC-2026-0099, RUSTSEC-2026-0104).
44+
rustls-webpki = { version = "0.103.13", default-features = false }
4345
rustls-pemfile = { version = "2.0", default-features = false, features = ["std"] }
4446
rustls-pki-types = { version = "1.0", default-features = false }
4547
hyper-rustls = { version = "0.27.7", default-features = false }

0 commit comments

Comments
 (0)