Skip to content

Commit

Permalink
Configure to use image built in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinFairise2 committed Aug 1, 2024
1 parent d3e949c commit 788d3d1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
19 changes: 11 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ variables:
TEST_INFRA_DEFINITIONS_BUILDIMAGES: b02a714d7de7
stages:
- manaul-jobs
- e2e
- build
- push
- e2e
- staging-deploy
- prod-deploy

Expand Down Expand Up @@ -68,7 +68,7 @@ push-image-agent-qa:
strategy: depend
variables:
IMG_SOURCES: $BUILD_DD_REGISTRY:otelcolcontrib-v${CI_COMMIT_SHORT_SHA}
IMG_DESTINATIONS: otel-collector-contrib:${CI_COMMIT_SHORT_SHA}
IMG_DESTINATIONS: otel-collector-contrib:${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}
IMG_REGISTRIES: agent-qa

build-ci-image:
Expand Down Expand Up @@ -154,16 +154,19 @@ prod-deploy-demo-eks:
KUBERNETES_MEMORY_REQUEST: 12Gi
KUBERNETES_MEMORY_LIMIT: 16Gi
KUBERNETES_CPU_REQUEST: 6
E2E_PIPELINE_ID: $CI_PIPELINE_ID
E2E_COMMIT_SHORT_SHA: $CI_COMMIT_SHORT_SHA
E2E_PUBLIC_KEY_PATH: /tmp/agent-qa-ssh-key.pub
E2E_PRIVATE_KEY_PATH: /tmp/agent-qa-ssh-key
E2E_KEY_PAIR_NAME: ci.open-elemetry-collector-contrib
E2E_OUTPUT_DIR: $CI_PROJECT_DIR/e2e-output
script:
- cd e2e-tests && go test $TARGETS/... -v timeout 0
- cd e2e-tests && go test $TARGETS/... -v timeout 0 --args -docker_secret $(aws ecr get-login-password)

# new-e2e-otel-collector:
# extends: .new_e2e_template
# variables:
# TARGETS: ./
# TEAM: otel
new-e2e-otel-collector:
extends: .new_e2e_template
needs: ['push-image-agent-qa']
variables:
TARGETS: ./
TEAM: otel

5 changes: 2 additions & 3 deletions e2e-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.13.1
github.com/pulumi/pulumi/sdk/v3 v3.126.0
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.28.4
)

Expand Down Expand Up @@ -156,7 +156,6 @@ require (
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/zclconf/go-cty v1.14.4 // indirect
github.com/zorkian/go-datadog-api v2.30.0+incompatible // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
Expand All @@ -176,7 +175,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.28.4 // indirect
k8s.io/client-go v0.28.4 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions e2e-tests/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions e2e-tests/otel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"context"
"flag"
"fmt"
"os"
"testing"

"github.com/DataDog/datadog-agent/test/new-e2e/pkg/runner"
otelcollector "github.com/DataDog/opentelemetry-collector-contrib/e2e-tests/otel-collector"
"github.com/DataDog/opentelemetry-collector-contrib/e2e-tests/otel-collector/otelparams"

"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e"
"github.com/stretchr/testify/assert"
Expand All @@ -33,11 +35,24 @@ func TestVMSuite(t *testing.T) {
extraParams.Set("ddagent:imagePullPassword", *dockerSecret, true)
extraParams.Set("ddagent:imagePullUsername", "AWS", false)

suiteParams := []e2e.SuiteOption{e2e.WithProvisioner(otelcollector.Provisioner(otelcollector.WithOTelOptions(), otelcollector.WithExtraParams(extraParams)))}
otelOptions := []otelparams.Option{}
// Use image built in the CI
pipelineID, ok1 := os.LookupEnv("E2E_PIPELINE_ID")
commitSHA, ok2 := os.LookupEnv("E2E_COMMIT_SHORT_SHA")
if ok1 && ok2 {
values := fmt.Sprintf(`
image:
tag: %s-%s
`, pipelineID, commitSHA)
otelOptions = append(otelOptions, otelparams.WithHelmValues(values))
}

suiteParams := []e2e.SuiteOption{e2e.WithProvisioner(otelcollector.Provisioner(otelcollector.WithOTelOptions(otelOptions...), otelcollector.WithExtraParams(extraParams)))}

e2e.Run(t, &otelSuite{}, suiteParams...)
}

// TODO write a test that actually test something
func (v *otelSuite) TestExecute() {
res, _ := v.Env().KubernetesCluster.Client().CoreV1().Pods("default").List(context.TODO(), v1.ListOptions{})
for _, pod := range res.Items {
Expand All @@ -53,7 +68,6 @@ func (v *otelSuite) TestExecute() {

assert.NoError(v.T(), err)
fmt.Printf("logs: %v", lo)
// assert.Equal(v.T(), 1, len(res.Items))

assert.Equal(v.T(), 1, len(res.Items))
}

0 comments on commit 788d3d1

Please sign in to comment.