Skip to content

Commit f492e63

Browse files
committed
reorg scenarios
1 parent 94f08f2 commit f492e63

28 files changed

+94
-149
lines changed

test/e2e/framework/azure/create-cilium-cluster.go

-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ func (c *CreateBYOCiliumCluster) Prevalidate() error {
6868
return nil
6969
}
7070

71-
func (c *CreateBYOCiliumCluster) Postvalidate() error {
72-
return nil
73-
}
74-
7571
func (c *CreateBYOCiliumCluster) Stop() error {
7672
return nil
7773
}

test/e2e/framework/azure/create-cluster.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
const (
1414
MaxNumberOfNodes = 3
1515
MaxPodsPerNode = 250
16-
AgentSKU = "Standard_D4s_v3"
16+
AgentSKU = "Standard_DS4_v2"
1717
)
1818

1919
var defaultClusterCreateTimeout = 30 * time.Minute
@@ -110,10 +110,6 @@ func (c *CreateCluster) Prevalidate() error {
110110
return nil
111111
}
112112

113-
func (c *CreateCluster) Postvalidate() error {
114-
return nil
115-
}
116-
117113
func (c *CreateCluster) Stop() error {
118114
return nil
119115
}

test/e2e/framework/azure/create-rg.go

-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ func (c *CreateResourceGroup) Prevalidate() error {
4343
return nil
4444
}
4545

46-
func (c *CreateResourceGroup) Postvalidate() error {
47-
return nil
48-
}
49-
5046
func (c *CreateResourceGroup) Stop() error {
5147
return nil
5248
}

test/e2e/framework/azure/create-vnet.go

-8
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ func (c *CreateVNet) Prevalidate() error {
5959
return nil
6060
}
6161

62-
func (c *CreateVNet) Postvalidate() error {
63-
return nil
64-
}
65-
6662
func (c *CreateVNet) Stop() error {
6763
return nil
6864
}
@@ -109,10 +105,6 @@ func (c *CreateSubnet) Prevalidate() error {
109105
return nil
110106
}
111107

112-
func (c *CreateSubnet) Postvalidate() error {
113-
return nil
114-
}
115-
116108
func (c *CreateSubnet) Stop() error {
117109
return nil
118110
}

test/e2e/framework/azure/delete-cluster.go

-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ func (d *DeleteCluster) Prevalidate() error {
4343
return nil
4444
}
4545

46-
func (d *DeleteCluster) Postvalidate() error {
47-
return nil
48-
}
49-
5046
func (d *DeleteCluster) Stop() error {
5147
return nil
5248
}

test/e2e/framework/azure/delete-rg.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ func (d *DeleteResourceGroup) Run() error {
2727
if err != nil {
2828
return fmt.Errorf("failed to create resource group client: %w", err)
2929
}
30-
3130
forceDeleteType := "Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets"
32-
poller, err := clientFactory.NewResourceGroupsClient().BeginDelete(ctx, d.ResourceGroupName, &armresources.ResourceGroupsClientBeginDeleteOptions{ForceDeletionTypes: to.Ptr(forceDeleteType)})
31+
_, err = clientFactory.NewResourceGroupsClient().BeginDelete(ctx, d.ResourceGroupName, &armresources.ResourceGroupsClientBeginDeleteOptions{ForceDeletionTypes: to.Ptr(forceDeleteType)})
3332
if err != nil {
3433
return fmt.Errorf("failed to finish the delete resource group request: %w", err)
3534
}
3635

37-
_, err = poller.PollUntilDone(ctx, nil)
38-
if err != nil {
39-
return fmt.Errorf("failed to pull the result for delete resource group: %w", err)
40-
}
41-
4236
log.Printf("resource group \"%s\" deleted successfully", d.ResourceGroupName)
4337
return nil
4438
}
@@ -47,10 +41,6 @@ func (d *DeleteResourceGroup) Prevalidate() error {
4741
return nil
4842
}
4943

50-
func (d *DeleteResourceGroup) Postvalidate() error {
51-
return nil
52-
}
53-
5444
func (d *DeleteResourceGroup) Stop() error {
5545
return nil
5646
}

test/e2e/framework/azure/enable-ama.go

-4
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ func (c *CreateAzureMonitor) Prevalidate() error {
112112
return nil
113113
}
114114

115-
func (c *CreateAzureMonitor) Postvalidate() error {
116-
return nil
117-
}
118-
119115
func (c *CreateAzureMonitor) Stop() error {
120116
return nil
121117
}

test/e2e/framework/azure/get-kubeconfig.go

-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ func (c *GetAKSKubeConfig) Prevalidate() error {
4848
return nil
4949
}
5050

51-
func (c *GetAKSKubeConfig) Postvalidate() error {
52-
return nil
53-
}
54-
5551
func (c *GetAKSKubeConfig) Stop() error {
5652
return nil
5753
}

test/e2e/framework/kubernetes/create-agnhost-statefulset.go

-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ func (c *CreateAgnhostStatefulSet) Prevalidate() error {
6666
return nil
6767
}
6868

69-
func (c *CreateAgnhostStatefulSet) Postvalidate() error {
70-
return nil
71-
}
72-
7369
func (c *CreateAgnhostStatefulSet) Stop() error {
7470
return nil
7571
}

test/e2e/framework/kubernetes/create-kapinger-deployment.go

-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ func (c *CreateKapingerDeployment) Prevalidate() error {
7070
return nil
7171
}
7272

73-
func (c *CreateKapingerDeployment) Postvalidate() error {
74-
return nil
75-
}
76-
7773
func (c *CreateKapingerDeployment) Stop() error {
7874
return nil
7975
}

test/e2e/framework/kubernetes/create-network-policy.go

-8
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ func (c *CreateDenyAllNetworkPolicy) Prevalidate() error {
7272
return nil
7373
}
7474

75-
func (c *CreateDenyAllNetworkPolicy) Postvalidate() error {
76-
return nil
77-
}
78-
7975
func (c *CreateDenyAllNetworkPolicy) Stop() error {
8076
return nil
8177
}
@@ -112,7 +108,3 @@ func (d *DeleteDenyAllNetworkPolicy) Run() error {
112108
func (d *DeleteDenyAllNetworkPolicy) Prevalidate() error {
113109
return nil
114110
}
115-
116-
func (d *DeleteDenyAllNetworkPolicy) Postvalidate() error {
117-
return nil
118-
}

test/e2e/framework/kubernetes/exec-pod.go

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ func (e *ExecInPod) Prevalidate() error {
3939
return nil
4040
}
4141

42-
func (e *ExecInPod) Postvalidate() error {
43-
return nil
44-
}
45-
4642
func (e *ExecInPod) Stop() error {
4743
return nil
4844
}

test/e2e/framework/kubernetes/port-forward.go

-5
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ func (p *PortForward) Prevalidate() error {
156156
return nil
157157
}
158158

159-
func (p *PortForward) Postvalidate() error {
160-
p.pf.Stop()
161-
return nil
162-
}
163-
164159
func (p *PortForward) Stop() error {
165160
p.pf.Stop()
166161
return nil

test/e2e/framework/types/examples/background_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ func (t *TestBackground) Prevalidate() error {
6060
return nil
6161
}
6262

63-
func (t *TestBackground) Postvalidate() error {
64-
return nil
65-
}
66-
6763
type counter struct {
6864
ticker *time.Ticker
6965
count int

test/e2e/framework/types/job.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ type StepWrapper struct {
3131
Opts *StepOptions
3232
}
3333

34-
// A Scenario is a logical grouping of steps
34+
// A Scenario is a logical grouping of steps, used to describe a scenario such as "test drop metrics"
35+
// which will require port forwarding, exec'ing, scraping, etc.
3536
type Scenario struct {
3637
Steps []*StepWrapper
3738
}
@@ -103,12 +104,6 @@ func (j *Job) Run() error {
103104
}
104105
}
105106

106-
for _, wrapper := range j.Steps {
107-
err := wrapper.Step.Postvalidate()
108-
if err != nil {
109-
return err //nolint:wrapcheck // don't wrap error, wouldn't provide any more context than the error itself
110-
}
111-
}
112107
return nil
113108
}
114109

@@ -208,13 +203,14 @@ func (j *Job) validateStep(stepw *StepWrapper) error {
208203
storedValue := j.Values.Get(parameter)
209204

210205
if storedValue == "" {
211-
if stepw.Opts.SkipSavingParamatersToJob {
206+
207+
switch {
208+
case stepw.Opts.SkipSavingParamatersToJob:
212209
continue
213-
} else if value != "" {
210+
case value != "":
214211
fmt.Printf("\"%s\" setting parameter \"%s\" in job context to \"%s\"\n", stepName, parameter, value)
215212
j.Values.Set(parameter, value)
216-
217-
} else {
213+
default:
218214
return fmt.Errorf("missing parameter \"%s\" for step \"%s\": %w", parameter, stepName, ErrMissingParameter)
219215
}
220216
continue

test/e2e/framework/types/runner.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/stretchr/testify/require"
77
)
88

9+
// A wrapper around a job, so that internal job components don't require things like *testing.T
10+
// and can be reused elsewhere
911
type Runner struct {
1012
t *testing.T
1113
Job *Job

test/e2e/framework/types/step.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
package types
22

33
var DefaultOpts = StepOptions{
4-
ExpectError: false,
4+
// when wanting to expect an error, set to true
5+
ExpectError: false,
6+
7+
// when wanting to avoid saving the parameters to the job,
8+
// such as a repetetive task where step is used multiple times sequentially,
9+
// but parameters are different each time
510
SkipSavingParamatersToJob: false,
611
}
712

813
type Step interface {
14+
// Useful when wanting to do parameter checking, for example
15+
// if a parameter length is known to be required less than 80 characters,
16+
// do this here so we don't find out later on when we run the step
17+
// when possible, try to avoid making external calls, this should be fast and simple
918
Prevalidate() error
19+
20+
// Primary step where test logic is executed
21+
// Returning an error will cause the test to fail
1022
Run() error
11-
Postvalidate() error
23+
24+
// Require for background steps
1225
Stop() error
1326
}
1427

test/e2e/framework/types/step_sleep.go

-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,3 @@ func (c *Sleep) Stop() error {
2222
func (c *Sleep) Prevalidate() error {
2323
return nil
2424
}
25-
26-
func (c *Sleep) Postvalidate() error {
27-
return nil
28-
}

test/e2e/framework/types/step_stop.go

-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@ func (c *Stop) Stop() error {
2828
func (c *Stop) Prevalidate() error {
2929
return nil
3030
}
31-
32-
func (c *Stop) Postvalidate() error {
33-
return nil
34-
}

test/e2e/scenarios/cns/scenarios.go

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package azuremonitor
2+
3+
import (
4+
k8s "github.com/Azure/azure-container-networking/test/e2e/framework/kubernetes"
5+
"github.com/Azure/azure-container-networking/test/e2e/framework/types"
6+
)
7+
8+
// todo: once AMA is rolled out
9+
func ValidateAMATargets() *types.Scenario {
10+
return &types.Scenario{
11+
Steps: []*types.StepWrapper{
12+
{
13+
Step: &k8s.PortForward{
14+
Namespace: "kube-system",
15+
LabelSelector: "k8s-app=cilium",
16+
LocalPort: "9965",
17+
RemotePort: "9965",
18+
},
19+
Opts: &types.StepOptions{
20+
RunInBackgroundWithID: "validate-ama-targets",
21+
},
22+
},
23+
{
24+
Step: &VerifyPrometheusMetrics{
25+
Address: "http://localhost:9090",
26+
},
27+
},
28+
{
29+
Step: &types.Stop{
30+
BackgroundID: "validate-ama-targets",
31+
},
32+
},
33+
},
34+
}
35+
}

test/e2e/scenarios/hubble/steps/validate-ama-targets.go test/e2e/scenarios/hubble/azuremonitor/validate-ama-targets.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package steps
1+
package azuremonitor
22

33
import (
44
"context"
@@ -62,10 +62,6 @@ func (v *VerifyPrometheusMetrics) Prevalidate() error {
6262
return nil
6363
}
6464

65-
func (v *VerifyPrometheusMetrics) Postvalidate() error {
66-
return nil
67-
}
68-
6965
func (v *VerifyPrometheusMetrics) Stop() error {
7066
return nil
7167
}

0 commit comments

Comments
 (0)