From 7dc3ddfc14cd568c9ae2abe553ad39d1cd1320a3 Mon Sep 17 00:00:00 2001 From: nickfelt Date: Fri, 21 Apr 2017 12:24:30 -0700 Subject: [PATCH] Skip FlowReporter logging for dry runs Since this feeds into ICANN reporting, we don't want to muddy the data there with dry-runs, which are always internal-only artifacts of tool usage and shouldn't really count as real attempts to do SRS actions, since they are always going to abort with no effect. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=153856915 --- java/google/registry/flows/FlowRunner.java | 6 ++++-- javatests/google/registry/flows/FlowRunnerTest.java | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/java/google/registry/flows/FlowRunner.java b/java/google/registry/flows/FlowRunner.java index 9e683562b..f7f0b9d71 100644 --- a/java/google/registry/flows/FlowRunner.java +++ b/java/google/registry/flows/FlowRunner.java @@ -73,8 +73,10 @@ public class FlowRunner { eppRequestSource, isDryRun ? "DRY_RUN" : "LIVE", isSuperuser ? "SUPERUSER" : "NORMAL"); - // Record information about this flow to the GAE request logs for reporting purposes. - flowReporter.recordToLogs(); + // Record flow info to the GAE request logs for reporting purposes if it's not a dry run. + if (!isDryRun) { + flowReporter.recordToLogs(); + } eppMetricBuilder.setCommandNameFromFlow(flowClass.getSimpleName()); if (!isTransactional) { eppMetricBuilder.incrementAttempts(); diff --git a/javatests/google/registry/flows/FlowRunnerTest.java b/javatests/google/registry/flows/FlowRunnerTest.java index 7ab5e1fb8..fd59a777c 100644 --- a/javatests/google/registry/flows/FlowRunnerTest.java +++ b/javatests/google/registry/flows/FlowRunnerTest.java @@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import com.google.appengine.api.users.User; @@ -119,6 +120,13 @@ public class FlowRunnerTest extends ShardableTestCase { verify(flowRunner.flowReporter).recordToLogs(); } + @Test + public void testRun_dryRun_doesNotCallFlowReporter() throws Exception { + flowRunner.isDryRun = true; + flowRunner.run(eppMetricBuilder); + verify(flowRunner.flowReporter, never()).recordToLogs(); + } + @Test public void testRun_legacyLoggingStatement_basic() throws Exception { flowRunner.run(eppMetricBuilder);