mirror of
https://github.com/google/nomulus.git
synced 2025-06-29 07:43:37 +02:00
Make FlowRunner log ICANN activity report field name
As part of b/36599833, this makes FlowRunner log the appropriate ICANN activity report field name for each flow it runs as part of a structured JSON log statement which can be parsed to generate ICANN activity reports (under the key "icannActivityReportField"). In order to support this, we introduce an annotation for Flow classes called @ReportingSpec and a corresponding enum of values for this annotation, which is IcannReportingTypes.ActivityReportField, that stores the mapping of constant enum values to field names. The mapping from flows to fields is fairly obvious, with three exceptions: - Application flows are all accounted under domains, since applications are technically just deferred domain creates within the EPP protocol - ClaimsCheckFlow is counted as a domain check - DomainAllocateFlow is counted as a domain create In addition, I've added tests to all the corresponding flows that we are indeed logging what we expect. We'll also need to log the TLD for this to be useful, but I'm doing that in a follow-up CL. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151283411
This commit is contained in:
parent
b03bd3b525
commit
91c2558feb
72 changed files with 520 additions and 24 deletions
|
@ -29,9 +29,11 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.testing.TestLogHandler;
|
||||
import google.registry.flows.annotations.ReportingSpec;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
|
||||
import google.registry.model.eppoutput.EppResponse;
|
||||
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
|
@ -67,6 +69,14 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@ReportingSpec(ActivityReportField.CONTACT_CHECK)
|
||||
static class TestReportingSpecCommandFlow implements Flow {
|
||||
@Override
|
||||
public ResponseOrGreeting run() throws EppException {
|
||||
return mock(EppResponse.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
Logger.getLogger(FlowRunner.class.getCanonicalName()).addHandler(handler);
|
||||
|
@ -85,18 +95,6 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
flowRunner.trid = Trid.create("client-123", "server-456");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_reportingLogStatement_basic() throws Exception {
|
||||
flowRunner.run();
|
||||
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
|
||||
.containsExactly(
|
||||
"trid", "server-456",
|
||||
"clientId", "TheRegistrar",
|
||||
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
|
||||
// Base64-encoding of "<xml/>":
|
||||
"xmlBytes", "PHhtbC8+");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_nonTransactionalCommand_incrementsMetricAttempts() throws Exception {
|
||||
flowRunner.run();
|
||||
|
@ -123,6 +121,31 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
assertThat(flowRunner.metric.build().getCommandName()).hasValue("TestCommand");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_reportingLogStatement_basic() throws Exception {
|
||||
flowRunner.run();
|
||||
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
|
||||
.containsExactly(
|
||||
"trid", "server-456",
|
||||
"clientId", "TheRegistrar",
|
||||
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
|
||||
"xmlBytes", "PHhtbC8+", // Base64-encoding of "<xml/>".
|
||||
"icannActivityReportField", "");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_reportingLogStatement_withReportingSpec() throws Exception {
|
||||
flowRunner.flowClass = TestReportingSpecCommandFlow.class;
|
||||
flowRunner.run();
|
||||
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
|
||||
.containsExactly(
|
||||
"trid", "server-456",
|
||||
"clientId", "TheRegistrar",
|
||||
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
|
||||
"xmlBytes", "PHhtbC8+", // Base64-encoding of "<xml/>".
|
||||
"icannActivityReportField", "srs-cont-check");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_reportingLogStatement_noClientId() throws Exception {
|
||||
flowRunner.clientId = "";
|
||||
|
@ -132,8 +155,8 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
"trid", "server-456",
|
||||
"clientId", "",
|
||||
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
|
||||
// Base64-encoding of "<xml/>":
|
||||
"xmlBytes", "PHhtbC8+");
|
||||
"xmlBytes", "PHhtbC8+", // Base64-encoding of "<xml/>".
|
||||
"icannActivityReportField", "");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -147,7 +170,8 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
"trid", "server-456",
|
||||
"clientId", "TheRegistrar",
|
||||
"xml", domainCreateXml,
|
||||
"xmlBytes", base64().encode(domainCreateXml.getBytes(UTF_8)));
|
||||
"xmlBytes", base64().encode(domainCreateXml.getBytes(UTF_8)),
|
||||
"icannActivityReportField", "");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue