Skip to content

Commit f7010b4

Browse files
bug fix (#723)
1 parent 8d6c073 commit f7010b4

File tree

2 files changed

+53
-13
lines changed

2 files changed

+53
-13
lines changed

v2/tests/client_access_tokens_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ func Test_AccessTokens(t *testing.T) {
8989
found := false
9090
for _, token := range tokens.Tokens {
9191
if token.Id != nil && tokenResp != nil && tokenResp.Id != nil && *token.Id == *tokenResp.Id {
92-
require.Equal(t, tokenResp.Id, token.Id)
93-
require.Equal(t, tokenResp.Name, token.Name)
94-
require.Equal(t, tokenResp.Fingerprint, token.Fingerprint)
95-
require.Equal(t, tokenResp.Active, token.Active)
96-
require.Equal(t, tokenResp.CreatedAt, token.CreatedAt)
97-
require.Equal(t, tokenResp.ValidUntil, token.ValidUntil)
92+
require.Equal(t, *tokenResp.Id, *token.Id)
93+
require.Equal(t, *tokenResp.Name, *token.Name)
94+
require.Equal(t, *tokenResp.Fingerprint, *token.Fingerprint)
95+
require.Equal(t, *tokenResp.Active, *token.Active)
96+
require.Equal(t, *tokenResp.CreatedAt, *token.CreatedAt)
97+
require.Equal(t, *tokenResp.ValidUntil, *token.ValidUntil)
9898
found = true
9999
break
100100
}
@@ -190,6 +190,8 @@ func Test_AccessTokens(t *testing.T) {
190190
}
191191
})
192192
})
193+
}, WrapOptions{
194+
Parallel: utils.NewType(false),
193195
})
194196
}
195197

v2/tests/client_replication_test.go

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"fmt"
2626
"os"
2727
"strconv"
28+
"strings"
2829
"testing"
2930
"time"
3031

@@ -33,6 +34,43 @@ import (
3334
"github.com/stretchr/testify/require"
3435
)
3536

37+
// getApplierEndpoint returns the endpoint from TEST_ENDPOINTS environment variable
38+
// converted to the format expected by applier options (tcp:// or ssl://).
39+
// TEST_ENDPOINTS must be set; if it is not, the test will fail.
40+
func getApplierEndpoint(t testing.TB) string {
41+
eps := getEndpointsFromEnv(t)
42+
// getEndpointsFromEnv will have already failed if TEST_ENDPOINTS is not set,
43+
// so we can safely use the first endpoint
44+
45+
// Get the first endpoint and convert from http/https to tcp/ssl format
46+
endpoint := eps[0]
47+
if strings.HasPrefix(endpoint, "https://") {
48+
endpoint = strings.Replace(endpoint, "https://", "ssl://", 1)
49+
} else if strings.HasPrefix(endpoint, "http://") {
50+
endpoint = strings.Replace(endpoint, "http://", "tcp://", 1)
51+
}
52+
53+
return endpoint
54+
}
55+
56+
// getSyncEndpoint returns the endpoint from TEST_ENDPOINTS environment variable
57+
// converted to the format expected by ReplicationSyncOptions (http+tcp:// or https+ssl://).
58+
// TEST_ENDPOINTS must be set; if it is not, the test will fail.
59+
func getSyncEndpoint(t testing.TB) string {
60+
eps := getEndpointsFromEnv(t)
61+
// getEndpointsFromEnv will have already failed if TEST_ENDPOINTS is not set,
62+
// so we can safely use the first endpoint
63+
64+
// Get the first endpoint and convert from http/https to http+tcp/https+ssl format
65+
endpoint := eps[0]
66+
if strings.HasPrefix(endpoint, "https://") {
67+
endpoint = strings.Replace(endpoint, "https://", "https+ssl://", 1)
68+
} else if strings.HasPrefix(endpoint, "http://") {
69+
endpoint = strings.Replace(endpoint, "http://", "http+tcp://", 1)
70+
}
71+
return endpoint
72+
}
73+
3674
func Test_CreateNewBatch(t *testing.T) {
3775
Wrap(t, func(t *testing.T, client arangodb.Client) {
3876
WithDatabase(t, client, nil, func(db arangodb.Database) {
@@ -233,7 +271,7 @@ func Test_UpdateApplierConfig(t *testing.T) {
233271
_, err := client.UpdateApplierConfig(ctx, db.Name(), utils.NewType(true), arangodb.ApplierOptions{
234272
ChunkSize: utils.NewType(1234),
235273
AutoStart: utils.NewType(true),
236-
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
274+
Endpoint: utils.NewType(getApplierEndpoint(t)),
237275
Database: utils.NewType(db.Name()),
238276
Username: utils.NewType("root"),
239277
})
@@ -243,7 +281,7 @@ func Test_UpdateApplierConfig(t *testing.T) {
243281
resp, err := client.UpdateApplierConfig(ctx, db.Name(), utils.NewType(false), arangodb.ApplierOptions{
244282
ChunkSize: utils.NewType(2596),
245283
AutoStart: utils.NewType(false),
246-
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
284+
Endpoint: utils.NewType(getApplierEndpoint(t)),
247285
Database: utils.NewType(db.Name()),
248286
})
249287
require.NoError(t, err)
@@ -274,7 +312,7 @@ func Test_ApplierStart(t *testing.T) {
274312
resp, err := client.UpdateApplierConfig(ctx, db.Name(), utils.NewType(false), arangodb.ApplierOptions{
275313
ChunkSize: utils.NewType(2596),
276314
AutoStart: utils.NewType(false),
277-
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
315+
Endpoint: utils.NewType(getApplierEndpoint(t)),
278316
Database: utils.NewType(db.Name()),
279317
})
280318
require.NoError(t, err)
@@ -324,7 +362,7 @@ func Test_ApplierStart(t *testing.T) {
324362
resp, err := client.UpdateApplierConfig(ctx, db.Name(), nil, arangodb.ApplierOptions{
325363
ChunkSize: utils.NewType(2596),
326364
AutoStart: utils.NewType(false),
327-
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
365+
Endpoint: utils.NewType(getApplierEndpoint(t)),
328366
Database: utils.NewType(db.Name()),
329367
})
330368
require.NoError(t, err)
@@ -404,7 +442,7 @@ func Test_MakeFollower(t *testing.T) {
404442
t.Run("Make Follower", func(t *testing.T) {
405443
resp, err := client.MakeFollower(ctx, db.Name(), arangodb.ApplierOptions{
406444
ChunkSize: utils.NewType(1234),
407-
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
445+
Endpoint: utils.NewType(getApplierEndpoint(t)),
408446
Database: utils.NewType(db.Name()),
409447
Username: utils.NewType("root"),
410448
})
@@ -448,7 +486,7 @@ func Test_GetWALReplicationEndpoints(t *testing.T) {
448486
t.Logf("Starting fromTick: %d\n", fromTick)
449487
t.Run("Update applier config with out query params", func(t *testing.T) {
450488
resp, err := client.UpdateApplierConfig(ctx, db.Name(), nil, arangodb.ApplierOptions{
451-
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
489+
Endpoint: utils.NewType(getApplierEndpoint(t)),
452490
Database: utils.NewType(db.Name()),
453491
Verbose: utils.NewType(true),
454492
})
@@ -675,7 +713,7 @@ func Test_StartReplicationSync(t *testing.T) {
675713
}
676714

677715
opts := arangodb.ReplicationSyncOptions{
678-
Endpoint: "http+tcp://127.0.0.1:8529",
716+
Endpoint: getSyncEndpoint(t),
679717
Username: "root",
680718
}
681719

0 commit comments

Comments
 (0)