mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
* Remove MDS and replace it with Controller This commit removes the MDS layer (and package) and shifts Controller package into its place. * add pprof/fgprof to serverless http router --------- Co-authored-by: Matthew Jaffee <jaffee@pilosa.com>
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package boltdb_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/featurebasedb/featurebase/v3/dax"
|
|
"github.com/featurebasedb/featurebase/v3/dax/controller/balancer/boltdb"
|
|
testbolt "github.com/featurebasedb/featurebase/v3/dax/test/boltdb"
|
|
"github.com/featurebasedb/featurebase/v3/errors"
|
|
"github.com/featurebasedb/featurebase/v3/logger"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNodeService(t *testing.T) {
|
|
db := testbolt.MustOpenDB(t)
|
|
defer testbolt.MustCloseDB(t, db)
|
|
|
|
t.Cleanup(func() {
|
|
testbolt.CleanupDB(t, db.Path())
|
|
})
|
|
|
|
ctx := context.Background()
|
|
|
|
// Initialize the buckets.
|
|
assert.NoError(t, db.InitializeBuckets(boltdb.BalancerBuckets...))
|
|
|
|
t.Run("Nodes", func(t *testing.T) {
|
|
ns := boltdb.NewNodeService(db, logger.NopLogger)
|
|
|
|
node1 := &dax.Node{
|
|
Address: "localhost:10101",
|
|
RoleTypes: []dax.RoleType{
|
|
"compute",
|
|
},
|
|
}
|
|
|
|
tx, err := db.BeginTx(ctx, true)
|
|
assert.NoError(t, err)
|
|
defer tx.Rollback()
|
|
|
|
// Create node.
|
|
assert.NoError(t, ns.CreateNode(tx, node1.Address, node1))
|
|
|
|
// Read node.
|
|
n, err := ns.ReadNode(tx, node1.Address)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, node1, n)
|
|
|
|
// Delete node.
|
|
assert.NoError(t, ns.DeleteNode(tx, node1.Address))
|
|
|
|
// Read node.
|
|
_, err = ns.ReadNode(tx, node1.Address)
|
|
if assert.Error(t, err) {
|
|
assert.True(t, errors.Is(err, dax.ErrNodeDoesNotExist))
|
|
}
|
|
|
|
assert.NoError(t, tx.Commit())
|
|
})
|
|
}
|