Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove kv Session service and sessionsv1 bucket (#18823)
* chore: remove sessionsv1 bucket * chore: add extra configuration to sessions.Service
- Loading branch information
Showing
11 changed files
with
243 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package all | ||
|
||
import "github.com/influxdata/influxdb/v2/kv/migration" | ||
|
||
// Migration0006_DeleteBucketSessionsv1 removes the sessionsv1 bucket | ||
// from the backing kv store. | ||
var Migration0006_DeleteBucketSessionsv1 = migration.DeleteBuckets("delete sessionsv1 bucket", []byte("sessionsv1")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package migration | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"testing" | ||
|
||
"github.com/influxdata/influxdb/v2/inmem" | ||
"github.com/influxdata/influxdb/v2/kv" | ||
) | ||
|
||
func Test_BucketsMigration_CreateBuckets(t *testing.T) { | ||
var ( | ||
ctx = context.Background() | ||
bucket = []byte("some_bucket") | ||
store = inmem.NewKVStore() | ||
) | ||
|
||
// bucket should not exist | ||
bucketShouldNotExist(t, store, bucket) | ||
|
||
// build new create buckets migration | ||
migration := CreateBuckets("create bucket some_bucket", bucket) | ||
|
||
// apply migration up | ||
if err := migration.Up(ctx, store); err != nil { | ||
t.Fatal("unexpected error", err) | ||
} | ||
|
||
// bucket should now exist | ||
bucketShouldExist(t, store, bucket) | ||
|
||
// apply migration down | ||
if err := migration.Down(ctx, store); err != nil { | ||
t.Fatal("unexpected error", err) | ||
} | ||
|
||
// bucket should no longer exist | ||
bucketShouldNotExist(t, store, bucket) | ||
} | ||
|
||
func Test_BucketsMigration_DeleteBuckets(t *testing.T) { | ||
var ( | ||
ctx = context.Background() | ||
bucket = []byte("some_bucket") | ||
store = inmem.NewKVStore() | ||
) | ||
|
||
// initially create bucket | ||
if err := store.CreateBucket(ctx, bucket); err != nil { | ||
t.Fatal("unexpected error", err) | ||
} | ||
|
||
// ensure bucket is there to start with | ||
bucketShouldExist(t, store, bucket) | ||
|
||
// build new delete buckets migration | ||
migration := DeleteBuckets("delete bucket some_bucket", bucket) | ||
|
||
// apply migration up | ||
if err := migration.Up(ctx, store); err != nil { | ||
t.Fatal("unexpected error", err) | ||
} | ||
|
||
// bucket should have been removed | ||
bucketShouldNotExist(t, store, bucket) | ||
|
||
// apply migration down | ||
if err := migration.Down(ctx, store); err != nil { | ||
t.Fatal("unexpected error", err) | ||
} | ||
|
||
// bucket should exist again | ||
bucketShouldExist(t, store, bucket) | ||
} | ||
|
||
func bucketShouldExist(t *testing.T, store kv.Store, bucket []byte) { | ||
t.Helper() | ||
|
||
if err := store.View(context.Background(), func(tx kv.Tx) error { | ||
_, err := tx.Bucket(bucket) | ||
return err | ||
}); err != nil { | ||
t.Fatal("unexpected error", err) | ||
} | ||
} | ||
|
||
func bucketShouldNotExist(t *testing.T, store kv.Store, bucket []byte) { | ||
t.Helper() | ||
|
||
if err := store.View(context.Background(), func(tx kv.Tx) error { | ||
_, err := tx.Bucket(bucket) | ||
return err | ||
}); !errors.Is(err, kv.ErrBucketNotFound) { | ||
t.Fatalf("expected bucket not found, got %q", err) | ||
} | ||
} |
Oops, something went wrong.