mirror of
https://github.com/google/nomulus
synced 2026-09-09 09:36:12 +00:00
Consolidate the use of URL parameters to specify database override (#1331)
There are actions for which we want to provide an override for the database to use, like when launching Spec11 and Invoicing pipelines. It make sense to consolidate around the same parameter provided from the same module for consistency in all cases, instead of defining an override for each action. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/google/nomulus/1331) <!-- Reviewable:end -->
This commit is contained in:
@@ -18,7 +18,6 @@ import dagger.Component;
|
||||
import google.registry.config.RegistryConfig.ConfigModule;
|
||||
import google.registry.cron.CronModule;
|
||||
import google.registry.dns.writer.VoidDnsWriterModule;
|
||||
import google.registry.module.backend.BackendModule;
|
||||
import google.registry.request.RequestModule;
|
||||
import google.registry.util.UtilsModule;
|
||||
import javax.inject.Singleton;
|
||||
@@ -26,7 +25,6 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
@Component(
|
||||
modules = {
|
||||
BackendModule.class,
|
||||
ConfigModule.class,
|
||||
CronModule.class,
|
||||
DnsModule.class,
|
||||
|
||||
+14
-11
@@ -25,15 +25,18 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.beam.BeamActionTestBase;
|
||||
import google.registry.model.common.DatabaseMigrationStateSchedule.PrimaryDatabase;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.io.IOException;
|
||||
import org.joda.time.YearMonth;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link google.registry.reporting.billing.GenerateInvoicesAction}. */
|
||||
@DualDatabaseTest
|
||||
class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
|
||||
@RegisterExtension
|
||||
@@ -44,7 +47,7 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
private FakeClock clock = new FakeClock();
|
||||
private GenerateInvoicesAction action;
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testLaunchTemplateJob_withPublish() throws Exception {
|
||||
action =
|
||||
new GenerateInvoicesAction(
|
||||
@@ -54,7 +57,7 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
"billing_bucket",
|
||||
"REG-INV",
|
||||
true,
|
||||
"DATASTORE",
|
||||
PrimaryDatabase.DATASTORE,
|
||||
new YearMonth(2017, 10),
|
||||
emailUtils,
|
||||
clock,
|
||||
@@ -63,7 +66,7 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
action.run();
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8);
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
assertThat(response.getPayload()).isEqualTo("Launched dataflow template.");
|
||||
assertThat(response.getPayload()).isEqualTo("Launched invoicing pipeline: jobid");
|
||||
|
||||
TaskMatcher matcher =
|
||||
new TaskMatcher()
|
||||
@@ -74,7 +77,7 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
assertTasksEnqueued("beam-reporting", matcher);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testLaunchTemplateJob_withoutPublish() throws Exception {
|
||||
action =
|
||||
new GenerateInvoicesAction(
|
||||
@@ -84,7 +87,7 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
"billing_bucket",
|
||||
"REG-INV",
|
||||
false,
|
||||
"DATASTORE",
|
||||
PrimaryDatabase.DATASTORE,
|
||||
new YearMonth(2017, 10),
|
||||
emailUtils,
|
||||
clock,
|
||||
@@ -93,11 +96,11 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
action.run();
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8);
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
assertThat(response.getPayload()).isEqualTo("Launched dataflow template.");
|
||||
assertThat(response.getPayload()).isEqualTo("Launched invoicing pipeline: jobid");
|
||||
assertNoTasksEnqueued("beam-reporting");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestOfyAndSql
|
||||
void testCaughtIOException() throws IOException {
|
||||
when(launch.execute()).thenThrow(new IOException("Pipeline error"));
|
||||
action =
|
||||
@@ -108,7 +111,7 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
"billing_bucket",
|
||||
"REG-INV",
|
||||
false,
|
||||
"DATASTORE",
|
||||
PrimaryDatabase.DATASTORE,
|
||||
new YearMonth(2017, 10),
|
||||
emailUtils,
|
||||
clock,
|
||||
@@ -116,8 +119,8 @@ class GenerateInvoicesActionTest extends BeamActionTestBase {
|
||||
dataflow);
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_INTERNAL_SERVER_ERROR);
|
||||
assertThat(response.getPayload()).isEqualTo("Template launch failed: Pipeline error");
|
||||
verify(emailUtils).sendAlertEmail("Template Launch failed due to Pipeline error");
|
||||
assertThat(response.getPayload()).isEqualTo("Pipeline launch failed: Pipeline error");
|
||||
verify(emailUtils).sendAlertEmail("Pipeline Launch failed due to Pipeline error");
|
||||
assertNoTasksEnqueued("beam-reporting");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.beam.BeamActionTestBase;
|
||||
import google.registry.model.common.DatabaseMigrationStateSchedule.PrimaryDatabase;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
@@ -51,7 +52,7 @@ class GenerateSpec11ReportActionTest extends BeamActionTestBase {
|
||||
"gs://reporting-project/reporting-bucket/",
|
||||
"api_key/a",
|
||||
clock.nowUtc().toLocalDate(),
|
||||
"DATASTORE",
|
||||
PrimaryDatabase.DATASTORE,
|
||||
clock,
|
||||
response,
|
||||
dataflow);
|
||||
@@ -73,13 +74,14 @@ class GenerateSpec11ReportActionTest extends BeamActionTestBase {
|
||||
"gs://reporting-project/reporting-bucket/",
|
||||
"api_key/a",
|
||||
clock.nowUtc().toLocalDate(),
|
||||
"DATASTORE",
|
||||
PrimaryDatabase.DATASTORE,
|
||||
clock,
|
||||
response,
|
||||
dataflow);
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
assertThat(response.getContentType()).isEqualTo(MediaType.PLAIN_TEXT_UTF_8);
|
||||
assertThat(response.getPayload()).isEqualTo("Launched Spec11 pipeline: jobid");
|
||||
TaskMatcher matcher =
|
||||
new TaskMatcher()
|
||||
.url("/_dr/task/publishSpec11")
|
||||
|
||||
Reference in New Issue
Block a user