Add limit to list_domains command

This allows list_domains to continue working for large TLDs.

TESTED=Deploys to alpha and it works to list the most recently created domains even
on a TLD with a huge number of domains on it (much more than .app has currently).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196717389
This commit is contained in:
mcilwain 2018-05-15 13:12:34 -07:00 committed by jianglai
parent e4f25c08e8
commit 9c0d3b6db3
11 changed files with 243 additions and 198 deletions

View file

@ -39,7 +39,8 @@ public class ListDomainsActionTest extends ListActionTestCase {
public void init() throws Exception {
createTld("foo");
action = new ListDomainsAction();
action.clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
action.clock = new FakeClock(DateTime.parse("2018-01-01TZ"));
action.limit = Integer.MAX_VALUE;
}
@Test
@ -110,7 +111,6 @@ public class ListDomainsActionTest extends ListActionTestCase {
"^example2.foo$");
}
@Test
public void testRun_twoLinesWithIdOnlyNoHeader() throws Exception {
action.tlds = ImmutableSet.of("foo");
@ -231,4 +231,23 @@ public class ListDomainsActionTest extends ListActionTestCase {
null,
"^Field 'badfield' not found - recognized fields are:");
}
@Test
public void testRun_limitFiltersOutOldestDomains() {
createTlds("bar", "baz");
action.tlds = ImmutableSet.of("foo", "bar");
action.limit = 2;
persistActiveDomain("example4.foo", DateTime.parse("2017-04-01TZ"));
persistActiveDomain("example1.foo", DateTime.parse("2017-01-01TZ"));
persistActiveDomain("example2.bar", DateTime.parse("2017-02-01TZ"));
persistActiveDomain("example3.bar", DateTime.parse("2017-03-01TZ"));
persistActiveDomain("example5.baz", DateTime.parse("2018-01-01TZ"));
testRunSuccess(
action,
null,
null,
null,
"^example3.bar$",
"^example4.foo$");
}
}