initial confirmation with some service and socket tests

Signed-off-by: Arthur Lutz <arthur@lutz.im>
This commit is contained in:
Arthur Lutz 2019-11-24 23:27:21 +01:00
parent 09c9638032
commit f0c678fb8b
10 changed files with 103 additions and 0 deletions

3
.gitignore vendored
View file

@ -15,3 +15,6 @@
*.save
*.autosav
*.autosave
junit-*.xml
.kitchen
tests/__pycache__/

View file

@ -35,6 +35,27 @@ The [post-installation](https://yunohost.org/#/postinstall) will need to be perf
The ```-d <DISTRIB>``` switch is mostly for advanced users who want to install the bleeding edge versions of YunoHost packages.
## Test with Kitchen
To launch tests and an development environment :
* install VirtualBox https://www.virtualbox.org/
* install Vagrant https://www.vagrantup.com/
* install Kitchen https://kitchen.ci/
* install testinfra with paramiko https://testinfra.readthedocs.io/
Run :
```
kitchen test
```
To login to your environment :
```
kitchen login
```
## Issues, Feedback
Please report issues here : https://github.com/YunoHost/issues/issues

1
bootstrap.sh Normal file
View file

@ -0,0 +1 @@
cd /vagrant && bash install_yunohost -a

24
kitchen.yml Normal file
View file

@ -0,0 +1,24 @@
---
driver:
name: vagrant
synced_folders:
- [".", "/vagrant"]
network:
- ["forwarded_port", {guest: 80, host: 8080}]
- ["forwarded_port", {guest: 443, host: 8443}]
provisioner:
name: shell
verifier:
name: inspec
platforms:
- name: debian/buster64
suites:
- name: default
verifier:
name: shell
command: py.test --hosts="paramiko://${KITCHEN_USERNAME}@${KITCHEN_HOSTNAME}:${KITCHEN_PORT}?ssh_identity_file=${KITCHEN_SSH_KEY}" --junit-xml "junit-${KITCHEN_INSTANCE}.xml" "tests/"

11
tests/test_metronome.py Normal file
View file

@ -0,0 +1,11 @@
def test_metronome_running_and_enabled(host):
metronome = host.service("metronome")
assert metronome.is_running
assert metronome.is_enabled
def test_metronome_sockets(host):
# FIXME TODO - no ipv6 ?
assert host.socket("tcp://0.0.0.0:5222").is_listening
assert host.socket("tcp://0.0.0.0:5269").is_listening

9
tests/test_nginx.py Normal file
View file

@ -0,0 +1,9 @@
def test_nginx_running_and_enabled(host):
nginx = host.service("nginx")
assert nginx.is_running
assert nginx.is_enabled
def test_nginx_sockets(host):
assert host.socket("tcp://80").is_listening
assert host.socket("tcp://443").is_listening

10
tests/test_rspamd.py Normal file
View file

@ -0,0 +1,10 @@
def test_rspamd_running_and_enabled(host):
rspamd = host.service("rspamd")
assert rspamd.is_running
assert rspamd.is_enabled
def test_rspamd_sockets(host):
assert host.socket("tcp://127.0.0.1:11332").is_listening
assert host.socket("tcp://127.0.0.1:11333").is_listening
assert host.socket("tcp://127.0.0.1:11334").is_listening

8
tests/test_slapd.py Normal file
View file

@ -0,0 +1,8 @@
def test_slapd_running_and_enabled(host):
ldap = host.service("slapd")
assert ldap.is_running
assert ldap.is_enabled
def test_slapd_sockets(host):
assert host.socket("tcp://636").is_listening

8
tests/test_ssh.py Normal file
View file

@ -0,0 +1,8 @@
def test_ssh_running_and_enabled(host):
ssh = host.service("ssh")
assert ssh.is_running
assert ssh.is_enabled
def test_ssh_sockets(host):
assert host.socket("tcp://22").is_listening

View file

@ -0,0 +1,8 @@
def test_yunohost_api_running_and_enabled(host):
yunohost_api = host.service("yunohost-api")
assert yunohost_api.is_running
assert yunohost_api.is_enabled
def test_yunohost_api_sockets(host):
assert host.socket("tcp://127.0.0.1:6787").is_listening