Skip to content

Commit d8d3a0e

Browse files
authored
feat(e2e-test): gen client and deletion of resources (#6995)
1 parent 5b74b42 commit d8d3a0e

File tree

7 files changed

+83
-55
lines changed

7 files changed

+83
-55
lines changed

tests/integration/godog/go.mod

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,28 @@ require (
1616
sigs.k8s.io/controller-runtime v0.22.4
1717
)
1818

19+
replace (
20+
github.com/seldonio/seldon-core/apis/go/v2 => ../../../apis/go
21+
github.com/seldonio/seldon-core/operator/v2 => ../../../operator
22+
)
23+
1924
require (
25+
github.com/beorn7/perks v1.0.1 // indirect
26+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2027
github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect
2128
github.com/cucumber/messages/go/v21 v21.0.1 // indirect
2229
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2330
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
2431
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
32+
github.com/fsnotify/fsnotify v1.9.0 // indirect
2533
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
2634
github.com/go-logr/logr v1.4.3 // indirect
2735
github.com/go-openapi/jsonpointer v0.21.1 // indirect
2836
github.com/go-openapi/jsonreference v0.21.0 // indirect
2937
github.com/go-openapi/swag v0.23.1 // indirect
3038
github.com/gofrs/uuid v4.3.1+incompatible // indirect
3139
github.com/gogo/protobuf v1.3.2 // indirect
40+
github.com/google/btree v1.1.3 // indirect
3241
github.com/google/gnostic-models v0.7.0 // indirect
3342
github.com/google/go-cmp v0.7.0 // indirect
3443
github.com/google/uuid v1.6.0 // indirect
@@ -41,20 +50,28 @@ require (
4150
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4251
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
4352
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
53+
github.com/pkg/errors v0.9.1 // indirect
4454
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
55+
github.com/prometheus/client_golang v1.22.0 // indirect
56+
github.com/prometheus/client_model v0.6.2 // indirect
57+
github.com/prometheus/common v0.65.0 // indirect
58+
github.com/prometheus/procfs v0.17.0 // indirect
4559
github.com/x448/float16 v0.8.4 // indirect
4660
go.yaml.in/yaml/v2 v2.4.2 // indirect
4761
go.yaml.in/yaml/v3 v3.0.4 // indirect
4862
golang.org/x/net v0.41.0 // indirect
4963
golang.org/x/oauth2 v0.30.0 // indirect
64+
golang.org/x/sync v0.15.0 // indirect
5065
golang.org/x/sys v0.33.0 // indirect
5166
golang.org/x/term v0.32.0 // indirect
5267
golang.org/x/text v0.26.0 // indirect
5368
golang.org/x/time v0.12.0 // indirect
5469
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
5570
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
5671
google.golang.org/protobuf v1.36.6 // indirect
72+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
5773
gopkg.in/inf.v0 v0.9.1 // indirect
74+
k8s.io/apiextensions-apiserver v0.34.1 // indirect
5875
k8s.io/klog/v2 v2.130.1 // indirect
5976
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
6077
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect

tests/integration/godog/go.sum

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lSh
2020
github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
2121
github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU=
2222
github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM=
23+
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
24+
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
2325
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
2426
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
2527
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
@@ -43,11 +45,15 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
4345
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
4446
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
4547
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
48+
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
49+
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
4650
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
4751
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
4852
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
4953
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5054
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
55+
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
56+
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
5157
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo=
5258
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
5359
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -73,13 +79,17 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
7379
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
7480
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
7581
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
82+
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
83+
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
7684
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
7785
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
7886
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
7987
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
8088
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
8189
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
8290
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
91+
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
92+
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
8393
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
8494
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
8595
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -111,10 +121,6 @@ github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUO
111121
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
112122
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
113123
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
114-
github.com/seldonio/seldon-core/apis/go/v2 v2.9.1 h1:9UcxnTFRuCDApZqy7cy3Rm6B/aaW2+3bjNXUKYVvlRY=
115-
github.com/seldonio/seldon-core/apis/go/v2 v2.9.1/go.mod h1:ptbV8xxTT6DI5hWGcOx74bizYhms/LhXBJ/04RD41jk=
116-
github.com/seldonio/seldon-core/operator/v2 v2.10.1 h1:Btn8xcFt5rPd4+xCMFAKwcuXGHAq4/nzE5EuYuNg0uI=
117-
github.com/seldonio/seldon-core/operator/v2 v2.10.1/go.mod h1:WMy17S3Q6QZTR2IP1OaIgRdh36RiNboT8jqCajJ6X9A=
118124
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
119125
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
120126
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=

tests/integration/godog/k8sclient/client.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ type K8sClient struct {
3333
KubeClient client.WithWatch
3434
}
3535

36-
var CRDLabels = map[string]string{
36+
var DefaultCRDLabelMap = map[string]string{
3737
"test-suite": "godog",
3838
}
3939

40+
const (
41+
DefaultCRDLabel = "test-suite=godog"
42+
)
43+
4044
// New todo: separate k8s client init and pass to new
4145
func New(namespace string) (*K8sClient, error) {
4246
k8sScheme := runtime.NewScheme()
@@ -78,8 +82,10 @@ func (k8s *K8sClient) ApplyModel(model *mlopsv1alpha1.Model) error {
7882
model.Labels = map[string]string{}
7983
}
8084

81-
// Add label
82-
model.Labels = CRDLabels
85+
// add labels
86+
for k, v := range DefaultCRDLabelMap {
87+
model.Labels[k] = v
88+
}
8389

8490
existing := &mlopsv1alpha1.Model{}
8591
key := client.ObjectKey{
@@ -102,12 +108,12 @@ func (k8s *K8sClient) ApplyModel(model *mlopsv1alpha1.Model) error {
102108
return k8s.KubeClient.Update(ctx, model)
103109
}
104110

105-
func (k8s *K8sClient) DeleteGodogTestModels(ctx context.Context) error {
111+
func (k8s *K8sClient) DeleteScenarioResources(ctx context.Context, labels client.MatchingLabels) error {
106112

107113
list := &mlopsv1alpha1.ModelList{}
108114
err := k8s.KubeClient.List(ctx, list,
109115
client.InNamespace(k8s.namespace),
110-
client.MatchingLabels{"test-suite": "godog"},
116+
labels,
111117
)
112118
if err != nil {
113119
return err

tests/integration/godog/k8sclient/watcher.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
"fmt"
1515
"sync"
1616

17-
mlopsv1alpha1 "github.com/seldonio/seldon-core/operator/v2/apis/mlops/v1alpha1"
17+
"github.com/seldonio/seldon-core/operator/v2/pkg/generated/clientset/versioned/typed/mlops/v1alpha1"
1818
"k8s.io/apimachinery/pkg/api/meta"
19+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1920
"k8s.io/apimachinery/pkg/runtime"
2021
"k8s.io/apimachinery/pkg/watch"
21-
"sigs.k8s.io/controller-runtime/pkg/client"
2222
)
2323

2424
type WatcherStorage interface {
@@ -31,9 +31,9 @@ type WatcherStorage interface {
3131
}
3232

3333
type WatcherStore struct {
34-
namespace string
35-
label map[string]string
36-
34+
namespace string
35+
label string
36+
mlopsClient v1alpha1.MlopsV1alpha1Interface
3737
modelWatcher watch.Interface
3838

3939
mu sync.RWMutex
@@ -52,20 +52,16 @@ type waiter struct {
5252
type ConditionFunc func(obj runtime.Object) (done bool, err error)
5353

5454
// NewWatcherStore receives events that match on a particular object list and creates a database store to query crd state
55-
func NewWatcherStore(namespace string, label map[string]string, w client.WithWatch) (*WatcherStore, error) {
56-
modelWatcher, err := w.Watch(
57-
context.Background(),
58-
&mlopsv1alpha1.ModelList{},
59-
client.InNamespace(namespace),
60-
client.MatchingLabels(label),
61-
)
55+
func NewWatcherStore(namespace string, label string, mlopsClient v1alpha1.MlopsV1alpha1Interface) (*WatcherStore, error) {
56+
modelWatcher, err := mlopsClient.Models(namespace).Watch(context.Background(), v1.ListOptions{LabelSelector: "test-suite=godog"})
6257
if err != nil {
6358
return nil, fmt.Errorf("failed to create model watcher: %w", err)
6459
}
6560

6661
return &WatcherStore{
6762
namespace: namespace,
6863
label: label,
64+
mlopsClient: mlopsClient,
6965
modelWatcher: modelWatcher,
7066
store: make(map[string]runtime.Object),
7167
doneChan: make(chan struct{}),

tests/integration/godog/scenario/scenario.go

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ import (
1414
"fmt"
1515

1616
"github.com/cucumber/godog"
17+
v "github.com/seldonio/seldon-core/operator/v2/pkg/generated/clientset/versioned"
1718
"github.com/seldonio/seldon-core/tests/integration/godog/k8sclient"
1819
"github.com/seldonio/seldon-core/tests/integration/godog/steps"
1920
"github.com/sirupsen/logrus"
21+
controllerruntime "sigs.k8s.io/controller-runtime"
2022
)
2123

2224
type SuiteDeps struct {
23-
K8sClient *k8sclient.K8sClient
24-
WatcherStore k8sclient.WatcherStorage
25+
k8sClient *k8sclient.K8sClient
26+
mlopsClient *v.Clientset
27+
watcherStore k8sclient.WatcherStorage
2528
}
2629

2730
// might have to pass the suit struct and other config with closures to avoid having global vars
@@ -41,41 +44,36 @@ type SuiteDeps struct {
4144
// }
4245
var suiteDeps SuiteDeps
4346

44-
// todo: think about how we can drive server config from a file
45-
// - have a default server for test
46-
// - but also have the posibility of specifying the servers deployed in the test suite
47-
48-
// we create a server config or multiple servers
49-
// server 1 caps mlserver
50-
// default modelCapDeployment = mlserver
51-
52-
// we can set the default model capabilities for models
53-
54-
// if we have an scenario and it doesn't specify the server capabilities that it is deployed to
55-
// it will deploy into the default server capability that might be in our server dpeloyment def
56-
5747
func InitializeTestSuite(ctx *godog.TestSuiteContext) {
48+
// todo: we should bootstrap config here
49+
5850
// Create long-lived deps here
5951
k8sClient, err := k8sclient.New("seldon-mesh")
6052
if err != nil {
6153
panic(fmt.Errorf("failed to create k8s client: %w", err))
6254
}
6355

64-
watchStore, err := k8sclient.NewWatcherStore("seldon-mesh", k8sclient.CRDLabels, k8sClient.KubeClient)
56+
clientSet, err := v.NewForConfig(controllerruntime.GetConfigOrDie())
57+
if err != nil {
58+
panic(fmt.Errorf("failed to mlops client: %w", err))
59+
}
60+
61+
watchStore, err := k8sclient.NewWatcherStore("seldon-mesh", k8sclient.DefaultCRDLabel, clientSet.MlopsV1alpha1())
6562
if err != nil {
6663
panic(fmt.Errorf("failed to create k8s watch store: %w", err))
6764
}
6865

69-
suiteDeps.K8sClient = k8sClient
70-
suiteDeps.WatcherStore = watchStore
66+
suiteDeps.k8sClient = k8sClient
67+
suiteDeps.mlopsClient = clientSet // todo: this clientSet might get use for get requests or for the mlops interface and could be passed to the world might be split up by type
68+
suiteDeps.watcherStore = watchStore
7169

7270
ctx.BeforeSuite(func() {
73-
suiteDeps.WatcherStore.Start()
71+
suiteDeps.watcherStore.Start()
7472
// e.g. create namespace, apply CRDs, etc.
7573
})
7674

7775
ctx.AfterSuite(func() {
78-
suiteDeps.WatcherStore.Stop()
76+
suiteDeps.watcherStore.Stop()
7977
// e.g. clean namespace, close clients if needed
8078
})
8179
}
@@ -85,8 +83,8 @@ func InitializeScenario(scenarioCtx *godog.ScenarioContext) {
8583
world, err := steps.NewWorld(steps.Config{
8684
Namespace: "seldon-mesh", //TODO configurable
8785
Logger: logrus.New().WithField("test_type", "godog"),
88-
KubeClient: suiteDeps.K8sClient,
89-
WatcherStorage: suiteDeps.WatcherStore,
86+
KubeClient: suiteDeps.k8sClient,
87+
WatcherStorage: suiteDeps.watcherStore,
9088
IngressHost: "localhost", //TODO configurable
9189
HTTPPort: 9000, //TODO configurable
9290
GRPCPort: 9000, //TODO configurable
@@ -100,11 +98,6 @@ func InitializeScenario(scenarioCtx *godog.ScenarioContext) {
10098

10199
// Before: reset state and prep cluster before each scenario
102100
scenarioCtx.Before(func(ctx context.Context, scenario *godog.Scenario) (context.Context, error) {
103-
if err := world.KubeClient.DeleteGodogTestModels(ctx); err != nil {
104-
return ctx, fmt.Errorf("error when deleting models on before steps: %w", err)
105-
}
106-
107-
// Create a fresh model for THIS scenario
108101
world.CurrentModel.Reset(world)
109102

110103
// Reset scenario-level state
@@ -114,10 +107,10 @@ func InitializeScenario(scenarioCtx *godog.ScenarioContext) {
114107

115108
// After: optional cleanup / rollback
116109
scenarioCtx.After(func(ctx context.Context, scenario *godog.Scenario, err error) (context.Context, error) {
117-
// e.g. clean up any resources if needed
118-
// if cleanupErr := world.KubeClient.DeleteGodogTestModels(); cleanupErr != nil && err == nil {
119-
// err = cleanupErr
120-
// }
110+
if err := world.KubeClient.DeleteScenarioResources(ctx, world.Label); err != nil {
111+
return ctx, fmt.Errorf("error when deleting models on before steps: %w", err)
112+
}
113+
121114
return ctx, err
122115
})
123116

tests/integration/godog/steps/model_steps.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ var testModels = map[string]TestModelConfig{
4949

5050
func LoadModelSteps(scenario *godog.ScenarioContext, w *World) {
5151
// Model Operations
52-
scenario.Step(`^I have an? "([^"]+)" model$`, w.CurrentModel.IHaveAModel)
52+
scenario.Step(`^I have an? "([^"]+)" model$`, func(modelName string) error {
53+
return w.CurrentModel.IHaveAModel(modelName, w.Label)
54+
})
5355
scenario.Step(`^the model has "(\d+)" min replicas$`, w.CurrentModel.SetMinReplicas)
5456
scenario.Step(`^the model has "(\d+)" max replicas$`, w.CurrentModel.SetMaxReplicas)
5557
scenario.Step(`^the model has "(\d+)" replicas$`, w.CurrentModel.SetReplicas)
@@ -104,7 +106,7 @@ func (m *Model) deployModelSpec(spec *godog.DocString, namespace string, _ *k8sc
104106
return nil
105107
}
106108

107-
func (m *Model) IHaveAModel(model string) error {
109+
func (m *Model) IHaveAModel(model string, label map[string]string) error {
108110
testModel, ok := testModels[model]
109111
if !ok {
110112
return fmt.Errorf("model %s not found", model)
@@ -128,7 +130,7 @@ func (m *Model) IHaveAModel(model string) error {
128130
CreationTimestamp: metav1.Time{},
129131
DeletionTimestamp: nil,
130132
DeletionGracePeriodSeconds: nil,
131-
Labels: nil,
133+
Labels: label,
132134
Annotations: nil,
133135
OwnerReferences: nil,
134136
Finalizers: nil,

tests/integration/godog/steps/world.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"net/http"
1515

1616
"github.com/seldonio/seldon-core/apis/go/v2/mlops/v2_dataplane"
17+
v "github.com/seldonio/seldon-core/operator/v2/pkg/generated/clientset/versioned"
1718
"github.com/seldonio/seldon-core/tests/integration/godog/k8sclient"
1819
"github.com/sirupsen/logrus"
1920
"google.golang.org/grpc"
@@ -23,13 +24,15 @@ import (
2324
type World struct {
2425
namespace string
2526
KubeClient *k8sclient.K8sClient
27+
k8sClient v.Interface
2628
WatcherStorage k8sclient.WatcherStorage
2729
StartingClusterState string //todo: this will be a combination of starting state awareness of core 2 such as the
2830
//todo: server config,seldon config and seldon runtime to be able to reconcile to starting state should we change
2931
//todo: the state such as reducing replicas to 0 of scheduler to test unavailability
3032
CurrentModel *Model
3133
infer inference
3234
logger *logrus.Entry
35+
Label map[string]string
3336
}
3437

3538
type Config struct {
@@ -65,6 +68,10 @@ func NewWorld(c Config) (*World, error) {
6568
}
6669
grpcClient := v2_dataplane.NewGRPCInferenceServiceClient(conn)
6770

71+
label := map[string]string{
72+
"scenario": randomSuffix(6),
73+
}
74+
6875
w := &World{
6976
namespace: c.Namespace,
7077
KubeClient: c.KubeClient,
@@ -75,6 +82,7 @@ func NewWorld(c Config) (*World, error) {
7582
httpPort: c.HTTPPort,
7683
grpc: grpcClient,
7784
ssl: c.SSL},
85+
Label: label,
7886
}
7987

8088
if c.Logger != nil {

0 commit comments

Comments
 (0)