@@ -14,6 +14,7 @@ import (
1414 e2epodoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"
1515
1616 kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
17+ "github.com/kubeovn/kube-ovn/pkg/request"
1718 "github.com/kubeovn/kube-ovn/pkg/util"
1819 "github.com/kubeovn/kube-ovn/test/e2e/framework"
1920)
@@ -52,12 +53,14 @@ var _ = framework.Describe("[group:slr]", func() {
5253 podClient * framework.PodClient
5354 subnetClient * framework.SubnetClient
5455 vpcClient * framework.VpcClient
56+ nadClient * framework.NetworkAttachmentDefinitionClient
5557
5658 namespaceName , suffix string
5759 vpcName , subnetName , clientPodName , label string
5860 stsName , stsSvcName string
5961 selSlrName , selSvcName string
6062 epSlrName , epSvcName string
63+ nadName string
6164 overlaySubnetCidr , vip string
6265 // TODO:// slr support dual-stack
6366 frontPort , selSlrFrontPort , epSlrFrontPort , backendPort int32
@@ -71,9 +74,8 @@ var _ = framework.Describe("[group:slr]", func() {
7174 podClient = f .PodClient ()
7275 subnetClient = f .SubnetClient ()
7376 vpcClient = f .VpcClient ()
74-
77+ nadClient = f . NetworkAttachmentDefinitionClient ()
7578 suffix = framework .RandomSuffix ()
76-
7779 namespaceName = f .Namespace .Name
7880 selSlrName = "sel-" + generateSwitchLBRuleName (suffix )
7981 selSvcName = generateServiceName (selSlrName )
@@ -84,6 +86,7 @@ var _ = framework.Describe("[group:slr]", func() {
8486 label = "slr"
8587 clientPodName = "client-" + suffix
8688 subnetName = generateSubnetName (suffix )
89+ nadName = subnetName
8790 vpcName = generateVpcName (suffix )
8891 frontPort = 8090
8992 selSlrFrontPort = 8091
@@ -94,15 +97,6 @@ var _ = framework.Describe("[group:slr]", func() {
9497 ginkgo .By ("Creating custom vpc" )
9598 vpc := framework .MakeVpc (vpcName , "" , false , false , []string {namespaceName })
9699 _ = vpcClient .CreateSync (vpc )
97- ginkgo .By ("Creating custom overlay subnet" )
98- overlaySubnet := framework .MakeSubnet (subnetName , "" , overlaySubnetCidr , "" , vpcName , "" , nil , nil , nil )
99- _ = subnetClient .CreateSync (overlaySubnet )
100- annotations := map [string ]string {
101- util .LogicalSwitchAnnotation : subnetName ,
102- }
103- ginkgo .By ("Creating client pod " + clientPodName )
104- clientPod := framework .MakePod (namespaceName , clientPodName , nil , annotations , framework .AgnhostImage , nil , nil )
105- podClient .CreateSync (clientPod )
106100 })
107101
108102 ginkgo .AfterEach (func () {
@@ -120,10 +114,41 @@ var _ = framework.Describe("[group:slr]", func() {
120114 subnetClient .DeleteSync (subnetName )
121115 ginkgo .By ("Deleting vpc " + vpcName )
122116 vpcClient .DeleteSync (vpcName )
117+ ginkgo .By ("Deleting network attachment definition " + nadName )
118+ nadClient .Delete (nadName )
123119 })
124120
125- framework . ConformanceIt ( "should access sts and slr svc ok" , func () {
121+ ginkgo . DescribeTable ( "Test SLR connectivity" , ginkgo . Label ( "Conformance" ) , func (customProvider bool ) {
126122 f .SkipVersionPriorTo (1 , 12 , "This feature was introduced in v1.12" )
123+
124+ ginkgo .By ("Creating custom overlay subnet" )
125+
126+ var provider string
127+ if customProvider {
128+ f .SkipVersionPriorTo (1 , 15 , "This feature was introduced in v1.15" )
129+ provider = fmt .Sprintf ("%s.%s.%s" , subnetName , f .Namespace .Name , util .OvnProvider )
130+ }
131+
132+ annotations := make (map [string ]string )
133+ if customProvider {
134+ annotations [fmt .Sprintf (util .LogicalSwitchAnnotationTemplate , provider )] = subnetName
135+ annotations [util .DefaultNetworkAnnotation ] = fmt .Sprintf ("%s/%s" , f .Namespace .Name , nadName )
136+ } else {
137+ annotations [util .LogicalSwitchAnnotation ] = subnetName
138+ }
139+
140+ overlaySubnet := framework .MakeSubnet (subnetName , "" , overlaySubnetCidr , "" , vpcName , provider , nil , nil , nil )
141+ _ = subnetClient .CreateSync (overlaySubnet )
142+
143+ if customProvider {
144+ nad := framework .MakeOVNNetworkAttachmentDefinition (subnetName , f .Namespace .Namespace , provider , []request.Route {})
145+ nadClient .Create (nad )
146+ }
147+
148+ ginkgo .By ("Creating client pod " + clientPodName )
149+ newClientPod := framework .MakePod (namespaceName , clientPodName , nil , annotations , framework .AgnhostImage , nil , nil )
150+ podClient .CreateSync (newClientPod )
151+
127152 ginkgo .By ("1. Creating sts svc with slr" )
128153 var (
129154 clientPod * corev1.Pod
@@ -136,9 +161,9 @@ var _ = framework.Describe("[group:slr]", func() {
136161 ginkgo .By ("Creating statefulset " + stsName + " with subnet " + subnetName )
137162 sts := framework .MakeStatefulSet (stsName , stsSvcName , int32 (replicas ), labels , framework .AgnhostImage )
138163 ginkgo .By ("Creating sts " + stsName )
139- sts . Spec . Template . Annotations = map [ string ] string {
140- util . LogicalSwitchAnnotation : subnetName ,
141- }
164+
165+ sts . Spec . Template . Annotations = annotations
166+
142167 portStr := strconv .Itoa (80 )
143168 webServerCmd := []string {"/agnhost" , "netexec" , "--http-port" , portStr }
144169 sts .Spec .Template .Spec .Containers [0 ].Command = webServerCmd
@@ -151,10 +176,10 @@ var _ = framework.Describe("[group:slr]", func() {
151176 TargetPort : intstr .FromInt32 (80 ),
152177 }}
153178 selector := map [string ]string {"app" : label }
154- annotations := map [string ]string {
179+ svcAnnotations := map [string ]string {
155180 util .LogicalSwitchAnnotation : subnetName ,
156181 }
157- stsSvc = framework .MakeService (stsSvcName , corev1 .ServiceTypeClusterIP , annotations , selector , ports , corev1 .ServiceAffinityNone )
182+ stsSvc = framework .MakeService (stsSvcName , corev1 .ServiceTypeClusterIP , svcAnnotations , selector , ports , corev1 .ServiceAffinityNone )
158183 stsSvc = serviceClient .CreateSync (stsSvc , func (s * corev1.Service ) (bool , error ) {
159184 return len (s .Spec .ClusterIPs ) != 0 , nil
160185 }, "cluster ips are not empty" )
@@ -352,5 +377,8 @@ var _ = framework.Describe("[group:slr]", func() {
352377 }
353378 ginkgo .By ("Checking endpoint switch lb service " + epSvc .Name )
354379 curlSvc (f , clientPodName , vip , epSlrFrontPort )
355- })
380+ },
381+ ginkgo .Entry ("SLR with default provider" , false ),
382+ ginkgo .Entry ("SLR with custom provider" , true ),
383+ )
356384})
0 commit comments