diff --git a/modules/couchbase/couchbase.go b/modules/couchbase/couchbase.go index b0889f54b2..5bd73a4eab 100644 --- a/modules/couchbase/couchbase.go +++ b/modules/couchbase/couchbase.go @@ -491,9 +491,14 @@ func (c *CouchbaseContainer) createPrimaryIndex(ctx context.Context, bucket buck body := map[string]string{ "statement": "CREATE PRIMARY INDEX on `" + bucket.name + "`", } - - _, err := c.doHttpRequest(ctx, QUERY_PORT, "/query/service", http.MethodPost, body, true) - + err := backoff.Retry(func() error { + response, err := c.doHttpRequest(ctx, QUERY_PORT, "/query/service", http.MethodPost, body, true) + firstError := gjson.Get(string(response), "errors.0.code").Int() + if firstError != 0 { + return errors.New("index creation failed") + } + return err + }, backoff.WithContext(backoff.NewExponentialBackOff(), ctx)) return err } diff --git a/modules/couchbase/couchbase_test.go b/modules/couchbase/couchbase_test.go index f05c08d16c..9fee51317e 100644 --- a/modules/couchbase/couchbase_test.go +++ b/modules/couchbase/couchbase_test.go @@ -12,7 +12,7 @@ import ( const ( // dockerImages { - enterpriseEdition = "couchbase:enterprise-7.1.3" + enterpriseEdition = "couchbase:enterprise-7.6.1" communityEdition = "couchbase:community-7.1.1" // } ) @@ -54,7 +54,15 @@ func TestCouchbaseWithEnterpriseContainer(t *testing.T) { ctx := context.Background() bucketName := "testBucket" - container, err := tccouchbase.Run(ctx, enterpriseEdition, tccouchbase.WithBuckets(tccouchbase.NewBucket(bucketName))) + bucket := tccouchbase.NewBucket(bucketName). + WithQuota(100). + WithReplicas(0). + WithFlushEnabled(true). + WithPrimaryIndex(true) + container, err := tccouchbase.Run(ctx, + enterpriseEdition, + tccouchbase.WithBuckets(bucket), + ) if err != nil { t.Fatal(err) }