From 42624f16cadb0e6bf1c4f9317c4c287a274a1c89 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 11 Nov 2020 13:13:42 -0500 Subject: Fix initialization errors Updated database initialization to correctly handle differences between mysql/mariadb syntax and h2 syntax. Change-Id: I6f2732da5d26201fc61ef8de7d30e3137220c184 Issue-ID: CCSDK-2978 Signed-off-by: Dan Timoney --- ms/neng/pom.xml | 4 +- ms/neng/src/main/compose/docker-compose.yaml | 22 +++++---- .../scripts/rel_18_10/create_base_tables.sql | 21 +++++---- .../scripts/rel_18_10/create_message_table.sql | 4 +- .../h2db/changelog/h2db.changelog-master.xml | 4 +- .../scripts/rel_18_10/create_base_tables.sql | 53 ++++++++++++++++++++++ 6 files changed, 83 insertions(+), 25 deletions(-) create mode 100644 ms/neng/src/test/resources/h2db/changelog/scripts/rel_18_10/create_base_tables.sql diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml index 1387dccd..4f43ffbe 100644 --- a/ms/neng/pom.xml +++ b/ms/neng/pom.xml @@ -140,7 +140,7 @@ copy-resources - validate + package ${basedir}/target/docker-stage @@ -180,7 +180,7 @@ io.fabric8 docker-maven-plugin - 0.16.5 + 0.28.0 false diff --git a/ms/neng/src/main/compose/docker-compose.yaml b/ms/neng/src/main/compose/docker-compose.yaml index 93dbbf0d..09c588a0 100644 --- a/ms/neng/src/main/compose/docker-compose.yaml +++ b/ms/neng/src/main/compose/docker-compose.yaml @@ -1,11 +1,13 @@ +version: '2.1' -nengdb: - image: mariadb +services: + nengdb: + image: mariadb:10.5 container_name: nengdb ports: - "${NENG_DB_PORT}:3306" - volumes: - - /var/lib/nengdb:/var/lib/mysql + #volumes: + # - /var/lib/nengdb:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: "${NENG_DB_ROOT}" @@ -13,17 +15,19 @@ nengdb: MYSQL_USER: "${NENG_DB_USER}" MYSQL_PASSWORD: "${NENG_DB_PASS}" -neng: - #depends_on: - #- nengdb - image: onap/ccsdk-apps-ms-neng + neng: + depends_on : + - nengdb + image: onap/ccsdk-apps-ms-neng:latest container_name: neng ports: - "${NENG_SERV_PORT}:8080" restart: always + links: + - nengdb:mariadb-galera environment: SPRING_PROFILE: "${SPRING_PROFILE}" - NENG_DB_URL: "${NENG_DB_URL}" + NENG_DB_URL: "jdbc:mysql://mariadb-galera:3306/neng" NENG_DB_USER: "${NENG_DB_USER}" NENG_DB_PASS: "${NENG_DB_PASS}" diff --git a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql index afb37437..2f47812b 100644 --- a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql +++ b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql @@ -1,7 +1,7 @@ --liquibase formatted sql --changeset template_table:18_10.create_tables_p1.sql -CREATE TABLE GENERATED_NAME (GENERATED_NAME_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +CREATE TABLE GENERATED_NAME (GENERATED_NAME_ID INTEGER PRIMARY KEY AUTO_INCREMENT, EXTERNAL_ID VARCHAR(500) NOT NULL COMMENT 'Key sent by SDNC', SEQUNCE_NUMBER INTEGER COMMENT 'Sequence number used for this name', SEQUENCE_NUMBER_ENC VARCHAR(100) COMMENT 'Alpha numeric equivalent of sequence_number column', @@ -13,29 +13,30 @@ IS_RELEASED CHAR(1) COMMENT 'Indicating if the entry is released/unassigned', CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, CREATED_BY VARCHAR(50), LAST_UPDATED_TIME DATETIME, -LAST_UPDATED_BY VARCHAR(50)); +LAST_UPDATED_BY VARCHAR(50) +) AUTO_INCREMENT=100; -- COMMENT 'TABLE TO STORE GENERATED NAMES'; -CREATE TABLE SERVICE_PARAMETER (SERVICE_PARAMETER_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +CREATE TABLE SERVICE_PARAMETER (SERVICE_PARAMETER_ID INTEGER PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(500) NOT NULL COMMENT 'Parameter name', VALUE VARCHAR(500) COMMENT 'Parameter value', CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP, CREATED_BY VARCHAR(50), LAST_UPDATED_TIME DATETIME, LAST_UPDATED_BY VARCHAR(50) -); +) AUTO_INCREMENT=100; -CREATE TABLE IDENTIFIER_MAP (IDENTIFIER_MAP_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +CREATE TABLE IDENTIFIER_MAP (IDENTIFIER_MAP_ID INTEGER PRIMARY KEY AUTO_INCREMENT, POLICY_FN_NAME VARCHAR(500) COMMENT 'Function name in policy manager' NOT NULL, JS_FN_NAME VARCHAR(500) COMMENT 'Equivalent name in Java or script', CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP, CREATED_BY VARCHAR(50), LAST_UPDATED_TIME DATETIME, LAST_UPDATED_BY VARCHAR(50) -); +) AUTO_INCREMENT=100; -CREATE TABLE EXTERNAL_INTERFACE (EXTERNAL_INTERFACE_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +CREATE TABLE EXTERNAL_INTERFACE (EXTERNAL_INTERFACE_ID INTEGER PRIMARY KEY AUTO_INCREMENT, SYSTEM VARCHAR(500) COMMENT 'Name of the external system', PARAM VARCHAR(500) COMMENT 'Parameters controlling the url', URL_SUFFIX VARCHAR(500) COMMENT 'The suffix of the URL for each value of the parameter', @@ -43,10 +44,10 @@ CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP, CREATED_BY VARCHAR(50), LAST_UPDATED_TIME DATETIME, LAST_UPDATED_BY VARCHAR(50) -); +) AUTO_INCREMENT=100; -CREATE TABLE POLICY_MAN_SIM (POLICY_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +CREATE TABLE POLICY_MAN_SIM (POLICY_ID INTEGER PRIMARY KEY AUTO_INCREMENT, POLICY_NAME VARCHAR(500) COMMENT 'Policy name' NOT NULL, POLICY_RESPONSE VARCHAR(10000) COMMENT 'Policy value', CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP -); +) AUTO_INCREMENT=100; diff --git a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_message_table.sql b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_message_table.sql index 33b42434..643f4c02 100644 --- a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_message_table.sql +++ b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_message_table.sql @@ -8,7 +8,7 @@ SERVICE_NAME VARCHAR(100) COMMENT 'Service name', START_TIME DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'Transaction start time', ELAPSED_MILLIS INTEGER , STATUS VARCHAR(20) COMMENT 'Transaction status', -REQUEST VARCHAR(10000) NOT NULL COMMENT 'Request JSON', -RESPONSE VARCHAR(20000) COMMENT 'Request JSON', +REQUEST LONGTEXT NOT NULL COMMENT 'Request JSON', +RESPONSE LONGTEXT COMMENT 'Request JSON', REQUESTER VARCHAR(50) COMMENT 'Requester' ); diff --git a/ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml b/ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml index 2826e4d4..6f8eab44 100644 --- a/ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml +++ b/ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml @@ -24,11 +24,11 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd"> - + - \ No newline at end of file + diff --git a/ms/neng/src/test/resources/h2db/changelog/scripts/rel_18_10/create_base_tables.sql b/ms/neng/src/test/resources/h2db/changelog/scripts/rel_18_10/create_base_tables.sql new file mode 100644 index 00000000..d58a01a6 --- /dev/null +++ b/ms/neng/src/test/resources/h2db/changelog/scripts/rel_18_10/create_base_tables.sql @@ -0,0 +1,53 @@ +--liquibase formatted sql +--changeset template_table:18_10.create_tables_p1.sql + +CREATE TABLE GENERATED_NAME (GENERATED_NAME_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +EXTERNAL_ID VARCHAR(500) NOT NULL COMMENT 'Key sent by SDNC', +SEQUNCE_NUMBER INTEGER COMMENT 'Sequence number used for this name', +SEQUENCE_NUMBER_ENC VARCHAR(100) COMMENT 'Alpha numeric equivalent of sequence_number column', +ELEMENT_TYPE VARCHAR(100) COMMENT 'The type of network element vnf-name, vm-name etc', +NAME VARCHAR(500) COMMENT 'Generated name', +PREFIX VARCHAR(100) COMMENT 'The prefix for the name. (The part of the name before the sequence number.)', +SUFFIX VARCHAR(100) COMMENT 'The suffix for the name. (The part of the name after the sequence number.)', +IS_RELEASED CHAR(1) COMMENT 'Indicating if the entry is released/unassigned', +CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, +CREATED_BY VARCHAR(50), +LAST_UPDATED_TIME DATETIME, +LAST_UPDATED_BY VARCHAR(50) +); +-- COMMENT 'TABLE TO STORE GENERATED NAMES'; + +CREATE TABLE SERVICE_PARAMETER (SERVICE_PARAMETER_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +NAME VARCHAR(500) NOT NULL COMMENT 'Parameter name', +VALUE VARCHAR(500) COMMENT 'Parameter value', +CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP, +CREATED_BY VARCHAR(50), +LAST_UPDATED_TIME DATETIME, +LAST_UPDATED_BY VARCHAR(50) +); + +CREATE TABLE IDENTIFIER_MAP (IDENTIFIER_MAP_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +POLICY_FN_NAME VARCHAR(500) COMMENT 'Function name in policy manager' NOT NULL, +JS_FN_NAME VARCHAR(500) COMMENT 'Equivalent name in Java or script', +CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP, +CREATED_BY VARCHAR(50), +LAST_UPDATED_TIME DATETIME, +LAST_UPDATED_BY VARCHAR(50) +); + + +CREATE TABLE EXTERNAL_INTERFACE (EXTERNAL_INTERFACE_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +SYSTEM VARCHAR(500) COMMENT 'Name of the external system', +PARAM VARCHAR(500) COMMENT 'Parameters controlling the url', +URL_SUFFIX VARCHAR(500) COMMENT 'The suffix of the URL for each value of the parameter', +CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP, +CREATED_BY VARCHAR(50), +LAST_UPDATED_TIME DATETIME, +LAST_UPDATED_BY VARCHAR(50) +); + +CREATE TABLE POLICY_MAN_SIM (POLICY_ID INTEGER PRIMARY KEY AUTO_INCREMENT(0,100), +POLICY_NAME VARCHAR(500) COMMENT 'Policy name' NOT NULL, +POLICY_RESPONSE VARCHAR(10000) COMMENT 'Policy value', +CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP +); -- cgit 1.2.3-korg