Skip to content

Commit 02f8c63

Browse files
authoredAug 7, 2023
some fixes in e2e (#3116)
1 parent d8fa839 commit 02f8c63

File tree

12 files changed

+49
-10
lines changed

12 files changed

+49
-10
lines changed
 

‎pkg/controller/subnet.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ func (c *Controller) enqueueUpdateSubnet(old, new interface{}) {
111111

112112
if oldSubnet.Spec.GatewayType != newSubnet.Spec.GatewayType {
113113
c.recorder.Eventf(newSubnet, v1.EventTypeNormal, "SubnetGatewayTypeChanged",
114-
"subnet gateway type changes from %s to %s ", oldSubnet.Spec.GatewayType, newSubnet.Spec.GatewayType)
114+
"subnet gateway type changes from %q to %q", oldSubnet.Spec.GatewayType, newSubnet.Spec.GatewayType)
115115
}
116116

117117
if oldSubnet.Spec.GatewayNode != newSubnet.Spec.GatewayNode {
118118
c.recorder.Eventf(newSubnet, v1.EventTypeNormal, "SubnetGatewayNodeChanged",
119-
"gateway node changes from %s to %s ", oldSubnet.Spec.GatewayNode, newSubnet.Spec.GatewayNode)
119+
"gateway node changes from %q to %q", oldSubnet.Spec.GatewayNode, newSubnet.Spec.GatewayNode)
120120
}
121121

122122
c.addOrUpdateSubnetQueue.Add(key)

‎test/e2e/framework/daemonset.go

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
type DaemonSetClient struct {
2323
f *Framework
2424
v1apps.DaemonSetInterface
25+
namespace string
2526
}
2627

2728
func (f *Framework) DaemonSetClient() *DaemonSetClient {
@@ -32,6 +33,7 @@ func (f *Framework) DaemonSetClientNS(namespace string) *DaemonSetClient {
3233
return &DaemonSetClient{
3334
f: f,
3435
DaemonSetInterface: f.ClientSet.AppsV1().DaemonSets(namespace),
36+
namespace: namespace,
3537
}
3638
}
3739

‎test/e2e/framework/deployment.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
type DeploymentClient struct {
3030
f *Framework
3131
v1apps.DeploymentInterface
32+
namespace string
3233
}
3334

3435
func (f *Framework) DeploymentClient() *DeploymentClient {
@@ -39,6 +40,7 @@ func (f *Framework) DeploymentClientNS(namespace string) *DeploymentClient {
3940
return &DeploymentClient{
4041
f: f,
4142
DeploymentInterface: f.ClientSet.AppsV1().Deployments(namespace),
43+
namespace: namespace,
4244
}
4345
}
4446

‎test/e2e/framework/endpoints.go

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
type EndpointsClient struct {
2222
f *Framework
2323
v1core.EndpointsInterface
24+
namespace string
2425
}
2526

2627
func (f *Framework) EndpointClient() *EndpointsClient {
@@ -31,6 +32,7 @@ func (f *Framework) EndpointsClientNS(namespace string) *EndpointsClient {
3132
return &EndpointsClient{
3233
f: f,
3334
EndpointsInterface: f.ClientSet.CoreV1().Endpoints(namespace),
35+
namespace: namespace,
3436
}
3537
}
3638

‎test/e2e/framework/event.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
type EventClient struct {
1414
f *Framework
1515
typedcorev1.EventInterface
16+
namespace string
1617
}
1718

1819
func (f *Framework) EventClient() *EventClient {
@@ -23,14 +24,15 @@ func (f *Framework) EventClientNS(namespace string) *EventClient {
2324
return &EventClient{
2425
f: f,
2526
EventInterface: f.ClientSet.CoreV1().Events(namespace),
27+
namespace: namespace,
2628
}
2729
}
2830

2931
// WaitToHaveEvent waits the provided resource to have the specified event(s)
3032
func (c *EventClient) WaitToHaveEvent(kind, name, eventType, reason, sourceComponent, sourceHost string) []corev1.Event {
3133
var result []corev1.Event
3234
err := wait.PollUntilContextTimeout(context.Background(), poll, timeout, false, func(ctx context.Context) (bool, error) {
33-
Logf("Waiting for %s %s/%s to have event %s/%s", kind, c.f.Namespace.Name, name, eventType, reason)
35+
Logf("Waiting for %s %s/%s to have event %s/%s", kind, c.namespace, name, eventType, reason)
3436
selector := fields.Set{
3537
"involvedObject.kind": kind,
3638
"involvedObject.name": name,

‎test/e2e/framework/network-policy.go

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
type NetworkPolicyClient struct {
1919
f *Framework
2020
v1net.NetworkPolicyInterface
21+
namespace string
2122
}
2223

2324
func (f *Framework) NetworkPolicyClient() *NetworkPolicyClient {
@@ -28,6 +29,7 @@ func (f *Framework) NetworkPolicyClientNS(namespace string) *NetworkPolicyClient
2829
return &NetworkPolicyClient{
2930
f: f,
3031
NetworkPolicyInterface: f.ClientSet.NetworkingV1().NetworkPolicies(namespace),
32+
namespace: namespace,
3133
}
3234
}
3335

‎test/e2e/framework/pod.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ import (
1717
type PodClient struct {
1818
f *Framework
1919
*e2epod.PodClient
20+
namespace string
2021
}
2122

2223
func (f *Framework) PodClient() *PodClient {
2324
return f.PodClientNS(f.Namespace.Name)
2425
}
2526

2627
func (f *Framework) PodClientNS(namespace string) *PodClient {
27-
return &PodClient{f, e2epod.PodClientNS(f.Framework, namespace)}
28+
return &PodClient{f, e2epod.PodClientNS(f.Framework, namespace), namespace}
2829
}
2930

3031
func (c *PodClient) GetPod(name string) *corev1.Pod {
@@ -75,12 +76,12 @@ func (c *PodClient) Patch(original, modified *corev1.Pod) *corev1.Pod {
7576
}
7677

7778
func (c *PodClient) WaitForRunning(name string) {
78-
err := e2epod.WaitTimeoutForPodRunningInNamespace(context.TODO(), c.f.ClientSet, name, c.f.Namespace.Name, timeout)
79+
err := e2epod.WaitTimeoutForPodRunningInNamespace(context.TODO(), c.f.ClientSet, name, c.namespace, timeout)
7980
ExpectNoError(err)
8081
}
8182

8283
func (c *PodClient) WaitForNotFound(name string) {
83-
err := e2epod.WaitForPodNotFoundInNamespace(context.TODO(), c.f.ClientSet, name, c.f.Namespace.Name, timeout)
84+
err := e2epod.WaitForPodNotFoundInNamespace(context.TODO(), c.f.ClientSet, name, c.namespace, timeout)
8485
ExpectNoError(err)
8586
}
8687

‎test/e2e/framework/service.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
type ServiceClient struct {
2424
f *Framework
2525
v1core.ServiceInterface
26+
namespace string
2627
}
2728

2829
func (f *Framework) ServiceClient() *ServiceClient {
@@ -33,6 +34,7 @@ func (f *Framework) ServiceClientNS(namespace string) *ServiceClient {
3334
return &ServiceClient{
3435
f: f,
3536
ServiceInterface: f.ClientSet.CoreV1().Services(namespace),
37+
namespace: namespace,
3638
}
3739
}
3840

‎test/e2e/framework/statefulset.go

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
type StatefulSetClient struct {
2020
f *Framework
2121
v1apps.StatefulSetInterface
22+
namespace string
2223
}
2324

2425
func (f *Framework) StatefulSetClient() *StatefulSetClient {
@@ -29,6 +30,7 @@ func (f *Framework) StatefulSetClientNS(namespace string) *StatefulSetClient {
2930
return &StatefulSetClient{
3031
f: f,
3132
StatefulSetInterface: f.ClientSet.AppsV1().StatefulSets(namespace),
33+
namespace: namespace,
3234
}
3335
}
3436

‎test/e2e/framework/switch-lb-rule.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
type SwitchLBRuleClient struct {
2424
f *Framework
2525
v1.SwitchLBRuleInterface
26+
namespace string
2627
}
2728

2829
func (f *Framework) SwitchLBRuleClient() *SwitchLBRuleClient {
@@ -33,6 +34,7 @@ func (f *Framework) SwitchLBRuleClientNS(namespace string) *SwitchLBRuleClient {
3334
return &SwitchLBRuleClient{
3435
f: f,
3536
SwitchLBRuleInterface: f.KubeOVNClientSet.KubeovnV1().SwitchLBRules(),
37+
namespace: namespace,
3638
}
3739
}
3840

‎test/e2e/kube-ovn/subnet/subnet.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -1032,20 +1032,20 @@ var _ = framework.Describe("[group:subnet]", func() {
10321032
eventClient = f.EventClientNS("default")
10331033
events := eventClient.WaitToHaveEvent("Subnet", subnetName, "Normal", "SubnetGatewayTypeChanged", "kube-ovn-controller", "")
10341034

1035-
message := fmt.Sprintf("subnet gateway type changes from %s to %s ", apiv1.GWDistributedType, apiv1.GWCentralizedType)
1035+
message := fmt.Sprintf("subnet gateway type changes from %q to %q", apiv1.GWDistributedType, apiv1.GWCentralizedType)
10361036
found := false
10371037
for _, event := range events {
1038-
if strings.Contains(event.Message, message) {
1038+
if event.Message == message {
10391039
found = true
10401040
break
10411041
}
10421042
}
10431043
framework.ExpectTrue(found, "no SubnetGatewayTypeChanged event")
10441044
found = false
10451045
events = eventClient.WaitToHaveEvent("Subnet", subnetName, "Normal", "SubnetGatewayNodeChanged", "kube-ovn-controller", "")
1046-
message = fmt.Sprintf("gateway node changes from %s to %s ", "", modifiedSubnet.Spec.GatewayNode)
1046+
message = fmt.Sprintf("gateway node changes from %q to %q", "", modifiedSubnet.Spec.GatewayNode)
10471047
for _, event := range events {
1048-
if strings.Contains(event.Message, message) {
1048+
if event.Message == message {
10491049
found = true
10501050
break
10511051
}
@@ -1073,6 +1073,7 @@ var _ = framework.Describe("[group:subnet]", func() {
10731073
}
10741074
}
10751075
})
1076+
10761077
framework.ConformanceIt("should support subnet add nat outgoing policy rules ", func() {
10771078
f.SkipVersionPriorTo(1, 12, "Support for subnet add nat outgoing policy rules in v1.12")
10781079

‎test/e2e/kube-ovn/underlay/underlay.go

+21
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ func makeProviderNetwork(providerNetworkName string, exchangeLinkName bool, link
4747
return framework.MakeProviderNetwork(providerNetworkName, exchangeLinkName, defaultInterface, customInterfaces, nil)
4848
}
4949

50+
func waitSubnetStatusUpdate(subnetName string, subnetClient *framework.SubnetClient, expectedUsingIPs float64) {
51+
ginkgo.By("Waiting for status of subnet " + subnetName + " to be updated")
52+
framework.WaitUntil(2*time.Second, 30*time.Second, func(_ context.Context) (bool, error) {
53+
subnet := subnetClient.Get(subnetName)
54+
if (subnet.Status.V4AvailableIPs != 0 && subnet.Status.V4UsingIPs != expectedUsingIPs) ||
55+
(subnet.Status.V6AvailableIPs != 0 && subnet.Status.V6UsingIPs != expectedUsingIPs) {
56+
return false, nil
57+
}
58+
return true, nil
59+
}, "")
60+
}
61+
5062
var _ = framework.SerialDescribe("[group:underlay]", func() {
5163
f := framework.NewDefaultFramework("underlay")
5264

@@ -521,6 +533,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
521533
args := []string{"netexec", "--http-port", strconv.Itoa(curlListenPort)}
522534
originUnderlayPod := framework.MakePod(namespaceName, u2oPodNameUnderlay, nil, annotations, framework.AgnhostImage, nil, args)
523535
underlayPod := podClient.CreateSync(originUnderlayPod)
536+
waitSubnetStatusUpdate(subnetName, subnetClient, 2)
524537

525538
ginkgo.By("Creating overlay subnet " + u2oOverlaySubnetName)
526539
cidr := framework.RandomCIDR(f.ClusterIpFamily)
@@ -552,6 +565,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
552565

553566
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
554567
underlayPod = podClient.CreateSync(originUnderlayPod)
568+
waitSubnetStatusUpdate(subnetName, subnetClient, 1)
555569

556570
subnet = subnetClient.Get(subnetName)
557571
checkU2OItems(f, subnet, underlayPod, overlayPod, false)
@@ -569,6 +583,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
569583

570584
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
571585
underlayPod = podClient.CreateSync(originUnderlayPod)
586+
waitSubnetStatusUpdate(subnetName, subnetClient, 2)
572587

573588
subnet = subnetClient.Get(subnetName)
574589
checkU2OItems(f, subnet, underlayPod, overlayPod, false)
@@ -596,6 +611,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
596611

597612
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
598613
underlayPod = podClient.CreateSync(originUnderlayPod)
614+
waitSubnetStatusUpdate(subnetName, subnetClient, 1)
599615

600616
subnet = subnetClient.Get(subnetName)
601617
checkU2OItems(f, subnet, underlayPod, overlayPod, false)
@@ -613,6 +629,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
613629

614630
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
615631
underlayPod = podClient.CreateSync(originUnderlayPod)
632+
waitSubnetStatusUpdate(subnetName, subnetClient, 2)
616633

617634
subnet = subnetClient.Get(subnetName)
618635
checkU2OItems(f, subnet, underlayPod, overlayPod, false)
@@ -654,6 +671,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
654671

655672
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
656673
underlayPod = podClient.CreateSync(originUnderlayPod)
674+
waitSubnetStatusUpdate(subnetName, subnetClient, 2)
657675

658676
subnet = subnetClient.Get(subnetName)
659677
checkU2OItems(f, subnet, underlayPod, overlayPod, false)
@@ -694,6 +712,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
694712

695713
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
696714
underlayPod = podClient.CreateSync(originUnderlayPod)
715+
waitSubnetStatusUpdate(subnetName, subnetClient, 2)
697716

698717
subnet = subnetClient.Get(subnetName)
699718
checkU2OItems(f, subnet, underlayPod, podOverlayCustomVPC, true)
@@ -712,6 +731,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
712731

713732
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
714733
underlayPod = podClient.CreateSync(originUnderlayPod)
734+
waitSubnetStatusUpdate(subnetName, subnetClient, 2)
715735

716736
subnet = subnetClient.Get(subnetName)
717737
checkU2OItems(f, subnet, underlayPod, overlayPod, false)
@@ -729,6 +749,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
729749

730750
ginkgo.By("Creating underlay pod " + u2oPodNameUnderlay)
731751
underlayPod = podClient.CreateSync(originUnderlayPod)
752+
waitSubnetStatusUpdate(subnetName, subnetClient, 1)
732753

733754
subnet = subnetClient.Get(subnetName)
734755
checkU2OItems(f, subnet, underlayPod, overlayPod, false)

0 commit comments

Comments
 (0)
Please sign in to comment.