diff --git a/docker-compose/Makefile b/docker-compose/Makefile index 5a667713ed71e480737ec434d04509ac73f1c82e..5aa715b84f64f4038ce946aa2cd9c33f9c53ba23 100644 --- a/docker-compose/Makefile +++ b/docker-compose/Makefile @@ -26,7 +26,7 @@ endif # the host. LOG_HOSTNAME ?= localhost -# If the first make argument is "start" or "stop"... +# If the first make argument is "start", "stop"... ifeq (start,$(firstword $(MAKECMDGOALS))) SERVICE_TARGET = true else ifeq (stop,$(firstword $(MAKECMDGOALS))) @@ -48,6 +48,8 @@ else ifeq (attach,$(firstword $(MAKECMDGOALS))) ifndef TANGO_HOST $(error TANGO_HOST must specify the Tango database device, e.g., make TANGO_HOST=powersupply-databaseds:10000 ...) endif +else ifeq (run,$(firstword $(MAKECMDGOALS))) + RUN_TARGET = true endif ifdef SERVICE_TARGET @@ -55,6 +57,13 @@ ifdef SERVICE_TARGET SERVICE := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) # ...and turn them into do-nothing targets $(eval $(SERVICE):;@:) +else ifdef RUN_TARGET + # Isolate second argument as service, the rest is arguments for run command + SERVICE := $(wordlist 2, 2, $(MAKECMDGOALS)) + # ...and turn them into do-nothing targets + $(eval $(SERVICE):;@:) + SERVICE_ARGS := $(wordlist 3, $(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + $(eval $(SERVICE_ARGS):;@:) endif # @@ -131,7 +140,7 @@ DOCKER_COMPOSE_ARGS := DISPLAY=$(DISPLAY) \ DOCKER_GID=$(DOCKER_GID) -.PHONY: up down minimal start stop restart build build-nocache status clean pull help +.PHONY: up down minimal run start stop restart build build-nocache status clean pull help .DEFAULT_GOAL := help pull: ## pull the images from the Docker hub @@ -150,6 +159,9 @@ build-nocache: ## rebuild images from scratch up: minimal ## start the base TANGO system and prepare requested services $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) up --no-start --no-recreate $(SERVICE) +run: minimal ## run a service using arguments and delete it afterwards + $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) run --rm $(SERVICE) $(SERVICE_ARGS) + down: ## stop all services and tear down the system $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) down ifneq ($(NETWORK_MODE),host) diff --git a/docker-compose/integration-test.yml b/docker-compose/integration-test.yml index e2be9144ef7d73b7108609a917529c019e109c62..ad4740833efa36708a54b21a9787cb91b6a7e46d 100644 --- a/docker-compose/integration-test.yml +++ b/docker-compose/integration-test.yml @@ -29,3 +29,8 @@ services: - --strict - -- - tox --recreate -e integration + command: +# Allow for arguments to be passed that wil be put after the entrypoint +# tox is configured to take these arguments as integration test directory +# specifications. + - "" diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh index 9c624fe40ce0ba775c8269c591ad218f282d8484..c6078a89008ce12bbc92f9a97c8ed89c47d7e51d 100755 --- a/sbin/run_integration_test.sh +++ b/sbin/run_integration_test.sh @@ -31,7 +31,6 @@ sleep 60 bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/LOFAR_ConfigDb.json bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/stations/simulators_ConfigDb.json bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/stations/dummy_positions_ConfigDb.json -#bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/integration_ConfigDb.json cd "$LOFAR20_DIR/docker-compose" || exit 1 make start sdptr-sim recv-sim unb2-sim apsct-sim apspu-sim @@ -51,5 +50,5 @@ sleep 60 cd "$LOFAR20_DIR/docker-compose" || exit 1 make up integration-test -# Run the integration test with the output displayed on stdout -docker start -a "${CONTAINER_NAME_PREFIX}"integration-test +# Run the default integration tests +make run integration-test default diff --git a/tangostationcontrol/tangostationcontrol/integration_test/README.md b/tangostationcontrol/tangostationcontrol/integration_test/README.md index 6609a2da61665aab3d93c9f4d716148e03428fba..efae3d939d6d34c67fe4fee6485092962e4c4343 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/README.md +++ b/tangostationcontrol/tangostationcontrol/integration_test/README.md @@ -1,5 +1,11 @@ # Integration Tests +Integration tests are separated into multi modules. Each module requires a +different state and configuration. These configurations are managed externally. + +Invocation of individual modules is achieved through tox: +`tox -e integration MODULE_SUBFOLDER` + ## Approach A special docker container is build to perform the integration tests. This @@ -7,9 +13,9 @@ container will be build by the makefiles but should only be started by the dedicated integration test script. This script will ensure that other containers are running and are in the required state. -* Launch recv-sim and sdptr-sim simulators. +* Launch simulators. * Reconfigure dsconfig to use these simulators. -* Create and start the integration-test container. +* Create and start the integration-test container for the specific module. ## Running @@ -18,8 +24,3 @@ are running and are in the required state. ```shell sbin/run_integration_test.sh ``` - -## Limitations - -Our makefile will always launch the new container upon creation, resulting in -the integration tests actually being run twice. diff --git a/tangostationcontrol/tangostationcontrol/integration_test/client/__init__.py b/tangostationcontrol/tangostationcontrol/integration_test/default/__init__.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/client/__init__.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/__init__.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/__init__.py b/tangostationcontrol/tangostationcontrol/integration_test/default/client/__init__.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/__init__.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/client/__init__.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/client/test_opcua_client_against_server.py b/tangostationcontrol/tangostationcontrol/integration_test/default/client/test_opcua_client_against_server.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/client/test_opcua_client_against_server.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/client/test_opcua_client_against_server.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/client/test_sdptr_sim.py b/tangostationcontrol/tangostationcontrol/integration_test/default/client/test_sdptr_sim.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/client/test_sdptr_sim.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/client/test_sdptr_sim.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/client/test_tcp_replicator.py b/tangostationcontrol/tangostationcontrol/integration_test/default/client/test_tcp_replicator.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/client/test_tcp_replicator.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/client/test_tcp_replicator.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/client/test_unb2_sim.py b/tangostationcontrol/tangostationcontrol/integration_test/default/client/test_unb2_sim.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/client/test_unb2_sim.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/client/test_unb2_sim.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/default/devices/__init__.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/base.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/base.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/base.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/base.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_apsct.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_apsct.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_apsct.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_apsct.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_apspu.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_apspu.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_apspu.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_apspu.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_beam.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_beam.py similarity index 97% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_beam.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_beam.py index 14841394fd308d11f1b8cb99bedd820fd86a1dde..21c93eab4f434350fa091523a421837513aadf9c 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_beam.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_beam.py @@ -7,6 +7,7 @@ # Distributed under the terms of the APACHE license. # See LICENSE.txt for more info. +import time import numpy import datetime import json @@ -74,6 +75,9 @@ class TestDeviceBeam(AbstractTestBases.TestDeviceBase): HBAT_delays_r1 = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) self.assertIsNotNone(HBAT_delays_r1) + time.sleep(3) + + # Verify writing operation does not lead to errors self.proxy.HBAT_set_pointing(self.pointing_direction) # write values to RECV HBAT_delays_r2 = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) self.assertIsNotNone(HBAT_delays_r2) diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_boot.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_boot.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_boot.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_boot.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_recv.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_recv.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_recv.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_recv.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sdp.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_sdp.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sdp.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_sdp.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sst.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_sst.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sst.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_sst.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_unb2.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_unb2.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_unb2.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_unb2.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_tango_database.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_tango_database.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/integration_test/devices/test_tango_database.py rename to tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_tango_database.py diff --git a/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/__init__.py b/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/test_demo.py b/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/test_demo.py new file mode 100644 index 0000000000000000000000000000000000000000..78ea0de074ee4f5336820a4fa91e88d3ef4a73c5 --- /dev/null +++ b/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/test_demo.py @@ -0,0 +1,28 @@ +# -*- 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. + +import logging + +from tangostationcontrol.integration_test import base + +logger = logging.getLogger() + + +class TestDemo(base.IntegrationTestCase): + """ This test will not be run until L2SS-484 is merged. + It serves as a trivial example of test exclusion since the unit tests pass + even though assertTrue(False) can trivially be determined to never succeed. + """ + + def setUp(self): + + super(TestDemo, self).setUp() + + def test_fail(self): + self.assertTrue(False) diff --git a/tangostationcontrol/tox.ini b/tangostationcontrol/tox.ini index fbacf0cbd7bcd0b21b26db755e9452757cfc0a17..fecac58843e1806b1254750841d5b54d708193ca 100644 --- a/tangostationcontrol/tox.ini +++ b/tangostationcontrol/tox.ini @@ -23,9 +23,9 @@ commands = stestr run {posargs} ; Warning running integration tests will make changes to your docker system! ; These tests should only be run by the integration-test docker container. passenv = TANGO_HOST -setenv = TESTS_DIR=./tangostationcontrol/integration_test +setenv = TESTS_DIR=./tangostationcontrol/integration_test/{posargs} commands = - stestr run --serial {posargs} + stestr run --serial ; The access to coverage as module is a bit of an ugly hack. This is due to ; cover inheriting testenv which has `sitepackages = True`, meaning that global