Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,7 @@ verify-config: generate-config
.PHONY: e2e
e2e:
./test/run.sh

.PHONY: rf-fmt
rf-fmt:
@./test/format.sh
6 changes: 5 additions & 1 deletion scripts/verify/verify-rf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ RF_VENV="${ROOTDIR}/_output/robotenv"
"${ROOTDIR}/scripts/fetch_tools.sh" robotframework

cd "${ROOTDIR}/test"
"${RF_VENV}/bin/robocop"

set -x
"${RF_VENV}/bin/robocop" --exclude 1015

"${RF_VENV}/bin/robotidy" --check --diff .
29 changes: 29 additions & 0 deletions test/.robotidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[tool.robotidy]
transform = [
"AddMissingEnd",
"NormalizeSeparators",
"DiscardEmptySections",
"MergeAndOrderSections",
"RemoveEmptySettings",
"ReplaceEmptyValues",
"NormalizeAssignments",
"OrderSettings",
"OrderSettingsSection",
"NormalizeTags",
"OrderTags",
"RenameVariables",
"IndentNestedKeywords",
"AlignSettingsSection",
"AlignVariablesSection",
"NormalizeNewLines",
"NormalizeSectionHeaderName",
"NormalizeSettingName",
"ReplaceRunKeywordIf",
"SplitTooLongLine:align_new_line=True",
"RenameTestCases",
"RenameKeywords",
"ReplaceReturns",
"ReplaceBreakContinue",
"InlineIf",
"NormalizeComments"
]
11 changes: 11 additions & 0 deletions test/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail

ROOTDIR=$(git rev-parse --show-toplevel)
RF_VENV="${ROOTDIR}/_output/robotenv"
"${ROOTDIR}/scripts/fetch_tools.sh" robotframework

cd "${ROOTDIR}/test"

"${RF_VENV}/bin/robotidy" .

1 change: 1 addition & 0 deletions test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ robotframework-scplibrary==1.2.0
robotframework-sshlibrary==3.8.0
pyyaml==6.0
robotframework-robocop==3.1.1
robotframework-tidy==4.3.0
35 changes: 18 additions & 17 deletions test/resources/common.resource
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
*** Settings ***
Documentation Keywords common to many test suites
Library OperatingSystem
Library String
Resource ../resources/kubeconfig.resource
Documentation Keywords common to many test suites

Library OperatingSystem
Library String
Resource ../resources/kubeconfig.resource


*** Keywords ***
Expand Down Expand Up @@ -34,28 +35,28 @@ Teardown Suite With Namespace

Check Required Env Variables
[Documentation] Fail if any of the required environment variables is missing.
IF "${USHIFT_HOST}"=="${EMPTY}"
IF "${USHIFT_HOST}"=="${EMPTY}"
Fatal Error USHIFT_HOST variable is required
END
IF "${USHIFT_USER}"=="${EMPTY}"
IF "${USHIFT_USER}"=="${EMPTY}"
Fatal Error USHIFT_USER variable is required
END

Upload String To File # robocop: disable=too-many-calls-in-keyword
[Documentation] Write the string to a remote file
[Arguments] ${content} ${remote_filename}
Upload String To File # robocop: disable=too-many-calls-in-keyword
[Documentation] Write the string to a remote file
[Arguments] ${content} ${remote_filename}
${rand}= Generate Random String
${local_tmp}= Join Path /tmp ${rand}
Create File ${local_tmp} ${content}
${rand}= Generate Random String
${remote_tmp}= Join Path /tmp ${rand}
Put File ${local_tmp} ${remote_tmp} mode=0644
Remove File ${local_tmp}
${stdout} ${rc}= Execute Command
Put File ${local_tmp} ${remote_tmp} mode=0644
Remove File ${local_tmp}
${stdout} ${rc}= Execute Command
... mv ${remote_tmp} ${remote_filename}
... sudo=True return_rc=True
Should Be Equal As Integers 0 ${rc}
${stdout} ${rc}= Execute Command
... sudo=True return_rc=True
Should Be Equal As Integers 0 ${rc}
${stdout} ${rc}= Execute Command
... chown root:root ${remote_filename}
... sudo=True return_rc=True
Should Be Equal As Integers 0 ${rc}
... sudo=True return_rc=True
Should Be Equal As Integers 0 ${rc}
19 changes: 10 additions & 9 deletions test/resources/kubeconfig.resource
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
*** Settings ***
Documentation Keywords for accessing a kubeconfig file for the MicroShift host
Library OperatingSystem
Library String
Resource ../resources/microshift-host.resource
Documentation Keywords for accessing a kubeconfig file for the MicroShift host

Library OperatingSystem
Library String
Resource ../resources/microshift-host.resource


*** Keywords ***
Expand All @@ -13,12 +14,12 @@ Get Kubeconfig
... cat /var/lib/microshift/resources/kubeadmin/${host}/kubeconfig
... sudo=True return_rc=True
Should Be Equal As Integers ${rc} 0
Should Not Be Empty ${kubeconfig}
Should Not Be Empty ${kubeconfig}
RETURN ${kubeconfig}

Setup Kubeconfig
[Documentation] Get the kubeconfig file from the configured $USHIFT_HOST, create a temporary file
... and export it as $KUBECONFIG variable.
... and export it as $KUBECONFIG variable.
${kubeconfig}= Get Kubeconfig ${USHIFT_HOST}
${rand}= Generate Random String
${path}= Join Path /tmp ${rand}
Expand All @@ -38,7 +39,7 @@ Run With Kubeconfig
IF ${allow_fail} == False
Should Be Equal As Integers ${result.rc} 0
END
RETURN ${result.stdout}
RETURN ${result.stdout}

Create Namespace
[Documentation] Creates a namespace with the given name.
Expand All @@ -48,9 +49,9 @@ Create Namespace
Create Random Namespace
[Documentation] Creates a namespace with a random name and return the name.
${rand}= Generate Random String
${rand}= Convert To Lowercase ${rand}
${rand}= Convert To Lowercase ${rand}
Run With Kubeconfig oc create namespace test-${rand}
RETURN test-${rand}
RETURN test-${rand}

Remove Namespace
[Documentation] Removes the given namespace.
Expand Down
67 changes: 33 additions & 34 deletions test/resources/microshift-config.resource
Original file line number Diff line number Diff line change
@@ -1,61 +1,60 @@
*** Settings ***
Documentation Keywords for running the microshift command line.
Documentation Keywords for running the microshift command line.

Library Process
Library String
Library OperatingSystem

Library SSHLibrary
Library DataFormats.py
Library Process
Library String
Library OperatingSystem
Library SSHLibrary
Library DataFormats.py


*** Keywords ***
Save Default MicroShift Config
[Documentation] Fetch the current config settings and preserve them as the default
[Documentation] Fetch the current config settings and preserve them as the default
...
... Sets the suite variable DEFAULT_MICROSHIFT_CONFIG to the text value
... based on the contents of /etc/microshift/config.yaml, if it exists, or
... an empty string if the file does not exist.
... Sets the suite variable DEFAULT_MICROSHIFT_CONFIG to the text value
... based on the contents of /etc/microshift/config.yaml, if it exists, or
... an empty string if the file does not exist.
...
... This keyword is meant to be used from a Setup step.
${stdout} ${rc}= Execute Command
... This keyword is meant to be used from a Setup step.
${stdout} ${rc}= Execute Command
... cat /etc/microshift/config.yaml
... sudo=True return_rc=True
IF ${rc} == 0
Set Suite Variable \${DEFAULT_MICROSHIFT_CONFIG} ${stdout}
... sudo=True return_rc=True
IF ${rc} == 0
Set Suite Variable \${DEFAULT_MICROSHIFT_CONFIG} ${stdout}
ELSE
Set Suite Variable \${DEFAULT_MICROSHIFT_CONFIG} ${EMPTY}
Set Suite Variable \${DEFAULT_MICROSHIFT_CONFIG} ${EMPTY}
END

Restore Default MicroShift Config
[Documentation] Replace the microshift config file with the original defaults.
[Documentation] Replace the microshift config file with the original defaults.
...
... If there was no configuration file originally, delete any file that is there now.
${len}= Get Length ${DEFAULT_MICROSHIFT_CONFIG}
IF ${len} == 0
... If there was no configuration file originally, delete any file that is there now.
${len}= Get Length ${DEFAULT_MICROSHIFT_CONFIG}
IF ${len} == 0
# If there was no configuration file to start with, we do not want to create
# a new one, even if it is empty.
Clear MicroShift Config
ELSE
Upload MicroShift Config ${DEFAULT_MICROSHIFT_CONFIG}
Upload MicroShift Config ${DEFAULT_MICROSHIFT_CONFIG}
END

Extend MicroShift Config
[Documentation] Return combination of default config and input argument as a string.
[Documentation] Return combination of default config and input argument as a string.
...
... The values are parsed as YAML and merged additively (no keys are deleted
... and list values are extended but not replaced) by 'Yaml Merge'.
[Arguments] ${config}
${merged}= Yaml Merge ${DEFAULT_MICROSHIFT_CONFIG} ${config}
RETURN ${merged}
... The values are parsed as YAML and merged additively (no keys are deleted
... and list values are extended but not replaced) by 'Yaml Merge'.
[Arguments] ${config}
${merged}= Yaml Merge ${DEFAULT_MICROSHIFT_CONFIG} ${config}
RETURN ${merged}

Clear MicroShift Config
[Documentation] Remove any configuration file
${stdout} ${rc}= Execute Command
[Documentation] Remove any configuration file
${stdout} ${rc}= Execute Command
... rm -f /etc/microshift/config.yaml
... sudo=True return_rc=True
... sudo=True return_rc=True

Upload MicroShift Config
[Documentation] Upload a new configuration file to the MicroShift host
[Arguments] ${config_content}
Upload String To File ${config_content} /etc/microshift/config.yaml
[Documentation] Upload a new configuration file to the MicroShift host
[Arguments] ${config_content}
Upload String To File ${config_content} /etc/microshift/config.yaml
26 changes: 14 additions & 12 deletions test/resources/microshift-host.resource
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
*** Settings ***
Documentation Keywords for working with the MicroShift host
Library SSHLibrary
Documentation Keywords for working with the MicroShift host

Library SSHLibrary


*** Keywords ***
Login MicroShift Host
[Documentation] Login to the MicroShift host via ssh and leave the connection open
[Documentation] Login to the MicroShift host via ssh and leave the connection open
...
... This keyword is meant to be used at the suite level. This ensures
... most tests already have an open connection. Any tests that will take
... action that disrupt that connection are responsible for restoring it.
... This keyword is meant to be used at the suite level. This ensures
... most tests already have an open connection. Any tests that will take
... action that disrupt that connection are responsible for restoring it.

Log Host: ${USHIFT_HOST}
IF '${SSH_PORT}'
Log Host: ${USHIFT_HOST}
IF '${SSH_PORT}'
SSHLibrary.Open Connection ${USHIFT_HOST} port=${SSH_PORT}
ELSE
SSHLibrary.Open Connection ${USHIFT_HOST}
END
# If there is an ssh key set in the global configuration, use that to
# login to the host. Otherwise assume that the ssh agent is running
# and configured properly.
IF '${SSH_PRIV_KEY}'
IF '${SSH_PRIV_KEY}'
SSHLibrary.Login With Public Key ${USHIFT_USER} ${SSH_PRIV_KEY}
ELSE
SSHLibrary.Login ${USHIFT_USER} allow_agent=True
SSHLibrary.Login ${USHIFT_USER} allow_agent=True
END

Logout MicroShift Host
[Documentation] Close the open ssh connection to the MicroShift host
[Documentation] Close the open ssh connection to the MicroShift host
SSHLibrary.Close Connection

Reboot MicroShift Host
Expand All @@ -37,7 +38,8 @@ Reboot MicroShift Host

SSHLibrary.Start Command reboot sudo=True
Sleep 30s
Wait Until Keyword Succeeds 5m 15s Login MicroShift Host
Wait Until Keyword Succeeds 5m 15s
... Login MicroShift Host

${rc}= SSHLibrary.Execute Command true return_stdout=False return_rc=True
Should Be Equal As Integers 0 ${rc}
Loading