072ce2f6b09607fcab0314565a08a043d43a0abb
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
23
24 import static org.junit.Assert.assertTrue;
25 import static org.junit.Assert.fail;
26 import java.sql.SQLException;
27 import java.util.concurrent.TimeUnit;
28 import org.junit.AfterClass;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
32 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
33 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType;
34 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
35 import ch.vorburger.exec.ManagedProcessException;
36
37 public class TestMariaDBIstanbul {
38
39     private static final String MARIADB_USERNAME = "sdnrdb";
40     private static final String MARIADB_PASSWORD = "sdnrdb";
41     //    private static final String MARIADB_HOST = "10.20.11.159";
42     private static final String MARIADB_HOST = "sdnrdb";
43     private static final int MARIADB_PORT = 3306;
44     private static final String MARIADB_DATABASENAME = "sdnrdb";
45
46     private static SqlDBClient dbService;
47
48     private static MariaDBTestBase testBase;
49     private static SqlDBDataProvider dbProvider;
50
51     @BeforeClass
52     public static void init() throws Exception {
53
54         //testBase = new MariaDBTestBase(MARIADB_HOST,MARIADB_PORT, MARIADB_DATABASENAME);
55         testBase = new MariaDBTestBase();
56         dbProvider = testBase.getDbProvider();
57         dbProvider.waitForDatabaseReady(30, TimeUnit.SECONDS);
58     //    dbProvider.setControllerId();
59
60     }
61
62     @AfterClass
63     public static void close() {
64         try {
65             testBase.close();
66         } catch (ManagedProcessException e) {
67             e.printStackTrace();
68         }
69     }
70
71     @Test
72     public void testCreate() {
73         DataMigrationProviderImpl provider = null;
74         try {
75             provider = new DataMigrationProviderImpl(SdnrDbType.MARIADB, testBase.getDBUrl(), testBase.getDBUsername(),
76                     testBase.getDBPassword(), true, 30000);
77         } catch (Exception e) {
78             e.printStackTrace();
79             fail(e.getMessage());
80         }
81         boolean success = provider.initDatabase(Release.ISTANBUL_R1, 1, 1, "", false, 1000);
82         assertTrue("init database failed",success);
83         try {
84             dbProvider.setControllerId();
85         } catch (SQLException e) {
86             fail(e.getMessage());
87         }
88
89     }
90 }