Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alain Takoudjou
slapos
Commits
f8815f4f
Commit
f8815f4f
authored
Jan 02, 2023
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Plain Diff
software/mosquitto: Added tests ...
See merge request
!1303
parents
0cf70a6e
1d83b3aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
185 additions
and
2 deletions
+185
-2
component/mosquitto/buildout.cfg
component/mosquitto/buildout.cfg
+8
-0
software/mosquitto/test/README.md
software/mosquitto/test/README.md
+1
-0
software/mosquitto/test/setup.py
software/mosquitto/test/setup.py
+28
-0
software/mosquitto/test/test.py
software/mosquitto/test/test.py
+140
-0
software/slapos-sr-testing/software.cfg
software/slapos-sr-testing/software.cfg
+8
-2
No files found.
component/mosquitto/buildout.cfg
View file @
f8815f4f
[buildout]
extends =
../cmake/buildout.cfg
../openssl/buildout.cfg
../libxslt/buildout.cfg
[mosquitto]
recipe = slapos.recipe.cmmi
...
...
@@ -9,5 +11,11 @@ md5sum = 22b7a8b05caa692cb22496b791529193
configure-command =
${cmake:location}/bin/cmake
configure-options =
-DDOCUMENTATION=OFF
-DWITH_CJSON=no
-DCMAKE_INSTALL_PREFIX=@@LOCATION@@
-DOPENSSL_ROOT_DIR=${openssl:location}
-DOPENSSL_INCLUDE_DIR=${openssl:location}/include
environment =
PATH=${openssl:location}/bin:${libxslt:location}/bin:%(PATH)s
LDFLAGS=-L${openssl:location}/lib -Wl,-rpath=${openssl:location}/lib -Wl,-rpath=@@LOCATION@@/lib
software/mosquitto/test/README.md
0 → 100644
View file @
f8815f4f
Tests for Mosquitto software release
software/mosquitto/test/setup.py
0 → 100644
View file @
f8815f4f
from
setuptools
import
setup
,
find_packages
version
=
"0.0.1.dev0"
name
=
"slapos.test.mosquitto"
with
open
(
"README.md"
)
as
f
:
long_description
=
f
.
read
()
setup
(
name
=
name
,
version
=
version
,
description
=
"Test for SlapOS Mosquitto"
,
long_description
=
long_description
,
long_description_content_type
=
"text/markdown"
,
maintainer
=
"Nexedi"
,
maintainer_email
=
"info@nexedi.com"
,
url
=
"https://lab.nexedi.com/nexedi/slapos"
,
packages
=
find_packages
(),
install_requires
=
[
"slapos.core"
,
"slapos.libnetworkcache"
,
"erp5.util"
,
"requests"
,
"paho-mqtt"
,
],
zip_safe
=
True
,
test_suite
=
"test"
,
)
software/mosquitto/test/test.py
0 → 100644
View file @
f8815f4f
import
os
import
time
import
paho.mqtt.client
as
mqtt
import
paho.mqtt.publish
as
publish
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
setUpModule
,
SlapOSInstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)))
class
TestMosquitto
(
SlapOSInstanceTestCase
):
"""
Test if mosquitto service can publish and subscribe
to specific topics with custom authentication ...
"""
def
on_connect
(
self
,
client
,
userdata
,
flags
,
rc
):
client
.
subscribe
(
"test"
)
self
.
code
=
rc
def
on_message
(
self
,
client
,
userdata
,
msg
):
self
.
topic
=
msg
.
topic
self
.
payload
=
str
(
msg
.
payload
.
decode
())
def
test_topic_ipv4
(
self
):
host
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"ipv4"
]
username
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"username"
]
password
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"password"
]
topic
=
"test"
payload
=
"Hello, World!"
client
=
mqtt
.
Client
()
client
.
on_connect
=
self
.
on_connect
client
.
on_message
=
self
.
on_message
client
.
username_pw_set
(
username
=
f"
{
username
}
"
,
password
=
f"
{
password
}
"
)
client
.
connect
(
f"
{
host
}
"
,
1883
,
10
)
client
.
loop_start
()
publish
.
single
(
topic
=
topic
,
payload
=
payload
,
hostname
=
f"
{
host
}
"
,
auth
=
{
"username"
:
f"
{
username
}
"
,
"password"
:
f"
{
password
}
"
}
)
time
.
sleep
(
10
)
client
.
loop_stop
()
self
.
assertEqual
(
self
.
code
,
0
)
self
.
assertEqual
(
self
.
topic
,
topic
)
def
test_payload_ipv4
(
self
):
host
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"ipv4"
]
username
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"username"
]
password
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"password"
]
topic
=
"test"
payload
=
"Hello, World!"
client
=
mqtt
.
Client
()
client
.
on_connect
=
self
.
on_connect
client
.
on_message
=
self
.
on_message
client
.
username_pw_set
(
username
=
f"
{
username
}
"
,
password
=
f"
{
password
}
"
)
client
.
connect
(
f"
{
host
}
"
,
1883
,
10
)
client
.
loop_start
()
publish
.
single
(
topic
=
topic
,
payload
=
payload
,
hostname
=
f"
{
host
}
"
,
auth
=
{
"username"
:
f"
{
username
}
"
,
"password"
:
f"
{
password
}
"
}
)
time
.
sleep
(
10
)
client
.
loop_stop
()
self
.
assertEqual
(
self
.
code
,
0
)
self
.
assertEqual
(
self
.
payload
,
payload
)
def
test_topic_ipv6
(
self
):
host
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"ipv6"
]
username
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"username"
]
password
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"password"
]
topic
=
"test"
payload
=
"Hello, World!"
client
=
mqtt
.
Client
()
client
.
on_connect
=
self
.
on_connect
client
.
on_message
=
self
.
on_message
client
.
username_pw_set
(
username
=
f"
{
username
}
"
,
password
=
f"
{
password
}
"
)
client
.
connect
(
f"
{
host
}
"
,
1883
,
10
)
client
.
loop_start
()
publish
.
single
(
topic
=
topic
,
payload
=
payload
,
hostname
=
f"
{
host
}
"
,
auth
=
{
"username"
:
f"
{
username
}
"
,
"password"
:
f"
{
password
}
"
}
)
time
.
sleep
(
10
)
client
.
loop_stop
()
self
.
assertEqual
(
self
.
code
,
0
)
self
.
assertEqual
(
self
.
topic
,
topic
)
def
test_payload_ipv6
(
self
):
host
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"ipv6"
]
username
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"username"
]
password
=
self
.
computer_partition
.
getConnectionParameterDict
()[
"password"
]
topic
=
"test"
payload
=
"Hello, World!"
client
=
mqtt
.
Client
()
client
.
on_connect
=
self
.
on_connect
client
.
on_message
=
self
.
on_message
client
.
username_pw_set
(
username
=
f"
{
username
}
"
,
password
=
f"
{
password
}
"
)
client
.
connect
(
f"
{
host
}
"
,
1883
,
10
)
client
.
loop_start
()
publish
.
single
(
topic
=
topic
,
payload
=
payload
,
hostname
=
f"
{
host
}
"
,
auth
=
{
"username"
:
f"
{
username
}
"
,
"password"
:
f"
{
password
}
"
}
)
time
.
sleep
(
10
)
client
.
loop_stop
()
self
.
assertEqual
(
self
.
code
,
0
)
self
.
assertEqual
(
self
.
payload
,
payload
)
software/slapos-sr-testing/software.cfg
View file @
f8815f4f
...
...
@@ -161,7 +161,6 @@ setup = ${slapos-repository:location}/software/hugo/test/
egg = slapos.test.matomo
setup = ${slapos-repository:location}/software/matomo/test/
[slapos.test.jupyter-setup]
<= setup-develop-egg
egg = slapos.test.jupyter
...
...
@@ -242,6 +241,11 @@ setup = ${slapos-repository:location}/software/erp5testnode/test/
egg = slapos.test.beremiz_ide
setup = ${slapos-repository:location}/software/beremiz-ide/test/
[slapos.test.mosquitto-setup]
<= setup-develop-egg
egg = slapos.test.mosquitto
setup = ${slapos-repository:location}/software/mosquitto/test/
[slapos.test.peertube-setup]
<= setup-develop-egg
egg = slapos.test.peertube
...
...
@@ -318,6 +322,7 @@ eggs +=
${slapos.test.matomo-setup:egg}
${slapos.test.metabase-setup:egg}
${slapos.test.monitor-setup:egg}
${slapos.test.mosquitto-setup:egg}
${slapos.test.nextcloud-setup:egg}
${slapos.test.nginx-push-stream-setup:egg}
${slapos.test.ors-amarisoft-setup:egg}
...
...
@@ -382,7 +387,6 @@ context =
tests =
json-schemas ${slapos.cookbook-setup:setup}
backupserver ${slapos.test.backupserver-setup:setup}
beremiz-ide ${slapos.test.beremiz-ide-setup:setup}
caddy-frontend ${slapos.test.caddy-frontend-setup:setup}
...
...
@@ -409,6 +413,7 @@ tests =
matomo ${slapos.test.matomo-setup:setup}
metabase ${slapos.test.metabase-setup:setup}
monitor ${slapos.test.monitor-setup:setup}
mosquitto ${slapos.test.mosquitto-setup:setup}
nextcloud ${slapos.test.nextcloud-setup:setup}
nginx-push-stream ${slapos.test.nginx-push-stream-setup:setup}
ors-amarisoft ${slapos.test.ors-amarisoft-setup:setup}
...
...
@@ -444,6 +449,7 @@ mysqlclient = 2.1.1
pexpect = 4.8.0
ptyprocess = 0.6.0
psycopg2 = 2.8.6
paho-mqtt = 1.5.0
# Patched eggs
PyPDF2 = 1.26.0+SlapOSPatched001
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment