summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-adaptor/provider
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-25 14:35:44 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-26 17:50:35 +0000
commit76c431ff25d09b69ea912f53ca96cbcdcb52a3fb (patch)
treebdf9d1baa6d85ea44d13218a80e93e8dda5f8517 /appc-config/appc-config-adaptor/provider
parentd6f7963013c9b16552509eb53381baef73740f8f (diff)
Fix for timeout error when logging >1MB data
Potentially large logs moved to TRACE level, INFO level logs limited in size and related tests updated Issue-ID: APPC-1489 Change-Id: I9ea85e64380479d835da03ed2af3e4ab96ece67e Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-config/appc-config-adaptor/provider')
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java34
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java20
2 files changed, 49 insertions, 5 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java
index 14c8c4110..60c032422 100644
--- a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java
+++ b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java
@@ -6,7 +6,7 @@
* =============================================================================
* Modifications Copyright (C) 2018-2019 IBM.
* =============================================================================
- * Modifications Copyright (C) 2018 Ericsson
+ * Modifications Copyright (C) 2018-2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class ConfigComponentAdaptor implements SvcLogicAdaptor {
-private static final EELFLogger log = EELFManager.getInstance().getLogger(ConfigComponentAdaptor.class);
+private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigComponentAdaptor.class);
DebugLog debugLog = new DebugLog();
private String configUrl = null;
private String configUser = null;
@@ -916,8 +916,19 @@ private HttpResponse sendXmlRequest(String xmlRequest, String url, String user,
WebResource webResource = client.resource(url);
log.info("SENDING...............");
- log.info(xmlRequest);
-
+ if (log.isTraceEnabled()) {
+ log.trace(xmlRequest);
+ }
+ else {
+ if(xmlRequest.length() > 255 ) {
+ log.info(xmlRequest.substring(0, 255));
+ log.info("\n...\n" + xmlRequest.length() +
+ " characters in request, turn on TRACE logging to log entire request");
+ }
+ else {
+ log.info(xmlRequest);
+ }
+ }
String authString = user + ":" + password;
byte[] authEncBytes = Base64.encode(authString);
String authStringEnc = new String(authEncBytes);
@@ -1015,6 +1026,21 @@ private String trimResponse(String response) {
}
runningConfig = sb.toString();
+ if (log.isTraceEnabled()) {
+ log.trace("ConfigComponentAdaptor:RunningConfig after trimResponse : " + runningConfig);
+ }
+ else {
+ if (runningConfig.length() > 255) {
+ log.info("ConfigComponentAdaptor:RunningConfig after trimResponse : " +
+ runningConfig.substring(0, 255));
+ log.info("\n...\n" + runningConfig.length() +
+ " characters in config, turn on TRACE logging to log entire config");
+ }
+ else {
+ log.info("ConfigComponentAdaptor:RunningConfig after trimResponse : " +
+ runningConfig);
+ }
+ }
log.info("ConfigComponentAdaptor:RunningConfig after trimResponse : " + runningConfig);
return runningConfig;
}
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java
index 8e8c156ed..a947f19fa 100644
--- a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java
@@ -8,7 +8,7 @@
* =============================================================================
* Modifications Copyright (C) 2018-2019 IBM.
* =============================================================================
- * Modifications Copyright (C) 2018 Ericsson
+ * Modifications Copyright (C) 2018-2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -257,6 +257,24 @@ public class ConfigComponentAdaptorTest {
}
@Test
+ public void testXmlGetrunningconfigLongResponse() throws TimedOutException, IOException {
+ Properties props = null;
+ ConfigComponentAdaptor cca = Mockito.spy(new ConfigComponentAdaptor(props));
+ Mockito.doReturn("<configuration xmlns=\"\n<data>\nData line 1\nData line 2\nData line 3\nData line 4\n"
+ + "Data line 5\nData line 6\nData line 7\nData line 8\nData line 9\n Data line 10\n"
+ + "Data line 11\nData line 12\nData line 13\nData line 14\nData line 15\n"
+ + "Data line 16\nData line 17\nData line 18\nData line 19\nData line 20</data>\n</configuration>")
+ .when(mockWrapper)
+ .receiveUntil(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString());
+ Mockito.doReturn(mockWrapper).when(cca).getSshJcraftWrapper();
+ String key = "xml-getrunningconfig";
+ Map<String, String> parameters = new HashMap<>();
+ loadSshParameters(parameters);
+ SvcLogicContext ctx = new SvcLogicContext();
+ assertEquals(ConfigStatus.SUCCESS, cca.configure(key, parameters, ctx));
+ }
+
+ @Test
public void testXmlGetrunningconfigExceptionFlow() throws TimedOutException, IOException {
Properties props = new Properties();
ConfigComponentAdaptor cca = Mockito.spy(new ConfigComponentAdaptor(props));