Skip to content

Commit

Permalink
Make "standard" e2e scenario target work (#3719) (#3744)
Browse files Browse the repository at this point in the history
  • Loading branch information
0sewa0 authored Sep 9, 2024
1 parent e14252e commit cba0da7
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 442 deletions.
55 changes: 24 additions & 31 deletions hack/make/tests/e2e.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test/e2e-publish:

## Run standard e2e test only
test/e2e/standard: manifests/crd/helm
$(GOTESTCMD) -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 200m -count=1 ./test/scenarios/standard -args --skip-labels "name=cloudnative-network-zone" $(SKIPCLEANUP)
$(GOTESTCMD) -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 200m -count=1 ./test/scenarios/standard -args $(SKIPCLEANUP)

## Run istio e2e test only
test/e2e/istio: manifests/crd/helm
Expand All @@ -38,99 +38,92 @@ test/e2e/release: manifests/crd/helm

## Runs ActiveGate e2e test only
test/e2e/activegate: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=activegate-default" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "activegate" $(SKIPCLEANUP)

## Runs ActiveGate proxy e2e test only
test/e2e/activegate/proxy: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=activegate-proxy" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --feature "activegate" $(SKIPCLEANUP)

## Runs ClassicFullStack e2e test only
test/e2e/classic: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=classic" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "classic" $(SKIPCLEANUP)

## Runs ClassicFullStack switch mode e2e test only
test/e2e/classic/switchmodes: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=classic-to-cloudnative" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "classic-to-cloudnative" $(SKIPCLEANUP)

## Runs CloudNative codemodules e2e test only
test/e2e/cloudnative/codemodules: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=cloudnative-codemodules-image" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "cloudnative-codemodules-image" $(SKIPCLEANUP)

## Runs CloudNative codemodules-with-proxy e2e test only
test/e2e/cloudnative/codemodules-with-proxy: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=codemodules-with-proxy" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --feature "codemodules-with-proxy" $(SKIPCLEANUP)

## Runs CloudNative codemodules-with-proxy-custom-ca e2e test only
test/e2e/cloudnative/codemodules-with-custom-ca: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=codemodules-with-proxy-custom-ca" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --feature "codemodules-with-proxy-custom-ca" $(SKIPCLEANUP)

## Runs CloudNative codemodules e2e test with proxy and AG custom certificate
test/e2e/cloudnative/codemodules-with-proxy-and-ag-cert: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=codemodules-with-proxy-and-ag-cert" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --feature "codemodules-with-proxy-and-ag-cert" $(SKIPCLEANUP)

## Runs CloudNative codemodules e2e test with proxy and AG custom certificates
test/e2e/cloudnative/codemodules-with-proxy-custom-ca-ag-cert: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=codemodules-with-proxy-custom-ca-ag-cert" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --feature "codemodules-with-proxy-custom-ca-ag-cert" $(SKIPCLEANUP)

## Runs CloudNative automatic injection disabled e2e test only
test/e2e/cloudnative/disabledautoinjection: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=cloudnative-disabled-auto-inject" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "cloudnative-disabled-auto-inject" $(SKIPCLEANUP)

## Runs CloudNative default e2e test only
test/e2e/cloudnative/default: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=cloudnative-default" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "cloudnative" $(SKIPCLEANUP)

## Runs CloudNative istio e2e test only
test/e2e/cloudnative/istio: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=cloudnative-istio" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --feature "cloudnative" $(SKIPCLEANUP)

## Runs CloudNative network problem e2e test only
test/e2e/cloudnative/resilience: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=cloudnative-csi-resilience" $(SKIPCLEANUP)

test/e2e/cloudnative/network-zone: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=cloudnative-network-zone" $(SKIPCLEANUP)

## Runs CloudNative proxy e2e test only
test/e2e/cloudnative/proxy: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --labels "name=cloudnative-proxy" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/istio -args --feature "cloudnative-csi-resilience" $(SKIPCLEANUP)

## Runs Classic/CloudNative mode switching tests
test/e2e/cloudnative/switchmodes: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=cloudnative-to-classic" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "cloudnative-to-classic" $(SKIPCLEANUP)

## Runs CloudNative upgrade e2e test only
test/e2e/cloudnative/upgrade: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/release -args --labels "name=cloudnative-upgrade" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/release -args --feature "cloudnative-upgrade" $(SKIPCLEANUP)

## Runs Application Monitoring metadata-enrichment e2e test only
test/e2e/applicationmonitoring/metadataenrichment: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=app-metadata-enrichment" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "metadata-enrichment" $(SKIPCLEANUP)

## Runs Application Monitoring label versio detection e2e test only
test/e2e/applicationmonitoring/labelversion: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=app-label-version" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "label-version" $(SKIPCLEANUP)

## Runs Application Monitoring readonly csi-volume e2e test only
test/e2e/applicationmonitoring/readonlycsivolume: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=app-read-only-csi-volume" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "app-read-only-csi-volume" $(SKIPCLEANUP)

## Runs Application Monitoring without CSI e2e test only
test/e2e/applicationmonitoring/withoutcsi: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=app-without-csi" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "app-monitoring-without-csi" $(SKIPCLEANUP)

## Runs public registry images e2e test only
test/e2e/publicregistry: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=public-registry-images" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "public-registry-images" $(SKIPCLEANUP)

## Runs SupportArchive e2e test only
test/e2e/supportarchive: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=support-archive" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "support-archive" $(SKIPCLEANUP)

## Runs Edgeconnect e2e test only
test/e2e/edgeconnect: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=edgeconnect-install,name=edgeconnect-install-provisioner,name=edgeconnect-install-k8s-automation" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "edgeconnect-.*" $(SKIPCLEANUP)

## Runs e2e tests on gke-autopilot
test/e2e/gke-autopilot: manifests/crd/helm
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --labels "name=app-metadata-enrichment,name=app-read-only-csi-volume,name=app-read-only-csi-volume,name=app-without-csi,name=activegate-default" $(SKIPCLEANUP)
go test -v -tags "$(shell ./hack/build/create_go_build_tags.sh true)" -timeout 20m -count=1 ./test/scenarios/standard -args --feature "app-metadata-enrichment|app-read-only-csi-volume|app-read-only-csi-volume|app-without-csi|activegate" $(SKIPCLEANUP)
3 changes: 3 additions & 0 deletions pkg/webhook/mutation/pod/init_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ func updateContainerInfo(request *dtwebhook.ReinvocationRequest, installContaine
pod := request.Pod
if installContainer == nil {
installContainer = findInstallContainer(pod.Spec.InitContainers)
if installContainer == nil {
return false
}
}

newContainers := request.NewContainers(containerIsInjected)
Expand Down
10 changes: 8 additions & 2 deletions pkg/webhook/mutation/pod/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ func (wh *webhook) handlePodMutation(ctx context.Context, mutationRequest *dtweb

mutationRequest.InstallContainer = createInstallInitContainerBase(wh.webhookImage, wh.clusterID, mutationRequest.Pod, mutationRequest.DynaKube)

isMutated := updateContainerInfo(mutationRequest.ToReinvocationRequest(), mutationRequest.InstallContainer)
_ = updateContainerInfo(mutationRequest.ToReinvocationRequest(), mutationRequest.InstallContainer)

var isMutated bool

for _, mutator := range wh.mutators {
if !mutator.Enabled(mutationRequest.BaseRequest) {
Expand Down Expand Up @@ -191,7 +193,11 @@ func (wh *webhook) handlePodReinvocation(mutationRequest *dtwebhook.MutationRequ

reinvocationRequest := mutationRequest.ToReinvocationRequest()

updateContainerInfo(reinvocationRequest, nil)
isMutated := updateContainerInfo(reinvocationRequest, nil)

if !isMutated { // == no new containers were detected, we only mutate new containers during reinvoke
return false
}

for _, mutator := range wh.mutators {
if mutator.Enabled(mutationRequest.BaseRequest) {
Expand Down
5 changes: 0 additions & 5 deletions test/features/activegate/activegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ func Feature(t *testing.T, proxySpec *dynakube.DynaKubeProxy) features.Feature {
dynakubeComponents.WithProxy(proxySpec))

builder := features.New("activegate")
if proxySpec == nil {
builder.WithLabel("name", "activegate-default")
} else {
builder.WithLabel("name", "activegate-proxy")
}
proxy.SetupProxyWithTeardown(t, builder, testDynakube)
proxy.CutOffDynatraceNamespace(builder, proxySpec)
proxy.IsDynatraceNamespaceCutOff(builder, testDynakube)
Expand Down
11 changes: 5 additions & 6 deletions test/features/applicationmonitoring/label_version_detection.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,26 @@ var (
// - preserved values of existing variables - build variables exist, feature flag exists, with additional configuration, values of build variables not get overwritten
// - incorrect custom mapping - invalid name of BUILD VERSION label, reference exists but actual label doesn't exist
func LabelVersionDetection(t *testing.T) features.Feature {
builder := features.New("label version")
builder.WithLabel("name", "app-label-version")
builder := features.New("label-version")

secretConfig := tenant.GetSingleTenantSecret(t)
defaultDynakube := *dynakubeComponents.New(
dynakubeComponents.WithName("dynakubeComponents-default"),
dynakubeComponents.WithName("dynakube-components-default"),
dynakubeComponents.WithApiUrl(secretConfig.ApiUrl),
dynakubeComponents.WithNameBasedOneAgentNamespaceSelector(),
dynakubeComponents.WithApplicationMonitoringSpec(&dynakube.ApplicationMonitoringSpec{
UseCSIDriver: false,
}),
dynakubeComponents.WithNameBasedOneAgentNamespaceSelector(),
)

labelVersionDynakube := *dynakubeComponents.New(
dynakubeComponents.WithName("dynakubeComponents-labels"),
dynakubeComponents.WithName("dynakube-components-labels"),
dynakubeComponents.WithAnnotations(map[string]string{dynakube.AnnotationFeatureLabelVersionDetection: "true"}),
dynakubeComponents.WithApiUrl(secretConfig.ApiUrl),
dynakubeComponents.WithNameBasedOneAgentNamespaceSelector(),
dynakubeComponents.WithApplicationMonitoringSpec(&dynakube.ApplicationMonitoringSpec{
UseCSIDriver: false,
}),
dynakubeComponents.WithNameBasedOneAgentNamespaceSelector(),
)

sampleApps := []*sample.App{
Expand Down
1 change: 0 additions & 1 deletion test/features/applicationmonitoring/metadata_enrichment.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type metadata struct {
// file contains required fields.
func MetadataEnrichment(t *testing.T) features.Feature {
builder := features.New("metadata-enrichment")
builder.WithLabel("name", "app-metadata-enrichment")
secretConfig := tenant.GetSingleTenantSecret(t)
testDynakube := *dynakubeComponents.New(
dynakubeComponents.WithApiUrl(secretConfig.ApiUrl),
Expand Down
3 changes: 1 addition & 2 deletions test/features/applicationmonitoring/read_only_csi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import (
var readOnlyInjection = map[string]string{dynakube.AnnotationFeatureReadOnlyCsiVolume: "true"}

func ReadOnlyCSIVolume(t *testing.T) features.Feature {
builder := features.New("read only csi volume")
builder.WithLabel("name", "app-read-only-csi-volume")
builder := features.New("app-read-only-csi-volume")
secretConfig := tenant.GetSingleTenantSecret(t)
testDynakube := *dynakubeComponents.New(
dynakubeComponents.WithAnnotations(readOnlyInjection),
Expand Down
3 changes: 1 addition & 2 deletions test/features/applicationmonitoring/without_csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import (

// ApplicationMonitoring deployment without CSI driver
func WithoutCSI(t *testing.T) features.Feature {
builder := features.New("application monitoring without csi driver enabled")
builder.WithLabel("name", "app-without-csi")
builder := features.New("app-monitoring-without-csi")
secretConfig := tenant.GetSingleTenantSecret(t)
appOnlyDynakube := *dynakubeComponents.New(
dynakubeComponents.WithApiUrl(secretConfig.ApiUrl),
Expand Down
3 changes: 1 addition & 2 deletions test/features/classic/classic.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import (
// installed and restarted to check if OneAgent is injected and can communicate
// with the *Dynatrace Cluster*.
func Feature(t *testing.T) features.Feature {
builder := features.New("install classic fullstack")
builder.WithLabel("name", "classic")
builder := features.New("classic")
secretConfig := tenant.GetSingleTenantSecret(t)
testDynakube := *dynakubeComponents.New(
dynakubeComponents.WithApiUrl(secretConfig.ApiUrl),
Expand Down
3 changes: 1 addition & 2 deletions test/features/classic/switch_modes/switch_modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ const (
)

func Feature(t *testing.T) features.Feature {
builder := features.New("switch from classic to cloudnative")
builder.WithLabel("name", "classic-to-cloudnative")
builder := features.New("classic-to-cloudnative")

// build classic full stack dynakube
secretConfig := tenant.GetSingleTenantSecret(t)
Expand Down
Loading

0 comments on commit cba0da7

Please sign in to comment.