Skip to content

Commit 2c50425

Browse files
EtiennePerotgvisor-bot
authored andcommitted
Internal change (diffbased).
PiperOrigin-RevId: 694595149
1 parent 7c2bcdd commit 2c50425

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

test/kubernetes/benchmarks/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package(
88
go_test(
99
name = "abslbuild_test",
1010
srcs = ["abslbuild_test.go"],
11+
nogo = False,
1112
tags = [
1213
"local",
1314
"noguitar",
@@ -26,6 +27,7 @@ go_test(
2627
go_test(
2728
name = "startup_test",
2829
srcs = ["startup_test.go"],
30+
nogo = False,
2931
tags = [
3032
"local",
3133
"noguitar",
@@ -43,6 +45,7 @@ go_test(
4345
go_test(
4446
name = "redis_test",
4547
srcs = ["redis_test.go"],
48+
nogo = False,
4649
tags = [
4750
"local",
4851
"noguitar",
@@ -61,6 +64,7 @@ go_test(
6164
go_test(
6265
name = "ruby_dev_test",
6366
srcs = ["ruby_dev_test.go"],
67+
nogo = False,
6468
tags = [
6569
"local",
6670
"noguitar",
@@ -80,6 +84,7 @@ go_test(
8084
go_test(
8185
name = "ffmpeg_test",
8286
srcs = ["ffmpeg_test.go"],
87+
nogo = False,
8388
tags = [
8489
"local",
8590
"noguitar",
@@ -98,6 +103,7 @@ go_test(
98103
go_test(
99104
name = "grpc_test",
100105
srcs = ["grpc_test.go"],
106+
nogo = False,
101107
tags = [
102108
"local",
103109
"noguitar",
@@ -116,6 +122,7 @@ go_test(
116122
go_test(
117123
name = "nginx_test",
118124
srcs = ["nginx_test.go"],
125+
nogo = False,
119126
tags = [
120127
"local",
121128
"noguitar",
@@ -135,6 +142,7 @@ go_test(
135142
go_test(
136143
name = "postgresql_test",
137144
srcs = ["postgresql_test.go"],
145+
nogo = False,
138146
tags = [
139147
"local",
140148
"noguitar",
@@ -153,6 +161,7 @@ go_test(
153161
go_test(
154162
name = "tensorflow_test",
155163
srcs = ["tensorflow_test.go"],
164+
nogo = False,
156165
tags = [
157166
"local",
158167
"noguitar",
@@ -171,6 +180,7 @@ go_test(
171180
go_test(
172181
name = "wordpress_test",
173182
srcs = ["wordpress_test.go"],
183+
nogo = False,
174184
tags = [
175185
"local",
176186
"noguitar",
@@ -190,6 +200,7 @@ go_test(
190200
go_test(
191201
name = "pytorch_test",
192202
srcs = ["pytorch_test.go"],
203+
nogo = False,
193204
tags = [
194205
"local",
195206
"noguitar",
@@ -210,6 +221,7 @@ go_test(
210221
embedsrcs = [
211222
"//test/kubernetes/benchmarks/resources:files", # keep
212223
],
224+
nogo = False,
213225
tags = [
214226
"local",
215227
"noguitar",
@@ -230,6 +242,7 @@ go_test(
230242
go_test(
231243
name = "stablediffusion_test",
232244
srcs = ["stablediffusion_test.go"],
245+
nogo = False,
233246
tags = [
234247
"local",
235248
"noguitar",
@@ -248,6 +261,7 @@ go_test(
248261
go_test(
249262
name = "gsutil_test",
250263
srcs = ["gsutil_test.go"],
264+
nogo = False,
251265
tags = [
252266
"local",
253267
"noguitar",

test/kubernetes/k8sctx/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ package(
77

88
go_library(
99
name = "k8sctx",
10+
testonly = True,
1011
srcs = [
1112
"k8sctx.go",
1213
"k8sctx_impl.go",
1314
],
15+
nogo = False,
1416
visibility = [
1517
"//visibility:public",
1618
],

test/kubernetes/testcluster/testcluster.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"io"
23+
"reflect"
2324
"strconv"
2425
"strings"
2526
"time"
@@ -132,8 +133,31 @@ type TestCluster struct {
132133
testNodepoolRuntimeOverride RuntimeType
133134
}
134135

136+
type testClusterConstructorKey int
137+
138+
const (
139+
// testClusterConstructor is the key for the context value that holds the
140+
// constructor function for TestCluster.
141+
// Defaults to newTestCluster.
142+
testClusterConstructor testClusterConstructorKey = iota
143+
)
144+
145+
// WithTestClusterConstructor returns a context that contains a custom
146+
// constructor for TestCluster.
147+
func WithTestClusterConstructor(ctx context.Context, constructor func(context.Context, *testpb.Cluster) (*TestCluster, error)) context.Context {
148+
return context.WithValue(ctx, testClusterConstructor, constructor)
149+
}
150+
135151
// NewTestCluster returns a new TestCluster client.
136-
func NewTestCluster(cluster *testpb.Cluster) (*TestCluster, error) {
152+
func NewTestCluster(ctx context.Context, cluster *testpb.Cluster) (*TestCluster, error) {
153+
constructor, ok := ctx.Value(testClusterConstructor).(func(context.Context, *testpb.Cluster) (*TestCluster, error))
154+
if !ok || constructor == nil || reflect.ValueOf(constructor).IsNil() {
155+
constructor = newTestCluster
156+
}
157+
return constructor(ctx, cluster)
158+
}
159+
160+
func newTestCluster(_ context.Context, cluster *testpb.Cluster) (*TestCluster, error) {
137161
config, err := clientcmd.BuildConfigFromFlags("" /*masterURL*/, cluster.GetCredentialFile())
138162
if err != nil {
139163
return nil, fmt.Errorf("BuildConfigFromFlags: %w", err)

test/kubernetes/tests/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package(
88
go_test(
99
name = "hello_test",
1010
srcs = ["hello_test.go"],
11+
nogo = False,
1112
tags = [
1213
"local",
1314
"noguitar",

0 commit comments

Comments
 (0)