Skip to content

Commit

Permalink
Merge pull request AliyunContainerService#774 from miaogreat/feature/…
Browse files Browse the repository at this point in the history
…skip_trunk

terway test:support skip trunk test
  • Loading branch information
l1b0k authored Jan 20, 2025
2 parents 5a55d24 + c0ea761 commit 6af5b5a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
36 changes: 21 additions & 15 deletions tests/connecctive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ func TestConnective(t *testing.T) {
}
mutateConfig := []PodConfig{}
if affinityLabel == "" {
mutateConfig = []PodConfig{
{
name: "normal config",
podFunc: func(pod *Pod) *Pod {
return pod
},
mutateConfig = []PodConfig{{
name: "normal config",
podFunc: func(pod *Pod) *Pod {
return pod
},
{
}}
if testTrunk {
mutateConfig = append(mutateConfig, PodConfig{
name: "trunk pod",
podFunc: func(pod *Pod) *Pod {
return pod.WithLabels(map[string]string{"netplan": "default"})
},
},
})
}
} else {
labelArr := strings.Split(affinityLabel, ":")
Expand All @@ -68,12 +68,14 @@ func TestConnective(t *testing.T) {
return pod.WithNodeAffinity(map[string]string{labelArr[0]: labelArr[1]})
},
},
{
name: fmt.Sprintf("trunk_%s", labelArr[0]),
}
if testTrunk {
mutateConfig = append(mutateConfig, PodConfig{
name: "trunk_trunk",
podFunc: func(pod *Pod) *Pod {
return pod.WithLabels(map[string]string{"netplan": "default"}).WithNodeAffinity(map[string]string{labelArr[0]: labelArr[1]})
},
},
})
}
}
for i := range mutateConfig {
Expand Down Expand Up @@ -410,12 +412,14 @@ func TestNetworkPolicy(t *testing.T) {
return pod
},
},
{
}
if testTrunk {
mutateConfig = append(mutateConfig, PodConfig{
name: "trunk pod",
podFunc: func(pod *Pod) *Pod {
return pod.WithLabels(map[string]string{"netplan": "default"})
},
},
})
}
} else {
labelArr := strings.Split(affinityLabel, ":")
Expand All @@ -429,12 +433,14 @@ func TestNetworkPolicy(t *testing.T) {
return pod.WithNodeAffinity(map[string]string{labelArr[0]: labelArr[1]})
},
},
{
}
if testTrunk {
mutateConfig = append(mutateConfig, PodConfig{
name: fmt.Sprintf("trunk_%s", labelArr[0]),
podFunc: func(pod *Pod) *Pod {
return pod.WithLabels(map[string]string{"netplan": "default"}).WithNodeAffinity(map[string]string{labelArr[0]: labelArr[1]})
},
},
})
}
}
for i := range mutateConfig {
Expand Down
5 changes: 3 additions & 2 deletions tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func init() {
flag.StringVar(&vSwitchIDs, "vswitch-ids", "", "extra vSwitchIDs")
flag.StringVar(&securityGroupIDs, "security-group-ids", "", "extra securityGroupIDs")
flag.StringVar(&affinityLabel, "label", "", "node affinity, format as key:value")
flag.BoolVar(&testTrunk, "enable-trunk", true, "enable trunk test")
defaultPodNetworkingName = "default-pn"
}

Expand Down Expand Up @@ -191,8 +192,8 @@ func checkENIConfig(ctx context.Context, config *envconf.Config) (context.Contex
if err != nil {
return nil, err
}
if cfg.EnableENITrunking {
testTrunk = true
if !cfg.EnableENITrunking {
testTrunk = false
testPodLevelConfig = true
}
if cfg.IPAMType == "crd" {
Expand Down

0 comments on commit 6af5b5a

Please sign in to comment.