Skip to content

Commit

Permalink
update makefile and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
snguyen64 committed Aug 26, 2024
1 parent 2bdb521 commit 50f51db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<YOUR-SUBSCRIPTION> && \
export AZURE_LOCATION=<location> && \
IMAGE_TAG=<YOUR-IMAGE-TAG> make test-e2e
```

For sample test, please check out:
[the Retina E2E.](./scenarios/retina/drop/scenario.go)
7 changes: 1 addition & 6 deletions test/e2e/jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
9 changes: 5 additions & 4 deletions test/e2e/retina_cilium_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,25 @@ 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)

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()
Expand Down

0 comments on commit 50f51db

Please sign in to comment.