summaryrefslogtreecommitdiffstats
path: root/grToolkit/provider/src/main
diff options
context:
space:
mode:
authorHaddox, Anthony <ah0647@att.com>2019-04-17 09:07:36 -0700
committerHaddox, Anthony <ah0647@att.com>2019-04-17 09:07:36 -0700
commit3a50557405e66759277ab71d85963d0943cd08d2 (patch)
treec654ce77976e554d853e241bd981daefde74dcc5 /grToolkit/provider/src/main
parenta5fa2ea36c115aba01eb3328fd95a12dd654ed00 (diff)
[CCSDK-1241] Increase GRToolkit Unit Test Coverage
Add unit tests for GRToolkit. Slight changes to make code testable. Change-Id: Ib435da58b62e7b8edda4876f0f3a262cbc41a8ca Issue-ID: CCSDK-1241 Signed-off-by: Haddox, Anthony <ah0647@att.com>
Diffstat (limited to 'grToolkit/provider/src/main')
-rwxr-xr-xgrToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java (renamed from grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java)27
-rwxr-xr-xgrToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java (renamed from grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java)2
-rwxr-xr-xgrToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java (renamed from grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java)2
-rwxr-xr-xgrToolkit/provider/src/main/resources/gr-toolkit.properties21
-rwxr-xr-xgrToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml2
5 files changed, 40 insertions, 14 deletions
diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java
index dc8534be..4e121e34 100755
--- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java
+++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.plugins;
+package org.onap.ccsdk.sli.plugins.grtoolkit;
import java.io.BufferedReader;
import java.io.File;
@@ -31,6 +31,7 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -47,9 +48,10 @@ import javax.annotation.Nonnull;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.onap.ccsdk.sli.core.dblib.DBLibConnection;
import org.onap.ccsdk.sli.core.dblib.DbLibService;
-import org.onap.ccsdk.sli.plugins.data.ClusterActor;
-import org.onap.ccsdk.sli.plugins.data.MemberBuilder;
+import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor;
+import org.onap.ccsdk.sli.plugins.grtoolkit.data.MemberBuilder;
import org.json.JSONArray;
import org.json.JSONException;
@@ -195,6 +197,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
}
} catch(IOException e) {
log.error("Couldn't load akka", e);
+ } catch(NullPointerException e) {
+ log.error("akkaConfig is null. Check properties file and restart {} bundle.", APP_NAME);
}
log.info("self:\n{}", self);
}
@@ -831,13 +835,16 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
private String getDatabaseHealth() {
log.info("Determining database health...");
try {
+ Connection connection = dbLib.getConnection();
log.info("DBLib isActive(): {}", dbLib.isActive());
- log.info("DBLib isReadOnly(): {}", dbLib.getConnection().isReadOnly());
- log.info("DBLib isClosed(): {}", dbLib.getConnection().isClosed());
- if(!dbLib.isActive() || dbLib.getConnection().isClosed() || dbLib.getConnection().isReadOnly()) {
+ log.info("DBLib isReadOnly(): {}", connection.isReadOnly());
+ log.info("DBLib isClosed(): {}", connection.isClosed());
+ if(!dbLib.isActive() || connection.isClosed() || connection.isReadOnly()) {
log.warn("Database is FAULTY");
+ connection.close();
return FAULTY;
}
+ connection.close();
log.info("Database is HEALTHY");
} catch(SQLException e) {
log.error("Database is FAULTY");
@@ -914,18 +921,18 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
return connection;
}
- private enum IpTables {
+ enum IpTables {
ADD,
DELETE
}
- private enum SiteConfiguration {
+ enum SiteConfiguration {
SOLO,
SINGLE,
GEO
}
- private enum HttpMethod {
+ enum HttpMethod {
GET("GET"),
POST("POST");
@@ -938,7 +945,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
}
}
- private class PropertyKeys {
+ class PropertyKeys {
static final String SITE_IDENTIFIER = "site.identifier";
static final String CONTROLLER_USE_SSL = "controller.useSsl";
static final String CONTROLLER_PORT_SSL = "controller.port.ssl";
diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java
index 1c8faac0..7cd503a9 100755
--- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java
+++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.plugins.data;
+package org.onap.ccsdk.sli.plugins.grtoolkit.data;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java
index 96dfa64a..8bbf574d 100755
--- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java
+++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.plugins.data;
+package org.onap.ccsdk.sli.plugins.grtoolkit.data;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.cluster.health.output.MembersBuilder;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.CommitStatusBuilder;
diff --git a/grToolkit/provider/src/main/resources/gr-toolkit.properties b/grToolkit/provider/src/main/resources/gr-toolkit.properties
index 2ddaa9a4..c008eea9 100755
--- a/grToolkit/provider/src/main/resources/gr-toolkit.properties
+++ b/grToolkit/provider/src/main/resources/gr-toolkit.properties
@@ -1,6 +1,25 @@
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2019 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=========================================================
+
akka.conf.location=/opt/opendaylight/current/controller/configuration/initial/akka.conf
adm.useSsl=true
-adm.fqdn=sdnmlcadm-conexus-it.ecomp.cci.att.com
+adm.fqdn=
adm.healthcheck=/healthcheck
adm.port.http=8181
adm.port.ssl=8443
diff --git a/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml b/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml
index 606ce277..5a4492c5 100755
--- a/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml
+++ b/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml
@@ -21,7 +21,7 @@
<reference id="configDatastore" interface="org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface"
odl:type="distributed-config"/>
- <bean id="provider" class="org.onap.ccsdk.sli.plugins.GrToolkitProvider">
+ <bean id="provider" class="org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider">
<argument ref="dataBroker" />
<argument ref="notificationService" />
<argument ref="rpcRegistry" />