summaryrefslogtreecommitdiffstats
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
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>
-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
-rw-r--r--appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/writer/FileWriterNode.java17
-rw-r--r--appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/writer/TestFileWriterNode.java27
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java17
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/executorImpl/GraphExecutorTest.java19
6 files changed, 123 insertions, 11 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));
diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/writer/FileWriterNode.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/writer/FileWriterNode.java
index 7e0ff015a..850efb572 100644
--- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/writer/FileWriterNode.java
+++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/writer/FileWriterNode.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +42,20 @@ public class FileWriterNode implements SvcLogicJavaPlugin {
public void writeFile(Map<String, String> inParams, SvcLogicContext ctx)
throws SvcLogicException {
- log.info("Received writeFile call with params : " + inParams);
+ if (log.isTraceEnabled()) {
+ log.trace("Received writeFile call with params : " + inParams);
+ }
+ else {
+ String mapString = inParams.toString();
+ if (mapString.length() > 255) {
+ log.info("Received writeFile call with params : " + mapString.substring(0, 255));
+ log.info("\n...\n" + mapString.length() +
+ " characters in parameters map, turn on TRACE logging to log entire parameter map");
+ }
+ else {
+ log.info("Received writeFile call with params : " + mapString);
+ }
+ }
String responsePrefix = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX);
try {
responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
diff --git a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/writer/TestFileWriterNode.java b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/writer/TestFileWriterNode.java
index 8bbc85451..44830ad56 100644
--- a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/writer/TestFileWriterNode.java
+++ b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/writer/TestFileWriterNode.java
@@ -7,6 +7,8 @@
* Copyright (C) 2017 Amdocs
* =============================================================================
* Modfication Copyright (C) 2018 IBM.
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,12 +51,31 @@ public class TestFileWriterNode {
assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,
ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));
}
-
- @Test(expected=SvcLogicException.class)
+
+ @Test
+ public void writeFileForLongParameters() throws Exception {
+ FileWriterNode FileWriterNode = new FileWriterNode();
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_FILE_NAME,
+ "src/test/resources/writer/testcvaas.json");
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_DATA,
+ "{'name':'Name','role':'admin'}");
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
+ inParams.put("TEST", "Lorem ipsum dolor sit amet, prompta mediocrem quo an, eos odio esse pertinax an."
+ + " Vis timeam suscipiantur no, eos ex vidisse appareat. Vel ipsum verterem in, qui eu cetero"
+ + " vituperatoribus. Semper insolens contentiones mei ea, vitae persius suavitate no quo, prompta"
+ + " impedit minimum cu sed. Everti disputationi id eam, essent.");
+ SvcLogicContext ctx = new SvcLogicContext();
+ FileWriterNode.writeFile(inParams, ctx);
+ assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,
+ ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));
+ }
+
+ @Test(expected = SvcLogicException.class)
public void testWriteFileForEmptyParams() throws Exception {
FileWriterNode FileWriterNode = new FileWriterNode();
Map<String, String> inParams = new HashMap<String, String>();
SvcLogicContext ctx = new SvcLogicContext();
FileWriterNode.writeFile(inParams, ctx);
- }
+ }
}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java
index 261d64e7a..10fc319a2 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java
@@ -92,7 +92,7 @@ public class GraphExecutor implements FlowExecutorInterface {
String parmName = (String) key;
String parmValue = ctx.getAttribute(parmName);
parms.put(parmName, parmValue);
- log.info(fn + "Setting Key= " + parmName + "and Value = " + parmValue);
+ log.info(fn + "Setting Key= " + parmName + " and Value = " + parmValue);
}
Properties returnParams =
@@ -105,7 +105,20 @@ public class GraphExecutor implements FlowExecutorInterface {
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
- log.info("NEW KEY = " + key + " -- " + returnParams.getProperty(key));
+ String property = returnParams.getProperty(key);
+ if (log.isTraceEnabled()) {
+ log.trace("NEW KEY = " + key + " -- " + property);
+ }
+ else {
+ if (property.length() > 255) {
+ log.info("NEW KEY = " + key + " -- " + property.substring(0, 255));
+ log.info("\n...\n" + property.length() +
+ " characters in property, turn on TRACE logging to log entire property");
+ }
+ else {
+ log.info("NEW KEY = " + key + " -- " + property);
+ }
+ }
ctx.setAttribute(key, returnParams.getProperty(key));
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/executorImpl/GraphExecutorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/executorImpl/GraphExecutorTest.java
index d7a4ce22f..50cb24d61 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/executorImpl/GraphExecutorTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/executorImpl/GraphExecutorTest.java
@@ -104,6 +104,25 @@ public class GraphExecutorTest {
}
@Test
+ public void testExecuteWithLongPropertyValue() throws Exception {
+ GraphExecutor graphExecutor = new GraphExecutor();
+ Whitebox.setInternalState(GraphExecutor.class, "log", log);
+ Properties properties = new Properties();
+ properties.put("TEST", "Lorem ipsum dolor sit amet, prompta mediocrem quo an, eos odio esse pertinax an."
+ + " Vis timeam suscipiantur no, eos ex vidisse appareat. Vel ipsum verterem in, qui eu cetero"
+ + " vituperatoribus. Semper insolens contentiones mei ea, vitae persius suavitate no quo, prompta"
+ + " impedit minimum cu sed. Everti disputationi id eam, essent.");
+ Transaction transaction = Mockito.spy(new Transaction());
+ transaction.setExecutionRPC("EXECUTION_RPC");
+ transaction.setPayload("PAYLOAD");
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("TEST", "TEST");
+ Mockito.when(svcLogic.execute(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
+ Mockito.anyString(), Mockito.any(Properties.class))).thenReturn(properties);
+ assertNull(graphExecutor.execute(transaction, ctx));
+ }
+
+ @Test
public void testExecuteFailure() throws Exception {
GraphExecutor graphExecutor = new GraphExecutor();
Whitebox.setInternalState(GraphExecutor.class, "log", log);