diff --git a/test/e2e/features/story_microshift.feature b/test/e2e/features/story_microshift.feature index 1270706122..54a6b45aaa 100644 --- a/test/e2e/features/story_microshift.feature +++ b/test/e2e/features/story_microshift.feature @@ -3,14 +3,15 @@ Feature: Microshift test stories Background: Given setting config property "preset" to value "microshift" succeeds - And setting config property "network-mode" to value "user" succeeds + And ensuring network mode user And executing single crc setup command succeeds And starting CRC with default bundle succeeds And ensuring oc command is available - + And ensuring microshift cluster is fully operational + # End-to-end health check - @microshift @testdata @linux @windows @darwin + @microshift @testdata @linux @windows @darwin @cleanup Scenario: Start and expose a basic HTTP service and check after restart Given executing "oc create namespace testproj" succeeds And executing "oc config set-context --current --namespace=testproj" succeeds diff --git a/test/e2e/testsuite/testsuite.go b/test/e2e/testsuite/testsuite.go index c27e70052a..a155ed0812 100644 --- a/test/e2e/testsuite/testsuite.go +++ b/test/e2e/testsuite/testsuite.go @@ -514,6 +514,10 @@ func InitializeScenario(s *godog.ScenarioContext) { DeleteFileFromCRCHome) s.Step(`^decode base64 file "(.*)" to "(.*)"$`, DecodeBase64File) + s.Step(`^ensuring network mode user$`, + EnsureUserNetworkmode) + s.Step(`^ensuring microshift cluster is fully operational$`, + EnsureMicroshiftClusterIsOperational) s.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) { @@ -978,3 +982,39 @@ func DecodeBase64File(inputFile, outputFile string) error { } return util.ExecuteCommandSucceedsOrFails(cmd, "succeeds") } + +func EnsureUserNetworkmode() error { + if runtime.GOOS == "linux" { + return crcCmd.SetConfigPropertyToValueSucceedsOrFails( + "network-mode", "user", "succeeds") + } + return nil +} + +// This function will wait until the microshift cluster got operational +func EnsureMicroshiftClusterIsOperational() error { + // First wait until crc report the cluster as running + err := crcCmd.WaitForClusterInState("running") + if err != nil { + return err + } + // Define the services to declare the cluster operational + services := map[string]string{ + ".*dns-default.*2/2.*Running.*": "oc get pods -n openshift-dns", + ".*ovnkube-master.*4/4.*Running.*": "oc get pods -n openshift-ovn-kubernetes", + ".*ovnkube-node.*1/1.*Running.*": "oc get pods -n openshift-ovn-kubernetes"} + + for operationalState, getPodCommand := range services { + var operational = false + for !operational { + if err := util.ExecuteCommandSucceedsOrFails(getPodCommand, "succeeds"); err != nil { + return err + } + operational = (nil == util.CommandReturnShouldMatch( + "stdout", + operationalState)) + } + } + + return nil +}