mirror of
https://github.com/google/nomulus.git
synced 2025-05-28 15:11:26 +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
|
@ -18,12 +18,14 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
|
||||
import static google.registry.testing.LogsSubject.assertAboutLogs;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.testing.TestLogHandler;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.model.EppResource;
|
||||
|
@ -38,8 +40,11 @@ import google.registry.model.tmch.ClaimsListShard.ClaimsListRevision;
|
|||
import google.registry.model.tmch.ClaimsListShard.ClaimsListSingleton;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import google.registry.util.TypeUtils.TypeInstantiator;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -51,6 +56,16 @@ import org.junit.Test;
|
|||
public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource>
|
||||
extends FlowTestCase<F> {
|
||||
|
||||
private final TestLogHandler logHandler = new TestLogHandler();
|
||||
|
||||
@Before
|
||||
public void beforeResourceFlowTestCase() {
|
||||
// Attach TestLogHandler to the root logger so it has access to all log messages.
|
||||
// Note that in theory for assertIcannReportingActivityFieldLogged() below it would suffice to
|
||||
// attach it only to the FlowRunner logger, but for some reason this doesn't work for all flows.
|
||||
Logger.getLogger("").addHandler(logHandler);
|
||||
}
|
||||
|
||||
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
|
||||
// Force the session to be cleared so that when we read it back, we read from Datastore and
|
||||
// not from the transaction cache or memcache.
|
||||
|
@ -151,4 +166,11 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
|||
.etaDelta(Duration.standardSeconds(75), Duration.standardSeconds(105)) // expected: 90
|
||||
.payload(expectedPayload));
|
||||
}
|
||||
|
||||
protected void assertIcannReportingActivityFieldLogged(String fieldName) {
|
||||
assertAboutLogs().that(logHandler)
|
||||
.hasLogAtLevelWithMessage(Level.INFO, "EPP-REPORTING-LOG-SIGNATURE")
|
||||
.which()
|
||||
.contains(fieldName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue