Skip to content

Commit d865c39

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

File tree

4 files changed

+69
-36
lines changed

4 files changed

+69
-36
lines changed

.github/workflows/test-module.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +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-
coremodules: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}"
23-
args: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}"
24-
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 }}
2552
debug_shell: ${{ github.event.inputs.debug_shell == 'true' || false }}
2653
secrets:
2754
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: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
# SPDX-License-Identifier: GPL-3.0-or-later
66
#
77

8-
#
9-
# Hint: access the test logs on HTTP port 8000 with this command:
10-
#
11-
# python -mhttp.server -d tests/outputs/ 8000 &
12-
#
13-
14-
set -e
8+
set -e -a
159

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

@@ -20,30 +14,31 @@ IMAGE_URL="${2:?missing IMAGE_URL argument}"
2014
shift 2
2115

2216
ssh_key="$(< $SSH_KEYFILE)"
17+
venvroot=/usr/local/venv
2318

24-
cleanup() {
25-
set +e
26-
podman cp rf-core-runner:/home/pwuser/outputs tests/
27-
podman stop rf-core-runner
28-
podman rm rf-core-runner
29-
}
30-
31-
trap cleanup EXIT
3219
podman run -i \
33-
--network=host \
34-
--volume=.:/home/pwuser/ns8-module:z \
35-
--volume=site-packages:/home/pwuser/.local/lib/python3.12/site-packages:z \
36-
--name rf-core-runner ghcr.io/marketsquare/robotframework-browser/rfbrowser-stable:19.1.2 \
37-
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'
3829
set -e
39-
echo "$ssh_key" > /home/pwuser/ns8-key
40-
pip install -q -r /home/pwuser/ns8-module/tests/pythonreq.txt
41-
mkdir ~/outputs
42-
cd /home/pwuser/ns8-module
43-
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} \
4439
-v IMAGE_URL:${IMAGE_URL} \
45-
-v SSH_KEYFILE:/home/pwuser/ns8-key \
46-
--name "$(basename $PWD)" \
40+
-v SSH_KEYFILE:/tmp/idssh \
41+
--name traefik \
4742
--skiponfailure unstable \
48-
-d ~/outputs ${@} /home/pwuser/ns8-module/tests/
43+
-d tests/outputs "${@}" tests/
4944
EOF

tests/__init__.robot

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Suite Teardown Tear down connection and test suite tools
88
${SSH_KEYFILE} %{HOME}/.ssh/id_ecdsa
99
${NODE_ADDR} 127.0.0.1
1010
${MID} traefik1
11+
${JOURNAL_SINCE} 0
12+
${SCENARIO} install
13+
${IMAGE_URL} ghcr.io/nethserver/traefik:latest
1114

1215
*** Keywords ***
1316
Connect to the node
@@ -21,6 +24,7 @@ Setup connection and test suite tools
2124
Connect to the node
2225
Save the journal begin timestamp
2326
Set Global Variable ${MID} ${MID}
27+
Run scenario
2428

2529
Tear down connection and test suite tools
2630
Collect the suite journal
@@ -30,6 +34,13 @@ Save the journal begin timestamp
3034
Set Global Variable ${JOURNAL_SINCE} ${tsnow}
3135

3236
Collect the suite journal
33-
Execute Command printf "Test suite starts at %s\n" "$(date -d @${JOURNAL_SINCE})" >>journal-dump.log
37+
Execute Command printf "Test suite starts at %s\n" "$(date -d @${JOURNAL_SINCE})" >journal-dump.log
3438
Execute Command journalctl >>journal-dump.log
3539
SSHLibrary.Get File journal-dump.log ${OUTPUT DIR}/journal-${SUITE NAME}.log
40+
41+
Run scenario
42+
Log Scenario ${SCENARIO} with ${IMAGE_URL} console=${True}
43+
IF r'${SCENARIO}' == 'update'
44+
${out} ${rc} = Execute Command api-cli run update-module --data '{"force":true,"module_url":"${IMAGE_URL}","instances":["${MID}"]}' return_rc=${True}
45+
Should Be Equal As Integers ${rc} 0 action update-module ${IMAGE_URL} failed
46+
END

0 commit comments

Comments
 (0)