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 --- .../config/generator/writer/FileWriterNode.java | 17 +++++++++++++- .../generator/writer/TestFileWriterNode.java | 27 +++++++++++++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) (limited to 'appc-config/appc-config-generator/provider') 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 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 inParams = new HashMap(); + 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 inParams = new HashMap(); SvcLogicContext ctx = new SvcLogicContext(); FileWriterNode.writeFile(inParams, ctx); - } + } } -- cgit 1.2.3-korg