Skip to content

Commit

Permalink
[e2e] story_microshift ensures operational status for cluster before …
Browse files Browse the repository at this point in the history
…deploy the sample service

previously the test service was deployed right after the crc start finished successfully, now we add some checks before deploy the service to ensure the cluster is operational: crc status + dns pods running + ovn pods running
  • Loading branch information
adrianriobo authored and praveenkumar committed Oct 16, 2023
1 parent 55a1014 commit da7e5a9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/e2e/features/story_microshift.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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
}

0 comments on commit da7e5a9

Please sign in to comment.