diff options
-rw-r--r-- | adapters/mso-catalog-db-adapter/src/main/java/db/migration/CloudConfig.java (renamed from adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java) | 0 | ||||
-rw-r--r-- | adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java (renamed from adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java) | 0 | ||||
-rw-r--r-- | adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml | 41 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/pom.xml | 4 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/main/resources/application-local.yaml | 5 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/main/resources/application.yaml | 20 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java | 127 | ||||
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/resources/application-test.yaml | 38 |
8 files changed, 39 insertions, 196 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/CloudConfig.java index 82139f21af..82139f21af 100644 --- a/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/CloudConfig.java diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java index 5acd8359ec..5acd8359ec 100644 --- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml index f84e194962..954e41aa68 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml @@ -20,6 +20,11 @@ spring: driver-class-name: org.mariadb.jdbc.Driver initialization-mode: always data: classpath*:data.sql + flyway: + baseline-on-migrate: false + url: jdbc:mariadb://localhost:3307/catalogdb + user: root + password: password jpa: generate-ddl: false show-sql: false @@ -69,9 +74,33 @@ management: enabled: true # Whether exporting of metrics to Prometheus is enabled. step: 1m # Step size (i.e. reporting frequency) to use. - -flyway: - baseline-on-migrate: false - jdbc-url: jdbc:mariadb://localhost:3307/catalogdb - user: root - password: password +cloud_config: + identity_services: + MTKEYSTONE: + identity_url: "http://localhost:5000/v2.0" + mso_id: "john" + mso_pass: "313DECE408AF7759D442D7B06DD9A6AA" + admin_tenant: "admin" + member_role: "_member_" + tenant_metadata: false + identity_server_type: "KEYSTONE" + identity_authentication_type: "USERNAME_PASSWORD" + cloud_sites: + mtn13: + region_id: "mtn13" + clli: "MDT13" + aic_version: "3.0" + identity_service_id: "MTN13" + orchestrator: "orchestrator" + cloudify_id: "mtn13" + regionOne: + region_id: "regionOne" + clli: "MT2" + aic_version: "2.5" + identity_service_id: "MTKEYSTONE" + cloudify_managers: + manager: + cloudify_url: "http://localhost:8080" + username: "user" + password: "password" + version: "2.0" diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 8d4f30b631..46e73246a0 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -261,10 +261,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.flywaydb</groupId> - <artifactId>flyway-core</artifactId> - </dependency> - <dependency> <groupId>org.onap.so</groupId> <artifactId>cxf-logging</artifactId> <version>${project.version}</version> diff --git a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml index 67c4dd3c22..ef9b113e70 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml @@ -108,8 +108,3 @@ spring: password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' role: ACTUATOR - -flyway: - outOfOrder: true - ignoreMissingMigrations: true - diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index 18084ced8d..e682060c74 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -18,10 +18,12 @@ mso: retryMultiplier: 60000 spring: datasource: - jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/catalogdb username: ${DB_USERNAME} password: ${DB_PASSWORD} driver-class-name: org.mariadb.jdbc.Driver + initialization-mode: never jpa: show-sql: true hibernate: @@ -43,18 +45,4 @@ management: export: prometheus: enabled: true # Whether exporting of metrics to Prometheus is enabled. - step: 1m # Step size (i.e. reporting frequency) to use. - - -flyway: - outOfOrder: true - ignoreMissingMigrations: true - baseline-on-migrate: true - validate-on-migrate: false - -org: - onap: - so: - adapters: - network: - encryptionKey: aa3871669d893c7fb8abbcda31b88b4f + step: 1m # Step size (i.e. reporting frequency) to use. diff --git a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java deleted file mode 100644 index d83e929d6e..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package db.migration; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.onap.so.adapters.vnf.BaseRestTestUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; - -public class CloudConfigMigrationTest extends BaseRestTestUtils { - - @Qualifier("dataSource") - @Autowired - DataSource dataSource; - - R__CloudConfigMigration cloudConfigMigration; - - @Before - public void setup() { - cloudConfigMigration = new R__CloudConfigMigration(); - } - - @Test - public void testMigrate() throws Exception { - System.setProperty("spring.profiles.active", "test"); - cloudConfigMigration.migrate(dataSource.getConnection()); - assertMigratedIdentityServiceData(); - assertMigratedCloudSiteData(); - assertMigratedCloudManagerData(); - } - - @Test - public void testMigrateNoData() throws Exception { - System.setProperty("spring.profiles.active", "nomigrate"); - int identityCount = getDataCount("identity_services"); - int cloudSiteCount = getDataCount("cloud_sites"); - int cloudManagerCount = getDataCount("cloudify_managers"); - - cloudConfigMigration.migrate(dataSource.getConnection()); - - Assert.assertEquals(identityCount, getDataCount("identity_services")); - Assert.assertEquals(cloudSiteCount, getDataCount("cloud_sites")); - Assert.assertEquals(cloudManagerCount, getDataCount("cloudify_managers")); - } - - - private int getDataCount(String tableName) throws Exception { - try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select count(1) from " + tableName)) { - while (rs.next()) { - return rs.getInt(1); - } - } - return 0; - } - - private void assertMigratedIdentityServiceData() throws Exception { - try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from identity_services where id='MTKEYSTONE'")) { - boolean dataAvailable = false; - while (rs.next()) { - dataAvailable = true; - Assert.assertEquals("MTKEYSTONE", rs.getString("id")); - Assert.assertEquals("http://localhost:5000/v2.0", rs.getString("identity_url")); - Assert.assertEquals("john", rs.getString("mso_id")); - Assert.assertEquals("313DECE408AF7759D442D7B06DD9A6AA", rs.getString("mso_pass")); - Assert.assertEquals("admin", rs.getString("admin_tenant")); - Assert.assertEquals("_member_", rs.getString("member_role")); - Assert.assertEquals("KEYSTONE", rs.getString("identity_server_type")); - Assert.assertEquals("USERNAME_PASSWORD", rs.getString("identity_authentication_type")); - } - Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable); - } - } - - private void assertMigratedCloudSiteData() throws Exception { - try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloud_sites where id='regionOne'")) { - boolean dataAvailable = false; - while (rs.next()) { - dataAvailable = true; - Assert.assertEquals("regionOne", rs.getString("id")); - Assert.assertEquals("regionOne", rs.getString("region_id")); - Assert.assertEquals("MT2", rs.getString("clli")); - Assert.assertEquals("2.5", rs.getString("cloud_version")); - Assert.assertEquals("MTKEYSTONE", rs.getString("identity_service_id")); - } - Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable); - } - } - - private void assertMigratedCloudManagerData() throws Exception { - try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloudify_managers where id='manager'")) { - boolean dataAvailable = false; - while (rs.next()) { - dataAvailable = true; - Assert.assertEquals("http://localhost:8080", rs.getString("cloudify_url")); - Assert.assertEquals("user", rs.getString("username")); - Assert.assertEquals("password", rs.getString("password")); - Assert.assertEquals("2.0", rs.getString("version")); - } - Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable); - } - } -} diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 175b08f747..781d49f908 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -88,10 +88,6 @@ spring: hibernate: ddl-auto: none database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - flyway: - baseline-on-migrate: true - out-of-order: true - ignore-missing-migrations: true security: usercredentials: - @@ -119,37 +115,3 @@ management: prometheus: enabled: true # Whether exporting of metrics to Prometheus is enabled. step: 1m # Step size (i.e. reporting frequency) to use. - - -cloud_config: - identity_services: - MTKEYSTONE: - identity_url: "http://localhost:5000/v2.0" - mso_id: "john" - mso_pass: "313DECE408AF7759D442D7B06DD9A6AA" - admin_tenant: "admin" - member_role: "_member_" - tenant_metadata: false - identity_server_type: "KEYSTONE" - identity_authentication_type: "USERNAME_PASSWORD" - cloud_sites: - mtn13: - region_id: "mtn13" - clli: "MDT13" - aic_version: "3.0" - identity_service_id: "MTN13" - orchestrator: "orchestrator" - cloudify_id: "mtn13" - regionOne: - region_id: "regionOne" - clli: "MT2" - aic_version: "2.5" - identity_service_id: "MTKEYSTONE" - cloudify_managers: - manager: - cloudify_url: "http://localhost:8080" - username: "user" - password: "password" - version: "2.0" - - |