-
Notifications
You must be signed in to change notification settings - Fork 229
USHIFT-1198: add tests for version API #1734
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
Merged
openshift-merge-robot
merged 5 commits into
openshift:main
from
dhellmann:USHIFT-1198-robot-test-version
May 23, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4afef39
update the log level to trace
dhellmann a63bfe3
return stdout from commands run with kubeconfig
dhellmann 7aa09d4
log stderr in Run With Kubeconfig
dhellmann 678b33e
USHIFT-1198: add tests for version API
dhellmann ffb0966
move login/logout to suite setup/teardown steps
dhellmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """Expose YAML parser to robot tests. | ||
| """ | ||
| import yaml | ||
| from robot.utils import DotDict | ||
|
|
||
|
|
||
| def yaml_parse(data): | ||
| """Parse input string as YAML and return DotDict instance.""" | ||
| parsed = yaml.safe_load(data) | ||
| return DotDict(parsed) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| *** Settings *** | ||
| Library Process | ||
| Library SSHLibrary | ||
| Library String | ||
| Library OperatingSystem | ||
| Resource ../resources/microshift-host.resource | ||
| Library ../resources/YAML.py | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| MicroShift Version | ||
| [Documentation] Run the version command | ||
| ${version_text} ${rc}= Execute Command | ||
| ... microshift version -o yaml | ||
| ... sudo=True return_rc=True | ||
| Should Be Equal As Integers ${rc} 0 | ||
| Should Not Be Empty ${version_text} | ||
| ${version}= Yaml Parse ${version_text} | ||
| RETURN ${version} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| *** Settings *** | ||
| Resource common.resource | ||
| Library YAML.py | ||
|
|
||
| *** Keywords *** | ||
|
|
||
| Oc Get | ||
| [Arguments] ${type} ${namespace} ${resource} | ||
|
|
||
| ${yaml_text}= Run With Kubeconfig oc get -n ${namespace} -o yaml ${type} ${resource} | ||
| ${yaml_data}= Yaml Parse ${yaml_text} | ||
|
|
||
|
dhellmann marked this conversation as resolved.
Outdated
|
||
| RETURN ${yaml_data} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| *** Settings *** | ||
| Documentation Tests related to the version of MicroShift | ||
|
|
||
| Resource ../resources/common.resource | ||
| Resource ../resources/oc.resource | ||
| Resource ../resources/microshift-process.resource | ||
| Library Collections | ||
| Library ../resources/YAML.py | ||
|
|
||
| Suite Setup Setup | ||
| Suite Teardown Teardown | ||
|
|
||
|
|
||
| *** Variables *** | ||
| ${USHIFT_HOST} ${EMPTY} | ||
| ${USHIFT_USER} ${EMPTY} | ||
|
|
||
|
|
||
| *** Test Cases *** | ||
| ConfigMap Contents | ||
| [Documentation] Check the version of the server | ||
|
|
||
| ${configmap}= Oc Get configmap kube-public microshift-version | ||
| Should Be Equal As Integers ${configmap.data.major} ${MAJOR_VERSION} | ||
| Should Be Equal As Integers ${configmap.data.minor} ${MINOR_VERSION} | ||
|
|
||
| CLI Output | ||
| [Documentation] Check the version reported by the process | ||
|
|
||
| ${version}= MicroShift Version | ||
| Should Be Equal As Integers ${version.major} ${MAJOR_VERSION} | ||
| Should Be Equal As Integers ${version.minor} ${MINOR_VERSION} | ||
| Should Start With ${version.gitVersion} ${Y_STREAM} | ||
|
|
||
| ConfigMap Matches CLI | ||
| [Documentation] Ensure the ConfigMap is being updated based on the actual binary version | ||
|
|
||
| ${configmap}= Oc Get configmap kube-public microshift-version | ||
| ${cli}= MicroShift Version | ||
| Should Be Equal ${configmap.data.version} ${cli.gitVersion} | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Setup | ||
| [Documentation] Test suite setup | ||
| Check Required Env Variables | ||
| Login MicroShift Host | ||
| Setup Kubeconfig | ||
| Read Expected Versions | ||
|
|
||
| Teardown | ||
| [Documentation] Test suite teardown | ||
| Remove Kubeconfig | ||
| Logout MicroShift Host | ||
|
|
||
| Read Expected Versions # robocop: disable=too-many-calls-in-keyword | ||
| [Documentation] Read ../Makefile.version.aarch64.var to find the expected versions | ||
| ... Sets suite variables FULL_VERSION, MAJOR_VERSION, MINOR_VERSION, and Y_STREAM based on | ||
| ... the content. | ||
|
|
||
| # The file contains content in this format: | ||
| # | ||
| # OCP_VERSION := 4.14.0-0.nightly-arm64-2023-05-04-012046 | ||
|
|
||
| ${unparsed}= OperatingSystem.Get File ../Makefile.version.aarch64.var | ||
|
|
||
| # 4.14.0-0.nightly-arm64-2023-05-04-012046 | ||
| ${version_full_raw}= Fetch From Right ${unparsed} := | ||
| ${version_full}= Strip String ${version_full_raw} | ||
| Set Suite Variable \${FULL_VERSION} ${version_full} | ||
|
|
||
| # 4 | ||
| ${major}= Fetch From Left ${version_full} . | ||
| Set Suite Variable \${MAJOR_VERSION} ${major} | ||
|
|
||
| # 14.0-0.nightly-arm64-2023-05-04-012046 | ||
| ${without_major}= Get Substring ${version_full} 2 | ||
|
|
||
| # 14 | ||
| ${minor}= Fetch From Left ${without_major} . | ||
| Set Suite Variable \${MINOR_VERSION} ${minor} | ||
|
|
||
| # 4.14 | ||
| ${ystream}= Format String {}.{} ${major} ${minor} | ||
| Set Suite Variable \${Y_STREAM} ${ystream} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.