Skip to content

Commit

Permalink
test: add DNS basic and advance metrics e2e (#353)
Browse files Browse the repository at this point in the history
# Description

Adding DNS basic and advance metrics e2e tests

## Related Issue

If this pull request is related to any issue, please mention it here.
Additionally, make sure that the issue is assigned to you before
submitting this pull request.

## Checklist

- [ ] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [ ] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [ ] I have correctly attributed the author(s) of the code.
- [ ] I have tested the changes locally.
- [ ] I have followed the project's style guidelines.
- [ ] I have updated the documentation, if necessary.
- [ ] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes
made.

## Additional Notes

Add any additional notes or context about the pull request here.

---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.
  • Loading branch information
nddq authored May 30, 2024
1 parent cd0df65 commit bf616ac
Show file tree
Hide file tree
Showing 28 changed files with 897 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
shell: bash
run: |
set -euo pipefail
go test -v ./test/e2e/scenarios/retina/*.go -timeout 30m -tags=e2e -count=1 -args -image-tag=$(make version) -image-registry=${{ vars.ACR_NAME }} -image-namespace=${{ github.repository}}
go test -v ./test/e2e/*.go -timeout 30m -tags=e2e -count=1 -args -image-tag=$(make version) -image-registry=${{vars.ACR_NAME}} -image-namespace=${{github.repository}}
2 changes: 1 addition & 1 deletion .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ jobs:
shell: bash
run: |
set -euo pipefail
go test -v ./test/e2e/scenarios/retina/*.go -timeout 30m -tags=e2e -count=1 -args -image-tag=$(make version) -image-registry=${{ vars.ACR_NAME }} -image-namespace=${{ github.repository}}
go test -v ./test/e2e/*.go -timeout 30m -tags=e2e -count=1 -args -image-tag=$(make version) -image-registry=${{ vars.ACR_NAME }} -image-namespace=${{ github.repository}}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ spec:
ports:
- name: retina
containerPort: {{ .Values.retinaPort }}
workingDir: $env:CONTAINER_SANDBOX_MOUNT_POINT
command:
- powershell.exe
- -command
Expand Down
2 changes: 1 addition & 1 deletion pkg/module/metrics/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestGetLabels(t *testing.T) {
},
{
name: "local context",
want: append(utils.DNSLabels, "ip", "namespace", "podname", "workloadKind", "workloadName", "service", "port"),
want: append(utils.DNSLabels, "ip", "namespace", "podname", "workload_kind", "workload_name", "service", "port"),
d: &DNSMetrics{
baseMetricObject: baseMetricObject{
srcCtx: &ContextOptions{
Expand Down
28 changes: 14 additions & 14 deletions pkg/module/metrics/drops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ func TestNewDrop(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -129,8 +129,8 @@ func TestNewDrop(t *testing.T) {
"destination_ip",
"destination_namespace",
"destination_podname",
"destination_workloadKind",
"destination_workloadName",
"destination_workload_kind",
"destination_workload_name",
"destination_service",
"destination_port",
},
Expand All @@ -153,8 +153,8 @@ func TestNewDrop(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -177,8 +177,8 @@ func TestNewDrop(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -202,8 +202,8 @@ func TestNewDrop(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand All @@ -228,8 +228,8 @@ func TestNewDrop(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand All @@ -255,8 +255,8 @@ func TestNewDrop(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand Down
32 changes: 16 additions & 16 deletions pkg/module/metrics/forward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ func TestNewForward(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -125,8 +125,8 @@ func TestNewForward(t *testing.T) {
"destination_ip",
"destination_namespace",
"destination_podname",
"destination_workloadKind",
"destination_workloadName",
"destination_workload_kind",
"destination_workload_name",
"destination_service",
"destination_port",
},
Expand All @@ -148,8 +148,8 @@ func TestNewForward(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -172,8 +172,8 @@ func TestNewForward(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -195,8 +195,8 @@ func TestNewForward(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -218,8 +218,8 @@ func TestNewForward(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand All @@ -242,8 +242,8 @@ func TestNewForward(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand All @@ -267,8 +267,8 @@ func TestNewForward(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand Down
48 changes: 24 additions & 24 deletions pkg/module/metrics/tcpflags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func TestNewTCPMetrics(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand All @@ -99,8 +99,8 @@ func TestNewTCPMetrics(t *testing.T) {
"destination_ip",
"destination_namespace",
"destination_podname",
"destination_workloadKind",
"destination_workloadName",
"destination_workload_kind",
"destination_workload_name",
"destination_service",
"destination_port",
},
Expand All @@ -122,8 +122,8 @@ func TestNewTCPMetrics(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand Down Expand Up @@ -154,8 +154,8 @@ func TestNewTCPMetrics(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand Down Expand Up @@ -184,8 +184,8 @@ func TestNewTCPMetrics(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand Down Expand Up @@ -222,8 +222,8 @@ func TestNewTCPMetrics(t *testing.T) {
"source_ip",
"source_namespace",
"source_podname",
"source_workloadKind",
"source_workloadName",
"source_workload_kind",
"source_workload_name",
"source_service",
"source_port",
},
Expand Down Expand Up @@ -261,8 +261,8 @@ func TestNewTCPMetrics(t *testing.T) {
"destination_ip",
"destination_namespace",
"destination_podname",
"destination_workloadKind",
"destination_workloadName",
"destination_workload_kind",
"destination_workload_name",
"destination_service",
"destination_port",
},
Expand Down Expand Up @@ -299,8 +299,8 @@ func TestNewTCPMetrics(t *testing.T) {
"destination_ip",
"destination_namespace",
"destination_podname",
"destination_workloadKind",
"destination_workloadName",
"destination_workload_kind",
"destination_workload_name",
"destination_service",
"destination_port",
},
Expand Down Expand Up @@ -338,8 +338,8 @@ func TestNewTCPMetrics(t *testing.T) {
"destination_ip",
"destination_namespace",
"destination_podname",
"destination_workloadKind",
"destination_workloadName",
"destination_workload_kind",
"destination_workload_name",
"destination_service",
"destination_port",
},
Expand Down Expand Up @@ -377,8 +377,8 @@ func TestNewTCPMetrics(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand Down Expand Up @@ -416,8 +416,8 @@ func TestNewTCPMetrics(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand Down Expand Up @@ -457,8 +457,8 @@ func TestNewTCPMetrics(t *testing.T) {
"ip",
"namespace",
"podname",
"workloadKind",
"workloadName",
"workload_kind",
"workload_name",
"service",
"port",
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/module/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const (
portCtxOption = "port"

// workloads context option
workloadKindCtxOption = "workloadKind"
workloadKindCtxOption = "workload_kind"

// workload context option
workloadNameCtxOption = "workloadName"
workloadNameCtxOption = "workload_name"

// workload context option
workloadCtxOption = "workload"
Expand Down
8 changes: 4 additions & 4 deletions pkg/module/metrics/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestNewCtxOps(t *testing.T) {
ctxType: source,
expected: []string{
"source_ip", "source_namespace", "source_podname",
"source_workloadKind", "source_workloadName", "source_service", "source_port",
"source_workload_kind", "source_workload_name", "source_service", "source_port",
},
f: &flow.Flow{},
expectedVals: []string{"unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "unknown"},
Expand All @@ -45,7 +45,7 @@ func TestNewCtxOps(t *testing.T) {
ctxType: destination,
expected: []string{
"destination_ip", "destination_namespace", "destination_podname",
"destination_workloadKind", "destination_workloadName", "destination_service", "destination_port",
"destination_workload_kind", "destination_workload_name", "destination_service", "destination_port",
},
f: &flow.Flow{},
expectedVals: []string{"unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "unknown"},
Expand All @@ -56,7 +56,7 @@ func TestNewCtxOps(t *testing.T) {
ctxType: source,
expected: []string{
"source_ip", "source_namespace", "source_podname",
"source_workloadKind", "source_workloadName", "source_service", "source_port",
"source_workload_kind", "source_workload_name", "source_service", "source_port",
},
f: &flow.Flow{
Source: &flow.Endpoint{
Expand All @@ -72,7 +72,7 @@ func TestNewCtxOps(t *testing.T) {
ctxType: destination,
expected: []string{
"destination_ip", "destination_namespace", "destination_podname",
"destination_workloadKind", "destination_workloadName", "destination_service", "destination_port",
"destination_workload_kind", "destination_workload_name", "destination_service", "destination_port",
},
f: &flow.Flow{
Destination: &flow.Endpoint{
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

// package common contains common functions and values that are used across multiple e2e tests.
package common

const (
RetinaPort int = 10093
// netObsRGtag is used to tag resources created by this test suite
NetObsRGtag = "-e2e-netobs-"
)
Loading

0 comments on commit bf616ac

Please sign in to comment.