Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions v2/tests/client_access_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ func Test_AccessTokens(t *testing.T) {
found := false
for _, token := range tokens.Tokens {
if token.Id != nil && tokenResp != nil && tokenResp.Id != nil && *token.Id == *tokenResp.Id {
require.Equal(t, tokenResp.Id, token.Id)
require.Equal(t, tokenResp.Name, token.Name)
require.Equal(t, tokenResp.Fingerprint, token.Fingerprint)
require.Equal(t, tokenResp.Active, token.Active)
require.Equal(t, tokenResp.CreatedAt, token.CreatedAt)
require.Equal(t, tokenResp.ValidUntil, token.ValidUntil)
require.Equal(t, *tokenResp.Id, *token.Id)
require.Equal(t, *tokenResp.Name, *token.Name)
require.Equal(t, *tokenResp.Fingerprint, *token.Fingerprint)
require.Equal(t, *tokenResp.Active, *token.Active)
require.Equal(t, *tokenResp.CreatedAt, *token.CreatedAt)
require.Equal(t, *tokenResp.ValidUntil, *token.ValidUntil)
found = true
break
}
Expand Down Expand Up @@ -190,6 +190,8 @@ func Test_AccessTokens(t *testing.T) {
}
})
})
}, WrapOptions{
Parallel: utils.NewType(false),
})
}

Expand Down
46 changes: 39 additions & 7 deletions v2/tests/client_replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"fmt"
"os"
"strconv"
"strings"
"testing"
"time"

Expand All @@ -33,6 +34,37 @@ import (
"github.com/stretchr/testify/require"
)

// getApplierEndpoint returns the endpoint from TEST_ENDPOINTS environment variable
// converted to the format expected by applier options (tcp:// or ssl://).
// If TEST_ENDPOINTS is not set, it defaults to tcp://127.0.0.1:8529.
func getApplierEndpoint(t testing.TB) string {
eps := getEndpointsFromEnv(t)
// getEndpointsFromEnv will have already failed if TEST_ENDPOINTS is not set,
// so we can safely use the first endpoint

// Get the first endpoint and convert from http/https to tcp/ssl format
endpoint := eps[0]
endpoint = strings.ReplaceAll(endpoint, "http://", "tcp://")
endpoint = strings.ReplaceAll(endpoint, "https://", "ssl://")

return endpoint
}

// getSyncEndpoint returns the endpoint from TEST_ENDPOINTS environment variable
// converted to the format expected by ReplicationSyncOptions (http+tcp:// or https+ssl://).
// If TEST_ENDPOINTS is not set, it defaults to http+tcp://127.0.0.1:8529.
func getSyncEndpoint(t testing.TB) string {
eps := getEndpointsFromEnv(t)
// getEndpointsFromEnv will have already failed if TEST_ENDPOINTS is not set,
// so we can safely use the first endpoint

// Get the first endpoint and convert from http/https to http+tcp/https+ssl format
endpoint := eps[0]
endpoint = strings.ReplaceAll(endpoint, "http://", "http+tcp://")
endpoint = strings.ReplaceAll(endpoint, "https://", "https+ssl://")
return endpoint
}

func Test_CreateNewBatch(t *testing.T) {
Wrap(t, func(t *testing.T, client arangodb.Client) {
WithDatabase(t, client, nil, func(db arangodb.Database) {
Expand Down Expand Up @@ -233,7 +265,7 @@ func Test_UpdateApplierConfig(t *testing.T) {
_, err := client.UpdateApplierConfig(ctx, db.Name(), utils.NewType(true), arangodb.ApplierOptions{
ChunkSize: utils.NewType(1234),
AutoStart: utils.NewType(true),
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
Endpoint: utils.NewType(getApplierEndpoint(t)),
Database: utils.NewType(db.Name()),
Username: utils.NewType("root"),
})
Expand All @@ -243,7 +275,7 @@ func Test_UpdateApplierConfig(t *testing.T) {
resp, err := client.UpdateApplierConfig(ctx, db.Name(), utils.NewType(false), arangodb.ApplierOptions{
ChunkSize: utils.NewType(2596),
AutoStart: utils.NewType(false),
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
Endpoint: utils.NewType(getApplierEndpoint(t)),
Database: utils.NewType(db.Name()),
})
require.NoError(t, err)
Expand Down Expand Up @@ -274,7 +306,7 @@ func Test_ApplierStart(t *testing.T) {
resp, err := client.UpdateApplierConfig(ctx, db.Name(), utils.NewType(false), arangodb.ApplierOptions{
ChunkSize: utils.NewType(2596),
AutoStart: utils.NewType(false),
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
Endpoint: utils.NewType(getApplierEndpoint(t)),
Database: utils.NewType(db.Name()),
})
require.NoError(t, err)
Expand Down Expand Up @@ -324,7 +356,7 @@ func Test_ApplierStart(t *testing.T) {
resp, err := client.UpdateApplierConfig(ctx, db.Name(), nil, arangodb.ApplierOptions{
ChunkSize: utils.NewType(2596),
AutoStart: utils.NewType(false),
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
Endpoint: utils.NewType(getApplierEndpoint(t)),
Database: utils.NewType(db.Name()),
})
require.NoError(t, err)
Expand Down Expand Up @@ -404,7 +436,7 @@ func Test_MakeFollower(t *testing.T) {
t.Run("Make Follower", func(t *testing.T) {
resp, err := client.MakeFollower(ctx, db.Name(), arangodb.ApplierOptions{
ChunkSize: utils.NewType(1234),
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
Endpoint: utils.NewType(getApplierEndpoint(t)),
Database: utils.NewType(db.Name()),
Username: utils.NewType("root"),
})
Expand Down Expand Up @@ -448,7 +480,7 @@ func Test_GetWALReplicationEndpoints(t *testing.T) {
t.Logf("Starting fromTick: %d\n", fromTick)
t.Run("Update applier config with out query params", func(t *testing.T) {
resp, err := client.UpdateApplierConfig(ctx, db.Name(), nil, arangodb.ApplierOptions{
Endpoint: utils.NewType("tcp://127.0.0.1:8529"),
Endpoint: utils.NewType(getApplierEndpoint(t)),
Database: utils.NewType(db.Name()),
Verbose: utils.NewType(true),
})
Expand Down Expand Up @@ -675,7 +707,7 @@ func Test_StartReplicationSync(t *testing.T) {
}

opts := arangodb.ReplicationSyncOptions{
Endpoint: "http+tcp://127.0.0.1:8529",
Endpoint: getSyncEndpoint(t),
Username: "root",
}

Expand Down