Documentation
¶
Overview ¶
Package testcontainer starts the servers oceanbase's oracle tests run against: one testcontainer of each per test binary, started by the first test that asks and removed by Terminate, which the package's TestMain calls.
MySQL80 answers for the grammar OceanBase inherited from MySQL. A test gets a database of its own on it, reached through an account that holds privileges only on the databases this package creates, so a statement a corpus runs (SET GLOBAL, SHUTDOWN, ALTER USER root) cannot change the server under the tests that follow. Those statements answer 1227 or 1044, which a verdict that looks for 1064 still reads as parsed. OceanBase answers for OceanBase itself, as root.
Index ¶
Constants ¶
const OceanBaseImage = "oceanbase/oceanbase-ce:4.3.5.6-106000012026040916"
OceanBaseImage is the build the recorded OceanBase verdicts were read on. The 4.3.5-lts tag moves with each patch release, so this names the patch.
const OceanBaseVersion = "5.7.25-OceanBase_CE-v4.3.5.6"
OceanBaseVersion is what SELECT VERSION() answers on OceanBaseImage.
Variables ¶
var MySQL80 = &Server{Image: "mysql:8.0", Args: []string{"--skip-log-bin"}}
MySQL80 is mysql:8.0. The binary log stays off so the restricted account can create routines (1419 otherwise).
var OceanBase = &oceanBase{}
OceanBase is the package's OceanBase CE in MySQL mode. Tests log in as root in the test tenant, so they may create accounts, use fixed database names and change server-wide settings.
Functions ¶
func OceanBaseTransient ¶
OceanBaseTransient reports an error OceanBase answers while it is between leaders or starved for CPU, which the same statement clears once the server settles. On a busy box (load average 380 on 20 cores, 2026-11-05) the root service is revoked and taken back within a minute, and a log stream changes leader.
A verdict must never read one of these as an answer: engineAccepts-style helpers take any code but 1064 to mean the statement parsed.
func OpenOceanBase ¶
OpenOceanBase opens dsn through a connector that runs each statement again while OceanBase answers a transient error, for up to three minutes, so no test has to wrap its own statements. A statement still failing after that returns the last error as a plain error.
Types ¶
type Database ¶
type Database struct {
// DB is a pool of connections that start in the database, on the restricted
// account, pinned to one connection so that USE and session state hold across
// statements.
DB *sql.DB
Name string
}
Database is a test's own database on a Server.
type Server ¶
type Server struct {
// Image is the pinned image.
Image string
// Args are the server's arguments.
Args []string
// contains filtered or unexported fields
}
Server is one MySQL server a test binary starts on first use.