Skip to content

Commit 10cd54b

Browse files
committed
Streamling the node/zone-picking logic
1 parent bc81a86 commit 10cd54b

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

test/e2e/network/traffic_distribution.go

+10-18
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,23 @@ var _ = common.SIGDescribe("Traffic Distribution", func() {
110110
////////////////////////////////////////////////////////////////////////////
111111

112112
ginkgo.It("should route traffic to an endpoint in the same zone when using PreferClose", func(ctx context.Context) {
113-
114113
ginkgo.By("finding 3 zones with schedulable nodes")
115-
allZonesSet, err := e2enode.GetSchedulableClusterZones(ctx, c)
116-
framework.ExpectNoError(err)
117-
if len(allZonesSet) < 3 {
118-
framework.Failf("got %d zones with schedulable nodes, want atleast 3 zones with schedulable nodes", len(allZonesSet))
119-
}
120-
zones := allZonesSet.UnsortedList()[:3]
121-
122-
ginkgo.By(fmt.Sprintf("finding a node in each of the chosen 3 zones %v", zones))
123114
nodeList, err := e2enode.GetReadySchedulableNodes(ctx, c)
124115
framework.ExpectNoError(err)
125116
nodeForZone := make(map[string]*v1.Node)
126-
for _, zone := range zones {
127-
found := false
128-
for _, node := range nodeList.Items {
129-
if zone == node.Labels[v1.LabelTopologyZone] {
130-
found = true
131-
nodeForZone[zone] = &node
132-
}
117+
for _, node := range nodeList.Items {
118+
zone := node.Labels[v1.LabelTopologyZone]
119+
if nodeForZone[zone] != nil {
120+
continue
133121
}
134-
if !found {
135-
framework.Failf("could not find a node in zone %q; nodes=\n%v", zone, format.Object(nodeList, 1 /* indent one level */))
122+
nodeForZone[zone] = &node
123+
if len(nodeForZone) == 3 {
124+
break
136125
}
137126
}
127+
if len(nodeForZone) < 3 {
128+
e2eskipper.Skipf("got %d zones with schedulable nodes, need at least 3", len(nodeForZone))
129+
}
138130

139131
var clientPods []*clientPod
140132
var serverPods []*serverPod

0 commit comments

Comments
 (0)