Skip to content
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
8 changes: 8 additions & 0 deletions tests/integration/godog/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test:
go test --godog.tags='@ModelDeployment,@CustomModelSpec' --godog.concurrency=3 -race

debug:
go test --godog.tags='@0' --godog.concurrency=1 -race

test-all:
cd cicd && go test -race
12 changes: 12 additions & 0 deletions tests/integration/godog/cicd/godog-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"namespace": "seldon-mesh",
"log_level": "debug",
"skip_cleanup" : false,
"skip_cleanup_on_error": false,
"inference" : {
"host": "localhost",
"httpPort": 9000,
"grpcPort": 9000,
"ssl": false
}
}
131 changes: 131 additions & 0 deletions tests/integration/godog/cicd/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package cicd__test

import (
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"testing"

"github.com/cucumber/godog"
"github.com/cucumber/godog/colors"
"github.com/seldonio/seldon-core/tests/integration/godog/suite"
"github.com/spf13/pflag"
)

const cmdOptPrefix = "godog."

var opts = godog.Options{
Output: colors.Colored(os.Stdout),
Format: "pretty",
}

func init() {
godog.BindCommandLineFlags(cmdOptPrefix, &opts)
}

type suiteCfg struct {
Name string
Path string
Tags string
Concurrency int
}

func runOne(name string, o godog.Options) int {
s := godog.TestSuite{
Name: name,
TestSuiteInitializer: suite.InitializeTestSuite,
ScenarioInitializer: suite.InitializeScenario,
Options: &o,
}
return s.Run()
}

func discoverFeatureSuites(featuresRoot string, concurrency int) ([]suiteCfg, error) {
entries, err := os.ReadDir(featuresRoot)
if err != nil {
return nil, fmt.Errorf("read features root %q: %w", featuresRoot, err)
}

// Collect subdirectories (each becomes a "suite group")
var dirs []string
for _, e := range entries {
if !e.IsDir() {
continue
}
name := e.Name()

// Skipping server dir
if strings.HasPrefix(name, ".") || name == "server" {
continue
}
dirs = append(dirs, name)
}

sort.Strings(dirs) // stable ordering across machines

var suites []suiteCfg
for _, d := range dirs {
path := filepath.Join(featuresRoot, d)

// Setup then run
suites = append(suites,
suiteCfg{Name: d + "-setup", Path: path, Tags: "@ServerSetup", Concurrency: concurrency},
suiteCfg{Name: d + "-run", Path: path, Tags: "~@ServerSetup", Concurrency: concurrency},
)
}

return suites, nil
}

func TestMain(m *testing.M) {
flagSet := pflag.CommandLine
flagSet.StringSliceVar(&opts.Paths, fmt.Sprintf("%s%s", cmdOptPrefix, "paths"), []string{}, "paths to feature files")
pflag.Parse()

custom := pflag.CommandLine.Changed(cmdOptPrefix+"paths") || pflag.CommandLine.Changed(cmdOptPrefix+"tags")

godogStatus := 0

if custom {
// Custom: run exactly what the user requested
godogStatus = runOne("godog-normal-run", opts)
} else {
// Aggregated: auto-discover feature suites
featuresRoot := "../features"
concurrency := 3 // or make this a flag/env if you want

suites, err := discoverFeatureSuites(featuresRoot, concurrency)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to discover suites: %v\n", err)
os.Exit(1)
}

failed := 0
for _, s := range suites {
o := opts
o.Paths = []string{s.Path}
o.Tags = s.Tags
o.Concurrency = s.Concurrency

fmt.Printf("\n=== Running Godog suite: %s path=%s tags=%q ===\n", s.Name, s.Path, s.Tags)
if st := runOne(s.Name, o); st != 0 {
failed++
}
}

fmt.Printf("\n=== Godog overall: %d/%d suites failed ===\n", failed, len(suites))
if failed > 0 {
godogStatus = 1
}
}

// Run any regular Go tests in this package too
testStatus := m.Run()
if testStatus > godogStatus {
godogStatus = testStatus
}

os.Exit(godogStatus)
}
Loading