Skip to content

Commit 046c450

Browse files
chore(ssi): create shared testing library (#43867)
### What does this PR do? This commit creates a shared testing library for Single Step Instrumentation in Kubernetes. This will enable us to have test helpers in the agent end to end tests as well as other repositories like injector-dev. ### Motivation When testing SSI, I find myself needing similar logic each time. Given a Kubernetes pod spec, does it have the things we expect? The default pod and container spec is not test friendly. One easy example is environment variables that exist in a list. Another example is a container image string that we need to know the registry or tag. The very clear place I need this library is for e2e tests. See my draft PR here that got too big: #43422. Another place I would like to use them is in[ injector-dev](https://github.com/DataDog/injector-dev/blob/main/tests/helm/a-group-of-services/scenario_test.go). ### Describe how you validated your changes This code was already being used to test SSI in our integration test. I expanded the usage in my draft PR for e2e tests so I know it covers that use case as well. I used [this guide](https://datadoghq.dev/datadog-agent/how-to/go/modules/) to create this PR. In addition, I ran the following commands: ```bash dda inv -- -e modules.validate -f # Format the modules.yaml dda inv modules.add-all-replace # Ensure the local replacements are added dda inv tidy # Ensure all modules have been tidied including our new one ``` ### Additional Notes I added basic unit tests to "test the tests". They're not exhaustive, but I figured as long as they exist they provide an easy path to extend them if our testing library needs modification. Co-authored-by: mark.spicer <mark.spicer@datadoghq.com>
1 parent 7476aa1 commit 046c450

180 files changed

Lines changed: 1217 additions & 404 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@
652652
/pkg/security/ @DataDog/agent-security
653653
/pkg/networkdevice/ @DataDog/ndm-core
654654
/pkg/snmp/ @DataDog/ndm-core
655+
/pkg/ssi/ @DataDog/injection-platform
655656
/pkg/tagger/ @DataDog/container-platform
656657
/pkg/windowsdriver/ @DataDog/windows-products
657658
/comp/core/workloadmeta/collectors/internal/cloudfoundry @DataDog/agent-integrations

comp/api/api/def/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ replace (
137137
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../../pkg/security/secl
138138
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../../pkg/security/seclwin
139139
github.com/DataDog/datadog-agent/pkg/serializer => ../../../../pkg/serializer
140+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../../pkg/ssi/testutils
140141
github.com/DataDog/datadog-agent/pkg/status/health => ../../../../pkg/status/health
141142
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../../pkg/tagger/types
142143
github.com/DataDog/datadog-agent/pkg/tagset => ../../../../pkg/tagset

comp/core/agenttelemetry/def/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ replace (
147147
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../../pkg/security/secl
148148
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../../pkg/security/seclwin
149149
github.com/DataDog/datadog-agent/pkg/serializer => ../../../../pkg/serializer
150+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../../pkg/ssi/testutils
150151
github.com/DataDog/datadog-agent/pkg/status/health => ../../../../pkg/status/health
151152
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../../pkg/tagger/types
152153
github.com/DataDog/datadog-agent/pkg/tagset => ../../../../pkg/tagset

comp/core/agenttelemetry/fx/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ replace (
234234
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../../pkg/security/secl
235235
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../../pkg/security/seclwin
236236
github.com/DataDog/datadog-agent/pkg/serializer => ../../../../pkg/serializer
237+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../../pkg/ssi/testutils
237238
github.com/DataDog/datadog-agent/pkg/status/health => ../../../../pkg/status/health
238239
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../../pkg/tagger/types
239240
github.com/DataDog/datadog-agent/pkg/tagset => ../../../../pkg/tagset

comp/core/agenttelemetry/impl/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ replace (
238238
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../../pkg/security/secl
239239
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../../pkg/security/seclwin
240240
github.com/DataDog/datadog-agent/pkg/serializer => ../../../../pkg/serializer
241+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../../pkg/ssi/testutils
241242
github.com/DataDog/datadog-agent/pkg/status/health => ../../../../pkg/status/health
242243
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../../pkg/tagger/types
243244
github.com/DataDog/datadog-agent/pkg/tagset => ../../../../pkg/tagset

comp/core/config/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ replace (
208208
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../pkg/security/secl
209209
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../pkg/security/seclwin
210210
github.com/DataDog/datadog-agent/pkg/serializer => ../../../pkg/serializer
211+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../pkg/ssi/testutils
211212
github.com/DataDog/datadog-agent/pkg/status/health => ../../../pkg/status/health
212213
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../pkg/tagger/types
213214
github.com/DataDog/datadog-agent/pkg/tagset => ../../../pkg/tagset

comp/core/configsync/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ replace (
226226
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../pkg/security/secl
227227
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../pkg/security/seclwin
228228
github.com/DataDog/datadog-agent/pkg/serializer => ../../../pkg/serializer
229+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../pkg/ssi/testutils
229230
github.com/DataDog/datadog-agent/pkg/status/health => ../../../pkg/status/health
230231
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../pkg/tagger/types
231232
github.com/DataDog/datadog-agent/pkg/tagset => ../../../pkg/tagset

comp/core/flare/builder/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ replace (
125125
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../../pkg/security/secl
126126
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../../pkg/security/seclwin
127127
github.com/DataDog/datadog-agent/pkg/serializer => ../../../../pkg/serializer
128+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../../pkg/ssi/testutils
128129
github.com/DataDog/datadog-agent/pkg/status/health => ../../../../pkg/status/health
129130
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../../pkg/tagger/types
130131
github.com/DataDog/datadog-agent/pkg/tagset => ../../../../pkg/tagset

comp/core/flare/types/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ replace (
140140
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../../pkg/security/secl
141141
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../../pkg/security/seclwin
142142
github.com/DataDog/datadog-agent/pkg/serializer => ../../../../pkg/serializer
143+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../../pkg/ssi/testutils
143144
github.com/DataDog/datadog-agent/pkg/status/health => ../../../../pkg/status/health
144145
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../../pkg/tagger/types
145146
github.com/DataDog/datadog-agent/pkg/tagset => ../../../../pkg/tagset

comp/core/hostname/hostnameinterface/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ replace (
146146
github.com/DataDog/datadog-agent/pkg/security/secl => ../../../../pkg/security/secl
147147
github.com/DataDog/datadog-agent/pkg/security/seclwin => ../../../../pkg/security/seclwin
148148
github.com/DataDog/datadog-agent/pkg/serializer => ../../../../pkg/serializer
149+
github.com/DataDog/datadog-agent/pkg/ssi/testutils => ../../../../pkg/ssi/testutils
149150
github.com/DataDog/datadog-agent/pkg/status/health => ../../../../pkg/status/health
150151
github.com/DataDog/datadog-agent/pkg/tagger/types => ../../../../pkg/tagger/types
151152
github.com/DataDog/datadog-agent/pkg/tagset => ../../../../pkg/tagset

0 commit comments

Comments
 (0)