Skip to content

Bug fix/v1 database cleanup #687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
33cbba8
start cleanup ov V1
dothebart Jun 2, 2025
e54c882
better use defer
dothebart Jun 3, 2025
5d207b4
better use defer
dothebart Jun 3, 2025
7e4ceaa
better use defer
dothebart Jun 3, 2025
6956994
clean up users after test
dothebart Jun 3, 2025
13d7c8f
lint
dothebart Jun 3, 2025
c440970
more cleanup of leftover databases
dothebart Jun 4, 2025
a82ff3a
lint
dothebart Jun 4, 2025
a8676e7
fix name
dothebart Jun 4, 2025
6cf71b0
lint
dothebart Jun 5, 2025
978cf8f
r2 currently out of scope
dothebart Jun 6, 2025
a6a9b92
fix query test, fix double delete
dothebart Jun 10, 2025
7f58d49
fix duplicate database create & cleanup
dothebart Jun 10, 2025
3f5c6d3
add missing cleanup
dothebart Jun 10, 2025
d579efa
add missing cleanup
dothebart Jun 10, 2025
b9c6d86
cleanup
dothebart Jun 10, 2025
898a8b8
disable replication2 test
dothebart Jun 10, 2025
c8df2c9
only in clusters
dothebart Jun 11, 2025
ee61242
later versions are incompatible with this test
dothebart Jun 11, 2025
afbc2a1
better error message
dothebart Jun 11, 2025
0a81472
longer timeouts
dothebart Jun 11, 2025
3f7d4cf
no news is good news, proper error messages
dothebart Jun 11, 2025
2fdfe02
add missing transaction cleanup
dothebart Jun 11, 2025
d442dcb
add the error message to the failure print
dothebart Jun 11, 2025
88508ba
choose uniq db name
dothebart Jun 11, 2025
666371d
give dropping of database more time
dothebart Jun 12, 2025
d0ce3db
longer deadline
dothebart Jun 12, 2025
602561d
lint
dothebart Jun 12, 2025
b6e9487
only abort the transaction if its not yet committed
dothebart Jun 12, 2025
08a9fe6
make sure cleanup of indices is done
dothebart Jun 13, 2025
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
24 changes: 24 additions & 0 deletions test/arangosearch_analyzers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {

dbname := "analyzer_test_ensure"
db := ensureDatabase(ctx, c, dbname, nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()

testCases := []struct {
Name string
Expand Down Expand Up @@ -444,6 +450,12 @@ func TestArangoSearchAnalyzerGet(t *testing.T) {

dbname := "analyzer_test_get"
db := ensureDatabase(ctx, c, dbname, nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
aname := "my-ngram"
def := driver.ArangoSearchAnalyzerDefinition{
Name: aname,
Expand Down Expand Up @@ -478,6 +490,12 @@ func TestArangoSearchAnalyzerGetAll(t *testing.T) {

dbname := "analyzer_test_get_all"
db := ensureDatabase(ctx, c, dbname, nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
aname := "my-ngram"
def := driver.ArangoSearchAnalyzerDefinition{
Name: aname,
Expand Down Expand Up @@ -518,6 +536,12 @@ func TestArangoSearchAnalyzerRemove(t *testing.T) {

dbname := "analyzer_test_get_all"
db := ensureDatabase(ctx, c, dbname, nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
aname := "my-ngram"
def := driver.ArangoSearchAnalyzerDefinition{
Name: aname,
Expand Down
21 changes: 18 additions & 3 deletions test/asyncjob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ func TestAsyncJobListPending(t *testing.T) {
skipResilientSingle(t)

db := ensureDatabase(ctx, c, databaseName("db", "async"), nil, t)
defer db.Remove(ctx)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(ctx, db, "frontend", nil, t)

idTransaction := runLongRequest(t, ctxAsync, db, 2, col.Name())
Expand Down Expand Up @@ -145,7 +150,12 @@ func TestAsyncJobCancel(t *testing.T) {
skipResilientSingle(t)

db := ensureDatabase(ctx, c, databaseName("db", "async", "cancel"), nil, t)
defer db.Remove(ctx)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()

aqlQuery := "FOR i IN 1..10 FOR j IN 1..10 LET x = sleep(1.0) FILTER i == 5 && j == 5 RETURN 42"
_, err := db.Query(ctxAsync, aqlQuery, nil)
Expand Down Expand Up @@ -192,7 +202,12 @@ func TestAsyncJobDelete(t *testing.T) {
skipResilientSingle(t)

db := ensureDatabase(ctx, c, databaseName("db", "async", "cancel"), nil, t)
defer db.Remove(ctx)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(ctx, db, "backend", nil, t)

t.Run("delete all jobs", func(t *testing.T) {
Expand Down
25 changes: 22 additions & 3 deletions test/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func waitForServerRestart(ctx context.Context, c driver.Client, t *testing.T) dr
}

return nil
}).RetryT(t, 100*time.Millisecond, 15*time.Second)
}).RetryT(t, 100*time.Millisecond, 30*time.Second)

// Wait for secret to start
newRetryFunc(func() error {
Expand All @@ -327,7 +327,7 @@ func waitForServerRestart(ctx context.Context, c driver.Client, t *testing.T) dr
}

return nil
}).RetryT(t, 100*time.Millisecond, 15*time.Second)
}).RetryT(t, 100*time.Millisecond, 30*time.Second)

return c
}
Expand All @@ -354,6 +354,13 @@ func TestBackupRestore(t *testing.T) {
colname := "col"

db := ensureDatabase(ctx, c, dbname, nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", dbname, err)
}
}()

col := ensureCollection(ctx, db, colname, nil, t)

// Write a document
Expand Down Expand Up @@ -576,6 +583,12 @@ func TestBackupCompleteCycle(t *testing.T) {
colname := "col"

db := ensureDatabase(ctx, c, dbname, nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", dbname, err)
}
}()
col := ensureCollection(ctx, db, colname, nil, t)

isSingle := false
Expand Down Expand Up @@ -750,6 +763,12 @@ func TestBackupRestoreWithViews(t *testing.T) {
trueVar := true

db := ensureDatabase(ctx, c, dbname, nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", dbname, err)
}
}()
col := ensureCollection(ctx, db, colname, nil, t)
ensureArangoSearchView(ctx, db, viewname, &driver.ArangoSearchViewProperties{
Links: driver.ArangoSearchLinks{
Expand Down Expand Up @@ -795,7 +814,7 @@ func TestBackupRestoreWithViews(t *testing.T) {
defer waitForHealthyClusterAfterBackup(t, c)

if isSingle {
waitctx, cancel := context.WithTimeout(ctx, 30*time.Second)
waitctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
c = waitForServerRestart(waitctx, c, t)
}
Expand Down
18 changes: 18 additions & 0 deletions test/benchmark_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ import (
func BenchmarkCollectionExists(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "collection_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(nil, db, "collection_exist_test", nil, b)

b.ResetTimer()
Expand All @@ -43,6 +49,12 @@ func BenchmarkCollectionExists(b *testing.B) {
func BenchmarkCollection(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "collection_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(nil, db, "collection_test", nil, b)

b.ResetTimer()
Expand All @@ -57,6 +69,12 @@ func BenchmarkCollection(b *testing.B) {
func BenchmarkCollections(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "collection_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
for i := 0; i < 10; i++ {
ensureCollection(nil, db, fmt.Sprintf("col%d", i), nil, b)
}
Expand Down
30 changes: 30 additions & 0 deletions test/benchmark_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import "testing"
func BenchmarkCreateDocument(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "document_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(nil, db, "document_test", nil, b)

b.ResetTimer()
Expand All @@ -44,6 +50,12 @@ func BenchmarkCreateDocument(b *testing.B) {
func BenchmarkCreateDocumentParallel(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "document_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(nil, db, "document_test", nil, b)

b.SetParallelism(100)
Expand All @@ -64,6 +76,12 @@ func BenchmarkCreateDocumentParallel(b *testing.B) {
func BenchmarkReadDocument(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "document_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(nil, db, "document_test", nil, b)
doc := UserDoc{
"Jan",
Expand All @@ -87,6 +105,12 @@ func BenchmarkReadDocument(b *testing.B) {
func BenchmarkReadDocumentParallel(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "document_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(nil, db, "document_test", nil, b)
doc := UserDoc{
"Jan",
Expand All @@ -112,6 +136,12 @@ func BenchmarkReadDocumentParallel(b *testing.B) {
func BenchmarkRemoveDocument(b *testing.B) {
c := createClient(b, nil)
db := ensureDatabase(nil, c, "document_test", nil, b)
defer func() {
err := db.Remove(nil)
if err != nil {
b.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(nil, db, "document_test", nil, b)

b.ResetTimer()
Expand Down
21 changes: 21 additions & 0 deletions test/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@ func TestResponseHeader(t *testing.T) {
} else {
var resp driver.Response
db := ensureDatabase(ctx, c, "_system", nil, t)
defer func() {
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
col := ensureCollection(ctx, db, "response_header_test", nil, t)
defer clean(t, ctx, col)

Expand Down Expand Up @@ -579,6 +585,21 @@ func TestClientConnectionReuse(t *testing.T) {
Options: driver.CreateDatabaseDefaultOptions{},
}, t)
}
defer func() {
for dbName, user := range dbUsers {
t.Logf("Dropping DB %s ...", dbName)
db := ensureDatabase(ctx, c, dbName, nil, t)
err := db.Remove(ctx)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", dbName, err)
}
u := ensureUser(ctx, c, user.UserName, nil, t)
err = u.Remove(ctx)
if err != nil {
t.Logf("Failed to delete user %s: %s ...", user.UserName, err)
}
}
}()

var wg sync.WaitGroup
const clientsPerDB = 20
Expand Down
6 changes: 6 additions & 0 deletions test/collection_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ func TestCollectionSchema(t *testing.T) {

name := "document_schema_validation_test"
db := ensureDatabase(nil, c, name, nil, t)
defer func() {
err := db.Remove(nil)
if err != nil {
t.Logf("Failed to drop database %s: %s ...", db.Name(), err)
}
}()
t.Run("Create collection with schema validation", func(t *testing.T) {
opts := driver.CreateCollectionOptions{
Schema: &driver.CollectionSchemaOptions{
Expand Down
Loading