Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal change (diffbased). #11161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion test/kubernetes/benchmarks/BUILD
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -26,6 +59,7 @@ go_test(
go_test(
name = "startup_test",
srcs = ["startup_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -43,6 +77,7 @@ go_test(
go_test(
name = "redis_test",
srcs = ["redis_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -61,6 +96,7 @@ go_test(
go_test(
name = "ruby_dev_test",
srcs = ["ruby_dev_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -80,6 +116,7 @@ go_test(
go_test(
name = "ffmpeg_test",
srcs = ["ffmpeg_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -98,6 +135,7 @@ go_test(
go_test(
name = "grpc_test",
srcs = ["grpc_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -116,6 +154,7 @@ go_test(
go_test(
name = "nginx_test",
srcs = ["nginx_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -135,6 +174,7 @@ go_test(
go_test(
name = "postgresql_test",
srcs = ["postgresql_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -153,6 +193,7 @@ go_test(
go_test(
name = "tensorflow_test",
srcs = ["tensorflow_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -171,6 +212,7 @@ go_test(
go_test(
name = "wordpress_test",
srcs = ["wordpress_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -190,6 +232,7 @@ go_test(
go_test(
name = "pytorch_test",
srcs = ["pytorch_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -210,6 +253,7 @@ go_test(
embedsrcs = [
"//test/kubernetes/benchmarks/resources:files", # keep
],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -230,6 +274,7 @@ go_test(
go_test(
name = "stablediffusion_test",
srcs = ["stablediffusion_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand All @@ -248,6 +293,7 @@ go_test(
go_test(
name = "gsutil_test",
srcs = ["gsutil_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand Down
2 changes: 2 additions & 0 deletions test/kubernetes/k8sctx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ package(

go_library(
name = "k8sctx",
testonly = True,
srcs = [
"k8sctx.go",
"k8sctx_impl.go",
],
nogo = False,
visibility = [
"//visibility:public",
],
Expand Down
26 changes: 25 additions & 1 deletion test/kubernetes/testcluster/testcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"io"
"reflect"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/kubernetes/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package(
go_test(
name = "hello_test",
srcs = ["hello_test.go"],
nogo = False,
tags = [
"local",
"noguitar",
Expand Down
Loading