From a99837db6a736cb995df2c017651560b22fa0101 Mon Sep 17 00:00:00 2001 From: Lu Liu Date: Tue, 21 May 2024 11:51:33 +0800 Subject: [PATCH] [qe] add crc config set/get preset test cases --- test/e2e/features/config.feature | 36 ++++++++++++++++++++++++++++++++ test/e2e/testsuite/testsuite.go | 2 ++ test/extended/crc/cmd/cmd.go | 5 +++++ 3 files changed, 43 insertions(+) diff --git a/test/e2e/features/config.feature b/test/e2e/features/config.feature index 244dc17f1e..dbf0f5ed3e 100644 --- a/test/e2e/features/config.feature +++ b/test/e2e/features/config.feature @@ -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 "" succeeds + And "JSON" config file "crc.json" in CRC home folder contains key "preset" with value matching "" + When getting config property "preset" succeeds + And stdout should contain "" + 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 "" fails + And stderr should contain "reason: Unknown preset" + + @linux @darwin @windows + Examples: Config property getting + | preset-value | + | podman | + | others | diff --git a/test/e2e/testsuite/testsuite.go b/test/e2e/testsuite/testsuite.go index 75a430d735..94270bbbe8 100644 --- a/test/e2e/testsuite/testsuite.go +++ b/test/e2e/testsuite/testsuite.go @@ -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)$`, diff --git a/test/extended/crc/cmd/cmd.go b/test/extended/crc/cmd/cmd.go index 3ff2cbef4b..b1389d7478 100644 --- a/test/extended/crc/cmd/cmd.go +++ b/test/extended/crc/cmd/cmd.go @@ -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)