Record metrics for WHOIS commands

Note that this does not write out metrics for invocations of the
nomulus tool.

This requires a slight refactoring of the existing WhoisResponse
interface so as to also support returning the number of results found
by the WHOIS query.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149461208
This commit is contained in:
mcilwain 2017-03-07 13:48:07 -08:00 committed by Ben McIlwain
parent 4eef02f17f
commit 3fcb564251
15 changed files with 247 additions and 62 deletions

View file

@ -37,6 +37,7 @@ import google.registry.model.host.HostResource;
import google.registry.model.registrar.Registrar;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
import google.registry.whois.WhoisResponse.WhoisResponseResults;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
@ -239,16 +240,16 @@ public class DomainWhoisResponseTest {
public void getPlainTextOutputTest() {
DomainWhoisResponse domainWhoisResponse =
new DomainWhoisResponse(domainResource, clock.nowUtc());
assertThat(domainWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer"))
.isEqualTo(loadWhoisTestFile("whois_domain.txt"));
assertThat(domainWhoisResponse.getResponse(false, "Doodle Disclaimer"))
.isEqualTo(WhoisResponseResults.create(loadWhoisTestFile("whois_domain.txt"), 1));
}
@Test
public void addImplicitOkStatusTest() {
DomainWhoisResponse domainWhoisResponse = new DomainWhoisResponse(
domainResource.asBuilder().setStatusValues(null).build(),
clock.nowUtc());
assertThat(domainWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer"))
DomainWhoisResponse domainWhoisResponse =
new DomainWhoisResponse(
domainResource.asBuilder().setStatusValues(null).build(), clock.nowUtc());
assertThat(domainWhoisResponse.getResponse(false, "Doodle Disclaimer").plainTextOutput())
.contains("Domain Status: ok");
}
}