@@ -80,46 +80,6 @@ var _ = Describe("RoundRobin", func() {
8080 Entry ("When the next index is 0" , 0 ),
8181 )
8282
83- DescribeTable ("it performs round-robin consecutively through the endpoints" ,
84- func (nextIdx int ) {
85- pool .NextIdx = nextIdx
86- e1 := route .NewEndpoint (& route.EndpointOpts {Host : "1.2.3.4" , Port : 5678 })
87- e2 := route .NewEndpoint (& route.EndpointOpts {Host : "5.6.7.8" , Port : 1234 })
88- e3 := route .NewEndpoint (& route.EndpointOpts {Host : "1.2.7.8" , Port : 1234 })
89- endpoints := []* route.Endpoint {e1 , e2 , e3 }
90-
91- for _ , e := range endpoints {
92- pool .Put (e )
93- }
94-
95- iter := route .NewRoundRobin (logger .Logger , pool , "" , false , false , "meow-az" )
96-
97- iteratedEndpoints := make ([]* route.Endpoint , len (endpoints ))
98- for i := 0 ; i < len (endpoints ); i += 1 {
99- n := iter .Next (i )
100- for _ , e := range endpoints {
101- if e == n {
102- iteratedEndpoints [i ] = e
103- break
104- }
105- }
106- }
107-
108- currentIndex := nextIdx
109- for i := 0 ; i < len (endpoints ); i += 1 {
110- if currentIndex >= len (endpoints ) {
111- currentIndex = 0
112- }
113- Expect (iteratedEndpoints [i ]).To (Equal (endpoints [currentIndex ]))
114- currentIndex ++
115- }
116-
117- },
118- Entry ("When the next index is 0" , 0 ),
119- Entry ("When the next index is 1" , 1 ),
120- Entry ("When the next index is 2" , 2 ),
121- )
122-
12383 DescribeTable ("it performs round-robin through the endpoints for two parallel-running iterators" ,
12484 func (nextIdx int ) {
12585 pool .NextIdx = nextIdx
@@ -131,11 +91,14 @@ var _ = Describe("RoundRobin", func() {
13191 pool .Put (e )
13292 }
13393
94+ By ("Create two iterators running over the same endpoint pool" )
13495 iter1 := route .NewRoundRobin (logger .Logger , pool , "" , false , false , "meow-az" )
13596 iter2 := route .NewRoundRobin (logger .Logger , pool , "" , false , false , "meow-az" )
13697
13798 iteratedEndpoints1 := make (map [* route.Endpoint ]int )
13899 iteratedEndpoints2 := make (map [* route.Endpoint ]int )
100+
101+ By ("Simulate retrying with attempts = endpoint number and count how many times both iterators iterate over every endpoint" )
139102 for i := 0 ; i < len (endpoints ); i += 1 {
140103 n := iter1 .Next (i )
141104 k := iter2 .Next (i )
@@ -148,10 +111,12 @@ var _ = Describe("RoundRobin", func() {
148111 }
149112 }
150113 }
151-
114+ By ( "Expect that first round robin iterator iterates over every endpoint exactly one time" )
152115 for e := range iteratedEndpoints1 {
153116 Expect (iteratedEndpoints1 [e ]).To (Equal (1 ))
154117 }
118+
119+ By ("Expect that second round robin iterator iterates over every endpoint exactly one time" )
155120 for e := range iteratedEndpoints2 {
156121 Expect (iteratedEndpoints2 [e ]).To (Equal (1 ))
157122 }
0 commit comments