From 98aeaac496ac868a97ce9096c1c51ce9a133992a Mon Sep 17 00:00:00 2001 From: Jakub Dominik Date: Thu, 14 Oct 2021 15:12:55 +0200 Subject: Extend SDNC persistent service to store CM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend SDNC persistent service to store received CM events into Elasticsearch and MariaDB Issue-ID: CCSDK-3497 Signed-off-by: Jakub Dominik Change-Id: I39983e59ef6512ad6c3864d47aebe1d615897146 Signed-off-by: Michael DÜrre --- .../wt/dataprovider/setup/MariaDBTestBase.java | 4 + .../setup/TestBaseReleaseInformation.java | 34 ++++++++ .../setup/TestHonoluluReleaseInformation.java | 34 ++++++++ .../setup/TestJakartaReleaseInformation.java | 46 +++++++++++ .../wt/dataprovider/setup/TestMariaDBIstanbul.java | 90 ---------------------- .../wt/dataprovider/setup/TestMariaDBJakarta.java | 90 ++++++++++++++++++++++ 6 files changed, 208 insertions(+), 90 deletions(-) create mode 100644 sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java create mode 100644 sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java create mode 100644 sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java delete mode 100644 sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBIstanbul.java create mode 100644 sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBJakarta.java (limited to 'sdnr/wt/data-provider/setup/src/test') diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java index 264f1203c..6fd4a40a4 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java @@ -5,6 +5,8 @@ * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. * All rights reserved. * ================================================================================ + * Update Copyright (C) 2021 Samsung Electronics 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 @@ -35,6 +37,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper.UnableToMapClassException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; @@ -136,6 +139,7 @@ public class MariaDBTestBase { createTable(dbService, EventlogEntity.class, Entity.Eventlog, true); createTable(dbService, FaultcurrentEntity.class, Entity.Faultcurrent, false); createTable(dbService, FaultlogEntity.class, Entity.Faultlog, true); + createTable(dbService, CmlogEntity.class, Entity.Cmlog, true); createTable(dbService, GuicutthroughEntity.class, Entity.Guicutthrough, true); createTable(dbService, Pmdata15mEntity.class, Entity.Historicalperformance15min, false); createTable(dbService, Pmdata24hEntity.class, Entity.Historicalperformance24h, false); diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java new file mode 100644 index 000000000..143611f36 --- /dev/null +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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 org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; + +import static org.junit.Assert.assertNotNull; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; + +public class TestBaseReleaseInformation { + + protected void assertValidComponents(ReleaseInformation ri) { + + assertNotNull(ri.getComponents()); + assertNotNull(ri.getConverter(ri.getReleas(),ComponentName.FAULTCURRENT)); + } +} diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java new file mode 100644 index 000000000..727d116fd --- /dev/null +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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 org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.honolulu.HonoluluReleaseInformation; + +public class TestHonoluluReleaseInformation extends TestBaseReleaseInformation{ + + @Test + public void test() { + this.assertValidComponents(new HonoluluReleaseInformation()); + } + +} diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java new file mode 100644 index 000000000..6258e31c2 --- /dev/null +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 Samsung Electronics 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 org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import java.util.Set; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.jakarta.JakartaReleaseInformation; + +public class TestJakartaReleaseInformation { + + @Test + public void testReleaseInformation() { + JakartaReleaseInformation ri = new JakartaReleaseInformation(); + Set components = ri.getComponents(); + assertTrue(components.contains(ComponentName.USERDATA)); + assertTrue(components.contains(ComponentName.REQUIRED_NETWORKELEMENT)); + assertTrue(components.contains(ComponentName.CMLOG)); + assertEquals("userdata", ri.getAlias(ComponentName.USERDATA)); + assertEquals("networkelement-connection", ri.getAlias(ComponentName.REQUIRED_NETWORKELEMENT)); + assertEquals("cmlog", ri.getAlias(ComponentName.CMLOG)); + assertEquals("cmlog-v7", ri.getIndex(ComponentName.CMLOG)); + } + +} diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBIstanbul.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBIstanbul.java deleted file mode 100644 index 072ce2f6b..000000000 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBIstanbul.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH 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 org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import java.sql.SQLException; -import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; -import ch.vorburger.exec.ManagedProcessException; - -public class TestMariaDBIstanbul { - - private static final String MARIADB_USERNAME = "sdnrdb"; - private static final String MARIADB_PASSWORD = "sdnrdb"; - // private static final String MARIADB_HOST = "10.20.11.159"; - private static final String MARIADB_HOST = "sdnrdb"; - private static final int MARIADB_PORT = 3306; - private static final String MARIADB_DATABASENAME = "sdnrdb"; - - private static SqlDBClient dbService; - - private static MariaDBTestBase testBase; - private static SqlDBDataProvider dbProvider; - - @BeforeClass - public static void init() throws Exception { - - //testBase = new MariaDBTestBase(MARIADB_HOST,MARIADB_PORT, MARIADB_DATABASENAME); - testBase = new MariaDBTestBase(); - dbProvider = testBase.getDbProvider(); - dbProvider.waitForDatabaseReady(30, TimeUnit.SECONDS); - // dbProvider.setControllerId(); - - } - - @AfterClass - public static void close() { - try { - testBase.close(); - } catch (ManagedProcessException e) { - e.printStackTrace(); - } - } - - @Test - public void testCreate() { - DataMigrationProviderImpl provider = null; - try { - provider = new DataMigrationProviderImpl(SdnrDbType.MARIADB, testBase.getDBUrl(), testBase.getDBUsername(), - testBase.getDBPassword(), true, 30000); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - boolean success = provider.initDatabase(Release.ISTANBUL_R1, 1, 1, "", false, 1000); - assertTrue("init database failed",success); - try { - dbProvider.setControllerId(); - } catch (SQLException e) { - fail(e.getMessage()); - } - - } -} diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBJakarta.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBJakarta.java new file mode 100644 index 000000000..d657704fb --- /dev/null +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBJakarta.java @@ -0,0 +1,90 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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 org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import java.sql.SQLException; +import java.util.concurrent.TimeUnit; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; +import ch.vorburger.exec.ManagedProcessException; + +public class TestMariaDBJakarta { + + private static final String MARIADB_USERNAME = "sdnrdb"; + private static final String MARIADB_PASSWORD = "sdnrdb"; + // private static final String MARIADB_HOST = "10.20.11.159"; + private static final String MARIADB_HOST = "sdnrdb"; + private static final int MARIADB_PORT = 3306; + private static final String MARIADB_DATABASENAME = "sdnrdb"; + + private static SqlDBClient dbService; + + private static MariaDBTestBase testBase; + private static SqlDBDataProvider dbProvider; + + @BeforeClass + public static void init() throws Exception { + + //testBase = new MariaDBTestBase(MARIADB_HOST,MARIADB_PORT, MARIADB_DATABASENAME); + testBase = new MariaDBTestBase(); + dbProvider = testBase.getDbProvider(); + dbProvider.waitForDatabaseReady(30, TimeUnit.SECONDS); + // dbProvider.setControllerId(); + + } + + @AfterClass + public static void close() { + try { + testBase.close(); + } catch (ManagedProcessException e) { + e.printStackTrace(); + } + } + + @Test + public void testCreate() { + DataMigrationProviderImpl provider = null; + try { + provider = new DataMigrationProviderImpl(SdnrDbType.MARIADB, testBase.getDBUrl(), testBase.getDBUsername(), + testBase.getDBPassword(), true, 30000); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + boolean success = provider.initDatabase(Release.JAKARTA_R1, 1, 1, "", false, 1000); + assertTrue("init database failed",success); + try { + dbProvider.setControllerId(); + } catch (SQLException e) { + fail(e.getMessage()); + } + + } +} -- cgit 1.2.3-korg