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 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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