mirror of
https://github.com/google/nomulus.git
synced 2025-06-29 15:53:35 +02:00
Add more options to the generate escrow deposit command (#1453)
This adds two new options: 1) An option to run RDE in lenient mode. 2) An option to run RDE with the new Beam pipeline regardless of the datastore setting. <!-- 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/1453) <!-- Reviewable:end -->
This commit is contained in:
parent
8dbb1d8491
commit
601c25be08
4 changed files with 90 additions and 2 deletions
|
@ -45,6 +45,7 @@ public abstract class RdeModule {
|
|||
public static final String PARAM_WATERMARK = "watermark";
|
||||
public static final String PARAM_WATERMARKS = "watermarks";
|
||||
public static final String PARAM_MANUAL = "manual";
|
||||
public static final String PARAM_BEAM = "beam";
|
||||
public static final String PARAM_DIRECTORY = "directory";
|
||||
public static final String PARAM_MODE = "mode";
|
||||
public static final String PARAM_REVISION = "revision";
|
||||
|
@ -72,6 +73,12 @@ public abstract class RdeModule {
|
|||
return extractBooleanParameter(req, PARAM_MANUAL);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter(PARAM_BEAM)
|
||||
static boolean provideBeam(HttpServletRequest req) {
|
||||
return extractBooleanParameter(req, PARAM_BEAM);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter(PARAM_DIRECTORY)
|
||||
static Optional<String> provideDirectory(HttpServletRequest req) {
|
||||
|
|
|
@ -264,6 +264,11 @@ public final class RdeStagingAction implements Runnable {
|
|||
@Inject @Config("beamStagingBucketUrl") String stagingBucketUrl;
|
||||
@Inject @Config("rdeBucket") String rdeBucket;
|
||||
@Inject @Parameter(RdeModule.PARAM_MANUAL) boolean manual;
|
||||
|
||||
@Inject
|
||||
@Parameter(RdeModule.PARAM_BEAM)
|
||||
boolean beam;
|
||||
|
||||
@Inject @Parameter(RdeModule.PARAM_DIRECTORY) Optional<String> directory;
|
||||
@Inject @Parameter(RdeModule.PARAM_MODE) ImmutableSet<String> modeStrings;
|
||||
@Inject @Parameter(RequestParameters.PARAM_TLDS) ImmutableSet<String> tlds;
|
||||
|
@ -289,7 +294,7 @@ public final class RdeStagingAction implements Runnable {
|
|||
logger.atInfo().log("Pending deposit: %s", pending);
|
||||
}
|
||||
ValidationMode validationMode = lenient ? LENIENT : STRICT;
|
||||
if (tm().isOfy()) {
|
||||
if (tm().isOfy() && !beam) {
|
||||
RdeStagingMapper mapper = new RdeStagingMapper(validationMode, pendings);
|
||||
RdeStagingReducer reducer = reducerFactory.create(validationMode, gcsUtils);
|
||||
mrRunner
|
||||
|
@ -382,6 +387,9 @@ public final class RdeStagingAction implements Runnable {
|
|||
if (revision.isPresent()) {
|
||||
throw new BadRequestException("Revision parameter not allowed in standard operation");
|
||||
}
|
||||
if (beam) {
|
||||
throw new BadRequestException("Beam parameter not allowed in standard operation");
|
||||
}
|
||||
|
||||
return ImmutableSetMultimap.copyOf(
|
||||
Multimaps.filterValues(
|
||||
|
|
|
@ -16,7 +16,9 @@ package google.registry.tools;
|
|||
|
||||
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
||||
import static google.registry.model.tld.Registries.assertTldsExist;
|
||||
import static google.registry.rde.RdeModule.PARAM_BEAM;
|
||||
import static google.registry.rde.RdeModule.PARAM_DIRECTORY;
|
||||
import static google.registry.rde.RdeModule.PARAM_LENIENT;
|
||||
import static google.registry.rde.RdeModule.PARAM_MANUAL;
|
||||
import static google.registry.rde.RdeModule.PARAM_MODE;
|
||||
import static google.registry.rde.RdeModule.PARAM_REVISION;
|
||||
|
@ -65,6 +67,20 @@ final class GenerateEscrowDepositCommand implements CommandWithRemoteApi {
|
|||
description = "Mode of operation: FULL for RDE deposits, THIN for BRDA deposits.")
|
||||
private RdeMode mode = RdeMode.FULL;
|
||||
|
||||
@Parameter(
|
||||
names = {"-l", "--lenient"},
|
||||
description =
|
||||
"Whether to run RDE in LENIENT mode, which omits validation of the generated "
|
||||
+ "XML deposit files.")
|
||||
private boolean lenient = false;
|
||||
|
||||
@Parameter(
|
||||
names = {"-b", "--beam"},
|
||||
description =
|
||||
"Whether to explicitly launch the beam pipeline instead of letting the action decide"
|
||||
+ " which one to run.")
|
||||
private boolean beam = false;
|
||||
|
||||
@Parameter(
|
||||
names = {"-r", "--revision"},
|
||||
description = "Revision number. Use >0 for resends.")
|
||||
|
@ -119,6 +135,8 @@ final class GenerateEscrowDepositCommand implements CommandWithRemoteApi {
|
|||
.param(PARAM_MANUAL, String.valueOf(true))
|
||||
.param(PARAM_MODE, mode.toString())
|
||||
.param(PARAM_DIRECTORY, outdir)
|
||||
.param(PARAM_LENIENT, Boolean.toString(lenient))
|
||||
.param(PARAM_BEAM, Boolean.toString(beam))
|
||||
.param(PARAM_TLDS, tlds.stream().collect(Collectors.joining(",")))
|
||||
.param(
|
||||
PARAM_WATERMARKS,
|
||||
|
|
|
@ -188,7 +188,55 @@ public class GenerateEscrowDepositCommandTest
|
|||
}
|
||||
|
||||
@Test
|
||||
void testCommand_success() throws Exception {
|
||||
void testCommand_successWithLenientValidationMode() throws Exception {
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"--lenient",
|
||||
"-r 42",
|
||||
"-o test");
|
||||
|
||||
assertTasksEnqueued(
|
||||
"rde-report",
|
||||
new TaskMatcher()
|
||||
.url("/_dr/task/rdeStaging")
|
||||
.header("Host", "backend.test.localhost")
|
||||
.param("mode", "THIN")
|
||||
.param("lenient", "true")
|
||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||
.param("tlds", "tld")
|
||||
.param("directory", "test")
|
||||
.param("manual", "true")
|
||||
.param("revision", "42"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommand_successWithBeam() throws Exception {
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"--beam",
|
||||
"-r 42",
|
||||
"-o test");
|
||||
|
||||
assertTasksEnqueued(
|
||||
"rde-report",
|
||||
new TaskMatcher()
|
||||
.url("/_dr/task/rdeStaging")
|
||||
.header("Host", "backend.test.localhost")
|
||||
.param("mode", "THIN")
|
||||
.param("beam", "true")
|
||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||
.param("tlds", "tld")
|
||||
.param("directory", "test")
|
||||
.param("manual", "true")
|
||||
.param("revision", "42"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommand_successWithDefaultValidationMode() throws Exception {
|
||||
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
|
||||
|
||||
assertTasksEnqueued(
|
||||
|
@ -197,6 +245,7 @@ public class GenerateEscrowDepositCommandTest
|
|||
.url("/_dr/task/rdeStaging")
|
||||
.header("Host", "backend.test.localhost")
|
||||
.param("mode", "THIN")
|
||||
.param("lenient", "false")
|
||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||
.param("tlds", "tld")
|
||||
.param("directory", "test")
|
||||
|
@ -213,6 +262,8 @@ public class GenerateEscrowDepositCommandTest
|
|||
new TaskMatcher()
|
||||
.url("/_dr/task/rdeStaging")
|
||||
.header("Host", "backend.test.localhost")
|
||||
.param("lenient", "false")
|
||||
.param("beam", "false")
|
||||
.param("mode", "THIN")
|
||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||
.param("tlds", "tld")
|
||||
|
@ -230,6 +281,8 @@ public class GenerateEscrowDepositCommandTest
|
|||
.url("/_dr/task/rdeStaging")
|
||||
.header("Host", "backend.test.localhost")
|
||||
.param("mode", "FULL")
|
||||
.param("lenient", "false")
|
||||
.param("beam", "false")
|
||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||
.param("tlds", "tld")
|
||||
.param("directory", "test")
|
||||
|
@ -252,6 +305,8 @@ public class GenerateEscrowDepositCommandTest
|
|||
.url("/_dr/task/rdeStaging")
|
||||
.header("Host", "backend.test.localhost")
|
||||
.param("mode", "THIN")
|
||||
.param("lenient", "false")
|
||||
.param("beam", "false")
|
||||
.param("watermarks", "2017-01-01T00:00:00.000Z,2017-01-02T00:00:00.000Z")
|
||||
.param("tlds", "tld,anothertld")
|
||||
.param("directory", "test")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue