diff --git a/test/kubernetes/benchmarks/BUILD b/test/kubernetes/benchmarks/BUILD index 8593cdabc2..212b04c7e7 100644 --- a/test/kubernetes/benchmarks/BUILD +++ b/test/kubernetes/benchmarks/BUILD @@ -1,13 +1,46 @@ -load("//tools:defs.bzl", "go_test") +load("//tools:defs.bzl", "go_test", "pkg_tar") package( default_applicable_licenses = ["//:license"], + default_visibility = ["//:sandbox"], licenses = ["notice"], ) +_PACKAGE = "//test/kubernetes/benchmarks" + +_ALL_BENCHMARK_TARGETS = [ + "%s:%s" % + ( + _PACKAGE, + f.replace(".go", ""), + ) + for f in glob(["**/*_test.go"]) +] + +genquery( + name = "all_benchmark_targets", + testonly = True, + expression = " union ".join(_ALL_BENCHMARK_TARGETS), + scope = _ALL_BENCHMARK_TARGETS, +) + +[pkg_tar( + name = "%s_tar" % (src[src.index(":") + 1:],), + testonly = True, + srcs = [src], + extension = "tar.bz2", +) for src in _ALL_BENCHMARK_TARGETS] + +filegroup( + name = "all_benchmark_test_binaries_tar", + testonly = True, + srcs = ["%s_tar" % (src[src.index(":") + 1:],) for src in _ALL_BENCHMARK_TARGETS], +) + go_test( name = "abslbuild_test", srcs = ["abslbuild_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -26,6 +59,7 @@ go_test( go_test( name = "startup_test", srcs = ["startup_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -43,6 +77,7 @@ go_test( go_test( name = "redis_test", srcs = ["redis_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -61,6 +96,7 @@ go_test( go_test( name = "ruby_dev_test", srcs = ["ruby_dev_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -80,6 +116,7 @@ go_test( go_test( name = "ffmpeg_test", srcs = ["ffmpeg_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -98,6 +135,7 @@ go_test( go_test( name = "grpc_test", srcs = ["grpc_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -116,6 +154,7 @@ go_test( go_test( name = "nginx_test", srcs = ["nginx_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -135,6 +174,7 @@ go_test( go_test( name = "postgresql_test", srcs = ["postgresql_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -153,6 +193,7 @@ go_test( go_test( name = "tensorflow_test", srcs = ["tensorflow_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -171,6 +212,7 @@ go_test( go_test( name = "wordpress_test", srcs = ["wordpress_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -190,6 +232,7 @@ go_test( go_test( name = "pytorch_test", srcs = ["pytorch_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -210,6 +253,7 @@ go_test( embedsrcs = [ "//test/kubernetes/benchmarks/resources:files", # keep ], + nogo = False, tags = [ "local", "noguitar", @@ -230,6 +274,7 @@ go_test( go_test( name = "stablediffusion_test", srcs = ["stablediffusion_test.go"], + nogo = False, tags = [ "local", "noguitar", @@ -248,6 +293,7 @@ go_test( go_test( name = "gsutil_test", srcs = ["gsutil_test.go"], + nogo = False, tags = [ "local", "noguitar", diff --git a/test/kubernetes/k8sctx/BUILD b/test/kubernetes/k8sctx/BUILD index a35e8a2488..0361ab7472 100644 --- a/test/kubernetes/k8sctx/BUILD +++ b/test/kubernetes/k8sctx/BUILD @@ -7,10 +7,12 @@ package( go_library( name = "k8sctx", + testonly = True, srcs = [ "k8sctx.go", "k8sctx_impl.go", ], + nogo = False, visibility = [ "//visibility:public", ], diff --git a/test/kubernetes/testcluster/testcluster.go b/test/kubernetes/testcluster/testcluster.go index 273b7d1ba5..fde5f3f713 100644 --- a/test/kubernetes/testcluster/testcluster.go +++ b/test/kubernetes/testcluster/testcluster.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "io" + "reflect" "strconv" "strings" "time" @@ -132,8 +133,31 @@ type TestCluster struct { testNodepoolRuntimeOverride RuntimeType } +type testClusterConstructorKey int + +const ( + // testClusterConstructor is the key for the context value that holds the + // constructor function for TestCluster. + // Defaults to newTestCluster. + testClusterConstructor testClusterConstructorKey = iota +) + +// WithTestClusterConstructor returns a context that contains a custom +// constructor for TestCluster. +func WithTestClusterConstructor(ctx context.Context, constructor func(context.Context, *testpb.Cluster) (*TestCluster, error)) context.Context { + return context.WithValue(ctx, testClusterConstructor, constructor) +} + // NewTestCluster returns a new TestCluster client. -func NewTestCluster(cluster *testpb.Cluster) (*TestCluster, error) { +func NewTestCluster(ctx context.Context, cluster *testpb.Cluster) (*TestCluster, error) { + constructor, ok := ctx.Value(testClusterConstructor).(func(context.Context, *testpb.Cluster) (*TestCluster, error)) + if !ok || constructor == nil || reflect.ValueOf(constructor).IsNil() { + constructor = newTestCluster + } + return constructor(ctx, cluster) +} + +func newTestCluster(_ context.Context, cluster *testpb.Cluster) (*TestCluster, error) { config, err := clientcmd.BuildConfigFromFlags("" /*masterURL*/, cluster.GetCredentialFile()) if err != nil { return nil, fmt.Errorf("BuildConfigFromFlags: %w", err) diff --git a/test/kubernetes/tests/BUILD b/test/kubernetes/tests/BUILD index 5f6235a068..0234680c1d 100644 --- a/test/kubernetes/tests/BUILD +++ b/test/kubernetes/tests/BUILD @@ -8,6 +8,7 @@ package( go_test( name = "hello_test", srcs = ["hello_test.go"], + nogo = False, tags = [ "local", "noguitar",