@@ -431,8 +431,8 @@ publish integration layer (arm64):
431431 - echo " Published layer ARN - ${LAYER_ARN}"
432432 {{ end }}
433433
434- # Integration Tests - Deploy CDK stacks with commit hash prefix (parallel by test suite)
435- integration-deploy- suite:
434+ # Integration Tests - Deploy, test, and cleanup each suite independently (parallel by test suite)
435+ integration-suite:
436436 stage: integration-tests
437437 tags: [" arch:amd64" ]
438438 image: $ {CI_DOCKER_TARGET_IMAGE}:$ {CI_DOCKER_TARGET_VERSION}
@@ -455,6 +455,7 @@ integration-deploy-suite:
455455 variables:
456456 IDENTIFIER: $ {CI_COMMIT_SHORT_SHA}
457457 AWS_DEFAULT_REGION: us-east-1
458+ DD_SITE: datadoghq.com
458459 {{ with $environment := (ds " environments" ).environments.sandbox }}
459460 before_script:
460461 - EXTERNAL_ID_NAME= {{ $environment .external_id }} ROLE_TO_ASSUME= {{ $environment .role_to_assume }} AWS_ACCOUNT= {{ $environment .account }} source .gitlab /scripts/get_secrets.sh
@@ -464,68 +465,23 @@ integration-deploy-suite:
464465 - npm ci
465466 {{ end }}
466467 script:
468+ # Deploy
467469 - echo " Deploying ${TEST_SUITE} CDK stack with identifier ${IDENTIFIER}..."
468470 - export EXTENSION_LAYER_ARN= $ (aws lambda list-layer-versions --layer-name " Datadog-Extension-ARM-${CI_COMMIT_SHORT_SHA}" --query 'LayerVersions[0].LayerVersionArn ' --output text --region us-east-1)
469471 - echo " Using integration test layer - ${EXTENSION_LAYER_ARN}"
470472 - export CDK_DEFAULT_ACCOUNT= $ (aws sts get-caller-identity --query Account --output text)
471473 - export CDK_DEFAULT_REGION= us-east-1
472474 - npm run build
473475 - npx cdk deploy " integ-${IDENTIFIER}-${TEST_SUITE}" --require-approval never
474-
475- # Integration Tests - Run Jest test suite (parallel by test suite)
476- integration-test-suite:
477- stage: integration-tests
478- tags: [" arch:amd64" ]
479- image: $ {CI_DOCKER_TARGET_IMAGE}:$ {CI_DOCKER_TARGET_VERSION}
480- parallel:
481- matrix:
482- - TEST_SUITE: [base, otlp]
483- rules:
484- - when: on_success
485- needs:
486- - integration-deploy-suite
487- variables:
488- IDENTIFIER: $ {CI_COMMIT_SHORT_SHA}
489- DD_SITE: datadoghq.com
490- {{ with $environment := (ds " environments" ).environments.sandbox }}
491- before_script:
492- - EXTERNAL_ID_NAME= {{ $environment .external_id }} ROLE_TO_ASSUME= {{ $environment .role_to_assume }} AWS_ACCOUNT= {{ $environment .account }} source .gitlab /scripts/get_secrets.sh
493- - curl -fsSL https://deb.nodesource.com /setup_20.x | bash -
494- - apt-get install -y nodejs
495- - cd integration-tests
496- - npm ci
497- script:
476+ # Test
498477 - echo " Running ${TEST_SUITE} integration tests with identifier ${IDENTIFIER}..."
499478 - export TEST_SUITE= $ {TEST_SUITE}
500479 - npx jest tests/$ {TEST_SUITE}.test.ts
501- {{ end }}
502- artifacts:
503- when: always
504- paths:
505- - integration-tests/test-results/
506- reports:
507- junit: integration-tests/test-results/junit-*.xml
508- expire_in: 30 days
509-
510- # Integration Tests - Cleanup stacks (parallel by test suite)
511- integration-cleanup-suite:
512- stage: integration-tests
513- tags: [" arch:amd64" ]
514- image: $ {CI_DOCKER_TARGET_IMAGE}:$ {CI_DOCKER_TARGET_VERSION}
515- parallel:
516- matrix:
517- - TEST_SUITE: [base, otlp]
518- rules:
519- - when: always
520- needs:
521- - integration-test-suite
522- variables:
523- IDENTIFIER: $ {CI_COMMIT_SHORT_SHA}
524480 {{ with $environment := (ds " environments" ).environments.sandbox }}
525- before_script:
481+ after_script:
482+ # Re-authenticate for cleanup (after_script runs in new shell)
526483 - EXTERNAL_ID_NAME= {{ $environment .external_id }} ROLE_TO_ASSUME= {{ $environment .role_to_assume }} AWS_ACCOUNT= {{ $environment .account }} source .gitlab /scripts/get_secrets.sh
527- {{ end }}
528- script:
484+ # Cleanup - always runs even if tests fail
529485 - echo " Destroying ${TEST_SUITE} CDK stack with identifier ${IDENTIFIER}..."
530486 - |
531487 STACK_NAME= " integ-${IDENTIFIER}-${TEST_SUITE}"
@@ -548,6 +504,14 @@ integration-cleanup-suite:
548504
549505 echo " ${TEST_SUITE} stack deleted successfully"
550506 fi
507+ {{ end }}
508+ artifacts:
509+ when: always
510+ paths:
511+ - integration-tests/test-results/
512+ reports:
513+ junit: integration-tests/test-results/junit-*.xml
514+ expire_in: 30 days
551515
552516# Integration Tests - Cleanup layer
553517integration-cleanup-layer:
@@ -557,7 +521,7 @@ integration-cleanup-layer:
557521 rules:
558522 - when: always
559523 needs:
560- - job: integration-cleanup- suite
524+ - job: integration-suite
561525 variables:
562526 IDENTIFIER: $ {CI_COMMIT_SHORT_SHA}
563527 {{ with $environment := (ds " environments" ).environments.sandbox }}
0 commit comments