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

@ -26,6 +26,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;
@ -81,15 +82,16 @@ public class NameserverWhoisResponseTest {
public void testGetTextOutput() {
NameserverWhoisResponse nameserverWhoisResponse =
new NameserverWhoisResponse(hostResource1, clock.nowUtc());
assertThat(nameserverWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer"))
.isEqualTo(loadWhoisTestFile("whois_nameserver.txt"));
assertThat(nameserverWhoisResponse.getResponse(false, "Doodle Disclaimer"))
.isEqualTo(WhoisResponseResults.create(loadWhoisTestFile("whois_nameserver.txt"), 1));
}
@Test
public void testGetMultipleNameserversResponse() {
NameserverWhoisResponse nameserverWhoisResponse =
new NameserverWhoisResponse(ImmutableList.of(hostResource1, hostResource2), clock.nowUtc());
assertThat(nameserverWhoisResponse.getPlainTextOutput(false, "Doodle Disclaimer"))
.isEqualTo(loadWhoisTestFile("whois_multiple_nameservers.txt"));
assertThat(nameserverWhoisResponse.getResponse(false, "Doodle Disclaimer"))
.isEqualTo(
WhoisResponseResults.create(loadWhoisTestFile("whois_multiple_nameservers.txt"), 2));
}
}