From d20a4788b6a50d5fc963f1584aa846af7ab9ea96 Mon Sep 17 00:00:00 2001
From: lukken <lukken@astron.nl>
Date: Wed, 21 Jul 2021 13:10:41 +0000
Subject: [PATCH] L2SS-240: Integration test script and CI

---
 .gitlab-ci.yml               | 10 ++++++++++
 sbin/run_integration_test.sh | 22 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100755 sbin/run_integration_test.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8dc230388..a458a07f8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -15,6 +15,7 @@ stages:
   - linting
   - static-analysis
   - unit-tests
+  - integration-tests
 linting:
   stage: linting
   script:
@@ -34,3 +35,12 @@ unit_test:
   script:
     - cd devices
     - tox -e py37
+integration_test:
+  stage: integration-tests
+  image: docker:19.03.12
+  services:
+    - docker:19.03.12-dind
+  before_script:
+    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+  script:
+    - ./sbin/run_integration_test.sh
diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh
new file mode 100755
index 000000000..d54163625
--- /dev/null
+++ b/sbin/run_integration_test.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Check if lofar20rc.sh is sourced and environment variables are set.
+if [ -z "$LOFAR20_DIR" ]; then
+  echo "\$LOFAR20_DIR is unset or blank, is lofar20rc.sh sourced correctly?"
+  exit 1
+fi
+
+# Start all required containers
+cd "$LOFAR20_DIR/docker-compose" || exit 1
+make start databaseds dsconfig device-sdp device-pcc jupyter elk sdptr-sim pypcc-sim
+
+# Update the dsconfig
+cd "$TANGO_LOFAR_LOCAL_DIR" || exit 1
+sbin/update_ConfigDb.sh CDB/integration_ConfigDb.json
+
+# Start the integration test
+cd "$LOFAR20_DIR/docker-compose" || exit 1
+make start integration-test
+
+# Run the integration test with the output displayed on stdout
+docker start -a integration-test
\ No newline at end of file
-- 
GitLab