@@ -25,6 +25,7 @@ type SuiteDeps struct {
2525 k8sClient * k8sclient.K8sClient
2626 mlopsClient * v.Clientset
2727 watcherStore k8sclient.WatcherStorage
28+ Config * GodogConfig
2829}
2930
3031// might have to pass the suit struct and other config with closures to avoid having global vars
@@ -46,9 +47,14 @@ var suiteDeps SuiteDeps
4647
4748func InitializeTestSuite (ctx * godog.TestSuiteContext ) {
4849 // todo: we should bootstrap config here
50+ // Load configuration from JSON file
51+ config , err := LoadConfig ()
52+ if err != nil {
53+ panic (fmt .Errorf ("failed to load config: %w" , err ))
54+ }
4955
5056 // Create long-lived deps here
51- k8sClient , err := k8sclient .New ("seldon-mesh" )
57+ k8sClient , err := k8sclient .New (config . Namespace )
5258 if err != nil {
5359 panic (fmt .Errorf ("failed to create k8s client: %w" , err ))
5460 }
@@ -58,14 +64,15 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
5864 panic (fmt .Errorf ("failed to mlops client: %w" , err ))
5965 }
6066
61- watchStore , err := k8sclient .NewWatcherStore ("seldon-mesh" , k8sclient .DefaultCRDLabel , clientSet .MlopsV1alpha1 ())
67+ watchStore , err := k8sclient .NewWatcherStore (config . Namespace , k8sclient .DefaultCRDLabel , clientSet .MlopsV1alpha1 ())
6268 if err != nil {
6369 panic (fmt .Errorf ("failed to create k8s watch store: %w" , err ))
6470 }
6571
6672 suiteDeps .k8sClient = k8sClient
6773 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
6874 suiteDeps .watcherStore = watchStore
75+ suiteDeps .Config = config
6976
7077 ctx .BeforeSuite (func () {
7178 suiteDeps .watcherStore .Start ()
@@ -79,16 +86,25 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
7986}
8087
8188func InitializeScenario (scenarioCtx * godog.ScenarioContext ) {
89+ log := logrus .New ()
90+ if suiteDeps .Config .LogLevel != "" {
91+ logLevel , err := logrus .ParseLevel (suiteDeps .Config .LogLevel )
92+ if err != nil {
93+ panic (fmt .Errorf ("failed to parse log level %s: %w" , logLevel , err ))
94+ }
95+ log .SetLevel (logLevel )
96+ }
97+
8298 // Create the world with long-lived deps once per scenario context
8399 world , err := steps .NewWorld (steps.Config {
84- Namespace : "seldon-mesh" , //TODO configurable
85- Logger : logrus . New () .WithField ("test_type" , "godog" ),
100+ Namespace : suiteDeps . Config . Namespace ,
101+ Logger : log .WithField ("test_type" , "godog" ),
86102 KubeClient : suiteDeps .k8sClient ,
87103 WatcherStorage : suiteDeps .watcherStore ,
88- IngressHost : "localhost" , //TODO configurable
89- HTTPPort : 9000 , //TODO configurable
90- GRPCPort : 9000 , //TODO configurable
91- SSL : false , //TODO configurable
104+ IngressHost : suiteDeps . Config . Inference . Host ,
105+ HTTPPort : suiteDeps . Config . Inference . HTTPPort ,
106+ GRPCPort : suiteDeps . Config . Inference . GRPCPort ,
107+ SSL : suiteDeps . Config . Inference . SSL ,
92108 })
93109 if err != nil {
94110 panic (fmt .Errorf ("failed to create world: %w" , err ))
@@ -107,6 +123,11 @@ func InitializeScenario(scenarioCtx *godog.ScenarioContext) {
107123
108124 // After: optional cleanup / rollback
109125 scenarioCtx .After (func (ctx context.Context , scenario * godog.Scenario , err error ) (context.Context , error ) {
126+ if suiteDeps .Config .SkipCleanup {
127+ log .WithField ("scenario" , scenario .Name ).Debug ("Skipping cleanup" )
128+ return ctx , nil
129+ }
130+
110131 if err := world .KubeClient .DeleteScenarioResources (ctx , world .Label ); err != nil {
111132 return ctx , fmt .Errorf ("error when deleting models on before steps: %w" , err )
112133 }
@@ -119,5 +140,4 @@ func InitializeScenario(scenarioCtx *godog.ScenarioContext) {
119140 steps .LoadExplicitModelSteps (scenarioCtx , world )
120141 steps .LoadInferenceSteps (scenarioCtx , world )
121142 // TODO: load other steps, e.g. pipeline, experiment, etc.
122-
123143}
0 commit comments