@@ -22,6 +22,7 @@ import (
2222type SuiteDeps struct {
2323 K8sClient * k8sclient.K8sClient
2424 WatcherStore k8sclient.WatcherStorage
25+ Config * GodogConfig
2526}
2627
2728// might have to pass the suit struct and other config with closures to avoid having global vars
@@ -55,19 +56,26 @@ var suiteDeps SuiteDeps
5556// it will deploy into the default server capability that might be in our server dpeloyment def
5657
5758func InitializeTestSuite (ctx * godog.TestSuiteContext ) {
59+ // Load configuration from JSON file
60+ config , err := LoadConfig ()
61+ if err != nil {
62+ panic (fmt .Errorf ("failed to load config: %w" , err ))
63+ }
64+
5865 // Create long-lived deps here
59- k8sClient , err := k8sclient .New ("seldon-mesh" )
66+ k8sClient , err := k8sclient .New (config . Namespace )
6067 if err != nil {
6168 panic (fmt .Errorf ("failed to create k8s client: %w" , err ))
6269 }
6370
64- watchStore , err := k8sclient .NewWatcherStore ("seldon-mesh" , k8sclient .CRDLabels , k8sClient .KubeClient )
71+ watchStore , err := k8sclient .NewWatcherStore (config . Namespace , k8sclient .CRDLabels , k8sClient .KubeClient )
6572 if err != nil {
6673 panic (fmt .Errorf ("failed to create k8s watch store: %w" , err ))
6774 }
6875
6976 suiteDeps .K8sClient = k8sClient
7077 suiteDeps .WatcherStore = watchStore
78+ suiteDeps .Config = config
7179
7280 ctx .BeforeSuite (func () {
7381 suiteDeps .WatcherStore .Start ()
@@ -81,16 +89,25 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
8189}
8290
8391func InitializeScenario (scenarioCtx * godog.ScenarioContext ) {
92+ log := logrus .New ()
93+ if suiteDeps .Config .LogLevel != "" {
94+ logLevel , err := logrus .ParseLevel (suiteDeps .Config .LogLevel )
95+ if err != nil {
96+ panic (fmt .Errorf ("failed to parse log level %s: %w" , logLevel , err ))
97+ }
98+ log .SetLevel (logLevel )
99+ }
100+
84101 // Create the world with long-lived deps once per scenario context
85102 world , err := steps .NewWorld (steps.Config {
86- Namespace : "seldon-mesh" , //TODO configurable
87- Logger : logrus . New () .WithField ("test_type" , "godog" ),
103+ Namespace : suiteDeps . Config . Namespace ,
104+ Logger : log .WithField ("test_type" , "godog" ),
88105 KubeClient : suiteDeps .K8sClient ,
89106 WatcherStorage : suiteDeps .WatcherStore ,
90- IngressHost : "localhost" , //TODO configurable
91- HTTPPort : 9000 , //TODO configurable
92- GRPCPort : 9000 , //TODO configurable
93- SSL : false , //TODO configurable
107+ IngressHost : suiteDeps . Config . Inference . Host ,
108+ HTTPPort : suiteDeps . Config . Inference . HTTPPort ,
109+ GRPCPort : suiteDeps . Config . Inference . GRPCPort ,
110+ SSL : suiteDeps . Config . Inference . SSL ,
94111 })
95112 if err != nil {
96113 panic (fmt .Errorf ("failed to create world: %w" , err ))
@@ -118,6 +135,13 @@ func InitializeScenario(scenarioCtx *godog.ScenarioContext) {
118135 // if cleanupErr := world.KubeClient.DeleteGodogTestModels(); cleanupErr != nil && err == nil {
119136 // err = cleanupErr
120137 // }
138+
139+ if suiteDeps .Config .SkipCleanup {
140+ log .WithField ("scenario" , scenario .Name ).Debug ("Skipping cleanup" )
141+ return ctx , nil
142+ }
143+
144+ // TODO clean up
121145 return ctx , err
122146 })
123147
@@ -126,5 +150,4 @@ func InitializeScenario(scenarioCtx *godog.ScenarioContext) {
126150 steps .LoadExplicitModelSteps (scenarioCtx , world )
127151 steps .LoadInferenceSteps (scenarioCtx , world )
128152 // TODO: load other steps, e.g. pipeline, experiment, etc.
129-
130153}
0 commit comments