Only inject EPP metric builder in a single place

This fixes recording of number of attempts and command name on EPP
flows, which was broken because a separate metric builder was
being injected in two places, EppController and FlowRunner, with the
one injected into FlowRunner being discarded rather than having changes
applied to the same instance as in EppController.

This also adds a test that the metric is created successfully inside
a flow. Note that tests already exist for EppController to ensure that
the metric is recorded correctly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=152306596
This commit is contained in:
mcilwain 2017-04-05 14:35:28 -07:00 committed by Ben McIlwain
parent 794743c7bc
commit 4606b1d08e
7 changed files with 58 additions and 36 deletions

View file

@ -125,6 +125,7 @@ import google.registry.model.registrar.Registrar;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.HistoryEntry;
import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.DatastoreHelper;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import java.util.Map;
@ -1996,4 +1997,13 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-create");
}
@Test
public void testEppMetric_isSuccessfullyCreated() throws Exception {
persistContactsAndHosts();
runFlow();
EppMetric eppMetric = getEppMetric();
assertThat(eppMetric.getCommandName()).hasValue("DomainCreate");
assertThat(eppMetric.getAttempts()).isEqualTo(1);
}
}