mirror of
https://github.com/google/nomulus.git
synced 2025-05-17 01:47:14 +02:00
Cut RegistryCursor over to global cursors
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125797729
This commit is contained in:
parent
6fa1c2d91c
commit
14522eac0c
18 changed files with 195 additions and 152 deletions
|
@ -161,6 +161,13 @@ public class Cursor extends ImmutableObject {
|
||||||
return create(cursorType, cursorTime, Key.create(scope));
|
return create(cursorType, cursorTime, Key.create(scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current time for a given cursor, or {@code START_OF_TIME} if the cursor is null.
|
||||||
|
*/
|
||||||
|
public static DateTime getCursorTimeOrStartOfTime(Cursor cursor) {
|
||||||
|
return cursor != null ? cursor.getCursorTime() : START_OF_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime getCursorTime() {
|
public DateTime getCursorTime() {
|
||||||
return cursorTime;
|
return cursorTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.googlecode.objectify.VoidWork;
|
import com.googlecode.objectify.VoidWork;
|
||||||
|
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.model.server.Lock;
|
import google.registry.model.server.Lock;
|
||||||
import google.registry.request.HttpException.NoContentException;
|
import google.registry.request.HttpException.NoContentException;
|
||||||
import google.registry.request.HttpException.ServiceUnavailableException;
|
import google.registry.request.HttpException.ServiceUnavailableException;
|
||||||
|
@ -50,13 +50,13 @@ import javax.inject.Inject;
|
||||||
* {@link NoContentException} is thrown to cancel the task.
|
* {@link NoContentException} is thrown to cancel the task.
|
||||||
*
|
*
|
||||||
* <p>The specific date for which the deposit is generated depends on the current position of the
|
* <p>The specific date for which the deposit is generated depends on the current position of the
|
||||||
* {@link RegistryCursor}. If the cursor is set to tomorrow, we do nothing and return 204 No
|
* {@link Cursor}. If the cursor is set to tomorrow, we do nothing and return 204 No Content. If the
|
||||||
* Content. If the cursor is set to today, then we create a deposit for today and advance the
|
* cursor is set to today, then we create a deposit for today and advance the cursor. If the cursor
|
||||||
* cursor. If the cursor is set to yesterday or earlier, then we create a deposit for that date,
|
* is set to yesterday or earlier, then we create a deposit for that date, advance the cursor, but
|
||||||
* advance the cursor, but we <i>do not</i> make any attempt to catch the cursor up to the current
|
* we <i>do not</i> make any attempt to catch the cursor up to the current time. Therefore <b>you
|
||||||
* time. Therefore <b>you must</b> set the cron interval to something less than the desired
|
* must</b> set the cron interval to something less than the desired interval, so the cursor can
|
||||||
* interval, so the cursor can catch up. For example, if the task is supposed to run daily, you
|
* catch up. For example, if the task is supposed to run daily, you should configure cron to execute
|
||||||
* should configure cron to execute it every twelve hours, or possibly less.
|
* it every twelve hours, or possibly less.
|
||||||
*/
|
*/
|
||||||
class EscrowTaskRunner {
|
class EscrowTaskRunner {
|
||||||
|
|
||||||
|
@ -97,7 +97,8 @@ class EscrowTaskRunner {
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
logger.info("tld=" + registry.getTld());
|
logger.info("tld=" + registry.getTld());
|
||||||
DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay();
|
DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay();
|
||||||
final DateTime nextRequiredRun = RegistryCursor.load(registry, cursorType).or(startOfToday);
|
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
|
||||||
|
final DateTime nextRequiredRun = (cursor == null ? startOfToday : cursor.getCursorTime());
|
||||||
if (nextRequiredRun.isAfter(startOfToday)) {
|
if (nextRequiredRun.isAfter(startOfToday)) {
|
||||||
throw new NoContentException("Already completed");
|
throw new NoContentException("Already completed");
|
||||||
}
|
}
|
||||||
|
@ -106,7 +107,8 @@ class EscrowTaskRunner {
|
||||||
ofy().transact(new VoidWork() {
|
ofy().transact(new VoidWork() {
|
||||||
@Override
|
@Override
|
||||||
public void vrun() {
|
public void vrun() {
|
||||||
RegistryCursor.save(registry, cursorType, nextRequiredRun.plus(interval));
|
ofy().save().entity(
|
||||||
|
Cursor.create(cursorType, nextRequiredRun.plus(interval), registry));
|
||||||
}});
|
}});
|
||||||
return null;
|
return null;
|
||||||
}};
|
}};
|
||||||
|
|
|
@ -16,8 +16,8 @@ package google.registry.rde;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.rde.RdeMode;
|
import google.registry.model.rde.RdeMode;
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
|
|
|
@ -18,18 +18,17 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
|
|
||||||
import com.googlecode.objectify.Work;
|
import com.googlecode.objectify.Work;
|
||||||
|
|
||||||
import google.registry.config.ConfigModule.Config;
|
import google.registry.config.ConfigModule.Config;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.rde.RdeMode;
|
import google.registry.model.rde.RdeMode;
|
||||||
import google.registry.model.registry.Registries;
|
import google.registry.model.registry.Registries;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.Registry.TldType;
|
import google.registry.model.registry.Registry.TldType;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -83,7 +82,7 @@ public final class PendingDepositChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableSetMultimap<String, PendingDeposit> getTldsAndWatermarksPendingDeposit(
|
private ImmutableSetMultimap<String, PendingDeposit> getTldsAndWatermarksPendingDeposit(
|
||||||
RdeMode mode, CursorType cursor, Duration interval, DateTime startingPoint) {
|
RdeMode mode, CursorType cursorType, Duration interval, DateTime startingPoint) {
|
||||||
checkArgument(interval.isLongerThan(Duration.ZERO));
|
checkArgument(interval.isLongerThan(Duration.ZERO));
|
||||||
ImmutableSetMultimap.Builder<String, PendingDeposit> builder =
|
ImmutableSetMultimap.Builder<String, PendingDeposit> builder =
|
||||||
new ImmutableSetMultimap.Builder<>();
|
new ImmutableSetMultimap.Builder<>();
|
||||||
|
@ -94,16 +93,14 @@ public final class PendingDepositChecker {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Avoid creating a transaction unless absolutely necessary.
|
// Avoid creating a transaction unless absolutely necessary.
|
||||||
Optional<DateTime> cursorValue = RegistryCursor.load(registry, cursor);
|
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
|
||||||
if (isBeforeOrAt(cursorValue.or(startingPoint), now)) {
|
DateTime cursorValue = (cursor != null ? cursor.getCursorTime() : startingPoint);
|
||||||
DateTime watermark;
|
if (isBeforeOrAt(cursorValue, now)) {
|
||||||
if (cursorValue.isPresent()) {
|
DateTime watermark = (cursor != null
|
||||||
watermark = cursorValue.get();
|
? cursor.getCursorTime()
|
||||||
} else {
|
: transactionallyInitializeCursor(registry, cursorType, startingPoint));
|
||||||
watermark = transactionallyInitializeCursor(registry, cursor, startingPoint);
|
|
||||||
}
|
|
||||||
if (isBeforeOrAt(watermark, now)) {
|
if (isBeforeOrAt(watermark, now)) {
|
||||||
builder.put(tld, PendingDeposit.create(tld, watermark, mode, cursor, interval));
|
builder.put(tld, PendingDeposit.create(tld, watermark, mode, cursorType, interval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,15 +109,16 @@ public final class PendingDepositChecker {
|
||||||
|
|
||||||
private DateTime transactionallyInitializeCursor(
|
private DateTime transactionallyInitializeCursor(
|
||||||
final Registry registry,
|
final Registry registry,
|
||||||
final CursorType cursor,
|
final CursorType cursorType,
|
||||||
final DateTime initialValue) {
|
final DateTime initialValue) {
|
||||||
return ofy().transact(new Work<DateTime>() {
|
return ofy().transact(new Work<DateTime>() {
|
||||||
@Override
|
@Override
|
||||||
public DateTime run() {
|
public DateTime run() {
|
||||||
for (DateTime value : RegistryCursor.load(registry, cursor).asSet()) {
|
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
|
||||||
return value;
|
if (cursor != null) {
|
||||||
|
return cursor.getCursorTime();
|
||||||
}
|
}
|
||||||
RegistryCursor.save(registry, cursor, initialValue);
|
ofy().save().entity(Cursor.create(cursorType, initialValue, registry));
|
||||||
return initialValue;
|
return initialValue;
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,10 @@ package google.registry.rde;
|
||||||
|
|
||||||
import static com.google.common.base.Verify.verify;
|
import static com.google.common.base.Verify.verify;
|
||||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||||
|
import static google.registry.model.common.Cursor.getCursorTimeOrStartOfTime;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.rde.RdeMode.FULL;
|
import static google.registry.model.rde.RdeMode.FULL;
|
||||||
import static google.registry.request.Action.Method.POST;
|
import static google.registry.request.Action.Method.POST;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|
||||||
|
|
||||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
@ -26,10 +27,10 @@ import com.google.common.io.ByteStreams;
|
||||||
import google.registry.config.ConfigModule.Config;
|
import google.registry.config.ConfigModule.Config;
|
||||||
import google.registry.gcs.GcsUtils;
|
import google.registry.gcs.GcsUtils;
|
||||||
import google.registry.keyring.api.KeyModule.Key;
|
import google.registry.keyring.api.KeyModule.Key;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.rde.RdeNamingUtils;
|
import google.registry.model.rde.RdeNamingUtils;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.rde.EscrowTaskRunner.EscrowTask;
|
import google.registry.rde.EscrowTaskRunner.EscrowTask;
|
||||||
import google.registry.request.Action;
|
import google.registry.request.Action;
|
||||||
import google.registry.request.HttpException.NoContentException;
|
import google.registry.request.HttpException.NoContentException;
|
||||||
|
@ -77,10 +78,11 @@ public final class RdeReportAction implements Runnable, EscrowTask {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runWithLock(DateTime watermark) throws Exception {
|
public void runWithLock(DateTime watermark) throws Exception {
|
||||||
DateTime stagingCursor =
|
DateTime cursorTime =
|
||||||
RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD).or(START_OF_TIME);
|
getCursorTimeOrStartOfTime(
|
||||||
if (!stagingCursor.isAfter(watermark)) {
|
ofy().load().key(Cursor.createKey(CursorType.RDE_UPLOAD, Registry.get(tld))).now());
|
||||||
logger.infofmt("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, stagingCursor);
|
if (!cursorTime.isAfter(watermark)) {
|
||||||
|
logger.infofmt("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, cursorTime);
|
||||||
throw new NoContentException("Waiting for RdeUploadAction to complete");
|
throw new NoContentException("Waiting for RdeUploadAction to complete");
|
||||||
}
|
}
|
||||||
String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0);
|
String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0);
|
||||||
|
|
|
@ -27,13 +27,13 @@ import google.registry.mapreduce.MapreduceRunner;
|
||||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||||
import google.registry.mapreduce.inputs.NullInput;
|
import google.registry.mapreduce.inputs.NullInput;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.model.index.EppResourceIndex;
|
import google.registry.model.index.EppResourceIndex;
|
||||||
import google.registry.model.rde.RdeMode;
|
import google.registry.model.rde.RdeMode;
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.request.Action;
|
import google.registry.request.Action;
|
||||||
import google.registry.request.Response;
|
import google.registry.request.Response;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
|
@ -89,8 +89,8 @@ import javax.inject.Inject;
|
||||||
* key and shows you its representation in lenient XML.
|
* key and shows you its representation in lenient XML.
|
||||||
*
|
*
|
||||||
* <p>Failed deposits will be retried indefinitely. This is because RDE and BRDA each have a
|
* <p>Failed deposits will be retried indefinitely. This is because RDE and BRDA each have a
|
||||||
* {@link RegistryCursor} for each TLD. Even if the cursor lags for days, it'll catch up gradually
|
* {@link Cursor} for each TLD. Even if the cursor lags for days, it'll catch up gradually on its
|
||||||
* on its own, once the data becomes valid.
|
* own, once the data becomes valid.
|
||||||
*
|
*
|
||||||
* <p>The third-party escrow provider will validate each deposit we send them. They do both schema
|
* <p>The third-party escrow provider will validate each deposit we send them. They do both schema
|
||||||
* validation and reference checking.
|
* validation and reference checking.
|
||||||
|
|
|
@ -18,6 +18,7 @@ import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
|
||||||
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
||||||
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
|
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
|
||||||
import static com.google.common.base.Verify.verify;
|
import static com.google.common.base.Verify.verify;
|
||||||
|
import static google.registry.model.common.Cursor.getCursorTimeOrStartOfTime;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
@ -33,11 +34,11 @@ import google.registry.config.ConfigModule.Config;
|
||||||
import google.registry.gcs.GcsUtils;
|
import google.registry.gcs.GcsUtils;
|
||||||
import google.registry.keyring.api.KeyModule;
|
import google.registry.keyring.api.KeyModule;
|
||||||
import google.registry.keyring.api.PgpHelper;
|
import google.registry.keyring.api.PgpHelper;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
import google.registry.model.rde.RdeMode;
|
import google.registry.model.rde.RdeMode;
|
||||||
import google.registry.model.rde.RdeNamingUtils;
|
import google.registry.model.rde.RdeNamingUtils;
|
||||||
import google.registry.model.rde.RdeRevision;
|
import google.registry.model.rde.RdeRevision;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.server.Lock;
|
import google.registry.model.server.Lock;
|
||||||
import google.registry.request.RequestParameters;
|
import google.registry.request.RequestParameters;
|
||||||
import google.registry.tldconfig.idn.IdnTableEnum;
|
import google.registry.tldconfig.idn.IdnTableEnum;
|
||||||
|
@ -201,7 +202,8 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
||||||
@Override
|
@Override
|
||||||
public void vrun() {
|
public void vrun() {
|
||||||
Registry registry = Registry.get(tld);
|
Registry registry = Registry.get(tld);
|
||||||
DateTime position = RegistryCursor.load(registry, key.cursor()).get();
|
DateTime position = getCursorTimeOrStartOfTime(
|
||||||
|
ofy().load().key(Cursor.createKey(key.cursor(), registry)).now());
|
||||||
DateTime newPosition = key.watermark().plus(key.interval());
|
DateTime newPosition = key.watermark().plus(key.interval());
|
||||||
if (!position.isBefore(newPosition)) {
|
if (!position.isBefore(newPosition)) {
|
||||||
logger.warning("Cursor has already been rolled forward.");
|
logger.warning("Cursor has already been rolled forward.");
|
||||||
|
@ -209,7 +211,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
||||||
}
|
}
|
||||||
verify(position.equals(key.watermark()),
|
verify(position.equals(key.watermark()),
|
||||||
"Partial ordering of RDE deposits broken: %s %s", position, key);
|
"Partial ordering of RDE deposits broken: %s %s", position, key);
|
||||||
RegistryCursor.save(registry, key.cursor(), newPosition);
|
ofy().save().entity(Cursor.create(key.cursor(), newPosition, registry)).now();
|
||||||
logger.infofmt("Rolled forward %s on %s cursor to %s", key.cursor(), tld, newPosition);
|
logger.infofmt("Rolled forward %s on %s cursor to %s", key.cursor(), tld, newPosition);
|
||||||
RdeRevision.saveRevision(tld, watermark, mode, revision);
|
RdeRevision.saveRevision(tld, watermark, mode, revision);
|
||||||
if (mode == RdeMode.FULL) {
|
if (mode == RdeMode.FULL) {
|
||||||
|
|
|
@ -18,10 +18,10 @@ import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
||||||
import static com.google.common.base.Verify.verify;
|
import static com.google.common.base.Verify.verify;
|
||||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||||
import static com.jcraft.jsch.ChannelSftp.OVERWRITE;
|
import static com.jcraft.jsch.ChannelSftp.OVERWRITE;
|
||||||
|
import static google.registry.model.common.Cursor.getCursorTimeOrStartOfTime;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.rde.RdeMode.FULL;
|
import static google.registry.model.rde.RdeMode.FULL;
|
||||||
import static google.registry.request.Action.Method.POST;
|
import static google.registry.request.Action.Method.POST;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ import com.jcraft.jsch.JSch;
|
||||||
import google.registry.config.ConfigModule.Config;
|
import google.registry.config.ConfigModule.Config;
|
||||||
import google.registry.gcs.GcsUtils;
|
import google.registry.gcs.GcsUtils;
|
||||||
import google.registry.keyring.api.KeyModule.Key;
|
import google.registry.keyring.api.KeyModule.Key;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.rde.RdeNamingUtils;
|
import google.registry.model.rde.RdeNamingUtils;
|
||||||
import google.registry.model.rde.RdeRevision;
|
import google.registry.model.rde.RdeRevision;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.rde.EscrowTaskRunner.EscrowTask;
|
import google.registry.rde.EscrowTaskRunner.EscrowTask;
|
||||||
import google.registry.rde.JSchSshSession.JSchSshSessionFactory;
|
import google.registry.rde.JSchSshSession.JSchSshSessionFactory;
|
||||||
import google.registry.request.Action;
|
import google.registry.request.Action;
|
||||||
|
@ -119,17 +119,17 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runWithLock(DateTime watermark) throws Exception {
|
public void runWithLock(DateTime watermark) throws Exception {
|
||||||
DateTime stagingCursor =
|
DateTime stagingCursorTime = getCursorTimeOrStartOfTime(
|
||||||
RegistryCursor.load(Registry.get(tld), CursorType.RDE_STAGING).or(START_OF_TIME);
|
ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get(tld))).now());
|
||||||
if (!stagingCursor.isAfter(watermark)) {
|
if (!stagingCursorTime.isAfter(watermark)) {
|
||||||
logger.infofmt("tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursor);
|
logger.infofmt("tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursorTime);
|
||||||
throw new ServiceUnavailableException("Waiting for RdeStagingAction to complete");
|
throw new ServiceUnavailableException("Waiting for RdeStagingAction to complete");
|
||||||
}
|
}
|
||||||
DateTime sftpCursor =
|
DateTime sftpCursorTime = getCursorTimeOrStartOfTime(
|
||||||
RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD_SFTP).or(START_OF_TIME);
|
ofy().load().key(Cursor.createKey(CursorType.RDE_UPLOAD_SFTP, Registry.get(tld))).now());
|
||||||
if (sftpCursor.plus(sftpCooldown).isAfter(clock.nowUtc())) {
|
if (sftpCursorTime.plus(sftpCooldown).isAfter(clock.nowUtc())) {
|
||||||
// Fail the task good and hard so it retries until the cooldown passes.
|
// Fail the task good and hard so it retries until the cooldown passes.
|
||||||
logger.infofmt("tld=%s cursor=%s sftpCursor=%s", tld, watermark, sftpCursor);
|
logger.infofmt("tld=%s cursor=%s sftpCursor=%s", tld, watermark, sftpCursorTime);
|
||||||
throw new ServiceUnavailableException("SFTP cooldown has not yet passed");
|
throw new ServiceUnavailableException("SFTP cooldown has not yet passed");
|
||||||
}
|
}
|
||||||
int revision = RdeRevision.getNextRevision(tld, watermark, FULL) - 1;
|
int revision = RdeRevision.getNextRevision(tld, watermark, FULL) - 1;
|
||||||
|
@ -145,8 +145,10 @@ public final class RdeUploadAction implements Runnable, EscrowTask {
|
||||||
ofy().transact(new VoidWork() {
|
ofy().transact(new VoidWork() {
|
||||||
@Override
|
@Override
|
||||||
public void vrun() {
|
public void vrun() {
|
||||||
RegistryCursor.save(
|
Cursor cursor =
|
||||||
Registry.get(tld), CursorType.RDE_UPLOAD_SFTP, ofy().getTransactionTime());
|
Cursor.create(
|
||||||
|
CursorType.RDE_UPLOAD_SFTP, ofy().getTransactionTime(), Registry.get(tld));
|
||||||
|
ofy().save().entity(cursor).now();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
response.setContentType(PLAIN_TEXT_UTF_8);
|
response.setContentType(PLAIN_TEXT_UTF_8);
|
||||||
|
|
|
@ -14,25 +14,24 @@
|
||||||
|
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
|
|
||||||
import com.beust.jcommander.Parameter;
|
import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
|
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registries;
|
import google.registry.model.registry.Registries;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.Registry.TldType;
|
import google.registry.model.registry.Registry.TldType;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.tools.Command.RemoteApiCommand;
|
import google.registry.tools.Command.RemoteApiCommand;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** Lists {@link RegistryCursor} timestamps used by locking rolling cursor tasks, like in RDE. */
|
/** Lists {@link Cursor} timestamps used by locking rolling cursor tasks, like in RDE. */
|
||||||
@Parameters(separators = " =", commandDescription = "Lists cursor timestamps used by LRC tasks")
|
@Parameters(separators = " =", commandDescription = "Lists cursor timestamps used by LRC tasks")
|
||||||
final class ListCursorsCommand implements RemoteApiCommand {
|
final class ListCursorsCommand implements RemoteApiCommand {
|
||||||
|
|
||||||
|
@ -63,8 +62,8 @@ final class ListCursorsCommand implements RemoteApiCommand {
|
||||||
if (filterEscrowEnabled && !registry.getEscrowEnabled()) {
|
if (filterEscrowEnabled && !registry.getEscrowEnabled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Optional<DateTime> cursor = RegistryCursor.load(registry, cursorType);
|
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
|
||||||
lines.add(String.format("%-25s%s", cursor.isPresent() ? cursor.get() : "absent", tld));
|
lines.add(String.format("%-25s%s", cursor != null ? cursor.getCursorTime() : "absent", tld));
|
||||||
}
|
}
|
||||||
for (String line : Ordering.natural().sortedCopy(lines)) {
|
for (String line : Ordering.natural().sortedCopy(lines)) {
|
||||||
System.out.println(line);
|
System.out.println(line);
|
||||||
|
|
|
@ -14,27 +14,24 @@
|
||||||
|
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.beust.jcommander.Parameter;
|
import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
|
|
||||||
import google.registry.model.common.Cursor;
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.tools.params.DateTimeParameter;
|
import google.registry.tools.params.DateTimeParameter;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** Modifies {code RegistryCursor} timestamps used by locking rolling cursor tasks, like in RDE. */
|
/** Modifies {@link Cursor} timestamps used by locking rolling cursor tasks, like in RDE. */
|
||||||
@Parameters(separators = " =", commandDescription = "Modifies cursor timestamps used by LRC tasks")
|
@Parameters(separators = " =", commandDescription = "Modifies cursor timestamps used by LRC tasks")
|
||||||
final class UpdateCursorsCommand extends MutatingCommand {
|
final class UpdateCursorsCommand extends MutatingCommand {
|
||||||
|
|
||||||
// TODO(b/28386088): Cut command over to new Cursor format
|
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
description = "TLDs on which to operate.",
|
description = "TLDs on which to operate.",
|
||||||
required = true)
|
required = true)
|
||||||
|
@ -57,16 +54,10 @@ final class UpdateCursorsCommand extends MutatingCommand {
|
||||||
protected void init() throws Exception {
|
protected void init() throws Exception {
|
||||||
for (String tld : tlds) {
|
for (String tld : tlds) {
|
||||||
Registry registry = Registry.get(tld);
|
Registry registry = Registry.get(tld);
|
||||||
Optional<DateTime> expectedTimestamp = RegistryCursor.load(registry, cursorType);
|
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
|
||||||
stageEntityChange(
|
stageEntityChange(
|
||||||
expectedTimestamp.isPresent()
|
cursor,
|
||||||
? RegistryCursor.create(registry, cursorType, expectedTimestamp.get())
|
Cursor.create(cursorType, newTimestamp, registry));
|
||||||
: null,
|
}
|
||||||
RegistryCursor.create(registry, cursorType, newTimestamp));
|
|
||||||
Cursor.CursorType newCursorType = Cursor.CursorType.valueOf(cursorType.name());
|
|
||||||
stageEntityChange(
|
|
||||||
null,
|
|
||||||
Cursor.create(newCursorType, newTimestamp, registry));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.backup;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
|
import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
@ -26,12 +27,12 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.googlecode.objectify.VoidWork;
|
import com.googlecode.objectify.VoidWork;
|
||||||
|
|
||||||
import google.registry.config.TestRegistryConfig;
|
import google.registry.config.TestRegistryConfig;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.ofy.CommitLogBucket;
|
import google.registry.model.ofy.CommitLogBucket;
|
||||||
import google.registry.model.ofy.CommitLogCheckpoint;
|
import google.registry.model.ofy.CommitLogCheckpoint;
|
||||||
import google.registry.model.ofy.Ofy;
|
import google.registry.model.ofy.Ofy;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
|
@ -309,7 +310,8 @@ public class CommitLogCheckpointStrategyTest {
|
||||||
@Override
|
@Override
|
||||||
public void vrun() {
|
public void vrun() {
|
||||||
String tld = "tld" + bucketId;
|
String tld = "tld" + bucketId;
|
||||||
RegistryCursor.save(Registry.get(tld), CursorType.RDE_REPORT, ofy.getTransactionTime());
|
ofy().save().entity(
|
||||||
|
Cursor.create(CursorType.RDE_REPORT, ofy.getTransactionTime(), Registry.get(tld)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fakeBucketIdSupplier.value = null;
|
fakeBucketIdSupplier.value = null;
|
||||||
|
|
|
@ -23,9 +23,9 @@ import static org.joda.time.Duration.standardSeconds;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.model.server.Lock;
|
import google.registry.model.server.Lock;
|
||||||
import google.registry.rde.EscrowTaskRunner.EscrowTask;
|
import google.registry.rde.EscrowTaskRunner.EscrowTask;
|
||||||
import google.registry.request.HttpException.NoContentException;
|
import google.registry.request.HttpException.NoContentException;
|
||||||
|
@ -77,13 +77,13 @@ public class EscrowTaskRunnerTest {
|
||||||
public void testRun_cursorIsToday_advancesCursorToTomorrow() throws Exception {
|
public void testRun_cursorIsToday_advancesCursorToTomorrow() throws Exception {
|
||||||
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
|
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
|
||||||
persistResource(
|
persistResource(
|
||||||
RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ")));
|
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
|
||||||
runner.lockRunAndRollForward(
|
runner.lockRunAndRollForward(
|
||||||
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
|
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
|
||||||
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
|
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
|
||||||
ofy().clearSessionCache();
|
ofy().clearSessionCache();
|
||||||
assertThat(RegistryCursor.load(registry, CursorType.RDE_STAGING))
|
Cursor cursor = ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, registry)).now();
|
||||||
.hasValue(DateTime.parse("2006-06-07TZ"));
|
assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-06-07TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -92,15 +92,16 @@ public class EscrowTaskRunnerTest {
|
||||||
runner.lockRunAndRollForward(
|
runner.lockRunAndRollForward(
|
||||||
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
|
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
|
||||||
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
|
verify(task).runWithLock(DateTime.parse("2006-06-06TZ"));
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), CursorType.RDE_STAGING))
|
Cursor cursor =
|
||||||
.hasValue(DateTime.parse("2006-06-07TZ"));
|
ofy().load().key(Cursor.createKey(CursorType.RDE_STAGING, Registry.get("lol"))).now();
|
||||||
|
assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-06-07TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_cursorInTheFuture_doesNothing() throws Exception {
|
public void testRun_cursorInTheFuture_doesNothing() throws Exception {
|
||||||
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
|
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
|
||||||
persistResource(
|
persistResource(
|
||||||
RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ")));
|
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ"), registry));
|
||||||
thrown.expect(NoContentException.class, "Already completed");
|
thrown.expect(NoContentException.class, "Already completed");
|
||||||
runner.lockRunAndRollForward(
|
runner.lockRunAndRollForward(
|
||||||
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
|
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
|
||||||
|
@ -112,7 +113,7 @@ public class EscrowTaskRunnerTest {
|
||||||
thrown.expect(ServiceUnavailableException.class, "Lock in use: " + lockName);
|
thrown.expect(ServiceUnavailableException.class, "Lock in use: " + lockName);
|
||||||
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
|
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
|
||||||
persistResource(
|
persistResource(
|
||||||
RegistryCursor.create(registry, CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ")));
|
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
|
||||||
Lock.executeWithLocks(
|
Lock.executeWithLocks(
|
||||||
new Callable<Void>() {
|
new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
package google.registry.rde;
|
package google.registry.rde;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.common.Cursor.CursorType.BRDA;
|
||||||
|
import static google.registry.model.common.Cursor.CursorType.RDE_STAGING;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.rde.RdeMode.FULL;
|
import static google.registry.model.rde.RdeMode.FULL;
|
||||||
import static google.registry.model.rde.RdeMode.THIN;
|
import static google.registry.model.rde.RdeMode.THIN;
|
||||||
import static google.registry.model.registry.RegistryCursor.CursorType.BRDA;
|
|
||||||
import static google.registry.model.registry.RegistryCursor.CursorType.RDE_STAGING;
|
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static org.joda.time.DateTimeConstants.TUESDAY;
|
import static org.joda.time.DateTimeConstants.TUESDAY;
|
||||||
|
@ -29,10 +29,10 @@ import com.google.common.collect.ImmutableSetMultimap;
|
||||||
|
|
||||||
import com.googlecode.objectify.VoidWork;
|
import com.googlecode.objectify.VoidWork;
|
||||||
|
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.ofy.Ofy;
|
import google.registry.model.ofy.Ofy;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
|
@ -107,10 +107,10 @@ public class PendingDepositCheckerTest {
|
||||||
createTldWithEscrowEnabled("lol");
|
createTldWithEscrowEnabled("lol");
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
Registry registry = Registry.get("lol");
|
Registry registry = Registry.get("lol");
|
||||||
assertThat(RegistryCursor.load(registry, RDE_STAGING)).isAbsent();
|
assertThat(ofy().load().key(Cursor.createKey(RDE_STAGING, registry)).now()).isNull();
|
||||||
checker.getTldsAndWatermarksPendingDepositForRdeAndBrda();
|
checker.getTldsAndWatermarksPendingDepositForRdeAndBrda();
|
||||||
assertThat(RegistryCursor.load(registry, RDE_STAGING))
|
assertThat(ofy().load().key(Cursor.createKey(RDE_STAGING, registry)).now().getCursorTime())
|
||||||
.hasValue(DateTime.parse("2000-01-01TZ"));
|
.isEqualTo(DateTime.parse("2000-01-01TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -122,7 +122,8 @@ public class PendingDepositCheckerTest {
|
||||||
setCursor(Registry.get("lol"), RDE_STAGING, yesterday);
|
setCursor(Registry.get("lol"), RDE_STAGING, yesterday);
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
checker.getTldsAndWatermarksPendingDepositForRdeAndBrda();
|
checker.getTldsAndWatermarksPendingDepositForRdeAndBrda();
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING)).hasValue(yesterday);
|
Cursor cursor = ofy().load().key(Cursor.createKey(RDE_STAGING, Registry.get("lol"))).now();
|
||||||
|
assertThat(cursor.getCursorTime()).isEqualTo(yesterday);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -134,9 +135,9 @@ public class PendingDepositCheckerTest {
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
setCursor(registry, RDE_STAGING, DateTime.parse("2000-01-02TZ")); // assume rde is already done
|
setCursor(registry, RDE_STAGING, DateTime.parse("2000-01-02TZ")); // assume rde is already done
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
assertThat(RegistryCursor.load(registry, BRDA)).isAbsent();
|
assertThat(ofy().load().key(Cursor.createKey(BRDA, registry)).now()).isNull();
|
||||||
assertThat(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda()).isEmpty();
|
assertThat(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda()).isEmpty();
|
||||||
assertThat(RegistryCursor.load(registry, BRDA)).isAbsent();
|
assertThat(ofy().load().key(Cursor.createKey(BRDA, registry)).now()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -173,7 +174,7 @@ public class PendingDepositCheckerTest {
|
||||||
ofy().transact(new VoidWork() {
|
ofy().transact(new VoidWork() {
|
||||||
@Override
|
@Override
|
||||||
public void vrun() {
|
public void vrun() {
|
||||||
RegistryCursor.save(registry, cursorType, value);
|
ofy().save().entity(Cursor.create(cursorType, value, registry));
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.rde;
|
||||||
import static com.google.appengine.api.urlfetch.HTTPMethod.PUT;
|
import static com.google.appengine.api.urlfetch.HTTPMethod.PUT;
|
||||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.GcsTestingUtils.writeGcsFile;
|
import static google.registry.testing.GcsTestingUtils.writeGcsFile;
|
||||||
|
@ -43,9 +44,9 @@ import com.google.common.io.ByteSource;
|
||||||
import google.registry.config.RegistryConfig;
|
import google.registry.config.RegistryConfig;
|
||||||
import google.registry.config.RegistryEnvironment;
|
import google.registry.config.RegistryEnvironment;
|
||||||
import google.registry.gcs.GcsUtils;
|
import google.registry.gcs.GcsUtils;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.request.HttpException.InternalServerErrorException;
|
import google.registry.request.HttpException.InternalServerErrorException;
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import google.registry.testing.BouncyCastleProviderRule;
|
import google.registry.testing.BouncyCastleProviderRule;
|
||||||
|
@ -121,11 +122,13 @@ public class RdeReportActionTest {
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
PGPPublicKey encryptKey = new RdeKeyringModule().get().getRdeStagingEncryptionKey();
|
PGPPublicKey encryptKey = new RdeKeyringModule().get().getRdeStagingEncryptionKey();
|
||||||
createTld("test");
|
createTld("test");
|
||||||
persistResource(RegistryCursor.create(
|
persistResource(
|
||||||
Registry.get("test"), CursorType.RDE_REPORT, DateTime.parse("2006-06-06TZ")));
|
Cursor.create(CursorType.RDE_REPORT, DateTime.parse("2006-06-06TZ"), Registry.get("test")));
|
||||||
persistResource(RegistryCursor.create(
|
persistResource(
|
||||||
Registry.get("test"), CursorType.RDE_UPLOAD, DateTime.parse("2006-06-07TZ")));
|
Cursor.create(CursorType.RDE_UPLOAD, DateTime.parse("2006-06-07TZ"), Registry.get("test")));
|
||||||
writeGcsFile(gcsService, reportFile,
|
writeGcsFile(
|
||||||
|
gcsService,
|
||||||
|
reportFile,
|
||||||
Ghostryde.encode(REPORT_XML.read(), encryptKey, "darkside.xml", DateTime.now()));
|
Ghostryde.encode(REPORT_XML.read(), encryptKey, "darkside.xml", DateTime.now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +187,11 @@ public class RdeReportActionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTime loadRdeReportCursor() {
|
private DateTime loadRdeReportCursor() {
|
||||||
return RegistryCursor.load(Registry.get("test"), CursorType.RDE_REPORT).get();
|
return ofy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(CursorType.RDE_REPORT, Registry.get("test")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImmutableMap<String, String> mapifyHeaders(Iterable<HTTPHeader> headers) {
|
private static ImmutableMap<String, String> mapifyHeaders(Iterable<HTTPHeader> headers) {
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
package google.registry.rde;
|
package google.registry.rde;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.common.Cursor.CursorType.BRDA;
|
||||||
|
import static google.registry.model.common.Cursor.CursorType.RDE_STAGING;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.registry.RegistryCursor.CursorType.BRDA;
|
|
||||||
import static google.registry.model.registry.RegistryCursor.CursorType.RDE_STAGING;
|
|
||||||
import static google.registry.rde.RdeFixtures.makeContactResource;
|
import static google.registry.rde.RdeFixtures.makeContactResource;
|
||||||
import static google.registry.rde.RdeFixtures.makeDomainResource;
|
import static google.registry.rde.RdeFixtures.makeDomainResource;
|
||||||
import static google.registry.rde.RdeFixtures.makeHostResource;
|
import static google.registry.rde.RdeFixtures.makeHostResource;
|
||||||
|
@ -46,11 +46,11 @@ import com.googlecode.objectify.VoidWork;
|
||||||
import google.registry.keyring.api.Keyring;
|
import google.registry.keyring.api.Keyring;
|
||||||
import google.registry.keyring.api.PgpHelper;
|
import google.registry.keyring.api.PgpHelper;
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.model.ofy.Ofy;
|
import google.registry.model.ofy.Ofy;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.request.RequestParameters;
|
import google.registry.request.RequestParameters;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
|
@ -295,10 +295,15 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday
|
clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday
|
||||||
action.run();
|
action.run();
|
||||||
executeTasksUntilEmpty("mapreduce", clock);
|
executeTasksUntilEmpty("mapreduce", clock);
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
|
assertThat(
|
||||||
.hasValue(DateTime.parse("2000-01-02TZ"));
|
ofy()
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), BRDA))
|
.load()
|
||||||
.hasValue(DateTime.parse("2000-01-04TZ"));
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("2000-01-02TZ"));
|
||||||
|
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("lol"))).now().getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("2000-01-04TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -311,10 +316,15 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
clock.setTo(DateTime.parse("2000-01-04TZ")); // Tuesday
|
clock.setTo(DateTime.parse("2000-01-04TZ")); // Tuesday
|
||||||
action.run();
|
action.run();
|
||||||
executeTasksUntilEmpty("mapreduce", clock);
|
executeTasksUntilEmpty("mapreduce", clock);
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
|
assertThat(
|
||||||
.hasValue(DateTime.parse("2000-01-05TZ"));
|
ofy()
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), BRDA))
|
.load()
|
||||||
.hasValue(DateTime.parse("2000-01-11TZ"));
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("2000-01-05TZ"));
|
||||||
|
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("lol"))).now().getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("2000-01-11TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -363,11 +373,14 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
.containsExactly("New Registrar", "The Registrar");
|
.containsExactly("New Registrar", "The Registrar");
|
||||||
assertThat(mapifyCounts(header)).containsEntry(RdeResourceType.REGISTRAR.getUri(), 2L);
|
assertThat(mapifyCounts(header)).containsEntry(RdeResourceType.REGISTRAR.getUri(), 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assertThat(
|
||||||
|
ofy().load().key(Cursor.createKey(RDE_STAGING, Registry.get("fop"))).now()
|
||||||
|
.getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("1971-01-02TZ"));
|
||||||
|
|
||||||
assertThat(RegistryCursor.load(Registry.get("fop"), RDE_STAGING))
|
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("fop"))).now().getCursorTime())
|
||||||
.hasValue(DateTime.parse("1971-01-02TZ"));
|
.isEqualTo(DateTime.parse("1971-01-12TZ"));
|
||||||
assertThat(RegistryCursor.load(Registry.get("fop"), BRDA))
|
|
||||||
.hasValue(DateTime.parse("1971-01-12TZ"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -561,8 +574,13 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
executeTasksUntilEmpty("mapreduce", clock);
|
executeTasksUntilEmpty("mapreduce", clock);
|
||||||
String firstDeposit = readXml("lol_1984-12-18_full_S1_R0.xml.ghostryde");
|
String firstDeposit = readXml("lol_1984-12-18_full_S1_R0.xml.ghostryde");
|
||||||
assertThat(firstDeposit).doesNotContain("ns1.justine.lol");
|
assertThat(firstDeposit).doesNotContain("ns1.justine.lol");
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
|
assertThat(
|
||||||
.hasValue(DateTime.parse("1984-12-19TZ"));
|
ofy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("1984-12-19TZ"));
|
||||||
|
|
||||||
// Second mapreduce should emit the old version of host.
|
// Second mapreduce should emit the old version of host.
|
||||||
action.response = new FakeResponse();
|
action.response = new FakeResponse();
|
||||||
|
@ -572,8 +590,14 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
assertThat(secondDeposit).contains("ns1.justine.lol");
|
assertThat(secondDeposit).contains("ns1.justine.lol");
|
||||||
assertThat(secondDeposit).contains("feed::a:bee");
|
assertThat(secondDeposit).contains("feed::a:bee");
|
||||||
assertThat(secondDeposit).doesNotContain("dead:beef::cafe");
|
assertThat(secondDeposit).doesNotContain("dead:beef::cafe");
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
|
|
||||||
.hasValue(DateTime.parse("1984-12-20TZ"));
|
assertThat(
|
||||||
|
ofy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("1984-12-20TZ"));
|
||||||
|
|
||||||
// Third mapreduce emits current version of host.
|
// Third mapreduce emits current version of host.
|
||||||
action.response = new FakeResponse();
|
action.response = new FakeResponse();
|
||||||
|
@ -583,8 +607,13 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
assertThat(thirdDeposit).contains("ns1.justine.lol");
|
assertThat(thirdDeposit).contains("ns1.justine.lol");
|
||||||
assertThat(thirdDeposit).doesNotContain("feed::a:bee");
|
assertThat(thirdDeposit).doesNotContain("feed::a:bee");
|
||||||
assertThat(thirdDeposit).contains("dead:beef::cafe");
|
assertThat(thirdDeposit).contains("dead:beef::cafe");
|
||||||
assertThat(RegistryCursor.load(Registry.get("lol"), RDE_STAGING))
|
assertThat(
|
||||||
.hasValue(DateTime.parse("1984-12-21TZ"));
|
ofy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
|
.isEqualTo(DateTime.parse("1984-12-21TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readXml(String objectName) throws IOException, PGPException {
|
private String readXml(String objectName) throws IOException, PGPException {
|
||||||
|
@ -623,7 +652,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
ofy().transact(new VoidWork() {
|
ofy().transact(new VoidWork() {
|
||||||
@Override
|
@Override
|
||||||
public void vrun() {
|
public void vrun() {
|
||||||
RegistryCursor.save(registry, cursorType, value);
|
ofy().save().entity(Cursor.create(cursorType, value, registry)).now();
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,10 @@ import com.googlecode.objectify.VoidWork;
|
||||||
|
|
||||||
import google.registry.gcs.GcsUtils;
|
import google.registry.gcs.GcsUtils;
|
||||||
import google.registry.keyring.api.Keyring;
|
import google.registry.keyring.api.Keyring;
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.rde.RdeRevision;
|
import google.registry.model.rde.RdeRevision;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
import google.registry.rde.JSchSshSession.JSchSshSessionFactory;
|
import google.registry.rde.JSchSshSession.JSchSshSessionFactory;
|
||||||
import google.registry.request.HttpException.ServiceUnavailableException;
|
import google.registry.request.HttpException.ServiceUnavailableException;
|
||||||
import google.registry.request.RequestParameters;
|
import google.registry.request.RequestParameters;
|
||||||
|
@ -264,7 +264,7 @@ public class RdeUploadActionTest {
|
||||||
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
||||||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||||
persistResource(
|
persistResource(
|
||||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
|
||||||
createAction(uploadUrl).runWithLock(uploadCursor);
|
createAction(uploadUrl).runWithLock(uploadCursor);
|
||||||
assertThat(response.getStatus()).isEqualTo(200);
|
assertThat(response.getStatus()).isEqualTo(200);
|
||||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||||
|
@ -283,7 +283,7 @@ public class RdeUploadActionTest {
|
||||||
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
||||||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||||
persistResource(
|
persistResource(
|
||||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
|
||||||
createAction(uploadUrl).runWithLock(uploadCursor);
|
createAction(uploadUrl).runWithLock(uploadCursor);
|
||||||
assertThat(response.getStatus()).isEqualTo(200);
|
assertThat(response.getStatus()).isEqualTo(200);
|
||||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||||
|
@ -311,7 +311,7 @@ public class RdeUploadActionTest {
|
||||||
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
||||||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
|
||||||
createAction(uploadUrl).runWithLock(uploadCursor);
|
createAction(uploadUrl).runWithLock(uploadCursor);
|
||||||
assertThat(response.getStatus()).isEqualTo(200);
|
assertThat(response.getStatus()).isEqualTo(200);
|
||||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||||
|
@ -331,7 +331,7 @@ public class RdeUploadActionTest {
|
||||||
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
||||||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||||
persistResource(
|
persistResource(
|
||||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
|
||||||
createAction(uploadUrl).runWithLock(uploadCursor);
|
createAction(uploadUrl).runWithLock(uploadCursor);
|
||||||
// Only verify signature for SFTP versions, since we check elsewhere that the GCS files are
|
// Only verify signature for SFTP versions, since we check elsewhere that the GCS files are
|
||||||
// identical to the ones sent over SFTP.
|
// identical to the ones sent over SFTP.
|
||||||
|
@ -349,7 +349,7 @@ public class RdeUploadActionTest {
|
||||||
DateTime stagingCursor = DateTime.parse("2010-10-17TZ");
|
DateTime stagingCursor = DateTime.parse("2010-10-17TZ");
|
||||||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||||
persistResource(
|
persistResource(
|
||||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
Cursor.create(CursorType.RDE_STAGING, stagingCursor, Registry.get("tld")));
|
||||||
thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingAction to complete");
|
thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingAction to complete");
|
||||||
createAction(null).runWithLock(uploadCursor);
|
createAction(null).runWithLock(uploadCursor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
|
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -39,8 +39,8 @@ public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand>
|
||||||
@Test
|
@Test
|
||||||
public void testListCursors_twoTldsOneAbsent_printsAbsentAndTimestampSorted() throws Exception {
|
public void testListCursors_twoTldsOneAbsent_printsAbsentAndTimestampSorted() throws Exception {
|
||||||
createTlds("foo", "bar");
|
createTlds("foo", "bar");
|
||||||
persistResource(RegistryCursor.create(
|
persistResource(
|
||||||
Registry.get("bar"), CursorType.BRDA, DateTime.parse("1984-12-18TZ")));
|
Cursor.create(CursorType.BRDA, DateTime.parse("1984-12-18TZ"), Registry.get("bar")));
|
||||||
runCommand("--type=BRDA");
|
runCommand("--type=BRDA");
|
||||||
assertThat(getStdoutAsLines())
|
assertThat(getStdoutAsLines())
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
|
||||||
|
import google.registry.model.common.Cursor;
|
||||||
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.RegistryCursor;
|
|
||||||
import google.registry.model.registry.RegistryCursor.CursorType;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -39,20 +40,19 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
|
||||||
|
|
||||||
void doUpdateTest() throws Exception {
|
void doUpdateTest() throws Exception {
|
||||||
runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "foo");
|
runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "foo");
|
||||||
assertThat(RegistryCursor.load(registry, CursorType.BRDA))
|
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now().getCursorTime())
|
||||||
.hasValue(DateTime.parse("1984-12-18TZ"));
|
.isEqualTo(DateTime.parse("1984-12-18TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateCursors_oldValueIsAbsent() throws Exception {
|
public void testUpdateCursors_oldValueIsAbsent() throws Exception {
|
||||||
assertThat(RegistryCursor.load(registry, CursorType.BRDA)).isAbsent();
|
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now()).isNull();
|
||||||
doUpdateTest();
|
doUpdateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateCursors_hasOldValue() throws Exception {
|
public void testUpdateCursors_hasOldValue() throws Exception {
|
||||||
persistResource(
|
persistResource(Cursor.create(CursorType.BRDA, DateTime.parse("1950-12-18TZ"), registry));
|
||||||
RegistryCursor.create(registry, CursorType.BRDA, DateTime.parse("1950-12-18TZ")));
|
|
||||||
doUpdateTest();
|
doUpdateTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue