From 8f666ad01770364a59d9bfd675c0e9acfb73b6ed Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Mon, 11 Jun 2018 08:47:54 -0700 Subject: [PATCH] Remove redundant inputXml log in EPP flows Currently the input XML to an EPP flow is logged twice, once in FlowRunner and once in FlowReporter. The log by FlowReporter was used by reporting but this is no longer the case. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=200057153 --- java/google/registry/flows/FlowReporter.java | 18 --------------- .../registry/flows/FlowReporterTest.java | 22 ------------------- 2 files changed, 40 deletions(-) diff --git a/java/google/registry/flows/FlowReporter.java b/java/google/registry/flows/FlowReporter.java index 885a9f86e..c59dea773 100644 --- a/java/google/registry/flows/FlowReporter.java +++ b/java/google/registry/flows/FlowReporter.java @@ -15,8 +15,6 @@ package google.registry.flows; import static com.google.common.collect.ImmutableSet.toImmutableSet; -import static com.google.common.io.BaseEncoding.base64; -import static google.registry.xml.XmlTransformer.prettyPrint; import static java.util.Collections.EMPTY_LIST; import com.google.common.base.Ascii; @@ -37,13 +35,6 @@ import org.json.simple.JSONValue; /** Reporter used by {@link FlowRunner} to record flow execution data for reporting. */ public class FlowReporter { - /** - * Log signature for recording flow EPP input data. - * - *

WARNING: DO NOT CHANGE this value unless you want to break reporting. - */ - private static final String EPPINPUT_LOG_SIGNATURE = "FLOW-LOG-SIGNATURE-EPPINPUT"; - /** * Log signature for recording flow metadata (anything beyond or derived from the raw EPP input). * @@ -62,15 +53,6 @@ public class FlowReporter { /** Records information about the current flow execution in the GAE request logs. */ public void recordToLogs() { - // WARNING: These log statements are parsed by reporting pipelines - be careful when changing. - // It should be safe to add new keys, but be very cautious in changing existing keys. - logger.atInfo().log( - "%s: %s", - EPPINPUT_LOG_SIGNATURE, - JSONValue.toJSONString( - ImmutableMap.of( - "xml", prettyPrint(inputXmlBytes), - "xmlBytes", base64().encode(inputXmlBytes)))); // Explicitly log flow metadata separately from the EPP XML itself so that it stays compact // enough to be sure to fit in a single log entry (the XML part in rare cases could be long // enough to overflow into multiple log entries, breaking routine parsing of the JSON format). diff --git a/javatests/google/registry/flows/FlowReporterTest.java b/javatests/google/registry/flows/FlowReporterTest.java index f503fdb4e..491b79a4b 100644 --- a/javatests/google/registry/flows/FlowReporterTest.java +++ b/javatests/google/registry/flows/FlowReporterTest.java @@ -14,9 +14,7 @@ package google.registry.flows; -import static com.google.common.io.BaseEncoding.base64; import static com.google.common.truth.Truth.assertThat; -import static google.registry.testing.TestDataHelper.loadFile; import static google.registry.testing.TestLogHandlerUtils.findFirstLogMessageByPrefix; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Mockito.mock; @@ -76,26 +74,6 @@ public class FlowReporterTest extends ShardableTestCase { when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target.foo")); } - @Test - public void testRecordToLogs_eppInput_basic() throws Exception { - flowReporter.recordToLogs(); - assertThat(parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-EPPINPUT: "))) - .containsExactly( - "xml", "\n", - "xmlBytes", "PHhtbC8+"); // Base64-encoding of "". - } - - @Test - public void testRecordToLogs_eppInput_complex() throws Exception { - String domainCreateXml = loadFile(getClass(), "domain_create_prettyprinted.xml"); - flowReporter.inputXmlBytes = domainCreateXml.getBytes(UTF_8); - flowReporter.recordToLogs(); - assertThat(parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-EPPINPUT: "))) - .containsExactly( - "xml", domainCreateXml, - "xmlBytes", base64().encode(domainCreateXml.getBytes(UTF_8))); - } - @Test public void testRecordToLogs_metadata_basic() throws Exception { when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true);