From 50f51db2c50507ca71b9d7ee1e022cfb202a3264 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Mon, 26 Aug 2024 21:22:19 +0000 Subject: [PATCH] update makefile and readme --- Makefile | 4 ++++ test/e2e/README.md | 14 +++++++++++++- test/e2e/jobs/jobs.go | 7 +------ test/e2e/retina_cilium_e2e_test.go | 9 +++++---- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 43c30e5404..4d81aa75e5 100644 --- a/Makefile +++ b/Makefile @@ -365,6 +365,10 @@ test: $(ENVTEST) # Run unit tests. go build -o test-summary ./test/utsummary/main.go CGO_ENABLED=0 KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use -p path)" go test -tags=unit,dashboard -skip=TestE2E* -coverprofile=coverage.out -v -json ./... | ./test-summary --progress --verbose +E2E_TEST_PATH ?= ./test/e2e/*.go +test-e2e: $(ENVTEST) # Run e2e tests. + CGO_ENABLED=0 go test -v $(E2E_TEST_PATH) -timeout 30m -tags=e2e -count=1 -args -image-tag=$(IMAGE_TAG) -image-registry=acnpublic.azurecr.io -image-namespace=microsoft/retina + coverage: # Code coverage. # go generate ./... && go test -tags=unit -coverprofile=coverage.out.tmp ./... cat coverage.out | grep -v "_bpf.go\|_bpfel_x86.go\|_bpfel_arm64.go|_generated.go|mock_" | grep -v mock > coveragenew.out diff --git a/test/e2e/README.md b/test/e2e/README.md index 06a4581b36..2a1b7deedb 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -13,7 +13,19 @@ ## Starter Example When authoring tests, make sure to prefix the test name with `TestE2E` so that it is skipped by existing pipeline unit test framework. -For reference, see the `test-all` recipe in the root [Makefile](../../Makefile). +For reference, see the `test-e2e` recipe in the root [Makefile](../../Makefile). + +## Running E2E Test + +You can execute all e2e tests in an AKS cluster. The image tag should be the image tag from the *Build Agent Images* pipeline on your PR. +You can also execute specific e2e tests (non-cilium and cilium) by setting `E2E_TEST_PATH`. If left empty, it will run all tests. +Example command: + +```bash +export AZURE_SUBSCRIPTION_ID= && \ +export AZURE_LOCATION= && \ +IMAGE_TAG= make test-e2e +``` For sample test, please check out: [the Retina E2E.](./scenarios/retina/drop/scenario.go) diff --git a/test/e2e/jobs/jobs.go b/test/e2e/jobs/jobs.go index 7e84ffeffe..58e2844d52 100644 --- a/test/e2e/jobs/jobs.go +++ b/test/e2e/jobs/jobs.go @@ -227,12 +227,7 @@ func InstallAndTestRetinaCiliumMetrics(kubeConfigFilePath, chartPath, valuesFile // Upgade to ciliumeventobserver plugin job.AddStep(&kubernetes.UpgradeRetinaHelmChart{ - Namespace: "kube-system", - ReleaseName: "retina", - KubeConfigFilePath: kubeConfigFilePath, - ChartPath: chartPath, - TagEnv: generic.DefaultTagEnv, - ValuesFile: valuesFilePath, + ValuesFile: valuesFilePath, }, nil) job.AddScenario(ciliumeventobserver.ValidateCiliumEventObserverDropMetric()) diff --git a/test/e2e/retina_cilium_e2e_test.go b/test/e2e/retina_cilium_e2e_test.go index fba37bb578..994fa1713a 100644 --- a/test/e2e/retina_cilium_e2e_test.go +++ b/test/e2e/retina_cilium_e2e_test.go @@ -16,12 +16,13 @@ import ( "github.com/stretchr/testify/require" ) +var retinaCiliumLocations = []string{"eastus2", "centralus", "southcentralus", "uksouth", "centralindia", "westus2"} + // TestE2ERetinaCilium tests all e2e scenarios for retina on cilium clusters func TestE2ERetinaCilium(t *testing.T) { curuser, err := user.Current() require.NoError(t, err) - - clusterName := curuser.Username + common.NetObsRGtag + "cilium-" + strconv.FormatInt(time.Now().Unix(), 10) + clusterName := curuser.Username + common.NetObsRGtag + "cil-" + strconv.FormatInt(time.Now().Unix(), 10) subID := os.Getenv("AZURE_SUBSCRIPTION_ID") require.NotEmpty(t, subID) @@ -29,11 +30,11 @@ func TestE2ERetinaCilium(t *testing.T) { location := os.Getenv("AZURE_LOCATION") if location == "" { var nBig *big.Int - nBig, err = rand.Int(rand.Reader, big.NewInt(int64(len(locations)))) + nBig, err = rand.Int(rand.Reader, big.NewInt(int64(len(retinaCiliumLocations)))) if err != nil { t.Fatalf("Failed to generate a secure random index: %v", err) } - location = locations[nBig.Int64()] + location = retinaCiliumLocations[nBig.Int64()] } cwd, err := os.Getwd()