From d561e7c17db012325d3443f857dfbacf29539e70 Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Thu, 8 Oct 2020 20:09:07 +0000 Subject: [PATCH] Move tests to //integration --- .travis.yml | 4 +- cmd/executor/BUILD | 66 +---------- integration/BUILD | 108 ++++++++++++++++++ .../testdata/Dockerfile.trivial | 0 .../testdata/build.yaml | 0 .../testdata/exec.yaml | 0 .../testdata/files.yaml | 0 .../testdata/testfiles.yaml | 0 8 files changed, 111 insertions(+), 67 deletions(-) create mode 100644 integration/BUILD rename {cmd/executor => integration}/testdata/Dockerfile.trivial (100%) rename {cmd/executor => integration}/testdata/build.yaml (100%) rename {cmd/executor => integration}/testdata/exec.yaml (100%) rename {cmd/executor => integration}/testdata/files.yaml (100%) rename {cmd/executor => integration}/testdata/testfiles.yaml (100%) diff --git a/.travis.yml b/.travis.yml index 6b6ecefbf9..a4cd99b5a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,11 +48,11 @@ jobs: script: &script_multiarch # Generate BUILD.bazel files (we do not check them in) - bazel run //:gazelle - - bazel build --cpu=${CPU} --curses=no //cmd/executor:all + - bazel build --cpu=${CPU} --curses=no //integration:all # Build all targets tagged with our architecture: - bazel build --cpu=${CPU} --curses=no $(bazel query 'attr("tags", "'${GOARCH}'", "//...")') # Run all tests not tagged as "manual": - - bazel test --cpu=${CPU} --curses=no --test_output=errors --test_timeout=900 //cmd/executor:all + - bazel test --cpu=${CPU} --curses=no --test_output=errors --test_timeout=900 //integration:all # Run all tests tagged with our architecture: - bazel test --cpu=${CPU} --curses=no --test_output=errors --test_timeout=900 $(bazel query 'attr("tags", "'${GOARCH}'", "//...")') diff --git a/cmd/executor/BUILD b/cmd/executor/BUILD index 5b52d7f98f..d4bcc67c60 100644 --- a/cmd/executor/BUILD +++ b/cmd/executor/BUILD @@ -53,72 +53,8 @@ ARCHITECTURES = [ symlinks = { "/kaniko/executor": "/kaniko/executor_" + arch, }, + visibility = ["//visibility:public"], workdir = "/workspace", ) for arch in ARCHITECTURES ] - -# Image with testdata -[ - container_image( - name = "buildtest_image_" + arch, - architecture = arch, - base = ":image_" + arch, - directory = "/workspace", - files = [ - ":testdata/Dockerfile.trivial", - ], - ) - for arch in ARCHITECTURES -] - -load("@io_bazel_rules_docker//contrib:test.bzl", "container_test") - -# Non-executable tests can run on any architecture, -# so do not tag them. -[ - container_test( - name = "image_files_" + arch + "_test", - configs = ["testdata/files.yaml"], - image = ":image_" + arch, - ) - for arch in ARCHITECTURES -] - -[ - container_test( - name = "buildtest_image_" + arch + "_test", - configs = [ - "testdata/files.yaml", - "testdata/testfiles.yaml", - ], - image = ":buildtest_image_" + arch, - ) - for arch in ARCHITECTURES -] - -[ - container_test( - name = "image_exec_" + arch + "_test", - configs = ["testdata/exec.yaml"], - image = ":image_" + arch, - tags = [ - "manual", - arch, - ], - ) - for arch in ARCHITECTURES -] - -[ - container_test( - name = "image_build_" + arch + "_test", - configs = ["testdata/build.yaml"], - image = ":buildtest_image_" + arch, - tags = [ - "manual", - arch, - ], - ) - for arch in ARCHITECTURES -] diff --git a/integration/BUILD b/integration/BUILD new file mode 100644 index 0000000000..bffd9d4c3a --- /dev/null +++ b/integration/BUILD @@ -0,0 +1,108 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "integration", + srcs = [ + "cleanup.go", + "cmd.go", + "config.go", + "gcs.go", + "images.go", + ], + importpath = "github.com/GoogleContainerTools/kaniko/integration", + tags = ["manual"], + visibility = ["//visibility:public"], + deps = ["//pkg/timing"], +) + +go_test( + name = "integration_test", + srcs = [ + "benchmark_test.go", + "integration_test.go", + "integration_with_context_test.go", + "integration_with_stdin_test.go", + "k8s_test.go", + ], + embed = [":integration"], + tags = ["manual"], + deps = [ + "//pkg/timing", + "//pkg/util", + "//testutil", + "//vendor/github.com/google/go-containerregistry/pkg/name", + "//vendor/github.com/google/go-containerregistry/pkg/v1/daemon", + "//vendor/github.com/pkg/errors", + ], +) + +load("@io_bazel_rules_docker//container:container.bzl", "container_image") +load("@io_bazel_rules_docker//contrib:test.bzl", "container_test") + +ARCHITECTURES = [ + "amd64", + "arm64", +] + +# Image with testdata +[ + container_image( + name = "buildtest_image_" + arch, + architecture = arch, + base = "//cmd/executor:image_" + arch, + directory = "/workspace", + files = [ + ":testdata/Dockerfile.trivial", + ], + ) + for arch in ARCHITECTURES +] + +# Non-executable tests can run on any architecture, +# so do not tag them. +[ + container_test( + name = "image_files_" + arch + "_test", + configs = ["testdata/files.yaml"], + image = "//cmd/executor:image_" + arch, + ) + for arch in ARCHITECTURES +] + +[ + container_test( + name = "buildtest_image_" + arch + "_test", + configs = [ + "testdata/files.yaml", + "testdata/testfiles.yaml", + ], + image = ":buildtest_image_" + arch, + ) + for arch in ARCHITECTURES +] + +[ + container_test( + name = "image_exec_" + arch + "_test", + configs = ["testdata/exec.yaml"], + image = "//cmd/executor:image_" + arch, + tags = [ + "manual", + arch, + ], + ) + for arch in ARCHITECTURES +] + +[ + container_test( + name = "image_build_" + arch + "_test", + configs = ["testdata/build.yaml"], + image = ":buildtest_image_" + arch, + tags = [ + "manual", + arch, + ], + ) + for arch in ARCHITECTURES +] diff --git a/cmd/executor/testdata/Dockerfile.trivial b/integration/testdata/Dockerfile.trivial similarity index 100% rename from cmd/executor/testdata/Dockerfile.trivial rename to integration/testdata/Dockerfile.trivial diff --git a/cmd/executor/testdata/build.yaml b/integration/testdata/build.yaml similarity index 100% rename from cmd/executor/testdata/build.yaml rename to integration/testdata/build.yaml diff --git a/cmd/executor/testdata/exec.yaml b/integration/testdata/exec.yaml similarity index 100% rename from cmd/executor/testdata/exec.yaml rename to integration/testdata/exec.yaml diff --git a/cmd/executor/testdata/files.yaml b/integration/testdata/files.yaml similarity index 100% rename from cmd/executor/testdata/files.yaml rename to integration/testdata/files.yaml diff --git a/cmd/executor/testdata/testfiles.yaml b/integration/testdata/testfiles.yaml similarity index 100% rename from cmd/executor/testdata/testfiles.yaml rename to integration/testdata/testfiles.yaml