-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore(ssi): add e2e tests #44034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
chore(ssi): add e2e tests #44034
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bad931a
chore(ssi): add e2e tests
betterengineering 78620b4
chore(ssi): fix agent dependent apps
betterengineering 822d06a
Use public registry
betterengineering 762dfba
Fix tests
betterengineering 8ad2a4a
fix service name generation
betterengineering 6d2e479
Merge branch 'main' into mark.spicer/INPLAT-792-add-ssi-e2e-tests
betterengineering 515e953
Merge branch 'main' into mark.spicer/INPLAT-792-add-ssi-e2e-tests
betterengineering 50d528b
Merge branch 'main' into mark.spicer/INPLAT-792-add-ssi-e2e-tests
betterengineering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2016-present Datadog, Inc. | ||
|
|
||
| // Package ssi provides end to end tests for Single Step Instrumentation. It focuses on user configuration and how that | ||
| // impacts targeting in Kubernetes. | ||
| package ssi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2016-present Datadog, Inc. | ||
| package ssi | ||
|
|
||
| import ( | ||
| "os" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes" | ||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/DataDog/datadog-agent/pkg/ssi/testutils" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/common/config" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/components/datadog/apps/singlestep" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/components/datadog/kubernetesagentparams" | ||
| compkube "github.com/DataDog/datadog-agent/test/e2e-framework/components/kubernetes" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/scenarios/aws/kindvm" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/testing/e2e" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/testing/environments" | ||
| provkindvm "github.com/DataDog/datadog-agent/test/e2e-framework/testing/provisioners/aws/kubernetes/kindvm" | ||
| ) | ||
|
|
||
| type localSDKInjectionSuite struct { | ||
| e2e.BaseSuite[environments.Kubernetes] | ||
| } | ||
|
|
||
| func TestLocalSDKInjectionSuite(t *testing.T) { | ||
| helmValues, err := os.ReadFile("testdata/local_sdk_injection.yaml") | ||
| require.NoError(t, err, "Could not open helm values file for test") | ||
| e2e.Run(t, &localSDKInjectionSuite{}, e2e.WithProvisioner(provkindvm.Provisioner( | ||
| provkindvm.WithRunOptions( | ||
| kindvm.WithAgentDependentWorkloadApp(func(e config.Env, kubeProvider *kubernetes.Provider, dependsOnAgent pulumi.ResourceOption) (*compkube.Workload, error) { | ||
| return singlestep.Scenario(e, kubeProvider, "local-sdk-injection", []singlestep.Namespace{ | ||
| { | ||
| Name: "application", | ||
| Apps: []singlestep.App{ | ||
| { | ||
| Name: DefaultAppName, | ||
| Image: "gcr.io/datadoghq/injector-dev/python", | ||
| Version: "d425e7df", | ||
| Port: 8080, | ||
| PodLabels: map[string]string{ | ||
| "admission.datadoghq.com/enabled": "true", | ||
| "tags.datadoghq.com/service": DefaultAppName, | ||
| }, | ||
| PodAnnotations: map[string]string{ | ||
| "admission.datadoghq.com/python-lib.version": "v3.18.1", | ||
| }, | ||
| }, | ||
| { | ||
| Name: "expect-no-injection", | ||
| Image: "gcr.io/datadoghq/injector-dev/python", | ||
| Version: "d425e7df", | ||
| Port: 8080, | ||
| }, | ||
| }, | ||
| }, | ||
| }, dependsOnAgent) | ||
| }), | ||
| kindvm.WithAgentOptions(kubernetesagentparams.WithHelmValues(string(helmValues))), | ||
| ), | ||
| ))) | ||
| } | ||
|
|
||
| func (v *localSDKInjectionSuite) TestClusterAgentInstalled() { | ||
| FindPodInNamespace(v.T(), v.Env().KubernetesCluster.Client(), "datadog", "cluster-agent") | ||
| } | ||
|
|
||
| func (v *localSDKInjectionSuite) TestExpectInjection() { | ||
| // Get clients. | ||
| intake := v.Env().FakeIntake.Client() | ||
| k8s := v.Env().KubernetesCluster.Client() | ||
|
|
||
| // Ensure the pod was injected. | ||
| pod := FindPodInNamespace(v.T(), k8s, "application", DefaultAppName) | ||
| podValidator := testutils.NewPodValidator(pod) | ||
| podValidator.RequireInjection(v.T(), DefaultExpectedContainers) | ||
| podValidator.RequireLibraryVersions(v.T(), map[string]string{ | ||
| "python": "v3.18.1", | ||
| }) | ||
| podValidator.RequireInjectorVersion(v.T(), "0.52.0") | ||
|
|
||
| // Ensure the service has traces. | ||
| require.Eventually(v.T(), func() bool { | ||
| traces := FindTracesForService(v.T(), intake, DefaultAppName) | ||
| return len(traces) != 0 | ||
| }, 1*time.Minute, 10*time.Second, "did not find any traces at intake for DD_SERVICE %s", DefaultAppName) | ||
| } | ||
|
|
||
| func (v *localSDKInjectionSuite) TestExpectNoInjection() { | ||
| pod := FindPodInNamespace(v.T(), v.Env().KubernetesCluster.Client(), "application", "expect-no-injection") | ||
| podValidator := testutils.NewPodValidator(pod) | ||
| podValidator.RequireNoInjection(v.T()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2016-present Datadog, Inc. | ||
|
|
||
| package ssi | ||
|
|
||
| import ( | ||
| "os" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes" | ||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/DataDog/datadog-agent/pkg/ssi/testutils" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/common/config" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/components/datadog/apps/singlestep" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/components/datadog/kubernetesagentparams" | ||
| compkube "github.com/DataDog/datadog-agent/test/e2e-framework/components/kubernetes" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/scenarios/aws/kindvm" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/testing/e2e" | ||
| "github.com/DataDog/datadog-agent/test/e2e-framework/testing/environments" | ||
| provkindvm "github.com/DataDog/datadog-agent/test/e2e-framework/testing/provisioners/aws/kubernetes/kindvm" | ||
| ) | ||
|
|
||
| type namespaceSelectionSuite struct { | ||
| e2e.BaseSuite[environments.Kubernetes] | ||
| } | ||
|
|
||
| func TestNamespaceSelectionSuite(t *testing.T) { | ||
| helmValues, err := os.ReadFile("testdata/namespace_selection.yaml") | ||
| require.NoError(t, err, "Could not open helm values file for test") | ||
| e2e.Run(t, &namespaceSelectionSuite{}, e2e.WithProvisioner(provkindvm.Provisioner( | ||
| provkindvm.WithRunOptions( | ||
| kindvm.WithAgentDependentWorkloadApp(func(e config.Env, kubeProvider *kubernetes.Provider, dependsOnAgent pulumi.ResourceOption) (*compkube.Workload, error) { | ||
| return singlestep.Scenario(e, kubeProvider, "namespace-selection", []singlestep.Namespace{ | ||
| { | ||
| Name: "expect-injection", | ||
| Apps: []singlestep.App{ | ||
| { | ||
| Name: DefaultAppName, | ||
| Image: "gcr.io/datadoghq/injector-dev/python", | ||
| Version: "d425e7df", | ||
| Port: 8080, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| Name: "expect-no-injection", | ||
| Apps: []singlestep.App{ | ||
| { | ||
| Name: DefaultAppName, | ||
| Image: "gcr.io/datadoghq/injector-dev/python", | ||
| Version: "d425e7df", | ||
| Port: 8080, | ||
| }, | ||
| }, | ||
| }, | ||
| }, dependsOnAgent) | ||
| }), | ||
| kindvm.WithAgentOptions(kubernetesagentparams.WithHelmValues(string(helmValues))), | ||
| ), | ||
| ))) | ||
| } | ||
|
|
||
| func (v *namespaceSelectionSuite) TestClusterAgentInstalled() { | ||
| FindPodInNamespace(v.T(), v.Env().KubernetesCluster.Client(), "datadog", "cluster-agent") | ||
| } | ||
|
|
||
| func (v *namespaceSelectionSuite) TestExpectInjection() { | ||
| // Get clients. | ||
| intake := v.Env().FakeIntake.Client() | ||
| k8s := v.Env().KubernetesCluster.Client() | ||
|
|
||
| // Ensure the pod was injected. | ||
| pod := FindPodInNamespace(v.T(), k8s, "expect-injection", DefaultAppName) | ||
| podValidator := testutils.NewPodValidator(pod) | ||
| podValidator.RequireInjection(v.T(), DefaultExpectedContainers) | ||
| podValidator.RequireLibraryVersions(v.T(), map[string]string{ | ||
| "python": "v3.18.1", | ||
| }) | ||
| podValidator.RequireInjectorVersion(v.T(), "0.52.0") | ||
|
|
||
| // Ensure the service has traces. | ||
| require.Eventually(v.T(), func() bool { | ||
| traces := FindTracesForService(v.T(), intake, DefaultAppName) | ||
| return len(traces) != 0 | ||
| }, 1*time.Minute, 10*time.Second, "did not find any traces at intake for DD_SERVICE %s", DefaultAppName) | ||
| } | ||
|
|
||
| func (v *namespaceSelectionSuite) TestExpectNoInjection() { | ||
| pods := GetPodsInNamespace(v.T(), v.Env().KubernetesCluster.Client(), "expect-no-injection") | ||
| for _, pod := range pods { | ||
| podValidator := testutils.NewPodValidator(&pod) | ||
| podValidator.RequireNoInjection(v.T()) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| clusterAgent: | ||
| admissionController: | ||
| configMode: "hostip" | ||
| datadog: | ||
| apm: | ||
| instrumentation: | ||
| enabled: false | ||
| enabledNamespaces: [] | ||
| injector: | ||
| imageTag: "0.52.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| clusterAgent: | ||
| admissionController: | ||
| configMode: "hostip" | ||
| datadog: | ||
| apm: | ||
| instrumentation: | ||
| enabled: true | ||
| injector: | ||
| imageTag: "0.52.0" | ||
| enabledNamespaces: | ||
| - "expect-injection" | ||
| libVersions: | ||
| python: "v3.18.1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| clusterAgent: | ||
| admissionController: | ||
| configMode: "hostip" | ||
| datadog: | ||
| apm: | ||
| instrumentation: | ||
| enabled: true | ||
| injector: | ||
| imageTag: "0.52.0" | ||
| enabledNamespaces: [] | ||
| targets: | ||
| - name: "python-apps" | ||
| podSelector: | ||
| matchLabels: | ||
| language: "python" | ||
| namespaceSelector: | ||
| matchLabels: | ||
| injection: "yes" | ||
| ddTraceVersions: | ||
| python: "v3.18.1" | ||
| ddTraceConfigs: | ||
| - name: "DD_PROFILING_ENABLED" | ||
| value: "true" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something I added in #43874 but it wasn't correct.