From cf90fcb1f1d8cc41742809bb2e98fab9da2631d6 Mon Sep 17 00:00:00 2001
From: Julien Leduc <julien.leduc@cern.ch>
Date: Mon, 31 Jul 2017 09:52:31 +0200
Subject: [PATCH] Purging Oracle DB recycle bin in init, otherwise CI DB size
 explodes because of the recycle bin content.

---
 .../ctafrontend/cc7/config/init/purge_recyclebin.ext     | 5 +++++
 .../docker/ctafrontend/cc7/opt/run/bin/init.sh           | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 continuousintegration/docker/ctafrontend/cc7/config/init/purge_recyclebin.ext

diff --git a/continuousintegration/docker/ctafrontend/cc7/config/init/purge_recyclebin.ext b/continuousintegration/docker/ctafrontend/cc7/config/init/purge_recyclebin.ext
new file mode 100644
index 0000000000..a2b173c1c0
--- /dev/null
+++ b/continuousintegration/docker/ctafrontend/cc7/config/init/purge_recyclebin.ext
@@ -0,0 +1,5 @@
+select * from user_ts_quotas;
+SELECT * FROM RECYCLEBIN;
+SELECT * FROM USER_RECYCLEBIN;
+purge recyclebin;
+quit;
diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh
index b184d4b99b..12f40620a9 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/init.sh
@@ -2,12 +2,15 @@
 
 . /opt/run/bin/init_pod.sh
 
+# oracle sqlplus client binary path
+ORACLE_SQLPLUS="/usr/bin/sqlplus64"
+
 # enable cta repository from previously built artifacts
 yum-config-manager --enable cta-artifacts
 yum-config-manager --enable ceph
 
 # install needed packages
-yum -y install cta-objectstore-tools cta-doc mt-st mtx lsscsi sg3_utils cta-catalogueutils ceph-common
+yum -y install cta-objectstore-tools cta-doc mt-st mtx lsscsi sg3_utils cta-catalogueutils ceph-common oracle-instantclient-sqlplus
 yum clean packages
 
 echo "Using this configuration for library:"
@@ -54,6 +57,10 @@ if [ "$KEEP_DATABASE" == "0" ]; then
     cta-catalogue-schema-create /etc/cta/cta_catalogue_db.conf
     chmod -R 777 $(dirname $(echo ${DATABASEURL} | cut -d: -f2)) # needed?
   else
+    # Oracle DB
+    echo "Purging Oracle recycle bin"
+    test -f ${ORACLE_SQLPLUS} || echo "ERROR: ORACLE SQLPLUS client is not present, cannot purge recycle bin: ${ORACLE_SQLPLUS}"
+    LD_LIBRARY_PATH=$(readlink ${ORACLE_SQLPLUS} | sed -e 's;/bin/[^/]\+;/lib;') ${ORACLE_SQLPLUS} $(echo $DATABASEURL | sed -e 's/oracle://') @/opt/ci/init/purge_recyclebin.ext
     cta-catalogue-schema-create /etc/cta/cta_catalogue_db.conf
   fi
 else
-- 
GitLab