From 30c8c7b29cfd9b844e3333bac944f119080e6397 Mon Sep 17 00:00:00 2001 From: pwalczysko Date: Tue, 19 Nov 2024 17:08:20 +0000 Subject: [PATCH] Add tests --- molecule/ome-demoserver/molecule.yml | 1 + molecule/tests/test_default.py | 33 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 molecule/tests/test_default.py diff --git a/molecule/ome-demoserver/molecule.yml b/molecule/ome-demoserver/molecule.yml index 4ad4b21c..48da6536 100644 --- a/molecule/ome-demoserver/molecule.yml +++ b/molecule/ome-demoserver/molecule.yml @@ -61,3 +61,4 @@ scenario: - destroy verifier: name: testinfra + directory: ../tests/ diff --git a/molecule/tests/test_default.py b/molecule/tests/test_default.py new file mode 100644 index 00000000..b534293c --- /dev/null +++ b/molecule/tests/test_default.py @@ -0,0 +1,33 @@ +import os +import pytest +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + +OMERO = '/opt/omero/server/OMERO.server/bin/omero' +OMERO_LOGIN = '-C -s localhost -u root -w omero' + + +@pytest.mark.parametrize("name", [ + 'nginx', + 'omero-server', + 'omero-web', + 'postgresql-16', +]) +def test_service_running_and_enabled(host, name): + service = host.service(name) + assert service.is_running + assert service.is_enabled + + +def test_omero_login(host): + with host.sudo('omero-server'): + host.check_output( + '/opt/omero/server/OMERO.server/bin/omero ' + 'login -C -s localhost -u root -w omero') + + +def test_omero_nginx_ssl(host): + out = host.check_output('curl -fkI https://localhost/') + assert 'Location: /webclient/' in out