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 11, 2025
1 parent b03610c commit 29d7534
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/e2e/features/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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
And accessing crc man pages 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 +74,4 @@ Feature: Basic test
And kubeconfig is cleaned up
# cleanup
When executing crc cleanup command succeeds
And executing "man -P cat crc" fails
And accessing crc man pages fails
41 changes: 41 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 @@ -1054,6 +1056,45 @@ func EnsureUserNetworkmode() error {
return nil
}

func EnsureCRCManPagesAvailability(expectedStatus string) error {
if runtime.GOOS == "windows" {
return nil
}
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")
if expectedStatus == "succeeds" {
for _, manPage := range expectedManFileList {
manFile := filepath.Join(manPageDir, manPage)
if _, err := os.Stat(manFile); os.IsNotExist(err) {
return fmt.Errorf("missing manpage : %s", manPage)
}
}
}
if expectedStatus == "fails" {
manFileList, err := os.ReadDir(manPageDir)
if err != nil {
return fmt.Errorf("failed to read manpage directory: %v", err)
}
if len(manFileList) != 0 {
return fmt.Errorf("expected manpages to be cleaned up, but found these in man pages directory : %s", manFileList)
}
}

return nil
}

func EnsureKubeConfigIsCleanedUp() error {
kubeConfig, cfg, err := machine.GetGlobalKubeConfig()
if err != nil {
Expand Down

0 comments on commit 29d7534

Please sign in to comment.