From c8cc3d67cb9d0b5d12fcce5f24c3bc701d9d96bf Mon Sep 17 00:00:00 2001 From: Kevin Fairise <132568982+KevinFairise2@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:24:00 +0200 Subject: [PATCH] =?UTF-8?q?Run=20docker=20fake=20intake=20test=20with=20ne?= =?UTF-8?q?w=20version=20of=20the=20fakeintake=20if=20mod=E2=80=A6=20(#244?= =?UTF-8?q?41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Run docker fake intake test with new version of the fakeintake if modified * try again * Move e2e_pre_test stage * Break fakeintake [skip cancel] * Break fakeintake for real this time * Rerun * Break fakeintake * Test +logs * Check if var is defined: * Check if var is defined * Try to understand why my evariable is not set * Fix rule * Fix rule * Factorize rules * Remove print * Fix anchor * Fix anchor * Log used fakeintake image * Update .gitlab-ci.yml Co-authored-by: Nicolas Schweitzer --------- Co-authored-by: Nicolas Schweitzer --- .gitlab-ci.yml | 47 ++++++++++++------- .gitlab/dev_container_deploy/fakeintake.yml | 4 +- .gitlab/e2e_pre_test/e2e_pre_test.yml | 6 ++- .../test-infra-definition/docker_test.go | 11 ++++- 4 files changed, 47 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5834cc894f9fd..adbbdce3a1e80 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,7 +77,6 @@ stages: - pkg_metrics - packaging - kitchen_deploy - - e2e_pre_test - kitchen_testing - container_build - container_scan @@ -92,6 +91,7 @@ stages: - choco_deploy - internal_image_deploy - install_script_testing + - e2e_pre_test - e2e - kitchen_cleanup - functional_test @@ -359,6 +359,15 @@ variables: .if_mergequeue: &if_mergequeue if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/ +.fakeintake_changes: &fakeintake_changes + changes: + paths: + - "test/fakeintake/**/*" + - .gitlab/binary_build/fakeintake.yml + - .gitlab/container_build/fakeintake.yml + - .gitlab/dev_container_deploy/fakeintake.yml + compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916 + # # Workflow rules # Rules used to define whether a pipeline should run, and with which variables @@ -764,6 +773,23 @@ workflow: # New E2E related rules +.on_e2e_or_fakeintake_changes_or_manual: + - <<: *if_main_branch + - !reference [.except_mergequeue] + - <<: *fakeintake_changes + variables: + FAKEINTAKE_IMAGE_OVERRIDE: "public.ecr.aws/datadog/fakeintake:v$CI_COMMIT_SHORT_SHA" + when: on_success + - changes: + paths: + - test/new-e2e/pkg/**/* + - test/new-e2e/test-infra-definition/* + - test/new-e2e/go.mod + compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916 + when: on_success + - when: manual + allow_failure: true + .on_e2e_main_release_or_rc: # This rule is used as a base for all new-e2e rules - <<: *if_disable_e2e_tests @@ -994,23 +1020,12 @@ workflow: - .go-version compare_to: main # TODO: use a variable, when this is supported https://gitlab.com/gitlab-org/gitlab/-/issues/369916 -.on_fakeintake_changes: &on_fakeintake_changes - changes: - - "test/fakeintake/**/*" - - .gitlab/binary_build/fakeintake.yml - - .gitlab/container_build/fakeintake.yml - - .gitlab/dev_container_deploy/fakeintake.yml - -.on_fakeintake_changes_on_main_or_manual: - - <<: *on_fakeintake_changes - if: $CI_COMMIT_BRANCH == "main" - - <<: *on_fakeintake_changes - when: manual - allow_failure: true +.on_fakeintake_changes: + - <<: *fakeintake_changes .on_fakeintake_changes_on_main: - - <<: *on_fakeintake_changes - if: $CI_COMMIT_BRANCH == "main" + - <<: *fakeintake_changes + - <<: *if_main_branch .fast_on_dev_branch_only: - <<: *if_main_branch diff --git a/.gitlab/dev_container_deploy/fakeintake.yml b/.gitlab/dev_container_deploy/fakeintake.yml index f95086a71c12d..326def46873f9 100644 --- a/.gitlab/dev_container_deploy/fakeintake.yml +++ b/.gitlab/dev_container_deploy/fakeintake.yml @@ -4,7 +4,7 @@ publish_fakeintake: stage: dev_container_deploy rules: - !reference [.except_mergequeue] - - !reference [.on_fakeintake_changes_on_main_or_manual] + - !reference [.on_fakeintake_changes] needs: - job: docker_build_fakeintake optional: false @@ -27,4 +27,4 @@ publish_fakeintake_latest: IMG_SOURCES: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent/fakeintake:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA} IMG_DESTINATIONS: fakeintake:latest IMG_REGISTRIES: public - IMG_SIGNING: "false" \ No newline at end of file + IMG_SIGNING: "false" diff --git a/.gitlab/e2e_pre_test/e2e_pre_test.yml b/.gitlab/e2e_pre_test/e2e_pre_test.yml index c9b20a6f37708..0489a7ad7d2a0 100644 --- a/.gitlab/e2e_pre_test/e2e_pre_test.yml +++ b/.gitlab/e2e_pre_test/e2e_pre_test.yml @@ -2,10 +2,12 @@ # Contains jobs which runs e2e tests to validate the new-e2e framework. e2e_pre_test: rules: - - !reference [.on_e2e_changes_or_manual] + - !reference [.on_e2e_or_fakeintake_changes_or_manual] stage: e2e_pre_test extends: .new_e2e_template - needs: [] + needs: + - job: publish_fakeintake + optional: true script: - inv -e new-e2e-tests.run --targets ./test-infra-definition --junit-tar junit-${CI_JOB_ID}.tgz ${EXTRA_PARAMS} after_script: diff --git a/test/new-e2e/test-infra-definition/docker_test.go b/test/new-e2e/test-infra-definition/docker_test.go index 76a8e85279a9e..1ede9e48f9d66 100644 --- a/test/new-e2e/test-infra-definition/docker_test.go +++ b/test/new-e2e/test-infra-definition/docker_test.go @@ -7,6 +7,7 @@ package testinfradefinition import ( "fmt" + "os" "regexp" "testing" "time" @@ -15,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments" awsdocker "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/docker" "github.com/DataDog/datadog-agent/test/new-e2e/pkg/utils/e2e/client/agentclient" + "github.com/DataDog/test-infra-definitions/scenarios/aws/fakeintake" "github.com/stretchr/testify/assert" ) @@ -23,7 +25,14 @@ type dockerSuite struct { } func TestDocker(t *testing.T) { - e2e.Run(t, &dockerSuite{}, e2e.WithProvisioner(awsdocker.Provisioner())) + var fakeintakeOpts []fakeintake.Option + + // When we modify the fakeintake, this test will run with the new version of the fakeintake + if fakeintakeImage, ok := os.LookupEnv("FAKEINTAKE_IMAGE_OVERRIDE"); ok { + t.Logf("Running with fakeintake image %s", fakeintakeImage) + fakeintakeOpts = append(fakeintakeOpts, fakeintake.WithImageURL(fakeintakeImage)) + } + e2e.Run(t, &dockerSuite{}, e2e.WithProvisioner(awsdocker.Provisioner(awsdocker.WithFakeIntakeOptions(fakeintakeOpts...)))) } func (v *dockerSuite) TestExecuteCommand() {