mirror of
https://github.com/google/nomulus.git
synced 2025-06-30 08:13:32 +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_WATERMARK = "watermark";
|
||||||
public static final String PARAM_WATERMARKS = "watermarks";
|
public static final String PARAM_WATERMARKS = "watermarks";
|
||||||
public static final String PARAM_MANUAL = "manual";
|
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_DIRECTORY = "directory";
|
||||||
public static final String PARAM_MODE = "mode";
|
public static final String PARAM_MODE = "mode";
|
||||||
public static final String PARAM_REVISION = "revision";
|
public static final String PARAM_REVISION = "revision";
|
||||||
|
@ -72,6 +73,12 @@ public abstract class RdeModule {
|
||||||
return extractBooleanParameter(req, PARAM_MANUAL);
|
return extractBooleanParameter(req, PARAM_MANUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Parameter(PARAM_BEAM)
|
||||||
|
static boolean provideBeam(HttpServletRequest req) {
|
||||||
|
return extractBooleanParameter(req, PARAM_BEAM);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Parameter(PARAM_DIRECTORY)
|
@Parameter(PARAM_DIRECTORY)
|
||||||
static Optional<String> provideDirectory(HttpServletRequest req) {
|
static Optional<String> provideDirectory(HttpServletRequest req) {
|
||||||
|
|
|
@ -264,6 +264,11 @@ public final class RdeStagingAction implements Runnable {
|
||||||
@Inject @Config("beamStagingBucketUrl") String stagingBucketUrl;
|
@Inject @Config("beamStagingBucketUrl") String stagingBucketUrl;
|
||||||
@Inject @Config("rdeBucket") String rdeBucket;
|
@Inject @Config("rdeBucket") String rdeBucket;
|
||||||
@Inject @Parameter(RdeModule.PARAM_MANUAL) boolean manual;
|
@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_DIRECTORY) Optional<String> directory;
|
||||||
@Inject @Parameter(RdeModule.PARAM_MODE) ImmutableSet<String> modeStrings;
|
@Inject @Parameter(RdeModule.PARAM_MODE) ImmutableSet<String> modeStrings;
|
||||||
@Inject @Parameter(RequestParameters.PARAM_TLDS) ImmutableSet<String> tlds;
|
@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);
|
logger.atInfo().log("Pending deposit: %s", pending);
|
||||||
}
|
}
|
||||||
ValidationMode validationMode = lenient ? LENIENT : STRICT;
|
ValidationMode validationMode = lenient ? LENIENT : STRICT;
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy() && !beam) {
|
||||||
RdeStagingMapper mapper = new RdeStagingMapper(validationMode, pendings);
|
RdeStagingMapper mapper = new RdeStagingMapper(validationMode, pendings);
|
||||||
RdeStagingReducer reducer = reducerFactory.create(validationMode, gcsUtils);
|
RdeStagingReducer reducer = reducerFactory.create(validationMode, gcsUtils);
|
||||||
mrRunner
|
mrRunner
|
||||||
|
@ -382,6 +387,9 @@ public final class RdeStagingAction implements Runnable {
|
||||||
if (revision.isPresent()) {
|
if (revision.isPresent()) {
|
||||||
throw new BadRequestException("Revision parameter not allowed in standard operation");
|
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(
|
return ImmutableSetMultimap.copyOf(
|
||||||
Multimaps.filterValues(
|
Multimaps.filterValues(
|
||||||
|
|
|
@ -16,7 +16,9 @@ package google.registry.tools;
|
||||||
|
|
||||||
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
||||||
import static google.registry.model.tld.Registries.assertTldsExist;
|
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_DIRECTORY;
|
||||||
|
import static google.registry.rde.RdeModule.PARAM_LENIENT;
|
||||||
import static google.registry.rde.RdeModule.PARAM_MANUAL;
|
import static google.registry.rde.RdeModule.PARAM_MANUAL;
|
||||||
import static google.registry.rde.RdeModule.PARAM_MODE;
|
import static google.registry.rde.RdeModule.PARAM_MODE;
|
||||||
import static google.registry.rde.RdeModule.PARAM_REVISION;
|
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.")
|
description = "Mode of operation: FULL for RDE deposits, THIN for BRDA deposits.")
|
||||||
private RdeMode mode = RdeMode.FULL;
|
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(
|
@Parameter(
|
||||||
names = {"-r", "--revision"},
|
names = {"-r", "--revision"},
|
||||||
description = "Revision number. Use >0 for resends.")
|
description = "Revision number. Use >0 for resends.")
|
||||||
|
@ -119,6 +135,8 @@ final class GenerateEscrowDepositCommand implements CommandWithRemoteApi {
|
||||||
.param(PARAM_MANUAL, String.valueOf(true))
|
.param(PARAM_MANUAL, String.valueOf(true))
|
||||||
.param(PARAM_MODE, mode.toString())
|
.param(PARAM_MODE, mode.toString())
|
||||||
.param(PARAM_DIRECTORY, outdir)
|
.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_TLDS, tlds.stream().collect(Collectors.joining(",")))
|
||||||
.param(
|
.param(
|
||||||
PARAM_WATERMARKS,
|
PARAM_WATERMARKS,
|
||||||
|
|
|
@ -188,7 +188,55 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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");
|
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
|
||||||
|
|
||||||
assertTasksEnqueued(
|
assertTasksEnqueued(
|
||||||
|
@ -197,6 +245,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
.url("/_dr/task/rdeStaging")
|
.url("/_dr/task/rdeStaging")
|
||||||
.header("Host", "backend.test.localhost")
|
.header("Host", "backend.test.localhost")
|
||||||
.param("mode", "THIN")
|
.param("mode", "THIN")
|
||||||
|
.param("lenient", "false")
|
||||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||||
.param("tlds", "tld")
|
.param("tlds", "tld")
|
||||||
.param("directory", "test")
|
.param("directory", "test")
|
||||||
|
@ -213,6 +262,8 @@ public class GenerateEscrowDepositCommandTest
|
||||||
new TaskMatcher()
|
new TaskMatcher()
|
||||||
.url("/_dr/task/rdeStaging")
|
.url("/_dr/task/rdeStaging")
|
||||||
.header("Host", "backend.test.localhost")
|
.header("Host", "backend.test.localhost")
|
||||||
|
.param("lenient", "false")
|
||||||
|
.param("beam", "false")
|
||||||
.param("mode", "THIN")
|
.param("mode", "THIN")
|
||||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||||
.param("tlds", "tld")
|
.param("tlds", "tld")
|
||||||
|
@ -230,6 +281,8 @@ public class GenerateEscrowDepositCommandTest
|
||||||
.url("/_dr/task/rdeStaging")
|
.url("/_dr/task/rdeStaging")
|
||||||
.header("Host", "backend.test.localhost")
|
.header("Host", "backend.test.localhost")
|
||||||
.param("mode", "FULL")
|
.param("mode", "FULL")
|
||||||
|
.param("lenient", "false")
|
||||||
|
.param("beam", "false")
|
||||||
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
.param("watermarks", "2017-01-01T00:00:00.000Z")
|
||||||
.param("tlds", "tld")
|
.param("tlds", "tld")
|
||||||
.param("directory", "test")
|
.param("directory", "test")
|
||||||
|
@ -252,6 +305,8 @@ public class GenerateEscrowDepositCommandTest
|
||||||
.url("/_dr/task/rdeStaging")
|
.url("/_dr/task/rdeStaging")
|
||||||
.header("Host", "backend.test.localhost")
|
.header("Host", "backend.test.localhost")
|
||||||
.param("mode", "THIN")
|
.param("mode", "THIN")
|
||||||
|
.param("lenient", "false")
|
||||||
|
.param("beam", "false")
|
||||||
.param("watermarks", "2017-01-01T00:00:00.000Z,2017-01-02T00:00:00.000Z")
|
.param("watermarks", "2017-01-01T00:00:00.000Z,2017-01-02T00:00:00.000Z")
|
||||||
.param("tlds", "tld,anothertld")
|
.param("tlds", "tld,anothertld")
|
||||||
.param("directory", "test")
|
.param("directory", "test")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue