Add db-migrator to CSIT tests 21/123221/2
authorktimoney <kevin.timoney@est.tech>
Mon, 9 Aug 2021 16:23:35 +0000 (17:23 +0100)
committerktimoney <kevin.timoney@est.tech>
Thu, 12 Aug 2021 07:28:12 +0000 (08:28 +0100)
Issue-ID: POLICY-3491
Change-Id: I987986da7325a040b80b031ae4e7fbf9776c4c54
Signed-off-by: ktimoney <kevin.timoney@est.tech>
csit/db_migrator_policy_init.sh [new file with mode: 0755]
csit/detmVers.sh
csit/docker-compose-all.yml

diff --git a/csit/db_migrator_policy_init.sh b/csit/db_migrator_policy_init.sh
new file mode 100755 (executable)
index 0000000..d7a7b3f
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+# ============LICENSE_START====================================================
+#  Copyright (C) 2021 Nordix Foundation.
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END======================================================
+
+export POLICY_HOME=/opt/app/policy
+export SQL_USER=${MYSQL_USER}
+export SQL_PASSWORD=${MYSQL_PASSWORD}
+
+/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB}
+
+/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report
+
+/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade
+rc=$?
+
+/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report
+
+nc -l -p 6824
+
+exit $rc
index a20cdf6..ce545e0 100644 (file)
@@ -1,5 +1,6 @@
 # ============LICENSE_START====================================================
 #  Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+#  Modification Copyright 2021. Nordix Foundation.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -64,3 +65,7 @@ echo POLICY_DISTRIBUTION_VERSION=${POLICY_DISTRIBUTION_VERSION}
 POLICY_CLAMP_VERSION=$(getVersion clamp)
 export POLICY_CLAMP_VERSION=${POLICY_CLAMP_VERSION:0:5}-SNAPSHOT-latest
 echo POLICY_CLAMP_VERSION=${POLICY_CLAMP_VERSION}
+
+POLICY_DOCKER_VERSION=$(getVersion docker)
+export POLICY_DOCKER_VERSION=${POLICY_DOCKER_VERSION:0:5}-SNAPSHOT-latest
+echo POLICY_DOCKER_VERSION=${POLICY_DOCKER_VERSION}
index d271f5c..50b2054 100644 (file)
@@ -2,6 +2,7 @@
 # ===========LICENSE_START====================================================
 #  Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
 #  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+#  Modification Copyright 2021. Nordix Foundation.
 # ============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -28,6 +29,27 @@ services:
          - ./config/db:/docker-entrypoint-initdb.d:ro
       expose:
        - 3306
+   policy-db-migrator:
+      image: nexus3.onap.org:10001/onap/policy-db-migrator:${POLICY_DOCKER_VERSION}
+      container_name: policy-db-migrator
+      hostname: policy-db-migrator
+      depends_on:
+        - mariadb
+      expose:
+       - 6824
+      env_file: config/db/db.conf
+      environment:
+        SQL_DB: policyadmin
+        SQL_HOST: mariadb
+      volumes:
+         - ./db_migrator_policy_init.sh:/opt/app/policy/bin/db_migrator_policy_init.sh:ro
+         - ./wait_for_port.sh:/opt/app/policy/bin/wait_for_port.sh:ro
+      entrypoint: /opt/app/policy/bin/wait_for_port.sh
+      command: [
+              '-c',
+                '/opt/app/policy/bin/db_migrator_policy_init.sh',
+                'mariadb', '3306'
+               ]
    simulator:
       image: nexus3.onap.org:10001/onap/policy-models-simulator:${POLICY_MODELS_VERSION}
       container_name: simulator
@@ -56,7 +78,7 @@ services:
       image: nexus3.onap.org:10001/onap/policy-api:${POLICY_API_VERSION}
       container_name: policy-api
       depends_on:
-       - mariadb
+       - policy-db-migrator
       hostname: policy-api
       expose:
        - 6969
@@ -67,7 +89,8 @@ services:
       entrypoint: ./wait_for_port.sh
       command: [
         '-c', './policy-api.sh',
-        'mariadb', '3306'
+        'mariadb', '3306',
+        'policy-db-migrator', '6824'
         ]
    pap:
       image: nexus3.onap.org:10001/onap/policy-pap:${POLICY_PAP_VERSION}