Skip to content

Commit 22c4362

Browse files
chore: enable renovate automerge
1 parent 42d5989 commit 22c4362

File tree

6 files changed

+134
-40
lines changed

6 files changed

+134
-40
lines changed

.github/workflows/clean-registry.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ jobs:
1212
steps:
1313
- uses: NethServer/ns8-github-actions/.github/actions/delete-image@v1
1414
with:
15-
images: "kickstart"
15+
images: "prometheus"
1616
delete_image_token: ${{ secrets.IMAGES_CLEANUP_TOKEN }}

.github/workflows/test-module.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,53 @@ name: Test module
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
debug_shell:
7+
description: "Debug shell"
8+
required: true
9+
type: boolean
510
workflow_run:
611
workflows: ["Publish images"]
712
types: [completed]
813

914
jobs:
1015
module:
1116
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == '' }}
12-
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+
1335
run_tests:
14-
needs: module
15-
uses: NethServer/ns8-github-actions/.github/workflows/test-on-ubuntu-runner.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
1642
with:
17-
args: "ghcr.io/${{needs.module.outputs.owner}}/${{needs.module.outputs.name}}:${{needs.module.outputs.tag}}"
18-
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 }}
52+
debug_shell: ${{ github.event.inputs.debug_shell == 'true' || false }}
53+
secrets:
54+
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: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
#!/bin/bash
22

3-
LEADER_NODE=$1
4-
IMAGE_URL=$2
5-
SSH_KEYFILE=${SSH_KEYFILE:-$HOME/.ssh/id_rsa}
3+
#
4+
# Copyright (C) 2025 Nethesis S.r.l.
5+
# SPDX-License-Identifier: GPL-3.0-or-later
6+
#
67

7-
ssh_key="$(cat $SSH_KEYFILE)"
8+
set -e -a
89

9-
podman run -i \
10-
-v .:/home/pwuser/ns8-module:z \
11-
--name rf-core-runner ghcr.io/marketsquare/robotframework-browser/rfbrowser-stable:19.1.2 \
12-
bash -l -s <<EOF
13-
set -e
14-
echo "$ssh_key" > /home/pwuser/ns8-key
15-
set -x
16-
pip install -r /home/pwuser/ns8-module/tests/pythonreq.txt
17-
mkdir ~/outputs
18-
cd /home/pwuser/ns8-module
19-
robot -v NODE_ADDR:${LEADER_NODE} \
20-
-v IMAGE_URL:${IMAGE_URL} \
21-
-v SSH_KEYFILE:/home/pwuser/ns8-key \
22-
-d ~/outputs /home/pwuser/ns8-module/tests/
23-
EOF
10+
SSH_KEYFILE=${SSH_KEYFILE:-$HOME/.ssh/id_rsa}
2411

25-
tests_res=$?
12+
LEADER_NODE="${1:?missing LEADER_NODE argument}"
13+
IMAGE_URL="${2:?missing IMAGE_URL argument}"
14+
shift 2
2615

27-
podman cp rf-core-runner:/home/pwuser/outputs tests/
28-
podman stop rf-core-runner
29-
podman rm rf-core-runner
16+
ssh_key="$(< $SSH_KEYFILE)"
17+
venvroot=/usr/local/venv
3018

31-
exit ${tests_res}
19+
podman run -i \
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'
29+
set -e
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} \
39+
-v IMAGE_URL:${IMAGE_URL} \
40+
-v SSH_KEYFILE:/tmp/idssh \
41+
--name prometheus \
42+
--skiponfailure unstable \
43+
-d tests/outputs "${@}" tests/
44+
EOF

tests/api.resource

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*** Settings ***
2+
Library SSHLibrary
3+
4+
*** Keywords ***
5+
Run task
6+
[Arguments] ${action} ${input} ${decode_json}=${TRUE} ${rc_expected}=0
7+
${stdout} ${stderr} ${rc} = Execute Command api-cli run ${action} --data '${input}' return_stdout=True return_stderr=True return_rc=True
8+
Should Be Equal As Integers ${rc_expected} ${rc} Run task ${action} failed!${\n}${stderr}
9+
IF ${decode_json} and len($stdout) > 0
10+
${response} = Evaluate json.loads('''${stdout}''') modules=json
11+
ELSE
12+
${response} = Set Variable ${stdout}
13+
END
14+
RETURN ${response}

tests/prometheus.robot

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,54 @@
11
*** Settings ***
22
Library SSHLibrary
3+
Resource api.resource
4+
5+
*** Variables ***
6+
${IMAGE_URL} ghcr.io/nethserver/prometheus:latest
7+
${SCENARIO} install
8+
9+
*** Keywords ***
10+
Retry test
11+
[Arguments] ${keyword}
12+
Wait Until Keyword Succeeds 60 seconds 1 second ${keyword}
13+
14+
Backend URL is reachable
15+
${rc} = Execute Command curl -f ${backend_url}
16+
... return_rc=True return_stdout=False
17+
Should Be Equal As Integers ${rc} 0
18+
319

420
*** Test Cases ***
5-
Check if prometheus is installed correctly
6-
${output} ${rc} = Execute Command add-module ${IMAGE_URL} 1
21+
Add module for ${SCENARIO} scenario
22+
IF r'${SCENARIO}' == 'update'
23+
Set Local Variable ${iurl} prometheus
24+
ELSE
25+
Set Local Variable ${iurl} ${IMAGE_URL}
26+
END
27+
${output} ${rc} = Execute Command add-module ${iurl} 1
728
... return_rc=True
829
Should Be Equal As Integers ${rc} 0
930
&{output} = Evaluate ${output}
1031
Set Suite Variable ${module_id} ${output.module_id}
1132

12-
Check if prometheus can be configured
13-
${rc} = Execute Command api-cli run module/${module_id}/configure-module --data '{}'
14-
... return_rc=True return_stdout=False
15-
Should Be Equal As Integers ${rc} 0
33+
Configure module
34+
# Assuming the test is running on a single node cluster
35+
${response} = Run task module/traefik1/get-route {"instance":"${module_id}"}
36+
Set Suite Variable ${backend_url} ${response['url']}
37+
38+
Update module
39+
Retry test Backend URL is reachable
40+
Log Scenario ${SCENARIO} with ${IMAGE_URL} console=${True}
41+
IF r'${SCENARIO}' == 'update'
42+
${out} ${rc} = Execute Command api-cli run update-module --data '{"force":true,"module_url":"${IMAGE_URL}","instances":["${module_id}"]}' return_rc=${True}
43+
Should Be Equal As Integers ${rc} 0 action update-module ${IMAGE_URL} failed
44+
END
1645

1746
Check if prometheus works as expected
18-
${rc} = Execute Command sleep 10 && curl -f http://127.0.0.1/prometheus/
19-
... return_rc=True return_stdout=False
20-
Should Be Equal As Integers ${rc} 0
47+
Retry test Backend URL is reachable
48+
49+
Verify prometheus frontend title
50+
${output} = Execute Command curl -L -s ${backend_url}
51+
Should Contain ${output} <title>Prometheus
2152

2253
Check if prometheus is removed correctly
2354
${rc} = Execute Command remove-module --no-preserve ${module_id}

0 commit comments

Comments
 (0)