Skip to content

Commit

Permalink
test (e2e) : update basic scenario to skip manpages check on windows (#…
Browse files Browse the repository at this point in the history
…4608)

+ Update manpages step in basic scenario to skip execution for windows
+ Instead of relying of man command output, only verify whether we've generated the man pages files correctly in the directory.

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Feb 13, 2025
1 parent b03610c commit df2b631
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 0 additions & 2 deletions test/e2e/features/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Feature: Basic test
* setting config property "enable-cluster-monitoring" to value "true" succeeds
* setting config property "memory" to value "16000" succeeds
Given executing single crc setup command succeeds
And executing "man -P cat crc" succeeds
When starting CRC with default bundle succeeds
Then stdout should contain "Started the OpenShift cluster"
# Check if user can copy-paste login details for developer and kubeadmin users
Expand Down Expand Up @@ -74,4 +73,3 @@ Feature: Basic test
And kubeconfig is cleaned up
# cleanup
When executing crc cleanup command succeeds
And executing "man -P cat crc" fails
10 changes: 10 additions & 0 deletions test/e2e/features/manpages.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@story_manpages
Feature: Check generation and cleanup of manpages

@linux @darwin @cleanup
Scenario: verify man pages are generated after crc setup and deleted on cleanup
When executing single crc setup command succeeds
Then accessing crc man pages succeeds

When executing crc cleanup command succeeds
Then accessing crc man pages fails
28 changes: 28 additions & 0 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ func InitializeScenario(s *godog.ScenarioContext) {
EnsureMicroshiftClusterIsOperational)
s.Step(`^kubeconfig is cleaned up$`,
EnsureKubeConfigIsCleanedUp)
s.Step(`^accessing crc man pages (succeeds|fails)$`,
EnsureCRCManPagesAvailability)

s.After(func(ctx context.Context, _ *godog.Scenario, err error) (context.Context, error) {

Expand Down Expand Up @@ -1074,6 +1076,32 @@ func EnsureKubeConfigIsCleanedUp() error {
return nil
}

func EnsureCRCManPagesAvailability(expectedStatus string) error {
expectedManFileList := []string{
"crc-bundle-generate.1.gz", "crc-config.1.gz", "crc-start.1.gz",
"crc-bundle.1.gz", "crc-console.1.gz", "crc-status.1.gz",
"crc-cleanup.1.gz", "crc-delete.1.gz", "crc-stop.1.gz",
"crc-config-get.1.gz", "crc-ip.1.gz", "crc-version.1.gz",
"crc-config-set.1.gz", "crc-oc-env.1.gz", "crc.1.gz",
"crc-config-unset.1.gz", "crc-podman-env.1.gz",
"crc-config-view.1.gz", "crc-setup.1.gz",
}
userHomeDir, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("failed to get user home directory: %v", err)
}
manPageDir := filepath.Join(userHomeDir, ".local", "share", "man", "man1")
for _, manPage := range expectedManFileList {
manFile := filepath.Join(manPageDir, manPage)
manCommand := fmt.Sprintf("man -P cat %s", manFile)
err := util.ExecuteCommandSucceedsOrFails(manCommand, expectedStatus)
if err != nil {
return err
}
}
return nil
}

// This function will wait until the microshift cluster got operational
func EnsureMicroshiftClusterIsOperational() error {
// First wait until crc report the cluster as running
Expand Down

0 comments on commit df2b631

Please sign in to comment.