@@ -26,7 +26,7 @@ import (
2626 "context"
2727 "reflect"
2828 "testing"
29- "time"
29+ // "time"
3030
3131 "github.com/dchest/uniuri"
3232
@@ -45,7 +45,12 @@ func TestLoadBalancingCursorHTTP(t *testing.T) {
4545 LoadBalancingCursorSubtest (t , false )
4646}
4747
48- // TestLoadBalancerCursorVST tests cursor forwarding with load-balanced conn.
48+ func wasForwarded (r * driver.Response ) bool {
49+ h := (* r ).Header ("x-arango-request-served-by" )
50+ return h != ""
51+ }
52+
53+ // tests cursor forwarding with load-balanced conn.
4954func LoadBalancingCursorSubtest (t * testing.T , useVst bool ) {
5055 c := client .MustNewInCluster ()
5156 kubecli := mustNewKubeClient (t )
@@ -54,6 +59,8 @@ func LoadBalancingCursorSubtest(t *testing.T, useVst bool) {
5459 // Prepare deployment config
5560 depl := newDeployment ("test-lb-" + uniuri .NewLen (4 ))
5661 depl .Spec .Mode = api .NewMode (api .DeploymentModeCluster )
62+ image := "dhly/arangodb:3.3.11-local"
63+ depl .Spec .Image = & image
5764
5865 // Create deployment
5966 _ , err := c .DatabaseV1alpha ().ArangoDeployments (ns ).Create (depl )
@@ -128,7 +135,7 @@ func LoadBalancingCursorSubtest(t *testing.T, useVst bool) {
128135 ExpectedDocuments : collectionData ["books" ],
129136 DocumentType : reflect .TypeOf (Book {}),
130137 },
131- queryTest {
138+ /* queryTest{
132139 Query: "FOR d IN books FILTER d.Title==@title SORT d.Title RETURN d",
133140 BindVars: map[string]interface{}{"title": "Book 02"},
134141 ExpectSuccess: true,
@@ -175,24 +182,25 @@ func LoadBalancingCursorSubtest(t *testing.T, useVst bool) {
175182 ExpectedDocuments: []interface{}{"Blair", "Clair", "Jake", "John", "Johnny", "Zz"},
176183 DocumentType: reflect.TypeOf("foo"),
177184 ExpectSuccess: true,
178- },
185+ },*/
179186 }
180187
188+ var r driver.Response
181189 // Setup context alternatives
182190 contexts := []queryTestContext {
183- queryTestContext {nil , false },
184- queryTestContext {context .Background (), false },
185- queryTestContext {driver .WithQueryCount (nil ), true },
186- queryTestContext {driver .WithQueryCount (nil , true ), true },
187- queryTestContext {driver .WithQueryCount (nil , false ), false },
188- queryTestContext {driver .WithQueryBatchSize (nil , 1 ), false },
189- queryTestContext {driver .WithQueryCache (nil ), false },
190- queryTestContext {driver .WithQueryCache (nil , true ), false },
191- queryTestContext {driver .WithQueryCache (nil , false ), false },
192- queryTestContext {driver .WithQueryMemoryLimit (nil , 60000 ), false },
193- queryTestContext {driver .WithQueryTTL (nil , time .Minute ), false },
194- queryTestContext {driver .WithQueryBatchSize (driver .WithQueryCount (nil ), 1 ), true },
195- queryTestContext {driver .WithQueryCache (driver .WithQueryCount (driver .WithQueryBatchSize (nil , 2 ))), true },
191+ /* queryTestContext{driver.WithResponse( nil, &r) , false},
192+ queryTestContext{driver.WithResponse( context.Background(), &r ), false},
193+ queryTestContext{driver.WithResponse(driver. WithQueryCount(nil), &r ), true},
194+ queryTestContext{driver.WithResponse(driver. WithQueryCount(nil, true), &r ), true},
195+ queryTestContext{driver.WithResponse(driver. WithQueryCount(nil, false), &r), false},*/
196+ queryTestContext {driver .WithResponse ( driver . WithQueryBatchSize (nil , 1 ), & r ), false },
197+ /* queryTestContext{driver.WithResponse(driver. WithQueryCache(nil), &r ), false},
198+ queryTestContext{driver.WithResponse(driver. WithQueryCache(nil, true), &r ), false},
199+ queryTestContext{driver.WithResponse(driver. WithQueryCache(nil, false), &r ), false},
200+ queryTestContext{driver.WithResponse(driver. WithQueryMemoryLimit(nil, 60000), &r ), false},
201+ queryTestContext{driver.WithResponse(driver. WithQueryTTL(nil, time.Minute), &r ), false},
202+ queryTestContext{driver.WithResponse(driver. WithQueryBatchSize(driver.WithQueryCount(nil), 1), &r ), true},
203+ queryTestContext{driver.WithResponse(driver. WithQueryCache(driver.WithQueryCount(driver.WithQueryBatchSize(nil, 2))), &r), true},*/
196204 }
197205
198206 // keep track of whether at least one request was forwarded internally to the
@@ -239,8 +247,9 @@ func LoadBalancingCursorSubtest(t *testing.T, useVst bool) {
239247 t .Error ("HasMore returned false, but ReadDocument returns a document" )
240248 }
241249 result = append (result , doc .Elem ().Interface ())
242- // TODO extract `x-arango-request-served-by` header
243- // if header exists, set someRequestForwarded = true
250+ if (wasForwarded (& r )) {
251+ someRequestForwarded = true
252+ }
244253 }
245254 if len (result ) != len (test .ExpectedDocuments ) {
246255 t .Errorf ("Expected %d documents, got %d in query %d (%s)" , len (test .ExpectedDocuments ), len (result ), i , test .Query )
0 commit comments