From 76c431ff25d09b69ea912f53ca96cbcdcb52a3fb Mon Sep 17 00:00:00 2001 From: Joss Armstrong Date: Mon, 25 Feb 2019 14:35:44 +0000 Subject: 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 --- .../flow/controller/executorImpl/GraphExecutor.java | 17 +++++++++++++++-- .../controller/executorImpl/GraphExecutorTest.java | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'appc-config/appc-flow-controller/provider') 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 @@ -103,6 +103,25 @@ public class GraphExecutorTest { assertNull(graphExecutor.execute(transaction, ctx)); } + @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(); -- cgit 1.2.3-korg