mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Use the actual EPP command flow name for EppMetrics
It was previously only using the name of the inner command XML element, e.g. "Create", "Delete", "Update", etc. This wasn't very useful because there was no way to discriminate between operations on different types of EPP resources. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151131491
This commit is contained in:
parent
0d32b6b7b2
commit
4260fb573f
5 changed files with 36 additions and 15 deletions
|
@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.testing.TestLogHandler;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
|
||||
import google.registry.model.eppoutput.EppResponse;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
|
@ -59,22 +60,21 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
|
||||
private final TestLogHandler handler = new TestLogHandler();
|
||||
|
||||
static class TestCommandFlow implements Flow {
|
||||
@Override
|
||||
public ResponseOrGreeting run() throws EppException {
|
||||
return mock(EppResponse.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
Logger.getLogger(FlowRunner.class.getCanonicalName()).addHandler(handler);
|
||||
|
||||
final EppResponse eppResponse = mock(EppResponse.class);
|
||||
|
||||
flowRunner.clientId = "TheRegistrar";
|
||||
flowRunner.credentials = new PasswordOnlyTransportCredentials();
|
||||
flowRunner.eppRequestSource = EppRequestSource.UNIT_TEST;
|
||||
flowRunner.flowProvider =
|
||||
Providers.<Flow>of(
|
||||
new Flow() {
|
||||
@Override
|
||||
public EppResponse run() {
|
||||
return eppResponse;
|
||||
}});
|
||||
flowRunner.flowProvider = Providers.<Flow>of(new TestCommandFlow());
|
||||
flowRunner.flowClass = TestCommandFlow.class;
|
||||
flowRunner.inputXmlBytes = "<xml/>".getBytes(UTF_8);
|
||||
flowRunner.isDryRun = false;
|
||||
flowRunner.isSuperuser = false;
|
||||
|
@ -98,18 +98,31 @@ public class FlowRunnerTest extends ShardableTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_notIsTransactional_incrementsMetricAttempts() throws Exception {
|
||||
public void testRun_nonTransactionalCommand_incrementsMetricAttempts() throws Exception {
|
||||
flowRunner.run();
|
||||
assertThat(flowRunner.metric.build().getAttempts()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_isTransactional_incrementsMetricAttempts() throws Exception {
|
||||
public void testRun_transactionalCommand_incrementsMetricAttempts() throws Exception {
|
||||
flowRunner.isTransactional = true;
|
||||
flowRunner.run();
|
||||
assertThat(flowRunner.metric.build().getAttempts()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_nonTransactionalCommand_setsCommandNameOnMetric() throws Exception {
|
||||
flowRunner.isTransactional = true;
|
||||
flowRunner.run();
|
||||
assertThat(flowRunner.metric.build().getCommandName()).hasValue("TestCommand");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_transactionalCommand_setsCommandNameOnMetric() throws Exception {
|
||||
flowRunner.run();
|
||||
assertThat(flowRunner.metric.build().getCommandName()).hasValue("TestCommand");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_reportingLogStatement_noClientId() throws Exception {
|
||||
flowRunner.clientId = "";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue