mirror of
https://github.com/google/nomulus.git
synced 2025-07-12 14:08:18 +02:00
Fix IcannReportingUploadAction to use correct year in January (#452)
* Fix IcannReportingUploadAction to use correct year in January * small fixes
This commit is contained in:
parent
43682aa7f4
commit
1912453f4e
4 changed files with 58 additions and 23 deletions
|
@ -81,12 +81,8 @@ public class IcannReportingStagingActionTest {
|
|||
.thenReturn(ImmutableList.of("c", "d"));
|
||||
}
|
||||
|
||||
private static void assertUploadTaskEnqueued(String subdir) {
|
||||
TaskMatcher matcher =
|
||||
new TaskMatcher()
|
||||
.url("/_dr/task/icannReportingUpload")
|
||||
.method("POST")
|
||||
.param("subdir", subdir);
|
||||
private static void assertUploadTaskEnqueued() {
|
||||
TaskMatcher matcher = new TaskMatcher().url("/_dr/task/icannReportingUpload").method("POST");
|
||||
assertTasksEnqueued("retryable-cron-tasks", matcher);
|
||||
}
|
||||
|
||||
|
@ -103,7 +99,7 @@ public class IcannReportingStagingActionTest {
|
|||
"Completed staging the following 2 ICANN reports:\na\nb",
|
||||
new InternetAddress("recipient@example.com"),
|
||||
new InternetAddress("sender@example.com")));
|
||||
assertUploadTaskEnqueued("default/dir");
|
||||
assertUploadTaskEnqueued();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -119,7 +115,7 @@ public class IcannReportingStagingActionTest {
|
|||
"Completed staging the following 4 ICANN reports:\na\nb\nc\nd",
|
||||
new InternetAddress("recipient@example.com"),
|
||||
new InternetAddress("sender@example.com")));
|
||||
assertUploadTaskEnqueued("default/dir");
|
||||
assertUploadTaskEnqueued();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -138,7 +134,7 @@ public class IcannReportingStagingActionTest {
|
|||
"Completed staging the following 4 ICANN reports:\na\nb\nc\nd",
|
||||
new InternetAddress("recipient@example.com"),
|
||||
new InternetAddress("sender@example.com")));
|
||||
assertUploadTaskEnqueued("default/dir");
|
||||
assertUploadTaskEnqueued();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -78,7 +78,6 @@ public class IcannReportingUploadActionTest {
|
|||
action.icannReporter = mockReporter;
|
||||
action.gcsUtils = new GcsUtils(gcsService, 1024);
|
||||
action.retrier = new Retrier(new FakeSleeper(new FakeClock()), 3);
|
||||
action.subdir = "icann/monthly/2006-06";
|
||||
action.reportingBucket = "basin";
|
||||
action.emailService = emailService;
|
||||
action.sender = new InternetAddress("sender@example.com");
|
||||
|
@ -151,6 +150,43 @@ public class IcannReportingUploadActionTest {
|
|||
new InternetAddress("sender@example.com")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_january() throws Exception {
|
||||
clock.setTo(DateTime.parse("2006-01-22T00:30:00Z"));
|
||||
persistResource(
|
||||
Cursor.create(
|
||||
CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-01-01TZ"), Registry.get("tld")));
|
||||
persistResource(
|
||||
Cursor.create(
|
||||
CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-01-01TZ"), Registry.get("tld")));
|
||||
writeGcsFile(
|
||||
gcsService,
|
||||
new GcsFilename("basin/icann/monthly/2005-12", "tld-transactions-200512.csv"),
|
||||
PAYLOAD_SUCCESS);
|
||||
writeGcsFile(
|
||||
gcsService,
|
||||
new GcsFilename("basin/icann/monthly/2005-12", "tld-activity-200512.csv"),
|
||||
PAYLOAD_SUCCESS);
|
||||
when(mockReporter.send(PAYLOAD_SUCCESS, "tld-activity-200512.csv")).thenReturn(true);
|
||||
when(mockReporter.send(PAYLOAD_SUCCESS, "tld-transactions-200512.csv")).thenReturn(true);
|
||||
|
||||
IcannReportingUploadAction action = createAction();
|
||||
action.run();
|
||||
verify(mockReporter).send(PAYLOAD_SUCCESS, "tld-activity-200512.csv");
|
||||
verify(mockReporter).send(PAYLOAD_SUCCESS, "tld-transactions-200512.csv");
|
||||
|
||||
verifyNoMoreInteractions(mockReporter);
|
||||
verify(emailService)
|
||||
.sendEmail(
|
||||
EmailMessage.create(
|
||||
"ICANN Monthly report upload summary: 2/2 succeeded",
|
||||
"Report Filename - Upload status:\n"
|
||||
+ "tld-activity-200512.csv - SUCCESS\n"
|
||||
+ "tld-transactions-200512.csv - SUCCESS",
|
||||
new InternetAddress("recipient@example.com"),
|
||||
new InternetAddress("sender@example.com")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_advancesCursor() throws Exception {
|
||||
writeGcsFile(
|
||||
|
@ -280,15 +316,18 @@ public class IcannReportingUploadActionTest {
|
|||
|
||||
@Test
|
||||
public void testFail_fileNotFound() throws Exception {
|
||||
clock.setTo(DateTime.parse("2006-01-22T00:30:00Z"));
|
||||
persistResource(
|
||||
Cursor.create(
|
||||
CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-01-01TZ"), Registry.get("tld")));
|
||||
IcannReportingUploadAction action = createAction();
|
||||
action.subdir = "somewhere/else";
|
||||
action.run();
|
||||
assertAboutLogs()
|
||||
.that(logHandler)
|
||||
.hasLogAtLevelWithMessage(
|
||||
Level.SEVERE,
|
||||
"Could not upload ICANN_UPLOAD_ACTIVITY report for foo because file"
|
||||
+ " foo-activity-200606.csv did not exist");
|
||||
"Could not upload ICANN_UPLOAD_ACTIVITY report for tld because file"
|
||||
+ " tld-activity-200512.csv did not exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -298,7 +337,6 @@ public class IcannReportingUploadActionTest {
|
|||
CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-08-01TZ"), Registry.get("foo")));
|
||||
clock.setTo(DateTime.parse("2006-08-01T00:30:00Z"));
|
||||
IcannReportingUploadAction action = createAction();
|
||||
action.subdir = "icann/monthly/2006-07";
|
||||
action.run();
|
||||
assertAboutLogs()
|
||||
.that(logHandler)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue