Skip to content

Commit a320fe0

Browse files
Disable V8-dependent API tests for V2 since future arangods will ship without V8
1 parent b9280bf commit a320fe0

File tree

6 files changed

+149
-108
lines changed

6 files changed

+149
-108
lines changed

v2/tests/asyncjob_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ func TestAsyncJobListPending(t *testing.T) {
111111
skipBelowVersion(client, ctx, "3.11.1", t)
112112
skipResilientSingleMode(t)
113113

114+
requireV8Enabled(client, ctx, t)
115+
114116
ctxAsync := connection.WithAsync(context.Background())
115117

116118
idTransaction := runLongRequest(t, ctxAsync, db, 2, col.Name())
@@ -254,6 +256,7 @@ func TestAsyncJobDelete(t *testing.T) {
254256
})
255257

256258
t.Run("delete pending job", func(t *testing.T) {
259+
requireV8Enabled(client, ctx, t)
257260
idTransaction := runLongRequest(t, ctxAsync, db, 10, col.Name())
258261
require.NotEmpty(t, idTransaction)
259262

@@ -275,6 +278,7 @@ func TestAsyncJobDelete(t *testing.T) {
275278
})
276279

277280
t.Run("delete expired jobs", func(t *testing.T) {
281+
requireV8Enabled(client, ctx, t)
278282
idTransaction := runLongRequest(t, ctxAsync, db, 10, col.Name())
279283
require.NotEmpty(t, idTransaction)
280284

v2/tests/database_query_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,7 @@ func Test_UserDefinedFunctions(t *testing.T) {
12711271
Wrap(t, func(t *testing.T, client arangodb.Client) {
12721272
WithDatabase(t, client, nil, func(db arangodb.Database) {
12731273
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
1274+
requireV8Enabled(client, ctx, tb)
12741275
// Define UDF details
12751276
namespace := "myfunctions::temperature::" + StringWithCharset(16, charset)
12761277
functionName := namespace + "::celsiustofahrenheit"

v2/tests/database_transactionsjs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Test_DatabaseTransactionsJS(t *testing.T) {
3434
Wrap(t, func(t *testing.T, client arangodb.Client) {
3535
WithDatabase(t, client, nil, func(db arangodb.Database) {
3636
WithCollectionV2(t, db, nil, func(col arangodb.Collection) {
37-
37+
requireV8Enabled(client, context.Background(), t)
3838
t.Run("Transaction ReturnValue", func(t *testing.T) {
3939
withContextT(t, defaultTestTimeout, func(ctx context.Context, t testing.TB) {
4040
txJSOptions := arangodb.TransactionJSOptions{

v2/tests/foxx_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func Test_FoxxItzpapalotlService(t *testing.T) {
3636
Wrap(t, func(t *testing.T, client arangodb.Client) {
3737
WithDatabase(t, client, nil, func(db arangodb.Database) {
3838
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
39+
requireV8Enabled(client, ctx, tb)
3940
if os.Getenv("TEST_CONNECTION") == "vst" {
4041
skipBelowVersion(client, ctx, "3.6", t)
4142
}
@@ -298,6 +299,7 @@ func Test_ListInstalledFoxxServices(t *testing.T) {
298299
Wrap(t, func(t *testing.T, client arangodb.Client) {
299300
WithDatabase(t, client, nil, func(db arangodb.Database) {
300301
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
302+
requireV8Enabled(client, ctx, tb)
301303
services, err := client.ListInstalledFoxxServices(ctx, db.Name(), nil)
302304
require.NoError(t, err)
303305
require.NotEmpty(t, services)
@@ -325,6 +327,7 @@ func Test_GetInstalledFoxxService(t *testing.T) {
325327
Wrap(t, func(t *testing.T, client arangodb.Client) {
326328
WithDatabase(t, client, nil, func(db arangodb.Database) {
327329
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
330+
requireV8Enabled(client, ctx, tb)
328331
mount := "/_api/foxx"
329332
serviceDetails, err := client.GetInstalledFoxxService(ctx, db.Name(), &mount)
330333
require.NoError(t, err)

v2/tests/tasks_test.go

Lines changed: 116 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -53,136 +53,145 @@ type TaskParams struct {
5353

5454
func Test_CreateNewTask(t *testing.T) {
5555
Wrap(t, func(t *testing.T, client arangodb.Client) {
56-
dbName := "_system"
57-
testCases := map[string]*arangodb.TaskOptions{
58-
"taskWithParams": {
59-
Name: utils.NewType("taskWithParams"),
60-
Command: utils.NewType("(function(params) { require('@arangodb').print(params); })(params)"),
61-
Period: utils.NewType(int64(2)),
62-
Params: map[string]interface{}{
63-
"test": "hello",
64-
},
65-
},
66-
"taskWithoutParams": {
67-
Name: utils.NewType("taskWithoutParams"),
68-
Command: utils.NewType("(function() { require('@arangodb').print('Hello'); })()"),
69-
Period: utils.NewType(int64(2)),
70-
},
71-
}
72-
73-
for name, options := range testCases {
56+
WithDatabase(t, client, nil, func(db arangodb.Database) {
7457
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
75-
createdTask, err := client.CreateTask(ctx, dbName, *options)
76-
require.NoError(t, err)
77-
require.NotNil(t, createdTask)
78-
require.Equal(t, name, *createdTask.Name())
79-
t.Logf("Params: %v", options.Params)
80-
// Proper params comparison
81-
// Check parameters
82-
if options.Params != nil {
83-
var params map[string]interface{}
84-
err = createdTask.Params(&params)
85-
86-
if err != nil {
87-
t.Logf("WARNING: Could not fetch task params (unsupported feature?): %v", err)
88-
} else if len(params) == 0 {
89-
t.Logf("WARNING: Task params exist but returned empty (ArangoDB limitation?)")
90-
} else {
91-
// Only check if params are actually returned
92-
require.Equal(t, options.Params, params)
93-
}
58+
requireV8Enabled(client, ctx, tb)
59+
testCases := map[string]*arangodb.TaskOptions{
60+
"taskWithParams": {
61+
Name: utils.NewType("taskWithParams"),
62+
Command: utils.NewType("(function(params) { require('@arangodb').print(params); })(params)"),
63+
Period: utils.NewType(int64(2)),
64+
Params: map[string]interface{}{
65+
"test": "hello",
66+
},
67+
},
68+
"taskWithoutParams": {
69+
Name: utils.NewType("taskWithoutParams"),
70+
Command: utils.NewType("(function() { require('@arangodb').print('Hello'); })()"),
71+
Period: utils.NewType(int64(2)),
72+
},
9473
}
9574

96-
taskInfo, err := client.Task(ctx, dbName, *createdTask.ID())
97-
require.NoError(t, err)
98-
require.NotNil(t, taskInfo)
99-
require.Equal(t, name, *taskInfo.Name())
100-
101-
tasks, err := client.Tasks(ctx, dbName)
102-
require.NoError(t, err)
103-
require.NotNil(t, tasks)
104-
require.Greater(t, len(tasks), 0, "Expected at least one task to be present")
105-
t.Logf("Found tasks: %v", tasks)
106-
if len(tasks) > 0 && tasks[0].ID() != nil {
107-
t.Logf("Task Id to be removed: %s\n", *tasks[0].ID())
108-
} else {
109-
t.Logf("Task Id to be removed: <nil>")
110-
}
111-
if id := createdTask.ID(); id != nil {
112-
require.NoError(t, client.RemoveTask(ctx, dbName, *id))
113-
t.Logf("Task %s removed successfully", *id)
114-
} else {
115-
t.Logf("Task ID is nil")
75+
for name, options := range testCases {
76+
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
77+
createdTask, err := client.CreateTask(ctx, db.Name(), *options)
78+
require.NoError(t, err)
79+
require.NotNil(t, createdTask)
80+
require.Equal(t, name, *createdTask.Name())
81+
t.Logf("Params: %v", options.Params)
82+
// Proper params comparison
83+
// Check parameters
84+
if options.Params != nil {
85+
var params map[string]interface{}
86+
err = createdTask.Params(&params)
87+
88+
if err != nil {
89+
t.Logf("WARNING: Could not fetch task params (unsupported feature?): %v", err)
90+
} else if len(params) == 0 {
91+
t.Logf("WARNING: Task params exist but returned empty (ArangoDB limitation?)")
92+
} else {
93+
// Only check if params are actually returned
94+
require.Equal(t, options.Params, params)
95+
}
96+
}
97+
98+
taskInfo, err := client.Task(ctx, db.Name(), *createdTask.ID())
99+
require.NoError(t, err)
100+
require.NotNil(t, taskInfo)
101+
require.Equal(t, name, *taskInfo.Name())
102+
103+
tasks, err := client.Tasks(ctx, db.Name())
104+
require.NoError(t, err)
105+
require.NotNil(t, tasks)
106+
require.Greater(t, len(tasks), 0, "Expected at least one task to be present")
107+
t.Logf("Found tasks: %v", tasks)
108+
if len(tasks) > 0 && tasks[0].ID() != nil {
109+
t.Logf("Task Id to be removed: %s\n", *tasks[0].ID())
110+
} else {
111+
t.Logf("Task Id to be removed: <nil>")
112+
}
113+
if id := createdTask.ID(); id != nil {
114+
require.NoError(t, client.RemoveTask(ctx, db.Name(), *id))
115+
t.Logf("Task %s removed successfully", *id)
116+
} else {
117+
t.Logf("Task ID is nil")
118+
}
119+
})
116120
}
117121
})
118-
}
122+
})
119123
}, WrapOptions{
120124
Parallel: utils.NewType(false),
121125
})
122126
}
123127

124128
func Test_ValidationsForCreateNewTask(t *testing.T) {
125129
Wrap(t, func(t *testing.T, client arangodb.Client) {
126-
dbName := "_system"
127-
testCases := map[string]*arangodb.TaskOptions{
128-
"taskWithoutCommand": {
129-
Name: utils.NewType("taskWithoutCommand"),
130-
Period: utils.NewType(int64(2)),
131-
},
132-
"taskWithoutPeriod": nil,
133-
}
134-
135-
for name, options := range testCases {
130+
WithDatabase(t, client, nil, func(db arangodb.Database) {
136131
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
137-
var err error
138-
if options == nil {
139-
_, err = client.CreateTask(ctx, dbName, arangodb.TaskOptions{})
140-
} else {
141-
_, err = client.CreateTask(ctx, dbName, *options)
132+
requireV8Enabled(client, ctx, tb)
133+
testCases := map[string]*arangodb.TaskOptions{
134+
"taskWithoutCommand": {
135+
Name: utils.NewType("taskWithoutCommand"),
136+
Period: utils.NewType(int64(2)),
137+
},
138+
"taskWithoutPeriod": nil,
142139
}
143140

144-
require.Error(t, err)
145-
t.Logf("Expected error for task '%s': %v", name, err)
141+
for name, options := range testCases {
142+
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
143+
var err error
144+
if options == nil {
145+
_, err = client.CreateTask(ctx, db.Name(), arangodb.TaskOptions{})
146+
} else {
147+
_, err = client.CreateTask(ctx, db.Name(), *options)
148+
}
149+
150+
require.Error(t, err)
151+
t.Logf("Expected error for task '%s': %v", name, err)
152+
})
153+
}
146154
})
147-
}
148-
155+
})
149156
}, WrapOptions{
150157
Parallel: utils.NewType(false),
151158
})
152159
}
153160

154161
func Test_TaskCreationWithId(t *testing.T) {
155162
Wrap(t, func(t *testing.T, client arangodb.Client) {
156-
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
157-
dbName := "_system"
158-
taskID := "test-task-id" + StringWithCharset(16, charset)
159-
options := &arangodb.TaskOptions{
160-
ID: &taskID, // Optional if CreateTaskWithID sets it, but safe to keep
161-
Name: utils.NewType("TestTaskWithID"),
162-
Command: utils.NewType("console.log('This is a test task with ID');"),
163-
Period: utils.NewType(int64(5)),
164-
}
165-
166-
// Create the task with explicit ID
167-
task, err := client.CreateTaskWithID(ctx, dbName, taskID, *options)
168-
require.NoError(t, err, "Expected task creation to succeed")
169-
require.NotNil(t, task, "Expected task to be non-nil")
170-
require.Equal(t, taskID, *task.ID(), "Task ID mismatch")
171-
require.Equal(t, *options.Name, *task.Name(), "Task Name mismatch")
172-
173-
// Retrieve and validate
174-
retrievedTask, err := client.Task(ctx, dbName, taskID)
175-
require.NoError(t, err, "Expected task retrieval to succeed")
176-
require.NotNil(t, retrievedTask, "Expected retrieved task to be non-nil")
177-
require.Equal(t, taskID, *retrievedTask.ID(), "Retrieved task ID mismatch")
178-
require.Equal(t, *options.Name, *retrievedTask.Name(), "Retrieved task Name mismatch")
179-
180-
_, err = client.CreateTaskWithID(ctx, dbName, taskID, *options)
181-
require.Error(t, err, "Creating a duplicate task should fail")
182-
183-
// Clean up
184-
err = client.RemoveTask(ctx, dbName, taskID)
185-
require.NoError(t, err, "Expected task removal to succeed")
163+
WithDatabase(t, client, nil, func(db arangodb.Database) {
164+
withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) {
165+
requireV8Enabled(client, ctx, tb)
166+
taskID := "test-task-id" + StringWithCharset(16, charset)
167+
options := &arangodb.TaskOptions{
168+
ID: &taskID, // Optional if CreateTaskWithID sets it, but safe to keep
169+
Name: utils.NewType("TestTaskWithID"),
170+
Command: utils.NewType("console.log('This is a test task with ID');"),
171+
Period: utils.NewType(int64(5)),
172+
}
173+
174+
// Create the task with explicit ID
175+
task, err := client.CreateTaskWithID(ctx, db.Name(), taskID, *options)
176+
require.NoError(t, err, "Expected task creation to succeed")
177+
require.NotNil(t, task, "Expected task to be non-nil")
178+
require.Equal(t, taskID, *task.ID(), "Task ID mismatch")
179+
require.Equal(t, *options.Name, *task.Name(), "Task Name mismatch")
180+
181+
// Retrieve and validate
182+
retrievedTask, err := client.Task(ctx, db.Name(), taskID)
183+
require.NoError(t, err, "Expected task retrieval to succeed")
184+
require.NotNil(t, retrievedTask, "Expected retrieved task to be non-nil")
185+
require.Equal(t, taskID, *retrievedTask.ID(), "Retrieved task ID mismatch")
186+
require.Equal(t, *options.Name, *retrievedTask.Name(), "Retrieved task Name mismatch")
187+
188+
_, err = client.CreateTaskWithID(ctx, db.Name(), taskID, *options)
189+
require.Error(t, err, "Creating a duplicate task should fail")
190+
191+
// Clean up
192+
err = client.RemoveTask(ctx, db.Name(), taskID)
193+
require.NoError(t, err, "Expected task removal to succeed")
194+
})
186195
})
187196
})
188197
}

v2/tests/util_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/stretchr/testify/require"
3030

3131
"github.com/arangodb/go-driver/v2/arangodb"
32+
"github.com/arangodb/go-driver/v2/utils"
3233
)
3334

3435
func getTestMode() string {
@@ -136,3 +137,26 @@ func skipVersionNotInRange(c arangodb.Client, ctx context.Context, minVersion, m
136137
}
137138
return x
138139
}
140+
141+
// requireV8Enabled skips the test if V8 is disabled in the ArangoDB server.
142+
// V8 is required for features like tasks, UDFs, Foxx, JS transactions, and simple queries.
143+
// This function checks the v8-version field in the version details.
144+
// If v8-version is "none", V8 is disabled and the test will be skipped.
145+
func requireV8Enabled(c arangodb.Client, ctx context.Context, t testing.TB) {
146+
versionInfo, err := c.VersionWithOptions(ctx, &arangodb.GetVersionOptions{
147+
Details: utils.NewType(true),
148+
})
149+
if err != nil {
150+
t.Fatalf("Failed to get version info with details: %s", err)
151+
}
152+
153+
// Check if v8-version exists in Details and if it's "none"
154+
if versionInfo.Details != nil {
155+
if v8Version, ok := versionInfo.Details["v8-version"]; ok {
156+
if v8VersionStr, ok := v8Version.(string); ok && v8VersionStr == "none" {
157+
t.Skip("Skipping test: V8 is disabled in this ArangoDB server (v8-version: none). " +
158+
"This test requires V8 enabled.")
159+
}
160+
}
161+
}
162+
}

0 commit comments

Comments
 (0)