Skip to content

Commit 930239c

Browse files
committed
add system tests
1 parent cacc856 commit 930239c

File tree

8 files changed

+216
-0
lines changed

8 files changed

+216
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ src/tedge/bin/tedge
99
tmp/
1010
/tedge-*
1111
binaries/zig-mosquitto/
12+
log.html
13+
output.xml
14+
report.html

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3",
3+
"robot.language-server.python": "${workspaceFolder}/.venv/bin/python3",
4+
"robot.python.executable": "${workspaceFolder}/.venv/bin/python3",
5+
"robot.pythonpath": [
6+
"${workspaceFolder}/tests/RobotFramework/.venv/bin/python3"
7+
],
8+
"python.envFile": "${workspaceFolder}/.env"
9+
}

justfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,17 @@ PACKAGE := "tedge-standalone"
44
# Build static binaries and create the tarball package
55
build target target_name *args:
66
./scripts/build.sh --target {{target}} --target-name {{target_name}} --package {{PACKAGE}} {{args}}
7+
8+
# Build artifacts to be used in system tests
9+
build-test:
10+
just build aarch64-linux-musl arm64-noupx --skip-upx
11+
just build aarch64-linux-musl arm64
12+
13+
# Install python virtual environment
14+
venv:
15+
[ -d .venv ] || python3 -m venv .venv
16+
./.venv/bin/pip3 install -r tests/requirements.txt
17+
18+
# Run tests
19+
test *args='':
20+
./.venv/bin/python3 -m robot.run --outputdir output {{args}} tests
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
*** Settings ***
2+
Resource ./resources/common.resource
3+
Library Cumulocity
4+
Library DeviceLibrary
5+
6+
Test Teardown Stop Device
7+
8+
*** Test Cases ***
9+
10+
Install From File With UPX
11+
${file}= Set Variable tedge-standalone-arm64.tar.gz
12+
Setup Device With Binaries image=busybox file=${file} target_dir=/root
13+
Install Standalone Binary ${file} target_dir=/root
14+
Bootstrap Using Basic Authentication
15+
16+
Install From File Without UPX
17+
${file}= Set Variable tedge-standalone-arm64-noupx.tar.gz
18+
Setup Device With Binaries image=busybox file=${file} target_dir=/root
19+
Install Standalone Binary ${file} target_dir=/root
20+
Bootstrap Using Basic Authentication
21+
22+
Install From URL With UPX
23+
Skip TODO
24+
Setup Device image=busybox
25+
DeviceLibrary.Execute Command cmd=wget -q -O - https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/install.sh | sh -s -- --install-path /data
26+
Bootstrap Using Basic Authentication
27+
28+
Install From URL Without UPX
29+
Skip TODO
30+
Setup Device image=busybox
31+
DeviceLibrary.Execute Command cmd=wget -q -O - https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/install.sh | sh -s -- --install-path /data --no-upx
32+
Bootstrap Using Basic Authentication
33+
34+
35+
*** Keywords ***
36+
37+
Bootstrap Using Basic Authentication
38+
[Arguments] ${install_path}=/data
39+
40+
${credentials}= Cumulocity.Bulk Register Device With Basic Auth external_id=${DEVICE_ID}
41+
${c8y_domain}= Cumulocity.Get Domain
42+
DeviceLibrary.Execute Command cmd=${install_path}/tedge/bootstrap.sh --c8y-url '${c8y_domain}' --device-user ${credentials.username} --device-password '${credentials.password}'
43+
44+
Cumulocity.Device Should Exist ${DEVICE_ID}
45+
Cumulocity.Device Should Have Event/s expected_text=tedge started up.* type=startup
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
*** Settings ***
2+
Resource ./resources/common.resource
3+
Library Cumulocity
4+
Library DeviceLibrary
5+
6+
Test Teardown Stop Device
7+
8+
*** Test Cases ***
9+
10+
Install From File With UPX
11+
${file}= Set Variable tedge-standalone-arm64.tar.gz
12+
Setup Device With Binaries image=busybox file=${file} target_dir=/root
13+
Install Standalone Binary ${file} target_dir=/root
14+
Bootstrap Using Certificate Authority
15+
16+
Install From File Without UPX
17+
${file}= Set Variable tedge-standalone-arm64-noupx.tar.gz
18+
Setup Device With Binaries image=busybox file=${file} target_dir=/root
19+
Install Standalone Binary ${file} target_dir=/root
20+
Bootstrap Using Certificate Authority
21+
22+
Install From URL With UPX
23+
Skip TODO
24+
Setup Device image=busybox
25+
DeviceLibrary.Execute Command cmd=wget -q -O - https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/install.sh | sh -s -- --install-path /data
26+
Bootstrap Using Certificate Authority
27+
28+
Install From URL Without UPX
29+
Skip TODO
30+
Setup Device image=busybox
31+
DeviceLibrary.Execute Command cmd=wget -q -O - https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/install.sh | sh -s -- --install-path /data --no-upx
32+
Bootstrap Using Certificate Authority
33+
34+
35+
Install on SysVInit Device
36+
${file}= Set Variable tedge-standalone-arm64-noupx.tar.gz
37+
Setup SysVInit Device With Binaries image=debian:12 file=${file} target_dir=/root
38+
Install Standalone Binary ${file} target_dir=/root
39+
Bootstrap Using Certificate Authority
40+
41+
*** Keywords ***
42+
43+
Bootstrap Using Certificate Authority
44+
[Arguments] ${install_path}=/data
45+
46+
${credentials}= Cumulocity.Bulk Register Device With Cumulocity CA external_id=${DEVICE_ID}
47+
${c8y_domain}= Cumulocity.Get Domain
48+
DeviceLibrary.Execute Command cmd=/data/tedge/bootstrap.sh --c8y-url '${c8y_domain}' --ca c8y --device-id '${DEVICE_ID}' --one-time-password '${credentials.one_time_password}'
49+
50+
Cumulocity.Device Should Exist ${DEVICE_ID}
51+
Cumulocity.Device Should Have Event/s expected_text=tedge started up.* type=startup
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
*** Settings ***
2+
Resource ./resources/common.resource
3+
Library Cumulocity
4+
Library DeviceLibrary
5+
6+
Test Teardown Stop Device
7+
8+
*** Test Cases ***
9+
10+
Install From File With UPX
11+
${file}= Set Variable tedge-standalone-arm64.tar.gz
12+
Setup Device With Binaries image=busybox file=${file} target_dir=/root
13+
Install Standalone Binary ${file} target_dir=/root
14+
Bootstrap Using Self-Signed Certificate
15+
16+
Install From File Without UPX
17+
${file}= Set Variable tedge-standalone-arm64-noupx.tar.gz
18+
Setup Device With Binaries image=busybox file=${file} target_dir=/root
19+
Install Standalone Binary ${file} target_dir=/root
20+
Bootstrap Using Self-Signed Certificate
21+
22+
Install From URL With UPX
23+
Skip TODO
24+
Setup Device image=busybox
25+
DeviceLibrary.Execute Command cmd=wget -q -O - https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/install.sh | sh -s -- --install-path /data
26+
Bootstrap Using Self-Signed Certificate
27+
28+
Install From URL Without UPX
29+
Skip TODO
30+
Setup Device image=busybox
31+
DeviceLibrary.Execute Command cmd=wget -q -O - https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/install.sh | sh -s -- --install-path /data --no-upx
32+
Bootstrap Using Self-Signed Certificate
33+
34+
35+
*** Keywords ***
36+
37+
Bootstrap Using Self-Signed Certificate
38+
[Arguments] ${install_path}=/data
39+
40+
${c8y_domain}= Cumulocity.Get Domain
41+
DeviceLibrary.Execute Command cmd=sh -c "env C8Y_USER='${C8Y_CONFIG.username}' C8Y_PASSWORD='${C8Y_CONFIG.password}' /data/tedge/bootstrap.sh --c8y-url '${c8y_domain}' --ca self-signed --device-id '${DEVICE_ID}'"
42+
43+
Cumulocity.Device Should Exist ${DEVICE_ID}
44+
Cumulocity.Device Should Have Event/s expected_text=tedge started up.* type=startup

tests/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
robotframework~=7.0.0
2+
robotframework-c8y @ git+https://github.com/reubenmiller/robotframework-c8y.git@0.42.4
3+
robotframework-devicelibrary[docker] @ git+https://github.com/reubenmiller/robotframework-devicelibrary.git@1.18.0
4+
robotframework-debuglibrary~=2.5.0

tests/resources/common.resource

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
*** Settings ***
2+
Library Cumulocity
3+
Library DeviceLibrary bootstrap_script=/dev/null
4+
5+
6+
*** Variables ***
7+
# Cumulocity settings
8+
&{C8Y_CONFIG}
9+
... host=%{C8Y_BASEURL= }
10+
... username=%{C8Y_USER= }
11+
... password=%{C8Y_PASSWORD= }
12+
... tenant=%{C8Y_TENANT= }
13+
14+
# Docker adapter settings (to control which image is used in the system tests).
15+
# The user just needs to set the IMAGE env variable
16+
&{DOCKER_CONFIG} image=%{TEST_IMAGE=}
17+
18+
19+
*** Keywords ***
20+
Setup Device
21+
[Arguments] ${image}=
22+
${DEVICE_ID}= DeviceLibrary.Setup skip_bootstrap=${True} image=${image}
23+
Set Suite Variable ${DEVICE_ID}
24+
25+
26+
Setup Device With Binaries
27+
[Arguments] ${image}= ${file}= ${target_dir}=/root
28+
${DEVICE_ID}= DeviceLibrary.Setup skip_bootstrap=${True} image=${image}
29+
Set Suite Variable ${DEVICE_ID}
30+
Transfer To Device ${CURDIR}/../../install.sh ${target_dir}/
31+
Transfer To Device ${CURDIR}/../../${file} ${target_dir}/
32+
33+
Setup SysVInit Device With Binaries
34+
[Arguments] ${image}=debian:12 ${file}= ${target_dir}=/root
35+
${DEVICE_ID}= DeviceLibrary.Setup skip_bootstrap=${True} image=${image}
36+
37+
Set Suite Variable ${DEVICE_ID}
38+
Transfer To Device ${CURDIR}/../../install.sh ${target_dir}/
39+
Transfer To Device ${CURDIR}/../../${file} ${target_dir}/
40+
41+
Install Standalone Binary
42+
[Arguments] ${file} ${target_dir}=/root
43+
DeviceLibrary.Execute Command cmd=${target_dir}/install.sh --file ${target_dir}/${file}
44+
45+
Stop Device
46+
Cumulocity.Delete Managed Object And Device User ${DEVICE_ID}

0 commit comments

Comments
 (0)