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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ verify: verify-fast

# Fast verification checks that developers can/should run locally
.PHONY: verify-fast
verify-fast: verify-go verify-assets verify-sh verify-py verify-config
verify-fast: verify-go verify-assets verify-sh verify-py verify-config verify-rf

# Full verification checks that should run in CI
.PHONY: verify-ci
Expand Down Expand Up @@ -155,6 +155,10 @@ verify-sh:
verify-py:
./scripts/verify/verify-py.sh

.PHONY: verify-rf
verify-rf:
./scripts/verify/verify-rf.sh

.PHONY: verify-containers
verify-containers:
./scripts/fetch_tools.sh hadolint && \
Expand Down
23 changes: 22 additions & 1 deletion scripts/fetch_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ IFS=$'\n\t'
ARCH="$(uname -m)"

SCRIPT_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
DEST_DIR="${DEST_DIR:-${SCRIPT_DIR}/../_output/bin}"
ROOT_DIR=$(realpath "${SCRIPT_DIR}/..")
DEFAULT_DEST_DIR="${ROOT_DIR}/_output/bin"
DEST_DIR="${DEST_DIR:-${DEFAULT_DEST_DIR}}"
[ -d "${DEST_DIR}" ] || mkdir -p "${DEST_DIR}"
DEST_DIR="$(realpath "${DEST_DIR}")"
WORK_DIR=$(mktemp -d)
Expand Down Expand Up @@ -164,6 +166,25 @@ get_controller-gen() {
GOBIN=${DEST_DIR} GOFLAGS="" go install sigs.k8s.io/controller-tools/cmd/controller-gen@${ver}
}

get_robotframework() {
local venv

if [ "${DEST_DIR}" = "${DEFAULT_DEST_DIR}" ]; then
# Probably running as the user, not in CI.
venv="${ROOT_DIR}/_output/robotenv"
else
# Probably running in automation environment where the output
# location has been changed.
venv="${DEST_DIR}"
fi

if [ ! -f "${venv}/bin/robot" ]; then
python3 -m venv "${venv}"
"${venv}/bin/python3" -m pip install --upgrade pip
"${venv}/bin/python3" -m pip install -r "${ROOT_DIR}/test/requirements.txt"
fi
}

tool_getters=$(declare -F | cut -d' ' -f3 | grep "get_" | sed 's/get_//g')

usage() {
Expand Down
10 changes: 10 additions & 0 deletions scripts/verify/verify-rf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/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/robocop"
1 change: 1 addition & 0 deletions test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ robotframework-requests==0.9.4
robotframework-scplibrary==1.2.0
robotframework-sshlibrary==3.8.0
pyyaml==6.0
robotframework-robocop==3.1.1
10 changes: 8 additions & 2 deletions test/resources/common.resource
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
*** Settings ***
Documentation Keywords common to many test suites
Library OperatingSystem
Library String
Resource ../resources/kubeconfig.resource


*** Keywords ***
Setup Suite
[Documentation] Setup a namespace-less test suite by configuring Kubeconfig
Expand Down Expand Up @@ -32,5 +34,9 @@ Teardown Suite With Namespace

Check Required Env Variables
[Documentation] Fail if any of the required environment variables is missing.
Run Keyword If "${USHIFT_HOST}"=="${EMPTY}" Fatal Error USHIFT_HOST variable is required
Run Keyword If "${USHIFT_USER}"=="${EMPTY}" Fatal Error USHIFT_USER variable is required
IF "${USHIFT_HOST}"=="${EMPTY}"
Fatal Error USHIFT_HOST variable is required
END
IF "${USHIFT_USER}"=="${EMPTY}"
Fatal Error USHIFT_USER variable is required
END
4 changes: 3 additions & 1 deletion test/resources/kubeconfig.resource
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
*** Settings ***
Documentation Keywords for accessing a kubeconfig file for the MicroShift host
Library OperatingSystem
Library String
Resource ../resources/microshift-host.resource


*** Keywords ***
Get Kubeconfig
[Documentation] Get the kubeconfig file from the host argument and return contents
Expand All @@ -12,7 +14,7 @@ Get Kubeconfig
... sudo=True return_rc=True
Should Be Equal As Integers ${rc} 0
Should Not Be Empty ${kubeconfig}
[Return] ${kubeconfig}
RETURN ${kubeconfig}

Setup Kubeconfig
[Documentation] Get the kubeconfig file from the configured $USHIFT_HOST, create a temporary file
Expand Down
3 changes: 2 additions & 1 deletion test/resources/microshift-host.resource
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*** Settings ***
Library SSHLibrary
Documentation Keywords for working with the MicroShift host
Library SSHLibrary


*** Keywords ***
Expand Down
5 changes: 4 additions & 1 deletion test/resources/microshift-process.resource
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
*** Settings ***
Documentation Keywords for running the microshift command line.

Library Process
Library SSHLibrary
Library String
Library OperatingSystem

Library SSHLibrary
Resource ../resources/microshift-host.resource
Library ../resources/YAML.py

Expand Down
11 changes: 10 additions & 1 deletion test/resources/oc.resource
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
*** Settings ***
Documentation Keywords for using the oc command line.
...
... Requires that the openshift-clients package be installed and
... 'oc' is in the $PATH.

Resource common.resource
Library YAML.py

*** Keywords ***

*** Keywords ***
Oc Get
[Documentation] Run 'oc get' for a specific instance of a type in a namespace.
... Returns the YAML output parsed to a DottedDict for use in
... other keywords.

[Arguments] ${type} ${namespace} ${resource}

${yaml_text}= Run With Kubeconfig oc get -n ${namespace} -o yaml ${type} ${resource}
Expand Down
6 changes: 1 addition & 5 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ if [ ! -f "${RF_VARIABLES}" ]; then
exit 1
fi

if [ ! -d "${RF_VENV}" ]; then
python3 -m venv "${RF_VENV}"
"${RF_VENV}/bin/python3" -m pip install --upgrade pip
"${RF_VENV}/bin/python3" -m pip install -r "${SCRIPTDIR}/requirements.txt"
fi
DEST_DIR="${RF_VENV}" "${ROOTDIR}/scripts/fetch_tools.sh" robotframework

cd "${SCRIPTDIR}" || (echo "Did not find ${SCRIPTDIR}" 1>&2; exit 1)

Expand Down
11 changes: 9 additions & 2 deletions test/suites/load-balancer.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Resource ../resources/kubeconfig.resource
Suite Setup Setup Suite With Namespace
Suite Teardown Teardown Suite With Namespace


*** Variables ***
${HELLO_USHIFT} assets/hello-microshift.yaml


*** Test Cases ***
Load Balancer Smoke Test
[Documentation] Verify that Load Balancer correctly exposes HTTP service
Expand All @@ -20,20 +22,24 @@ Load Balancer Smoke Test
... Create Hello MicroShift Pod AND
... Expose Hello MicroShift Pod Via LB

Wait Until Keyword Succeeds 3x 3s Access Hello Microshift via LB
Wait Until Keyword Succeeds 3x 3s Access Hello Microshift Via LB

[Teardown] Run Keywords
... Delete Hello MicroShift Pod Route And Service


*** Keywords ***
Create Hello MicroShift Pod
[Documentation] Create a pod running the "hello microshift" application
Run With Kubeconfig oc create -f ${HELLO_USHIFT} -n ${NAMESPACE}
Run With Kubeconfig oc wait pods -l app\=hello-microshift --for condition\=Ready --timeout\=60s -n ${NAMESPACE}

Expose Hello MicroShift Pod Via LB
[Documentation] Expose the "hello microshift" application through the load balancer
Run With Kubeconfig oc create service loadbalancer hello-microshift --tcp=5678:8080 -n ${NAMESPACE}

Access Hello Microshift via LB
Access Hello Microshift Via LB
[Documentation] Try to retrieve data from the "hello microshift" service end point
${result}= Run Process
... curl -i http://hello-microshift.cluster.local --connect-to "hello-microshift.cluster.local:80:${USHIFT_HOST}:5678"
... shell=True timeout=15s
Expand All @@ -43,6 +49,7 @@ Access Hello Microshift via LB
Should Match ${result.stdout} *Hello MicroShift*

Delete Hello MicroShift Pod Route And Service
[Documentation] Remove the "hello microshift" resources
Run With Kubeconfig oc delete route hello-microshift -n ${NAMESPACE} True
Run With Kubeconfig oc delete service hello-microshift -n ${NAMESPACE} True
Run With Kubeconfig oc delete -f ${HELLO_USHIFT} -n ${NAMESPACE} True