Skip to content

Commit

Permalink
[qe] add crc config set/get preset test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyLuLiu authored and adrianriobo committed May 27, 2024
1 parent 0f14537 commit a99837d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/e2e/features/config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,39 @@ Feature: Test configuration settings
And executing crc setup command succeeds
Then stderr should not contain "Skipping above check"

@linux @darwin @windows
Scenario: CRC config set and get preset property (default cases)
When setting config property "preset" to value "openshift" succeeds
And "JSON" config file "crc.json" in CRC home folder does not contain key "preset"
When getting config property "preset" succeeds
And stdout should contain "Configuration property 'preset' is not set"
And stdout should contain "openshift"
When unsetting config property "preset" succeeds
And stdout should contain "Successfully unset configuration property 'preset'"
And "JSON" config file "crc.json" in CRC home folder does not contain key "preset"


Scenario: CRC config set and get preset property (positive cases)
When setting config property "preset" to value "<preset-value>" succeeds
And "JSON" config file "crc.json" in CRC home folder contains key "preset" with value matching "<preset-value>"
When getting config property "preset" succeeds
And stdout should contain "<preset-value>"
When unsetting config property "preset" succeeds
And stdout should contain "Successfully unset configuration property 'preset'"
And "JSON" config file "crc.json" in CRC home folder does not contain key "preset"

@linux @darwin @windows
Examples: Config property preset setting positive
| preset-value |
| microshift |
| okd |

Scenario: CRC config set preset (negtive cases)
When setting config property "preset" to value "<preset-value>" fails
And stderr should contain "reason: Unknown preset"

@linux @darwin @windows
Examples: Config property getting
| preset-value |
| podman |
| others |
2 changes: 2 additions & 0 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ func InitializeScenario(s *godog.ScenarioContext) {
StartCRCWithDefaultBundleAndNameServerSucceedsOrFails)
s.Step(`^setting config property "(.*)" to value "(.*)" (succeeds|fails)$`,
SetConfigPropertyToValueSucceedsOrFails)
s.Step(`^getting config property "(.*)" (succeeds|fails)$`,
crcCmd.GetConfigPropertySucceedsOrFails)
s.Step(`^unsetting config property "(.*)" (succeeds|fails)$`,
crcCmd.UnsetConfigPropertySucceedsOrFails)
s.Step(`^login to the oc cluster (succeeds|fails)$`,
Expand Down
5 changes: 5 additions & 0 deletions test/extended/crc/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ func UnsetConfigPropertySucceedsOrFails(property string, expected string) error
return util.ExecuteCommandSucceedsOrFails(cmd, expected)
}

func GetConfigPropertySucceedsOrFails(property string, expected string) error {
cmd := "crc config get " + property
return util.ExecuteCommandSucceedsOrFails(cmd, expected)
}

func WaitForClusterInState(state string) error {
return util.MatchRepetitionsWithRetry(state, CheckCRCStatus, clusterStateRepetition,
clusterStateRetryCount, clusterStateTimeout)
Expand Down

0 comments on commit a99837d

Please sign in to comment.