Documentation
¶
Overview ¶
Package test provides configurations and utility functions for NoSQL client test.
Index ¶
- Constants
- Variables
- func AssertReadKB(assert *assert.Assertions, expectReadKB, readKB, readUnits, prepCost int, ...)
- func AssertReadUnits(assert *assert.Assertions, readKB, readUnits, prepCost int, isAbsolute bool)
- func AssertWriteKB(assert *assert.Assertions, expectWriteKB, writeKB int)
- func CompareMapValue(m1, m2 *types.MapValue, checkInsertionOrder bool) bool
- func DeleteTable(table string, pks ...string) (err error)
- func ExecuteQueryRequest(client *nosqldb.Client, queryReq *nosqldb.QueryRequest) ([]*types.MapValue, error)
- func ExecuteQueryStmt(client *nosqldb.Client, stmt string) ([]*types.MapValue, error)
- func GenBytes(n int) []byte
- func GenCreateTableStmt(table string, numCols int, colNamePrefix string) string
- func GenString(n int) string
- func IsCloud() bool
- func IsOnPrem() bool
- func IsOnPremSecureStore() bool
- func SetInterceptor(i Interceptor)
- func VersionsEqual(v1, v2 types.Version) bool
- type Config
- type Interceptor
- type NoSQLTestSuite
- func (suite *NoSQLTestSuite) AddToTables(table string)
- func (suite *NoSQLTestSuite) AssertReadWriteKB(res nosqldb.Result, expReadKB, expWriteKB, prepCost int, isAbsolute bool)
- func (suite *NoSQLTestSuite) AssertZeroReadWriteKB(res nosqldb.Result)
- func (suite *NoSQLTestSuite) CreateTable(createStmt string, limits *nosqldb.TableLimits)
- func (suite *NoSQLTestSuite) CreateTables(numTables int, nsName string, offset int) (tables []string, tableLimits []*nosqldb.TableLimits)
- func (suite *NoSQLTestSuite) DoQueryWithNamespace(stmt string, namespace string, expRows int)
- func (suite *NoSQLTestSuite) DropTable(table string, dropIfExists bool)
- func (suite *NoSQLTestSuite) DropTableWithNamespace(table string, dropIfExists bool, namespace string)
- func (suite *NoSQLTestSuite) ExecuteDDL(stmt string)
- func (suite *NoSQLTestSuite) ExecuteQueryRequest(queryReq *nosqldb.QueryRequest) ([]*types.MapValue, error)
- func (suite *NoSQLTestSuite) ExecuteQueryStmt(stmt string) ([]*types.MapValue, error)
- func (suite *NoSQLTestSuite) ExecuteQueryStmtWithNamespace(stmt string, namespace string) ([]*types.MapValue, error)
- func (suite *NoSQLTestSuite) ExecuteTableDDL(stmt string)
- func (suite *NoSQLTestSuite) ExecuteTableDDLWithNamespace(stmt string, namespace string)
- func (suite *NoSQLTestSuite) GetNsTableName(ns, table string) string
- func (suite *NoSQLTestSuite) GetTableName(table string) string
- func (suite *NoSQLTestSuite) ReCreateTable(table, createStmt string, limits *nosqldb.TableLimits)
- func (suite *NoSQLTestSuite) SetupSuite()
- func (suite *NoSQLTestSuite) TearDownSuite()
- Bugs
Constants ¶
const ( // OkCreateTableTmpl is a template for generating table creation statement. // The table name should be provided when using the template. OkCreateTableTmpl = "create table %s (id integer, c1 string, c2 long, primary key(id))" // OkTimeout represents a valid value for operation request timeout. OkTimeout = 6 * time.Second // BadTimeout represents an invalid value for operation request timeout // that is less than 1 millisecond. BadTimeout = time.Millisecond - 1 // WaitTimeout represents the timeout value that usually used in the // WaitForXXX operation. WaitTimeout = 15 * time.Second // MaxReadKBLimit represents the limit on the maximum read KB during an operation. MaxReadKBLimit = 2 * 1024 // MaxWriteKBLimit represents the limit on the maximum write KB during an operation. MaxWriteKBLimit = 2 * 1024 // MaxQuerySizeLimit represents the limit on a query string length. MaxQuerySizeLimit = 10 * 1024 // MinQueryCost represents the minimum cost for a query operation. MinQueryCost = 2 // MinReadKB represents the minimum read KB for a query operation MinReadKB = 1 // MaxDataSizeLimit represents the limit on data size for a row. // It is 512 KB. MaxDataSizeLimit = 512 * 1024 // MaxBatchOpNumberLimit represents the limit on number of operations for a batch operation. MaxBatchOpNumberLimit = 50 )
Variables ¶
var ( // OkTableLimits represents a valid value for TableLimits. OkTableLimits = &nosqldb.TableLimits{ReadUnits: 2, WriteUnits: 2, StorageGB: 1} // BadTableLimits represents an invalid value for TableLimits. BadTableLimits = &nosqldb.TableLimits{} )
Functions ¶
func AssertReadKB ¶
func AssertReadKB(assert *assert.Assertions, expectReadKB, readKB, readUnits, prepCost int, isAbsolute bool)
AssertReadKB checks if readKB is the same as expectReadKB.
func AssertReadUnits ¶
func AssertReadUnits(assert *assert.Assertions, readKB, readUnits, prepCost int, isAbsolute bool)
AssertReadUnits checks if readUnits is as expected.
func AssertWriteKB ¶
func AssertWriteKB(assert *assert.Assertions, expectWriteKB, writeKB int)
AssertWriteKB checks if writeKB is the same as expectWriteKB.
func CompareMapValue ¶
CompareMapValue compares underlying map values of m1 and m2, it also compares insertion order of the values if checkInsertionOrder is specified. It returns true if the values are equal, otherwise returns false.
func DeleteTable ¶
DeleteTable deletes all rows from the specified table. The primary key column names must be provided in the pks arguments.
func ExecuteQueryRequest ¶
func ExecuteQueryRequest(client *nosqldb.Client, queryReq *nosqldb.QueryRequest) ([]*types.MapValue, error)
ExecuteQueryRequest executes the specified query request using the specified client. It returns query results as a slice of *types.MapValue.
func ExecuteQueryStmt ¶
ExecuteQueryStmt executes the specified query statement using the specified client. It returns query results as a slice of *types.MapValue.
func GenCreateTableStmt ¶
GenCreateTableStmt generates a "create table" statement with the specified table name and number of columns.
func GenString ¶
GenString randomly generates a string that contains the specified number of characters.
func IsCloud ¶
func IsCloud() bool
IsCloud returns true if tests are configured to run against the NoSQL cloud service or clous simulator, returns false otherwise.
func IsOnPrem ¶
func IsOnPrem() bool
IsOnPrem returns true if tests are configured to run against the on-premise NoSQL database servers, returns false otherwise.
func IsOnPremSecureStore ¶
func IsOnPremSecureStore() bool
IsOnPremSecureStore returns true if tests are configured to run against the on-premise NoSQL database server that has security enabled, returns false otherwise.
func SetInterceptor ¶
func SetInterceptor(i Interceptor)
SetInterceptor set the specified interceptor.
func VersionsEqual ¶ added in v1.4.1
Types ¶
type Config ¶
type Config struct { // Version specifies the Oracle NoSQL Database on-premise release version // or the Oracle NoSQL Cloud Simulator release version. // // This is used to determine the tests that only apply to specific releases. Version string `json:"version"` // TablePrefix specifies a prefix for table names created in the tests. TablePrefix string `json:"tablePrefix"` // DropTablesOnTearDown specifies whether to drop the tables that were // created during testing on teardown of test suite. // // If not specified, the tables are kept after test. DropTablesOnTearDown bool `json:"dropTablesOnTearDown"` // NoSQL database client configurations. nosqldb.Config `json:"clientConfig"` Verbose bool `json:"verbose"` // For extended testing RunExtended bool `json:"runExtended"` // For testing SerialVersion int16 `json:"serialVersion"` }
Config represents a test configuration.
func (*Config) IsCloud ¶
IsCloud returns true if tests are configured to run against the NoSQL cloud service or cloud simulator, returns false otherwise.
func (*Config) IsCloudSim ¶
IsCloudSim returns true if tests are configured to run against the NoSQL cloud simulator, returns false otherwise.
func (*Config) IsOnPrem ¶
IsOnPrem returns true if tests are configured to run against the on-premise NoSQL database servers, returns false otherwise.
func (*Config) IsOnPremSecureStore ¶
IsOnPremSecureStore returns true if tests are configured to run against the on-premise NoSQL database server that has security enabled, returns false otherwise.
type Interceptor ¶
type Interceptor interface { // OnSetupClient sets up the specified NoSQL client for testing. OnSetupClient(client *nosqldb.Client) error // OnSetupTestSuite creates test resources before all tests run. OnSetupTestSuite() error // OnTearDownTestSuite releases test resources after all tests run. OnTearDownTestSuite() error }
Interceptor represents an interceptor that used to inject customized procedures to setup NoSQL client, setup and teardown test resources.
This is used for internal tests.
type NoSQLTestSuite ¶
type NoSQLTestSuite struct { suite.Suite *Config Client *nosqldb.Client // contains filtered or unexported fields }
NoSQLTestSuite provides generic utility methods and configurations for test suites.
It should be embedded into test suites that test the cases where a NoSQL client is needed.
func NewNoSQLTestSuite ¶
func NewNoSQLTestSuite() *NoSQLTestSuite
NewNoSQLTestSuite creates a NoSQLTestSuite instance.
func (*NoSQLTestSuite) AddToTables ¶
func (suite *NoSQLTestSuite) AddToTables(table string)
ExecuteQueryRequest executes the query request. AddToTables adds the specified table into a table list, in which all tables would be dropped on TearDownSuite if DropTablesOnTearDown is specified in test configuration.
func (*NoSQLTestSuite) AssertReadWriteKB ¶
func (suite *NoSQLTestSuite) AssertReadWriteKB(res nosqldb.Result, expReadKB, expWriteKB, prepCost int, isAbsolute bool)
AssertReadWriteKB checks if the readKB/writeKB are as expected.
func (*NoSQLTestSuite) AssertZeroReadWriteKB ¶
func (suite *NoSQLTestSuite) AssertZeroReadWriteKB(res nosqldb.Result)
AssertZeroReadWriteKB asserts the operation consumed zero readKB/writeKB.
func (*NoSQLTestSuite) CreateTable ¶
func (suite *NoSQLTestSuite) CreateTable(createStmt string, limits *nosqldb.TableLimits)
CreateTable creates a table using the specified statement and table limit. The table limit is ignored when test against the on-premise NoSQL server.
func (*NoSQLTestSuite) CreateTables ¶
func (suite *NoSQLTestSuite) CreateTables(numTables int, nsName string, offset int) (tables []string, tableLimits []*nosqldb.TableLimits)
CreateTables creates the specified number of tables in namespace, returns table names and limits of the tables that are created. If the specified namespace nsName is empty, the tables will be created in the default namespace.
func (*NoSQLTestSuite) DoQueryWithNamespace ¶ added in v1.4.2
func (suite *NoSQLTestSuite) DoQueryWithNamespace(stmt string, namespace string, expRows int)
DoQueryWithNamespace executes the query statement in given namespace and expects a given number of rows returned
func (*NoSQLTestSuite) DropTable ¶
func (suite *NoSQLTestSuite) DropTable(table string, dropIfExists bool)
DropTable drops the table.
func (*NoSQLTestSuite) DropTableWithNamespace ¶ added in v1.4.2
func (suite *NoSQLTestSuite) DropTableWithNamespace(table string, dropIfExists bool, namespace string)
DropTable drops the table.
func (*NoSQLTestSuite) ExecuteDDL ¶
func (suite *NoSQLTestSuite) ExecuteDDL(stmt string)
ExecuteDDL executes the specified DDL statement using a SystemRequest.
func (*NoSQLTestSuite) ExecuteQueryRequest ¶
func (suite *NoSQLTestSuite) ExecuteQueryRequest(queryReq *nosqldb.QueryRequest) ([]*types.MapValue, error)
ExecuteQueryRequest executes the query request.
func (*NoSQLTestSuite) ExecuteQueryStmt ¶
func (suite *NoSQLTestSuite) ExecuteQueryStmt(stmt string) ([]*types.MapValue, error)
ExecuteQueryStmt executes the query statement.
func (*NoSQLTestSuite) ExecuteQueryStmtWithNamespace ¶ added in v1.4.2
func (suite *NoSQLTestSuite) ExecuteQueryStmtWithNamespace(stmt string, namespace string) ([]*types.MapValue, error)
ExecuteQueryStmtWithNamespace executes the query statement in given namespace
func (*NoSQLTestSuite) ExecuteTableDDL ¶
func (suite *NoSQLTestSuite) ExecuteTableDDL(stmt string)
func (*NoSQLTestSuite) ExecuteTableDDLWithNamespace ¶ added in v1.4.2
func (suite *NoSQLTestSuite) ExecuteTableDDLWithNamespace(stmt string, namespace string)
ExecuteTableDDL executes the specified DDL statement using a TableRequest.
func (*NoSQLTestSuite) GetNsTableName ¶
func (suite *NoSQLTestSuite) GetNsTableName(ns, table string) string
GetNsTableName returns a namespace qualified table name. The table name may have a prefix if the tablePrefix is specified in test configuration.
func (*NoSQLTestSuite) GetTableName ¶
func (suite *NoSQLTestSuite) GetTableName(table string) string
GetTableName returns a table name that may have a prefix if the tablePrefix is specified in test configuration.
func (*NoSQLTestSuite) ReCreateTable ¶
func (suite *NoSQLTestSuite) ReCreateTable(table, createStmt string, limits *nosqldb.TableLimits)
ReCreateTable drops and re-creates a table.
func (*NoSQLTestSuite) SetupSuite ¶
func (suite *NoSQLTestSuite) SetupSuite()
SetupSuite is used to setup test resources before test.
This implements the suite.SetupAllSuite interface defined in the testify package.
func (*NoSQLTestSuite) TearDownSuite ¶
func (suite *NoSQLTestSuite) TearDownSuite()
TearDownSuite is used to clean up test resources after test.
This implements the suite.TearDownAllSuite interface defined in the testify package.
Notes ¶
Bugs ¶
DoTableRequestAndWait does not seem to work for MiniCloud.