From 90834818b38f31a3138a8de46610d63709deffbe Mon Sep 17 00:00:00 2001 From: thijs snijder <snijder@astron.nl> Date: Tue, 27 Sep 2022 13:29:35 +0200 Subject: [PATCH] docker integration test --- .../default/devices/test_device_docker.py | 35 ++++++++++++++ .../test/devices/test_device_docker.py | 47 ------------------- 2 files changed, 35 insertions(+), 47 deletions(-) create mode 100644 tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_docker.py delete mode 100644 tangostationcontrol/tangostationcontrol/test/devices/test_device_docker.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_docker.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_docker.py new file mode 100644 index 000000000..adc0dff0a --- /dev/null +++ b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_docker.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# +# This file is part of the LOFAR 2.0 Station Software +# +# +# +# Distributed under the terms of the APACHE license. +# See LICENSE.txt for more info. + +from .base import AbstractTestBases + +import time + +class TestDeviceDocker(AbstractTestBases.TestDeviceBase): + + def setUp(self): + super().setUp("STAT/Docker/1") + + def test_toggle(self): + """ + Test turning off and on a running docker container + """ + self.proxy.boot() + + # Turn the recv container off and check that it is indeed turned off + self.proxy.device_recv_RW = False + time.sleep(10) + self.assertEqual(self.device_recv_R, False) + + # Turn the recv container on and check that it is indeed turned on + self.proxy.device_recv_RW = True + self.assertEqual(self.device_recv_R, True) + + + diff --git a/tangostationcontrol/tangostationcontrol/test/devices/test_device_docker.py b/tangostationcontrol/tangostationcontrol/test/devices/test_device_docker.py deleted file mode 100644 index 1fbfbb131..000000000 --- a/tangostationcontrol/tangostationcontrol/test/devices/test_device_docker.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of the LOFAR 2.0 Station Software -# -# -# -# Distributed under the terms of the APACHE license. -# See LICENSE.txt for more info. - -from tango.test_context import DeviceTestContext - -from tangostationcontrol.devices import docker_device - -import numpy - -from tangostationcontrol.test.devices import device_base - - -class TestDockerDevice(device_base.DeviceTestCase): - - DOCKER_PROPERTIES = {'Docker_Base_URL': "unix:///var/run/docker.sock"} - - def setUp(self): - # DeviceTestCase setUp patches lofar_device DeviceProxy - super(TestDockerDevice, self).setUp() - - - def test_read(self): - """Test whether the device-docker container is running""" - with DeviceTestContext(docker_device.Docker, properties=self.DOCKER_PROPERTIES, process=True) as proxy: - self.assertEqual(proxy.device_docker_R, True) - - def test_toggle(self): - """ - Test turning off and on a running docker container - """ - with DeviceTestContext(docker_device.Docker, properties=self.DOCKER_PROPERTIES, process=True) as proxy: - # Turn the recv container off and check that it is indeed turned off - proxy.device_recv_RW = False - self.assertEqual(self.device_recv_R, False) - - # Turn the recv container on and check that it is indeed turned on - proxy.device_recv_RW = True - self.assertEqual(self.device_recv_R, True) - - - -- GitLab