Skip to content

Commit 1b73613

Browse files
chore: test update scenario
- enable automerge - test both install and update scenarios - use vanilla robotframework for backend tests only
1 parent e971cf2 commit 1b73613

File tree

6 files changed

+78
-52
lines changed

6 files changed

+78
-52
lines changed

.github/workflows/test-module.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,41 @@ on:
1414
jobs:
1515
module:
1616
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == '' }}
17-
uses: NethServer/ns8-github-actions/.github/workflows/module-info.yml@main
17+
uses: NethServer/ns8-github-actions/.github/workflows/module-info.yml@v1
18+
19+
chooser:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
node_a: ${{ steps.pick.outputs.node_a }}
23+
node_b: ${{ steps.pick.outputs.node_b }}
24+
steps:
25+
- id: pick
26+
run: |
27+
if (( $GITHUB_RUN_NUMBER % 2 )); then
28+
echo "node_a=rl1" >> "$GITHUB_OUTPUT"
29+
echo "node_b=dn1" >> "$GITHUB_OUTPUT"
30+
else
31+
echo "node_a=dn1" >> "$GITHUB_OUTPUT"
32+
echo "node_b=rl1" >> "$GITHUB_OUTPUT"
33+
fi
34+
1835
run_tests:
19-
needs: module
20-
uses: NethServer/ns8-github-actions/.github/workflows/test-on-digitalocean-infra.yml@main
36+
needs: [module, chooser]
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
scenario: [install, update]
41+
uses: NethServer/ns8-github-actions/.github/workflows/test-on-digitalocean-infra.yml@v1
2142
with:
22-
args: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}"
23-
repo_ref: ${{needs.module.outputs.sha}}
43+
coremodules: ${{ matrix.scenario == 'install' && format('ghcr.io/{0}/{1}:{2}', needs.module.outputs.owner, needs.module.outputs.name, needs.module.outputs.tag) || '' }}
44+
leader_nodes: >-
45+
${{
46+
matrix.scenario == 'install'
47+
&& needs.chooser.outputs.node_a
48+
|| needs.chooser.outputs.node_b
49+
}}
50+
args: ${{ format('ghcr.io/{0}/{1}:{2} -v SCENARIO:{3}', needs.module.outputs.owner, needs.module.outputs.name, needs.module.outputs.tag, matrix.scenario) }}
51+
repo_ref: ${{ needs.module.outputs.sha }}
2452
debug_shell: ${{ github.event.inputs.debug_shell == 'true' || false }}
2553
secrets:
2654
do_token: ${{ secrets.do_token }}

renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
4-
"local>NethServer/.github:ns8"
4+
"local>NethServer/.github:ns8-automerge"
55
]
66
}

test-module.sh

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
#!/bin/bash
22

33
#
4-
# Copyright (C) 2024 Nethesis S.r.l.
4+
# Copyright (C) 2025 Nethesis S.r.l.
55
# SPDX-License-Identifier: GPL-3.0-or-later
66
#
77

8-
set -e
8+
set -e -a
99

10-
LEADER_NODE=$1
11-
IMAGE_URL=$2
12-
shift 2
1310
SSH_KEYFILE=${SSH_KEYFILE:-$HOME/.ssh/id_rsa}
1411

15-
ssh_key="$(< $SSH_KEYFILE)"
12+
LEADER_NODE="${1:?missing LEADER_NODE argument}"
13+
IMAGE_URL="${2:?missing IMAGE_URL argument}"
14+
shift 2
1615

17-
cleanup() {
18-
set +e
19-
podman cp rf-core-runner:/home/pwuser/outputs tests/
20-
podman stop rf-core-runner
21-
podman rm rf-core-runner
22-
}
16+
ssh_key="$(< $SSH_KEYFILE)"
17+
venvroot=/usr/local/venv
2318

24-
trap cleanup EXIT
2519
podman run -i \
26-
--network=host \
27-
-v .:/home/pwuser/ns8-module:z \
28-
--volume=site-packages:/home/pwuser/.local/lib/python3.8/site-packages:Z \
29-
--name rf-core-runner ghcr.io/marketsquare/robotframework-browser/rfbrowser-stable:19.1.1 \
30-
bash -l -s <<EOF
20+
--volume=.:/srv/source:z \
21+
--volume=rftest-cache:${venvroot}:z \
22+
--replace --name=rftest \
23+
--env=ssh_key \
24+
--env=venvroot \
25+
--env=LEADER_NODE \
26+
--env=IMAGE_URL \
27+
docker.io/python:3.11-alpine \
28+
ash -l -s -- "${@}" <<'EOF'
3129
set -e
32-
echo "$ssh_key" > /home/pwuser/ns8-key
33-
pip install -q -r /home/pwuser/ns8-module/tests/pythonreq.txt
34-
mkdir ~/outputs
35-
cd /home/pwuser/ns8-module
36-
exec robot -v NODE_ADDR:${LEADER_NODE} \
30+
echo "$ssh_key" > /tmp/idssh
31+
if [ ! -x ${venvroot}/bin/robot ] ; then
32+
python3 -mvenv ${venvroot} --upgrade
33+
${venvroot}/bin/pip3 install -q -r /srv/source/tests/pythonreq.txt
34+
fi
35+
cd /srv/source
36+
mkdir -vp tests/outputs/
37+
exec ${venvroot}/bin/robot \
38+
-v NODE_ADDR:${LEADER_NODE} \
3739
-v IMAGE_URL:${IMAGE_URL} \
38-
-v SSH_KEYFILE:/home/pwuser/ns8-key \
40+
-v SSH_KEYFILE:/tmp/idssh \
3941
--name loki \
4042
--skiponfailure unstable \
41-
-d ~/outputs ${@} /home/pwuser/ns8-module/tests/
43+
-d tests/outputs "${@}" tests/
4244
EOF
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
*** Settings ***
22
Library SSHLibrary
33

4-
*** Test Cases ***
5-
Module installation
6-
${output} ${rc} = Execute Command add-module ${IMAGE_URL} 1
7-
... return_rc=True
8-
Should Be Equal As Integers ${rc} 0
9-
&{output} = Evaluate ${output}
10-
Set Global Variable ${MID} ${output.module_id}
4+
*** Variables ***
5+
${MID} loki1
116

7+
*** Test Cases ***
128
Check if loki service is loaded correctly
139
${output} ${rc} = Execute Command runagent -m ${MID} systemctl --user show --property=LoadState loki
1410
... return_rc=True

tests/90__uninstall.robot

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/__init__.robot

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ Library DateTime
55
*** Variables ***
66
${SSH_KEYFILE} %{HOME}/.ssh/id_ecdsa
77
${NODE_ADDR} 127.0.0.1
8-
${MID} loki0
8+
${MID} loki1
99
${IMAGE_URL} ghcr.io/nethserver/loki:latest
10+
${JOURNAL_SINCE} 0
11+
${SCENARIO} install
1012

1113
*** Keywords ***
1214
Connect to the node
@@ -22,14 +24,24 @@ Save the journal begin timestamp
2224
Set Global Variable ${JOURNAL_SINCE} ${tsnow}
2325

2426
Collect the suite journal
25-
Execute Command journalctl -S @${JOURNAL_SINCE} >journal-dump.log
27+
Execute Command printf "Test suite starts at %s\n" "$(date -d @${JOURNAL_SINCE})" >journal-dump.log
28+
Execute Command journalctl >>journal-dump.log
2629
Get File journal-dump.log ${OUTPUT DIR}/journal-${SUITE NAME}.log
2730

31+
Run scenario
32+
Log Scenario ${SCENARIO} with ${IMAGE_URL} console=${True}
33+
IF r'${SCENARIO}' == 'update'
34+
${out} ${rc} = Execute Command api-cli run update-module --data '{"force":true,"module_url":"${IMAGE_URL}","instances":["${MID}"]}' return_rc=${True}
35+
Should Be Equal As Integers ${rc} 0 action update-module ${IMAGE_URL} failed
36+
END
37+
38+
2839
*** Settings ***
2940
Suite Setup Run Keywords
3041
... Connect to the Node
3142
... Wait until boot completes
3243
... Save the journal begin timestamp
44+
... Run scenario
3345

3446
Suite Teardown Run Keywords
3547
... Collect the suite journal

0 commit comments

Comments
 (0)