MCPcopy Index your code
hub / github.com/bytebase/bytebase / GetStarRocksContainer

Function GetStarRocksContainer

backend/common/testcontainer/testcontainer.go:286–326  ·  view source on GitHub ↗

GetStarRocksContainer creates a StarRocks (allin1) container for testing. The allin1 image bundles the FE and BE; information_schema is served by the BE, so this waits until the backend actually serves queries rather than only the FE port being open. NOTE: requires an amd64 host — the StarRocks BE

(ctx context.Context)

Source from the content-addressed store, hash-verified

284// come alive under emulation). bytebase CI runs on amd64; locally, run without -short on an
285// amd64 machine, or the test is skipped via testing.Short().
286func GetStarRocksContainer(ctx context.Context) (retC *Container, retErr error) {
287 req := testcontainers.ContainerRequest{
288 Image: "starrocks/allin1-ubuntu:3.4.10",
289 ExposedPorts: []string{"9030/tcp"},
290 WaitingFor: wait.ForListeningPort("9030/tcp").WithStartupTimeout(5 * time.Minute),
291 }
292 c, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
293 ContainerRequest: req,
294 Started: true,
295 })
296 if err != nil {
297 return nil, err
298 }
299 host, err := c.Host(ctx)
300 if err != nil {
301 return nil, err
302 }
303 port, err := c.MappedPort(ctx, "9030/tcp")
304 if err != nil {
305 return nil, err
306 }
307 dsn := fmt.Sprintf("root@tcp(%s:%s)/?multiStatements=true", host, port.Port())
308 db, err := sql.Open("mysql", dsn)
309 if err != nil {
310 return nil, err
311 }
312 defer func() {
313 if retErr != nil {
314 db.Close()
315 }
316 }()
317 if err := waitStarRocksReady(ctx, db); err != nil {
318 return nil, err
319 }
320 return &Container{
321 container: c,
322 host: host,
323 port: port.Port(),
324 db: db,
325 }, nil
326}
327
328// GetTestStarRocksContainer creates a StarRocks container and fails the test on error. It
329// skips on non-amd64 hosts: the StarRocks all-in-one BE has no working arm64 build (it never

Callers 1

Calls 4

waitStarRocksReadyFunction · 0.85
PortMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected