From e5336da12c5f91a907105ff2a0902603ab8251db Mon Sep 17 00:00:00 2001
From: lukken <lukken@astron.nl>
Date: Mon, 2 May 2022 16:45:16 +0000
Subject: [PATCH] L2SS-776: Add configdb and observation device

---
 CDB/test_environment_ConfigDb.json    | 11 +++++++
 docker-compose/device-observation.yml | 45 +++++++++++++++++++++++++++
 sbin/run_integration_test.sh          |  1 +
 3 files changed, 57 insertions(+)
 create mode 100644 CDB/test_environment_ConfigDb.json
 create mode 100644 docker-compose/device-observation.yml

diff --git a/CDB/test_environment_ConfigDb.json b/CDB/test_environment_ConfigDb.json
new file mode 100644
index 000000000..eaa786547
--- /dev/null
+++ b/CDB/test_environment_ConfigDb.json
@@ -0,0 +1,11 @@
+{
+    "servers": {
+        "Observation": {
+            "STAT": {
+                "Observation": {
+                    "STAT/Observation/1": {}
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/docker-compose/device-observation.yml b/docker-compose/device-observation.yml
new file mode 100644
index 000000000..f0017a898
--- /dev/null
+++ b/docker-compose/device-observation.yml
@@ -0,0 +1,45 @@
+#
+# Docker compose file that launches a LOFAR2.0 station's
+# Observation device.
+#
+# Defines:
+#   - device-observation: LOFAR2.0 station Observation
+#
+# Requires:
+#   - lofar-device-base.yml
+#
+version: '2'
+
+services:
+  device-observation:
+    image: device-observation
+    # build explicitly, as docker-compose does not understand a local image
+    # being shared among services.
+    build:
+        context: ..
+        dockerfile: docker-compose/lofar-device-base/Dockerfile
+        args:
+            SOURCE_IMAGE: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/tango-itango:${TANGO_ITANGO_VERSION}
+    container_name: ${CONTAINER_NAME_PREFIX}device-observation
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "100m"
+        max-file: "10"
+    networks:
+      - control
+    ports:
+      - "5717:5717" # unique port for this DS
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
+    volumes:
+        - ..:/opt/lofar/tango:rw
+    environment:
+      - TANGO_HOST=${TANGO_HOST}
+    working_dir: /opt/lofar/tango
+    entrypoint:
+      - bin/start-ds.sh
+      # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA
+      # can't know about our Docker port forwarding
+      - l2ss-observation Observation STAT -v -ORBendPoint giop:tcp:0:5717 -ORBendPointPublish giop:tcp:${HOSTNAME}:5717
+    restart: unless-stopped
diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh
index 7e0cf3b27..c276433a4 100755
--- a/sbin/run_integration_test.sh
+++ b/sbin/run_integration_test.sh
@@ -41,6 +41,7 @@ make start elk
 # Update the dsconfig
 # Do not remove `bash`, otherwise statement ignored by gitlab ci shell!
 bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/LOFAR_ConfigDb.json
+bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/test_environment_ConfigDb.json
 bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/tango-archiver-data/archiver-devices.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
-- 
GitLab