Skip to content

Commit

Permalink
chore(tests): upgrade to RF 19
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidePrincipi committed Jan 17, 2025
1 parent 4528998 commit 44be018
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 34 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/test-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Test module

on:
workflow_dispatch:
inputs:
debug_shell:
description: "Debug shell"
required: true
type: boolean
workflow_run:
workflows: ["Publish images"]
types: [completed]
Expand All @@ -10,11 +15,13 @@ jobs:
module:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == '' }}
uses: NethServer/ns8-github-actions/.github/workflows/module-info.yml@main
run_tests_on_do:
run_tests:
needs: module
uses: NethServer/ns8-github-actions/.github/workflows/test-on-digitalocean-infra.yml@main
with:
coremodules: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}"
args: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}"
repo_ref: ${{needs.module.outputs.sha}}
debug_shell: ${{ github.event.inputs.debug_shell == 'true' || false }}
secrets:
do_token: ${{ secrets.do_token }}
63 changes: 41 additions & 22 deletions test-module.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
#!/bin/bash

LEADER_NODE=$1
#
# Copyright (C) 2025 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

#
# Hint: access the test logs on HTTP port 8000 with this command:
#
# python -mhttp.server -d tests/outputs/ 8000 &
#

set -e

SSH_KEYFILE=${SSH_KEYFILE:-$HOME/.ssh/id_rsa}

ssh_key="$(cat $SSH_KEYFILE)"
LEADER_NODE="${1:?missing LEADER_NODE argument}"
IMAGE_URL="${2:?missing IMAGE_URL argument}"
shift 2

ssh_key="$(< $SSH_KEYFILE)"

cleanup() {
set +e
podman cp rf-core-runner:/home/pwuser/outputs tests/
podman stop rf-core-runner
podman rm rf-core-runner
}

trap cleanup EXIT
podman run -i \
--volume=site-packages:/home/pwuser/.local/lib/python3.8/site-packages:Z \
-v .:/home/pwuser/ns8-module:z \
--name rf-core-runner ghcr.io/marketsquare/robotframework-browser/rfbrowser-stable:v10.0.3 \
--network=host \
--volume=.:/home/pwuser/ns8-module:z \
--volume=site-packages:/home/pwuser/.local/lib/python3.12/site-packages:z \
--name rf-core-runner ghcr.io/marketsquare/robotframework-browser/rfbrowser-stable:19.1.2 \
bash -l -s <<EOF
set -e
echo "$ssh_key" > /home/pwuser/ns8-key
set -x
pip install -r /home/pwuser/ns8-module/tests/pythonreq.txt
mkdir ~/outputs
cd /home/pwuser/ns8-module
robot -v NODE_ADDR:${LEADER_NODE} \
-v SSH_KEYFILE:/home/pwuser/ns8-key \
-d ~/outputs /home/pwuser/ns8-module/tests/
set -e
echo "$ssh_key" > /home/pwuser/ns8-key
pip install -q -r /home/pwuser/ns8-module/tests/pythonreq.txt
mkdir ~/outputs
cd /home/pwuser/ns8-module
exec robot -v NODE_ADDR:${LEADER_NODE} \
-v IMAGE_URL:${IMAGE_URL} \
-v SSH_KEYFILE:/home/pwuser/ns8-key \
--name "$(basename $PWD)" \
--skiponfailure unstable \
-d ~/outputs ${@} /home/pwuser/ns8-module/tests/
EOF

tests_res=$?

podman cp rf-core-runner:/home/pwuser/outputs tests/
podman stop rf-core-runner
podman rm rf-core-runner

exit ${tests_res}
2 changes: 1 addition & 1 deletion tests/api.resource
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Run task
ELSE
${response} = Set Variable ${stdout}
END
[Return] ${response}
RETURN ${response}
12 changes: 2 additions & 10 deletions tests/pythonreq.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
robotframework==4.1.2
robotframework-sshlibrary==3.8.0
robotframework-requests==0.9.2
bcrypt==3.2.0
cffi==1.15.0
cryptography==36.0.1
paramiko==2.9.2
pycparser==2.21
pynacl==1.5.0
scp==0.14.2
robotframework
robotframework-sshlibrary

0 comments on commit 44be018

Please sign in to comment.