mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
* Database isolation: Balancer
Remove naive Balancer
remove debugging lines
Thread dax.Transaction through Controller
Change role to roleType
Swap out Balancer interface with new one
Standardize InvalidTransaction error
Add some interface comments
* Remove type.Worker; replace with type.Address
* Remove database validate from Queryer
This is already being handled in the `CreateTable()` method. Prior
to doing that validation, we were getting a panic, but that's no longer
the case.
* Remove dax.TableQualifier; replace with dax.QualifiedDatabaseID
* Update IDK test to create database
(cherry picked from commit d971cfc269)
87 lines
2 KiB
Go
87 lines
2 KiB
Go
// Package test include external test apps, helper functions, and test data.
|
|
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/featurebasedb/featurebase/v3/dax"
|
|
)
|
|
|
|
// TestQualifiedTable is a test helper function for creating a table based on a
|
|
// general configuration. This function creates a Table with a random TableID.
|
|
// If you need to specify the TableID yourself, use the TestQualifiedTableWithID
|
|
// function.
|
|
func TestQualifiedTable(t *testing.T, qdbid dax.QualifiedDatabaseID, name dax.TableName, partitionN int, keyed bool) *dax.QualifiedTable {
|
|
t.Helper()
|
|
|
|
var pkFieldType dax.BaseType
|
|
if keyed {
|
|
pkFieldType = dax.BaseTypeString
|
|
} else {
|
|
pkFieldType = dax.BaseTypeID
|
|
}
|
|
|
|
tbl := dax.NewTable(name)
|
|
tbl.PartitionN = partitionN
|
|
tbl.Fields = []*dax.Field{
|
|
{
|
|
Name: dax.PrimaryKeyFieldName,
|
|
Type: pkFieldType,
|
|
},
|
|
}
|
|
|
|
return dax.NewQualifiedTable(
|
|
qdbid,
|
|
tbl,
|
|
)
|
|
}
|
|
|
|
// TestQualifiedDatabaseWithID is a test helper function for creating a database
|
|
// based on a general configuration, and having the specified DatabaseID.
|
|
func TestQualifiedDatabaseWithID(t *testing.T, orgID dax.OrganizationID, id dax.DatabaseID, name dax.DatabaseName, opts dax.DatabaseOptions) *dax.QualifiedDatabase {
|
|
t.Helper()
|
|
|
|
db := dax.Database{
|
|
ID: dax.DatabaseID(id),
|
|
Name: name,
|
|
Options: opts,
|
|
}
|
|
|
|
qdb := &dax.QualifiedDatabase{
|
|
OrganizationID: orgID,
|
|
Database: db,
|
|
}
|
|
|
|
return qdb
|
|
}
|
|
|
|
// TestQualifiedTableWithID is a test helper function for creating a table based
|
|
// on a general configuration, and having the specified TableID.
|
|
func TestQualifiedTableWithID(t *testing.T, qdbid dax.QualifiedDatabaseID, id string, name dax.TableName, partitionN int, keyed bool) *dax.QualifiedTable {
|
|
t.Helper()
|
|
|
|
var pkFieldType dax.BaseType
|
|
if keyed {
|
|
pkFieldType = dax.BaseTypeString
|
|
} else {
|
|
pkFieldType = dax.BaseTypeID
|
|
}
|
|
|
|
tbl := &dax.Table{
|
|
ID: dax.TableID(id),
|
|
Name: name,
|
|
}
|
|
|
|
tbl.PartitionN = partitionN
|
|
tbl.Fields = []*dax.Field{
|
|
{
|
|
Name: dax.PrimaryKeyFieldName,
|
|
Type: pkFieldType,
|
|
},
|
|
}
|
|
|
|
return dax.NewQualifiedTable(
|
|
qdbid,
|
|
tbl,
|
|
)
|
|
}
|