Skip to content

Commit

Permalink
bazel: run docker image tests under Bazel
Browse files Browse the repository at this point in the history
This commit is to add a test infrastructure for docker image in TeamCity using
bazel.
It downloads the docker image tar from an upstream build configuration
(not fully implemented yet, cockroachdb#72394 ), loads the docker image from the tar,
builds a docker container based on it, and runs SQL queries inside that
container.

Release note: None
  • Loading branch information
ZhouXing19 committed Jan 3, 2022
1 parent bc88633 commit ebceb55
Show file tree
Hide file tree
Showing 7 changed files with 667 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build/teamcity/cockroach/ci/tests/docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -euo pipefail

dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))"
source "$dir/teamcity-support.sh"

tc_prepare

tc_start_block "Run docker image tests"
bazel run \
//pkg/testutils/docker:docker_test \
--config=crosslinux --config=test \
--test_timeout=1800
tc_end_block "Run docker image tests"
1 change: 1 addition & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ ALL_TESTS = [
"//pkg/storage/fs:fs_test",
"//pkg/storage/metamorphic:metamorphic_test",
"//pkg/storage:storage_test",
"//pkg/testutils/docker:docker_test",
"//pkg/testutils/floatcmp:floatcmp_test",
"//pkg/testutils/keysutils:keysutils_test",
"//pkg/testutils/lint/passes/errwrap:errwrap_test",
Expand Down
37 changes: 37 additions & 0 deletions pkg/testutils/docker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "testutils_docker",
srcs = ["docker_utils.go"],
importpath = "github.com/cockroachdb/cockroach/pkg/testutils/docker",
visibility = ["//visibility:public"],
deps = [
"@com_github_cockroachdb_errors//:errors",
"@com_github_docker_docker//api/types",
"@com_github_docker_docker//api/types/container",
"@com_github_docker_docker//api/types/filters",
"@com_github_docker_docker//client",
"@com_github_docker_docker//pkg/stdcopy",
"@com_github_docker_go_connections//nat",
"@org_golang_x_net//context",
],
)

go_test(
name = "docker_test",
size = "enormous",
srcs = ["single_node_docker_test.go"],
data = glob([
"testdata/single-node-test/docker-entrypoint-initdb.d/**",
]) + [
"//pkg/testutils/docker:testdata/single-node-test/docker-entrypoint-initdb.d",
],
embed = [":testutils_docker"],
deps = [
"//pkg/util/contextutil",
"//pkg/util/log",
"@com_github_cockroachdb_errors//:errors",
"@com_github_docker_docker//client",
"@org_golang_x_net//context",
],
)
Loading

0 comments on commit ebceb55

Please sign in to comment.