Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[e2e] story_microshift ensures operational status for cluster #3857

Merged
merged 1 commit into from
Oct 16, 2023
Merged
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
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 @@ -991,3 +995,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no comments, just maybe that the func doc comment usually starts with func name and describes output. But that's super minor.

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
}
Loading