Skip to content

Commit

Permalink
Adds config test to check for running services
Browse files Browse the repository at this point in the history
Used to determine whether paxctld is running inside the VMs. The most
important is sd-svs-disp, since that's where we'll be installing
libreoffice, and libreoffice requires pax flags to be set on java dependencies
in order for the package to install successfully.

Removes the previous implementation of a service check in favor of a
more generalized approach. Overall, the config test suite should
probably be reorganized.
  • Loading branch information
Conor Schaefer committed Jun 6, 2019
1 parent 16d4446 commit 39c5a46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 0 additions & 7 deletions tests/test_svs_disp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import subprocess
import unittest

from base import SD_VM_Local_Test
Expand All @@ -16,12 +15,6 @@ def test_sd_svs_disp_config_package_installed(self):
def test_sd_svs_disp_libreoffice_installed(self):
self.assertTrue(self._package_is_installed("libreoffice"))

def test_sd_svs_disp_paxctld_is_running(self):
cmd = ["qvm-run", "-p", "sd-svs-disp",
"/usr/sbin/service paxctld status"]
p = subprocess.check_output(cmd)
self.assertTrue("active (running)".encode() in p)


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_SVS_Disp_Tests)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_vms_exist.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def _check_kernel(self, vm):
assert kernel_version.endswith("-grsec")
assert kernel_version == EXPECTED_KERNEL_VERSION

def _check_service_running(self, vm, service):
"""
Ensures a given service is running inside a given VM.
Uses systemctl is-active to query the service state.
"""
cmd = "systemctl is-active {}".format(service)
stdout, stderr = vm.run(cmd)
service_status = stdout.decode("utf-8").rstrip()
assert service_status == "active"

def test_sd_whonix_config(self):
vm = self.app.domains["sd-whonix"]
nvm = vm.netvm
Expand Down Expand Up @@ -65,6 +75,7 @@ def test_sd_svs_config(self):
self.assertFalse(vm.provides_network)
self.assertFalse(vm.template_for_dispvms)
self._check_kernel(vm)
self._check_service_running(vm, "paxctld")
self.assertTrue('sd-workstation' in vm.tags)

def test_sd_svs_disp_config(self):
Expand All @@ -75,6 +86,7 @@ def test_sd_svs_disp_config(self):
self.assertFalse(vm.provides_network)
self.assertTrue(vm.template_for_dispvms)
self._check_kernel(vm)
self._check_service_running(vm, "paxctld")
self.assertTrue('sd-workstation' in vm.tags)

def test_sd_gpg_config(self):
Expand All @@ -97,6 +109,7 @@ def test_sd_workstation_template(self):
self.assertTrue(vm.kernel == "")
self.assertTrue('sd-workstation' in vm.tags)
self._check_kernel(vm)
self._check_service_running(vm, "paxctld")

def test_sd_proxy_template(self):
vm = self.app.domains["sd-proxy-template"]
Expand Down

0 comments on commit 39c5a46

Please sign in to comment.