mirror of
https://github.com/google/nomulus.git
synced 2025-08-18 07:24:05 +02:00
Update ExpandRecurringBillingEventsAction to use the beam pipeline (#1907)
Due to the way the beam pipeline is designed, it will expand an recurring billing event when its event time is in scope for expansion, instead of billing time. This means that the one time will be generated 45 days earlier. This would negate the need to check if the expansion is finished when generating monthly invoices. We will need to backfill the past 45 days of onetimes before the new code is deployed. As an illustration, with the old code, a cursor time of 2023-01-17 means that all auto-renewals whose billing time is before 2023-01-17 were created, which corresponds to an effective cursor time of 2022-12-03 (45 days before 2023-01-17) for event time. This cursor will need to be brought to 2023-01-17 to ensure that there is no gap in generated event times when switching to use the new code.
This commit is contained in:
parent
5210ac0419
commit
8088efb25c
10 changed files with 239 additions and 1482 deletions
File diff suppressed because it is too large
Load diff
|
@ -126,7 +126,7 @@ public class ExpandRecurringBillingEventsPipelineTest {
|
|||
assertThrows(IllegalArgumentException.class, this::runPipeline);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("End time 2021-02-02T00:00:05.001Z must be on or before now");
|
||||
.contains("End time 2021-02-02T00:00:05.001Z must be at or before now");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
package google.registry.reporting.billing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.common.Cursor.CursorType.RECURRING_BILLING;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -26,7 +24,6 @@ import static org.mockito.Mockito.when;
|
|||
import com.google.cloud.tasks.v2.HttpMethod;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.beam.BeamActionTestBase;
|
||||
import google.registry.model.common.Cursor;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
|
||||
import google.registry.reporting.ReportingModule;
|
||||
|
@ -35,10 +32,8 @@ import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
|||
import google.registry.testing.FakeClock;
|
||||
import google.registry.util.CloudTasksUtils;
|
||||
import java.io.IOException;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.joda.time.YearMonth;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
|
@ -55,13 +50,6 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
|||
private CloudTasksUtils cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
private GenerateInvoicesAction action;
|
||||
|
||||
@BeforeEach
|
||||
@Override
|
||||
protected void beforeEach() throws Exception {
|
||||
super.beforeEach();
|
||||
persistResource(Cursor.createGlobal(RECURRING_BILLING, DateTime.parse("2017-11-30TZ")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLaunchTemplateJob_withPublish() throws Exception {
|
||||
action =
|
||||
|
@ -142,55 +130,4 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
|||
verify(emailUtils).sendAlertEmail("Pipeline Launch failed due to Pipeline error");
|
||||
cloudTasksHelper.assertNoTasksEnqueued("beam-reporting");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailsToGenerateInvoicesNotExpandedBillingEvents() throws Exception {
|
||||
persistResource(Cursor.createGlobal(RECURRING_BILLING, DateTime.parse("2017-10-30TZ")));
|
||||
action =
|
||||
new GenerateInvoicesAction(
|
||||
"test-project",
|
||||
"test-region",
|
||||
"staging_bucket",
|
||||
"billing_bucket",
|
||||
"REG-INV",
|
||||
false,
|
||||
new YearMonth(2017, 10),
|
||||
emailUtils,
|
||||
cloudTasksUtils,
|
||||
clock,
|
||||
response,
|
||||
dataflow);
|
||||
action.run();
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8);
|
||||
assertThat(response.getStatus()).isEqualTo(SC_INTERNAL_SERVER_ERROR);
|
||||
assertThat(response.getPayload())
|
||||
.isEqualTo(
|
||||
"Pipeline launch failed: Latest billing events expansion cycle hasn't finished yet,"
|
||||
+ " terminating invoicing pipeline");
|
||||
cloudTasksHelper.assertNoTasksEnqueued("beam-reporting");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSucceedsToGenerateInvoicesFirstDayOfTheYear() throws Exception {
|
||||
persistResource(Cursor.createGlobal(RECURRING_BILLING, DateTime.parse("2017-01-01T13:15:00Z")));
|
||||
action =
|
||||
new GenerateInvoicesAction(
|
||||
"test-project",
|
||||
"test-region",
|
||||
"staging_bucket",
|
||||
"billing_bucket",
|
||||
"REG-INV",
|
||||
false,
|
||||
new YearMonth(2016, 12),
|
||||
emailUtils,
|
||||
cloudTasksUtils,
|
||||
clock,
|
||||
response,
|
||||
dataflow);
|
||||
action.run();
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8);
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
assertThat(response.getPayload()).isEqualTo("Launched invoicing pipeline: jobid");
|
||||
cloudTasksHelper.assertNoTasksEnqueued("beam-reporting");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue