mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Convert even more classes to auditedOfy() (#1157)
* Convert even more classes to auditedOfy() This covers almost all of the classes in the second round of the sheet. There are still some classes that need conversion but this is the vast majority of them. https://docs.google.com/spreadsheets/d/1aFEFuyH6vVW6b-h71O9f5CuUc6Y7YjZ2kdRL3lwXcVk/edit?resourcekey=0-guwZVKfSH-pntER1tUit6w#gid=1355213322 for notes
This commit is contained in:
parent
8a8ad6e997
commit
7b03d28ab1
73 changed files with 635 additions and 545 deletions
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package google.registry.backup;
|
package google.registry.backup;
|
||||||
|
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.EntityTranslator;
|
import com.google.appengine.api.datastore.EntityTranslator;
|
||||||
import com.google.common.collect.AbstractIterator;
|
import com.google.common.collect.AbstractIterator;
|
||||||
|
@ -45,7 +45,7 @@ public class BackupUtils {
|
||||||
* {@link OutputStream} in delimited protocol buffer format.
|
* {@link OutputStream} in delimited protocol buffer format.
|
||||||
*/
|
*/
|
||||||
static void serializeEntity(ImmutableObject entity, OutputStream stream) throws IOException {
|
static void serializeEntity(ImmutableObject entity, OutputStream stream) throws IOException {
|
||||||
EntityTranslator.convertToPb(ofy().save().toEntity(entity)).writeDelimitedTo(stream);
|
EntityTranslator.convertToPb(auditedOfy().save().toEntity(entity)).writeDelimitedTo(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,11 +61,12 @@ public class BackupUtils {
|
||||||
@Override
|
@Override
|
||||||
protected ImmutableObject computeNext() {
|
protected ImmutableObject computeNext() {
|
||||||
EntityProto proto = new EntityProto();
|
EntityProto proto = new EntityProto();
|
||||||
if (proto.parseDelimitedFrom(input)) { // False means end of stream; other errors throw.
|
if (proto.parseDelimitedFrom(input)) { // False means end of stream; other errors throw.
|
||||||
return ofy().load().fromEntity(EntityTranslator.createFromPb(proto));
|
return auditedOfy().load().fromEntity(EntityTranslator.createFromPb(proto));
|
||||||
}
|
}
|
||||||
return endOfData();
|
return endOfData();
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImmutableList<ImmutableObject> deserializeEntities(byte[] bytes) {
|
public static ImmutableList<ImmutableObject> deserializeEntities(byte[] bytes) {
|
||||||
|
|
|
@ -18,7 +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 google.registry.backup.ExportCommitLogDiffAction.LOWER_CHECKPOINT_TIME_PARAM;
|
import static google.registry.backup.ExportCommitLogDiffAction.LOWER_CHECKPOINT_TIME_PARAM;
|
||||||
import static google.registry.backup.ExportCommitLogDiffAction.UPPER_CHECKPOINT_TIME_PARAM;
|
import static google.registry.backup.ExportCommitLogDiffAction.UPPER_CHECKPOINT_TIME_PARAM;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ public final class CommitLogCheckpointAction implements Runnable {
|
||||||
final CommitLogCheckpoint checkpoint = strategy.computeCheckpoint();
|
final CommitLogCheckpoint checkpoint = strategy.computeCheckpoint();
|
||||||
logger.atInfo().log(
|
logger.atInfo().log(
|
||||||
"Generated candidate checkpoint for time: %s", checkpoint.getCheckpointTime());
|
"Generated candidate checkpoint for time: %s", checkpoint.getCheckpointTime());
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
DateTime lastWrittenTime = CommitLogCheckpointRoot.loadRoot().getLastWrittenTime();
|
DateTime lastWrittenTime = CommitLogCheckpointRoot.loadRoot().getLastWrittenTime();
|
||||||
if (isBeforeOrAt(checkpoint.getCheckpointTime(), lastWrittenTime)) {
|
if (isBeforeOrAt(checkpoint.getCheckpointTime(), lastWrittenTime)) {
|
||||||
|
@ -73,7 +72,7 @@ public final class CommitLogCheckpointAction implements Runnable {
|
||||||
"Newer checkpoint already written at time: %s", lastWrittenTime);
|
"Newer checkpoint already written at time: %s", lastWrittenTime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ofy()
|
auditedOfy()
|
||||||
.saveWithoutBackup()
|
.saveWithoutBackup()
|
||||||
.entities(
|
.entities(
|
||||||
checkpoint, CommitLogCheckpointRoot.create(checkpoint.getCheckpointTime()));
|
checkpoint, CommitLogCheckpointRoot.create(checkpoint.getCheckpointTime()));
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.backup;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static java.lang.Boolean.FALSE;
|
import static java.lang.Boolean.FALSE;
|
||||||
import static java.lang.Boolean.TRUE;
|
import static java.lang.Boolean.TRUE;
|
||||||
|
@ -75,9 +75,17 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
||||||
@Inject MapreduceRunner mrRunner;
|
@Inject MapreduceRunner mrRunner;
|
||||||
@Inject Response response;
|
@Inject Response response;
|
||||||
@Inject Clock clock;
|
@Inject Clock clock;
|
||||||
@Inject @Config("commitLogDatastoreRetention") Duration maxAge;
|
|
||||||
@Inject @Parameter(PARAM_DRY_RUN) boolean isDryRun;
|
@Inject
|
||||||
@Inject DeleteOldCommitLogsAction() {}
|
@Config("commitLogDatastoreRetention")
|
||||||
|
Duration maxAge;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Parameter(PARAM_DRY_RUN)
|
||||||
|
boolean isDryRun;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DeleteOldCommitLogsAction() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -138,12 +146,12 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
||||||
// If it isn't a Key<CommitLogManifest> then it should be an EppResource, which we need to
|
// If it isn't a Key<CommitLogManifest> then it should be an EppResource, which we need to
|
||||||
// load to emit the revisions.
|
// load to emit the revisions.
|
||||||
//
|
//
|
||||||
Object object = ofy().load().key(key).now();
|
Object object = auditedOfy().load().key(key).now();
|
||||||
checkNotNull(object, "Received a key to a missing object. key: %s", key);
|
checkNotNull(object, "Received a key to a missing object. key: %s", key);
|
||||||
checkState(
|
checkState(
|
||||||
object instanceof EppResource,
|
object instanceof EppResource,
|
||||||
"Received a key to an object that isn't EppResource nor CommitLogManifest."
|
"Received a key to an object that isn't EppResource nor CommitLogManifest."
|
||||||
+ " Key: %s object type: %s",
|
+ " Key: %s object type: %s",
|
||||||
key,
|
key,
|
||||||
object.getClass().getName());
|
object.getClass().getName());
|
||||||
|
|
||||||
|
@ -224,8 +232,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
||||||
* OK to delete this manifestKey. If even one source returns "false" (meaning "it's not OK to
|
* OK to delete this manifestKey. If even one source returns "false" (meaning "it's not OK to
|
||||||
* delete this manifest") then it won't be deleted.
|
* delete this manifest") then it won't be deleted.
|
||||||
*/
|
*/
|
||||||
static class DeleteOldCommitLogsReducer
|
static class DeleteOldCommitLogsReducer extends Reducer<Key<CommitLogManifest>, Boolean, Void> {
|
||||||
extends Reducer<Key<CommitLogManifest>, Boolean, Void> {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -4918760187627937268L;
|
private static final long serialVersionUID = -4918760187627937268L;
|
||||||
|
|
||||||
|
@ -241,12 +248,12 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Status status();
|
public abstract Status status();
|
||||||
|
|
||||||
public abstract int numDeleted();
|
public abstract int numDeleted();
|
||||||
|
|
||||||
static DeletionResult create(Status status, int numDeleted) {
|
static DeletionResult create(Status status, int numDeleted) {
|
||||||
return
|
return new AutoValue_DeleteOldCommitLogsAction_DeleteOldCommitLogsReducer_DeletionResult(
|
||||||
new AutoValue_DeleteOldCommitLogsAction_DeleteOldCommitLogsReducer_DeletionResult(
|
status, numDeleted);
|
||||||
status, numDeleted);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,8 +264,7 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reduce(
|
public void reduce(
|
||||||
final Key<CommitLogManifest> manifestKey,
|
final Key<CommitLogManifest> manifestKey, ReducerInput<Boolean> canDeleteVerdicts) {
|
||||||
ReducerInput<Boolean> canDeleteVerdicts) {
|
|
||||||
ImmutableMultiset<Boolean> canDeleteMultiset = ImmutableMultiset.copyOf(canDeleteVerdicts);
|
ImmutableMultiset<Boolean> canDeleteMultiset = ImmutableMultiset.copyOf(canDeleteVerdicts);
|
||||||
if (canDeleteMultiset.count(TRUE) > 1) {
|
if (canDeleteMultiset.count(TRUE) > 1) {
|
||||||
getContext().incrementCounter("commit log manifests incorrectly mapped multiple times");
|
getContext().incrementCounter("commit log manifests incorrectly mapped multiple times");
|
||||||
|
@ -267,47 +273,54 @@ public final class DeleteOldCommitLogsAction implements Runnable {
|
||||||
getContext().incrementCounter("commit log manifests referenced multiple times");
|
getContext().incrementCounter("commit log manifests referenced multiple times");
|
||||||
}
|
}
|
||||||
if (canDeleteMultiset.contains(FALSE)) {
|
if (canDeleteMultiset.contains(FALSE)) {
|
||||||
getContext().incrementCounter(
|
getContext()
|
||||||
canDeleteMultiset.contains(TRUE)
|
.incrementCounter(
|
||||||
? "old commit log manifests still referenced"
|
canDeleteMultiset.contains(TRUE)
|
||||||
: "new (or nonexistent) commit log manifests referenced");
|
? "old commit log manifests still referenced"
|
||||||
getContext().incrementCounter(
|
: "new (or nonexistent) commit log manifests referenced");
|
||||||
"EPP resource revisions handled",
|
getContext()
|
||||||
canDeleteMultiset.count(FALSE));
|
.incrementCounter("EPP resource revisions handled", canDeleteMultiset.count(FALSE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeletionResult deletionResult = tm().transactNew(() -> {
|
DeletionResult deletionResult =
|
||||||
CommitLogManifest manifest = ofy().load().key(manifestKey).now();
|
tm().transactNew(
|
||||||
// It is possible that the same manifestKey was run twice, if a shard had to be restarted
|
() -> {
|
||||||
// or some weird failure. If this happens, we want to exit immediately.
|
CommitLogManifest manifest = auditedOfy().load().key(manifestKey).now();
|
||||||
// Note that this can never happen in dryRun.
|
// It is possible that the same manifestKey was run twice, if a shard had to be
|
||||||
if (manifest == null) {
|
// restarted or some weird failure. If this happens, we want to exit
|
||||||
return DeletionResult.create(DeletionResult.Status.ALREADY_DELETED, 0);
|
// immediately. Note that this can never happen in dryRun.
|
||||||
}
|
if (manifest == null) {
|
||||||
// Doing a sanity check on the date. This is the only place we use the CommitLogManifest,
|
return DeletionResult.create(DeletionResult.Status.ALREADY_DELETED, 0);
|
||||||
// so maybe removing this test will improve performance. However, unless it's proven that
|
}
|
||||||
// the performance boost is significant (and we've tested this enough to be sure it never
|
// Doing a sanity check on the date. This is the only place we use the
|
||||||
// happens)- the safty of "let's not delete stuff we need from prod" is more important.
|
// CommitLogManifest, so maybe removing this test will improve performance.
|
||||||
if (manifest.getCommitTime().isAfter(deletionThreshold)) {
|
// However, unless it's proven that the performance boost is significant (and
|
||||||
return DeletionResult.create(DeletionResult.Status.AFTER_THRESHOLD, 0);
|
// we've tested this enough to be sure it never happens)- the safety of "let's
|
||||||
}
|
// not delete stuff we need from prod" is more important.
|
||||||
Iterable<Key<CommitLogMutation>> commitLogMutationKeys = ofy().load()
|
if (manifest.getCommitTime().isAfter(deletionThreshold)) {
|
||||||
.type(CommitLogMutation.class)
|
return DeletionResult.create(DeletionResult.Status.AFTER_THRESHOLD, 0);
|
||||||
.ancestor(manifestKey)
|
}
|
||||||
.keys()
|
Iterable<Key<CommitLogMutation>> commitLogMutationKeys =
|
||||||
.iterable();
|
auditedOfy()
|
||||||
ImmutableList<Key<?>> keysToDelete = ImmutableList.<Key<?>>builder()
|
.load()
|
||||||
.addAll(commitLogMutationKeys)
|
.type(CommitLogMutation.class)
|
||||||
.add(manifestKey)
|
.ancestor(manifestKey)
|
||||||
.build();
|
.keys()
|
||||||
// Normally in a dry run we would log the entities that would be deleted, but those can
|
.iterable();
|
||||||
// number in the millions so we skip the logging.
|
ImmutableList<Key<?>> keysToDelete =
|
||||||
if (!isDryRun) {
|
ImmutableList.<Key<?>>builder()
|
||||||
ofy().deleteWithoutBackup().keys(keysToDelete);
|
.addAll(commitLogMutationKeys)
|
||||||
}
|
.add(manifestKey)
|
||||||
return DeletionResult.create(DeletionResult.Status.SUCCESS, keysToDelete.size());
|
.build();
|
||||||
});
|
// Normally in a dry run we would log the entities that would be deleted, but
|
||||||
|
// those can number in the millions so we skip the logging.
|
||||||
|
if (!isDryRun) {
|
||||||
|
auditedOfy().deleteWithoutBackup().keys(keysToDelete);
|
||||||
|
}
|
||||||
|
return DeletionResult.create(
|
||||||
|
DeletionResult.Status.SUCCESS, keysToDelete.size());
|
||||||
|
});
|
||||||
|
|
||||||
switch (deletionResult.status()) {
|
switch (deletionResult.status()) {
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
|
|
|
@ -25,7 +25,7 @@ import static google.registry.backup.BackupUtils.GcsMetadataKeys.NUM_TRANSACTION
|
||||||
import static google.registry.backup.BackupUtils.GcsMetadataKeys.UPPER_BOUND_CHECKPOINT;
|
import static google.registry.backup.BackupUtils.GcsMetadataKeys.UPPER_BOUND_CHECKPOINT;
|
||||||
import static google.registry.backup.BackupUtils.serializeEntity;
|
import static google.registry.backup.BackupUtils.serializeEntity;
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
||||||
import static java.nio.channels.Channels.newOutputStream;
|
import static java.nio.channels.Channels.newOutputStream;
|
||||||
|
@ -89,11 +89,14 @@ public final class ExportCommitLogDiffAction implements Runnable {
|
||||||
checkArgument(lowerCheckpointTime.isBefore(upperCheckpointTime));
|
checkArgument(lowerCheckpointTime.isBefore(upperCheckpointTime));
|
||||||
// Load the boundary checkpoints - lower is exclusive and may not exist (on the first export,
|
// Load the boundary checkpoints - lower is exclusive and may not exist (on the first export,
|
||||||
// when lowerCheckpointTime is START_OF_TIME), whereas the upper is inclusive and must exist.
|
// when lowerCheckpointTime is START_OF_TIME), whereas the upper is inclusive and must exist.
|
||||||
CommitLogCheckpoint lowerCheckpoint = lowerCheckpointTime.isAfter(START_OF_TIME)
|
CommitLogCheckpoint lowerCheckpoint =
|
||||||
? verifyNotNull(ofy().load().key(CommitLogCheckpoint.createKey(lowerCheckpointTime)).now())
|
lowerCheckpointTime.isAfter(START_OF_TIME)
|
||||||
: null;
|
? verifyNotNull(
|
||||||
|
auditedOfy().load().key(CommitLogCheckpoint.createKey(lowerCheckpointTime)).now())
|
||||||
|
: null;
|
||||||
CommitLogCheckpoint upperCheckpoint =
|
CommitLogCheckpoint upperCheckpoint =
|
||||||
verifyNotNull(ofy().load().key(CommitLogCheckpoint.createKey(upperCheckpointTime)).now());
|
verifyNotNull(
|
||||||
|
auditedOfy().load().key(CommitLogCheckpoint.createKey(upperCheckpointTime)).now());
|
||||||
|
|
||||||
// Load the keys of all the manifests to include in this diff.
|
// Load the keys of all the manifests to include in this diff.
|
||||||
List<Key<CommitLogManifest>> sortedKeys = loadAllDiffKeys(lowerCheckpoint, upperCheckpoint);
|
List<Key<CommitLogManifest>> sortedKeys = loadAllDiffKeys(lowerCheckpoint, upperCheckpoint);
|
||||||
|
@ -117,7 +120,7 @@ public final class ExportCommitLogDiffAction implements Runnable {
|
||||||
// asynchronously load the entities for the next one.
|
// asynchronously load the entities for the next one.
|
||||||
List<List<Key<CommitLogManifest>>> keyChunks = partition(sortedKeys, batchSize);
|
List<List<Key<CommitLogManifest>>> keyChunks = partition(sortedKeys, batchSize);
|
||||||
// Objectify's map return type is asynchronous. Calling .values() will block until it loads.
|
// Objectify's map return type is asynchronous. Calling .values() will block until it loads.
|
||||||
Map<?, CommitLogManifest> nextChunkToExport = ofy().load().keys(keyChunks.get(0));
|
Map<?, CommitLogManifest> nextChunkToExport = auditedOfy().load().keys(keyChunks.get(0));
|
||||||
for (int i = 0; i < keyChunks.size(); i++) {
|
for (int i = 0; i < keyChunks.size(); i++) {
|
||||||
// Force the async load to finish.
|
// Force the async load to finish.
|
||||||
Collection<CommitLogManifest> chunkValues = nextChunkToExport.values();
|
Collection<CommitLogManifest> chunkValues = nextChunkToExport.values();
|
||||||
|
@ -125,10 +128,10 @@ public final class ExportCommitLogDiffAction implements Runnable {
|
||||||
// Since there is no hard bound on how much data this might be, take care not to let the
|
// Since there is no hard bound on how much data this might be, take care not to let the
|
||||||
// Objectify session cache fill up and potentially run out of memory. This is the only safe
|
// Objectify session cache fill up and potentially run out of memory. This is the only safe
|
||||||
// point to do this since at this point there is no async load in progress.
|
// point to do this since at this point there is no async load in progress.
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
// Kick off the next async load, which can happen in parallel to the current GCS export.
|
// Kick off the next async load, which can happen in parallel to the current GCS export.
|
||||||
if (i + 1 < keyChunks.size()) {
|
if (i + 1 < keyChunks.size()) {
|
||||||
nextChunkToExport = ofy().load().keys(keyChunks.get(i + 1));
|
nextChunkToExport = auditedOfy().load().keys(keyChunks.get(i + 1));
|
||||||
}
|
}
|
||||||
exportChunk(gcsStream, chunkValues);
|
exportChunk(gcsStream, chunkValues);
|
||||||
logger.atInfo().log("Exported %d manifests", chunkValues.size());
|
logger.atInfo().log("Exported %d manifests", chunkValues.size());
|
||||||
|
@ -192,7 +195,8 @@ public final class ExportCommitLogDiffAction implements Runnable {
|
||||||
return ImmutableSet.of();
|
return ImmutableSet.of();
|
||||||
}
|
}
|
||||||
Key<CommitLogBucket> bucketKey = getBucketKey(bucketNum);
|
Key<CommitLogBucket> bucketKey = getBucketKey(bucketNum);
|
||||||
return ofy().load()
|
return auditedOfy()
|
||||||
|
.load()
|
||||||
.type(CommitLogManifest.class)
|
.type(CommitLogManifest.class)
|
||||||
.ancestor(bucketKey)
|
.ancestor(bucketKey)
|
||||||
.filterKey(">=", CommitLogManifest.createKey(bucketKey, lowerBound))
|
.filterKey(">=", CommitLogManifest.createKey(bucketKey, lowerBound))
|
||||||
|
@ -208,7 +212,7 @@ public final class ExportCommitLogDiffAction implements Runnable {
|
||||||
new ImmutableList.Builder<>();
|
new ImmutableList.Builder<>();
|
||||||
for (CommitLogManifest manifest : chunk) {
|
for (CommitLogManifest manifest : chunk) {
|
||||||
entities.add(ImmutableList.of(manifest));
|
entities.add(ImmutableList.of(manifest));
|
||||||
entities.add(ofy().load().type(CommitLogMutation.class).ancestor(manifest));
|
entities.add(auditedOfy().load().type(CommitLogMutation.class).ancestor(manifest));
|
||||||
}
|
}
|
||||||
for (ImmutableObject entity : concat(entities.build())) {
|
for (ImmutableObject entity : concat(entities.build())) {
|
||||||
serializeEntity(entity, gcsStream);
|
serializeEntity(entity, gcsStream);
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.backup;
|
||||||
|
|
||||||
import static google.registry.backup.ExportCommitLogDiffAction.DIFF_FILE_PREFIX;
|
import static google.registry.backup.ExportCommitLogDiffAction.DIFF_FILE_PREFIX;
|
||||||
import static google.registry.model.ofy.EntityWritePriorities.getEntityPriority;
|
import static google.registry.model.ofy.EntityWritePriorities.getEntityPriority;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
|
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
|
||||||
import static org.joda.time.Duration.standardHours;
|
import static org.joda.time.Duration.standardHours;
|
||||||
|
@ -151,7 +151,7 @@ public class ReplayCommitLogsToSqlAction implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleEntityPut(Entity entity) {
|
private void handleEntityPut(Entity entity) {
|
||||||
Object ofyPojo = ofy().toPojo(entity);
|
Object ofyPojo = auditedOfy().toPojo(entity);
|
||||||
if (ofyPojo instanceof DatastoreEntity) {
|
if (ofyPojo instanceof DatastoreEntity) {
|
||||||
DatastoreEntity datastoreEntity = (DatastoreEntity) ofyPojo;
|
DatastoreEntity datastoreEntity = (DatastoreEntity) ofyPojo;
|
||||||
datastoreEntity
|
datastoreEntity
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.Iterators.peekingIterator;
|
import static com.google.common.collect.Iterators.peekingIterator;
|
||||||
import static google.registry.backup.BackupUtils.createDeserializingIterator;
|
import static google.registry.backup.BackupUtils.createDeserializingIterator;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.DatastoreService;
|
import com.google.appengine.api.datastore.DatastoreService;
|
||||||
import com.google.appengine.api.datastore.Entity;
|
import com.google.appengine.api.datastore.Entity;
|
||||||
|
@ -146,10 +146,10 @@ public class RestoreCommitLogsAction implements Runnable {
|
||||||
private CommitLogManifest restoreOneTransaction(PeekingIterator<ImmutableObject> commitLogs) {
|
private CommitLogManifest restoreOneTransaction(PeekingIterator<ImmutableObject> commitLogs) {
|
||||||
final CommitLogManifest manifest = (CommitLogManifest) commitLogs.next();
|
final CommitLogManifest manifest = (CommitLogManifest) commitLogs.next();
|
||||||
Result<?> deleteResult = deleteAsync(manifest.getDeletions());
|
Result<?> deleteResult = deleteAsync(manifest.getDeletions());
|
||||||
List<Entity> entitiesToSave = Lists.newArrayList(ofy().save().toEntity(manifest));
|
List<Entity> entitiesToSave = Lists.newArrayList(auditedOfy().save().toEntity(manifest));
|
||||||
while (commitLogs.hasNext() && commitLogs.peek() instanceof CommitLogMutation) {
|
while (commitLogs.hasNext() && commitLogs.peek() instanceof CommitLogMutation) {
|
||||||
CommitLogMutation mutation = (CommitLogMutation) commitLogs.next();
|
CommitLogMutation mutation = (CommitLogMutation) commitLogs.next();
|
||||||
entitiesToSave.add(ofy().save().toEntity(mutation));
|
entitiesToSave.add(auditedOfy().save().toEntity(mutation));
|
||||||
entitiesToSave.add(EntityTranslator.createFromPbBytes(mutation.getEntityProtoBytes()));
|
entitiesToSave.add(EntityTranslator.createFromPbBytes(mutation.getEntityProtoBytes()));
|
||||||
}
|
}
|
||||||
saveRaw(entitiesToSave);
|
saveRaw(entitiesToSave);
|
||||||
|
@ -176,7 +176,8 @@ public class RestoreCommitLogsAction implements Runnable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
retrier.callWithRetry(
|
retrier.callWithRetry(
|
||||||
() -> ofy().saveWithoutBackup().entities(objectsToSave).now(), RuntimeException.class);
|
() -> auditedOfy().saveWithoutBackup().entities(objectsToSave).now(),
|
||||||
|
RuntimeException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<?> deleteAsync(Set<Key<?>> keysToDelete) {
|
private Result<?> deleteAsync(Set<Key<?>> keysToDelete) {
|
||||||
|
@ -185,7 +186,7 @@ public class RestoreCommitLogsAction implements Runnable {
|
||||||
}
|
}
|
||||||
return dryRun || keysToDelete.isEmpty()
|
return dryRun || keysToDelete.isEmpty()
|
||||||
? new ResultNow<Void>(null)
|
? new ResultNow<Void>(null)
|
||||||
: ofy().deleteWithoutBackup().keys(keysToDelete);
|
: auditedOfy().deleteWithoutBackup().keys(keysToDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ import javax.annotation.Nullable;
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Convert an Objectify entity to a Datastore {@link Entity}: {@code
|
* <li>Convert an Objectify entity to a Datastore {@link Entity}: {@code
|
||||||
* ofy().save().toEntity(..)}
|
* auditedOfy().save().toEntity(..)}
|
||||||
* <li>Entity is serializable, but the more efficient approach is to convert an Entity to a
|
* <li>Entity is serializable, but the more efficient approach is to convert an Entity to a
|
||||||
* ProtocolBuffer ({@link com.google.storage.onestore.v3.OnestoreEntity.EntityProto}) and then
|
* ProtocolBuffer ({@link com.google.storage.onestore.v3.OnestoreEntity.EntityProto}) and then
|
||||||
* to raw bytes.
|
* to raw bytes.
|
||||||
|
|
|
@ -34,7 +34,7 @@ import static google.registry.model.ResourceTransferUtils.denyPendingTransfer;
|
||||||
import static google.registry.model.ResourceTransferUtils.handlePendingTransferOnDelete;
|
import static google.registry.model.ResourceTransferUtils.handlePendingTransferOnDelete;
|
||||||
import static google.registry.model.ResourceTransferUtils.updateForeignKeyIndexDeletionTime;
|
import static google.registry.model.ResourceTransferUtils.updateForeignKeyIndexDeletionTime;
|
||||||
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
|
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE;
|
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE_FAILURE;
|
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE_FAILURE;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.HOST_DELETE;
|
import static google.registry.model.reporting.HistoryEntry.Type.HOST_DELETE;
|
||||||
|
@ -336,7 +336,7 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
||||||
DeletionRequest deletionRequest, boolean hasNoActiveReferences) {
|
DeletionRequest deletionRequest, boolean hasNoActiveReferences) {
|
||||||
DateTime now = tm().getTransactionTime();
|
DateTime now = tm().getTransactionTime();
|
||||||
EppResource resource =
|
EppResource resource =
|
||||||
ofy().load().key(deletionRequest.key()).now().cloneProjectedAtTime(now);
|
auditedOfy().load().key(deletionRequest.key()).now().cloneProjectedAtTime(now);
|
||||||
// Double-check transactionally that the resource is still active and in PENDING_DELETE.
|
// Double-check transactionally that the resource is still active and in PENDING_DELETE.
|
||||||
if (!doesResourceStateAllowDeletion(resource, now)) {
|
if (!doesResourceStateAllowDeletion(resource, now)) {
|
||||||
return DeletionResult.create(Type.ERRORED, "");
|
return DeletionResult.create(Type.ERRORED, "");
|
||||||
|
@ -409,7 +409,7 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
||||||
} else {
|
} else {
|
||||||
resourceToSave = resource.asBuilder().removeStatusValue(PENDING_DELETE).build();
|
resourceToSave = resource.asBuilder().removeStatusValue(PENDING_DELETE).build();
|
||||||
}
|
}
|
||||||
ofy().save().<ImmutableObject>entities(resourceToSave, historyEntry, pollMessage);
|
auditedOfy().save().<ImmutableObject>entities(resourceToSave, historyEntry, pollMessage);
|
||||||
return DeletionResult.create(
|
return DeletionResult.create(
|
||||||
deleteAllowed ? Type.DELETED : Type.NOT_DELETED, pollMessageText);
|
deleteAllowed ? Type.DELETED : Type.NOT_DELETED, pollMessageText);
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,8 @@ public class DeleteContactsAndHostsAction implements Runnable {
|
||||||
Key.create(
|
Key.create(
|
||||||
checkNotNull(params.get(PARAM_RESOURCE_KEY), "Resource to delete not specified"));
|
checkNotNull(params.get(PARAM_RESOURCE_KEY), "Resource to delete not specified"));
|
||||||
EppResource resource =
|
EppResource resource =
|
||||||
checkNotNull(ofy().load().key(resourceKey).now(), "Resource to delete doesn't exist");
|
checkNotNull(
|
||||||
|
auditedOfy().load().key(resourceKey).now(), "Resource to delete doesn't exist");
|
||||||
checkState(
|
checkState(
|
||||||
resource instanceof ContactResource || resource instanceof HostResource,
|
resource instanceof ContactResource || resource instanceof HostResource,
|
||||||
"Cannot delete a %s via this action",
|
"Cannot delete a %s via this action",
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkState;
|
||||||
import static google.registry.config.RegistryEnvironment.PRODUCTION;
|
import static google.registry.config.RegistryEnvironment.PRODUCTION;
|
||||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
||||||
import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInput;
|
import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInput;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.request.Action.Method.POST;
|
import static google.registry.request.Action.Method.POST;
|
||||||
|
|
||||||
|
@ -125,12 +125,11 @@ public class DeleteLoadTestDataAction implements Runnable {
|
||||||
Key.create(EppResourceIndex.create(Key.create(resource)));
|
Key.create(EppResourceIndex.create(Key.create(resource)));
|
||||||
final Key<? extends ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(resource);
|
final Key<? extends ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(resource);
|
||||||
int numEntitiesDeleted =
|
int numEntitiesDeleted =
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
// This ancestor query selects all descendant entities.
|
// This ancestor query selects all descendant entities.
|
||||||
List<Key<Object>> resourceAndDependentKeys =
|
List<Key<Object>> resourceAndDependentKeys =
|
||||||
ofy().load().ancestor(resource).keys().list();
|
auditedOfy().load().ancestor(resource).keys().list();
|
||||||
ImmutableSet<Key<?>> allKeys =
|
ImmutableSet<Key<?>> allKeys =
|
||||||
new ImmutableSet.Builder<Key<?>>()
|
new ImmutableSet.Builder<Key<?>>()
|
||||||
.add(fki)
|
.add(fki)
|
||||||
|
@ -140,7 +139,7 @@ public class DeleteLoadTestDataAction implements Runnable {
|
||||||
if (isDryRun) {
|
if (isDryRun) {
|
||||||
logger.atInfo().log("Would hard-delete the following entities: %s", allKeys);
|
logger.atInfo().log("Would hard-delete the following entities: %s", allKeys);
|
||||||
} else {
|
} else {
|
||||||
ofy().deleteWithoutBackup().keys(allKeys);
|
auditedOfy().deleteWithoutBackup().keys(allKeys);
|
||||||
}
|
}
|
||||||
return allKeys.size();
|
return allKeys.size();
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static google.registry.config.RegistryEnvironment.PRODUCTION;
|
import static google.registry.config.RegistryEnvironment.PRODUCTION;
|
||||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
||||||
import static google.registry.model.ResourceTransferUtils.updateForeignKeyIndexDeletionTime;
|
import static google.registry.model.ResourceTransferUtils.updateForeignKeyIndexDeletionTime;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.registry.Registries.getTldsOfType;
|
import static google.registry.model.registry.Registries.getTldsOfType;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_DELETE;
|
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_DELETE;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
@ -166,7 +166,7 @@ public class DeleteProberDataAction implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteDomain(final Key<DomainBase> domainKey) {
|
private void deleteDomain(final Key<DomainBase> domainKey) {
|
||||||
final DomainBase domain = ofy().load().key(domainKey).now();
|
final DomainBase domain = auditedOfy().load().key(domainKey).now();
|
||||||
|
|
||||||
DateTime now = DateTime.now(UTC);
|
DateTime now = DateTime.now(UTC);
|
||||||
|
|
||||||
|
@ -220,14 +220,13 @@ public class DeleteProberDataAction implements Runnable {
|
||||||
final Key<? extends ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(domain);
|
final Key<? extends ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(domain);
|
||||||
|
|
||||||
int entitiesDeleted =
|
int entitiesDeleted =
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
// This ancestor query selects all descendant HistoryEntries, BillingEvents,
|
// This ancestor query selects all descendant HistoryEntries, BillingEvents,
|
||||||
// PollMessages,
|
// PollMessages,
|
||||||
// and TLD-specific entities, as well as the domain itself.
|
// and TLD-specific entities, as well as the domain itself.
|
||||||
List<Key<Object>> domainAndDependentKeys =
|
List<Key<Object>> domainAndDependentKeys =
|
||||||
ofy().load().ancestor(domainKey).keys().list();
|
auditedOfy().load().ancestor(domainKey).keys().list();
|
||||||
ImmutableSet<Key<?>> allKeys =
|
ImmutableSet<Key<?>> allKeys =
|
||||||
new ImmutableSet.Builder<Key<?>>()
|
new ImmutableSet.Builder<Key<?>>()
|
||||||
.add(fki)
|
.add(fki)
|
||||||
|
@ -237,7 +236,7 @@ public class DeleteProberDataAction implements Runnable {
|
||||||
if (isDryRun) {
|
if (isDryRun) {
|
||||||
logger.atInfo().log("Would hard-delete the following entities: %s", allKeys);
|
logger.atInfo().log("Would hard-delete the following entities: %s", allKeys);
|
||||||
} else {
|
} else {
|
||||||
ofy().deleteWithoutBackup().keys(allKeys);
|
auditedOfy().deleteWithoutBackup().keys(allKeys);
|
||||||
}
|
}
|
||||||
return allKeys.size();
|
return allKeys.size();
|
||||||
});
|
});
|
||||||
|
@ -268,7 +267,7 @@ public class DeleteProberDataAction implements Runnable {
|
||||||
// poll messages, or auto-renews because these will all be hard-deleted the next
|
// poll messages, or auto-renews because these will all be hard-deleted the next
|
||||||
// time the
|
// time the
|
||||||
// mapreduce runs anyway.
|
// mapreduce runs anyway.
|
||||||
ofy().save().entities(deletedDomain, historyEntry);
|
auditedOfy().save().entities(deletedDomain, historyEntry);
|
||||||
updateForeignKeyIndexDeletionTime(deletedDomain);
|
updateForeignKeyIndexDeletionTime(deletedDomain);
|
||||||
dnsQueue.addDomainRefreshTask(deletedDomain.getDomainName());
|
dnsQueue.addDomainRefreshTask(deletedDomain.getDomainName());
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,7 +91,8 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Cursor cursor = ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now();
|
Cursor cursor =
|
||||||
|
tm().loadByKeyIfPresent(Cursor.createGlobalVKey(RECURRING_BILLING)).orElse(null);
|
||||||
DateTime executeTime = clock.nowUtc();
|
DateTime executeTime = clock.nowUtc();
|
||||||
DateTime persistedCursorTime = (cursor == null ? START_OF_TIME : cursor.getCursorTime());
|
DateTime persistedCursorTime = (cursor == null ? START_OF_TIME : cursor.getCursorTime());
|
||||||
DateTime cursorTime = cursorTimeParam.orElse(persistedCursorTime);
|
DateTime cursorTime = cursorTimeParam.orElse(persistedCursorTime);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.batch;
|
package google.registry.batch;
|
||||||
|
|
||||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_FAST;
|
import static google.registry.mapreduce.MapreduceRunner.PARAM_FAST;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
|
||||||
import com.google.appengine.tools.mapreduce.Mapper;
|
import com.google.appengine.tools.mapreduce.Mapper;
|
||||||
|
@ -104,13 +104,13 @@ public class ResaveAllEppResourcesAction implements Runnable {
|
||||||
boolean resaved =
|
boolean resaved =
|
||||||
tm().transact(
|
tm().transact(
|
||||||
() -> {
|
() -> {
|
||||||
EppResource originalResource = ofy().load().key(resourceKey).now();
|
EppResource originalResource = auditedOfy().load().key(resourceKey).now();
|
||||||
EppResource projectedResource =
|
EppResource projectedResource =
|
||||||
originalResource.cloneProjectedAtTime(tm().getTransactionTime());
|
originalResource.cloneProjectedAtTime(tm().getTransactionTime());
|
||||||
if (isFast && originalResource.equals(projectedResource)) {
|
if (isFast && originalResource.equals(projectedResource)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ofy().save().entity(projectedResource).now();
|
auditedOfy().save().entity(projectedResource).now();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,11 +25,8 @@ import static com.google.common.collect.Iterables.any;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static com.google.common.collect.Sets.intersection;
|
import static com.google.common.collect.Sets.intersection;
|
||||||
import static com.google.common.collect.Sets.union;
|
import static com.google.common.collect.Sets.union;
|
||||||
import static google.registry.model.DatabaseMigrationUtils.getPrimaryDatabase;
|
|
||||||
import static google.registry.model.common.DatabaseTransitionSchedule.PrimaryDatabase.DATASTORE;
|
|
||||||
import static google.registry.model.common.DatabaseTransitionSchedule.TransitionId.REPLAYED_ENTITIES;
|
|
||||||
import static google.registry.model.domain.DomainBase.MAX_REGISTRATION_YEARS;
|
import static google.registry.model.domain.DomainBase.MAX_REGISTRATION_YEARS;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.registry.Registries.findTldForName;
|
import static google.registry.model.registry.Registries.findTldForName;
|
||||||
import static google.registry.model.registry.Registries.getTlds;
|
import static google.registry.model.registry.Registries.getTlds;
|
||||||
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
|
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
|
||||||
|
@ -1083,8 +1080,8 @@ public class DomainFlowUtils {
|
||||||
|
|
||||||
private static List<? extends HistoryEntry> findRecentHistoryEntries(
|
private static List<? extends HistoryEntry> findRecentHistoryEntries(
|
||||||
DomainBase domainBase, DateTime now, Duration maxSearchPeriod) {
|
DomainBase domainBase, DateTime now, Duration maxSearchPeriod) {
|
||||||
if (getPrimaryDatabase(REPLAYED_ENTITIES).equals(DATASTORE)) {
|
if (tm().isOfy()) {
|
||||||
return ofy()
|
return auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(HistoryEntry.class)
|
.type(HistoryEntry.class)
|
||||||
.ancestor(domainBase)
|
.ancestor(domainBase)
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.base.CaseFormat.LOWER_HYPHEN;
|
||||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
|
@ -205,9 +205,9 @@ public class KmsKeyring implements Keyring {
|
||||||
String encryptedData;
|
String encryptedData;
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
KmsSecret secret =
|
KmsSecret secret =
|
||||||
ofy().load().key(Key.create(getCrossTldKey(), KmsSecret.class, keyName)).now();
|
auditedOfy().load().key(Key.create(getCrossTldKey(), KmsSecret.class, keyName)).now();
|
||||||
checkState(secret != null, "Requested secret '%s' does not exist.", keyName);
|
checkState(secret != null, "Requested secret '%s' does not exist.", keyName);
|
||||||
encryptedData = ofy().load().key(secret.getLatestRevision()).now().getEncryptedValue();
|
encryptedData = auditedOfy().load().key(secret.getLatestRevision()).now().getEncryptedValue();
|
||||||
} else {
|
} else {
|
||||||
Optional<KmsSecretRevision> revision =
|
Optional<KmsSecretRevision> revision =
|
||||||
tm().transact(() -> KmsSecretRevisionSqlDao.getLatestRevision(keyName));
|
tm().transact(() -> KmsSecretRevisionSqlDao.getLatestRevision(keyName));
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.transform;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
import static com.google.common.collect.Maps.transformValues;
|
import static com.google.common.collect.Maps.transformValues;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
import static java.lang.annotation.ElementType.FIELD;
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
@ -189,7 +189,7 @@ public abstract class ImmutableObject implements Cloneable {
|
||||||
private static Object hydrate(Object value) {
|
private static Object hydrate(Object value) {
|
||||||
if (value instanceof Key) {
|
if (value instanceof Key) {
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
return hydrate(ofy().load().key((Key<?>) value).now());
|
return hydrate(auditedOfy().load().key((Key<?>) value).now());
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
} else if (value instanceof Map) {
|
} else if (value instanceof Map) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static google.registry.config.RegistryConfig.getEppResourceCachingDuration;
|
import static google.registry.config.RegistryConfig.getEppResourceCachingDuration;
|
||||||
import static google.registry.config.RegistryConfig.getEppResourceMaxCachedEntries;
|
import static google.registry.config.RegistryConfig.getEppResourceMaxCachedEntries;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.util.CollectionUtils.entriesToImmutableMap;
|
import static google.registry.util.CollectionUtils.entriesToImmutableMap;
|
||||||
|
@ -220,8 +220,8 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||||
Class<ForeignKeyIndex<E>> fkiClass = mapToFkiClass(clazz);
|
Class<ForeignKeyIndex<E>> fkiClass = mapToFkiClass(clazz);
|
||||||
return ImmutableMap.copyOf(
|
return ImmutableMap.copyOf(
|
||||||
inTransaction
|
inTransaction
|
||||||
? ofy().load().type(fkiClass).ids(foreignKeys)
|
? auditedOfy().load().type(fkiClass).ids(foreignKeys)
|
||||||
: tm().doTransactionless(() -> ofy().load().type(fkiClass).ids(foreignKeys)));
|
: tm().doTransactionless(() -> auditedOfy().load().type(fkiClass).ids(foreignKeys)));
|
||||||
} else {
|
} else {
|
||||||
String property = RESOURCE_CLASS_TO_FKI_PROPERTY.get(clazz);
|
String property = RESOURCE_CLASS_TO_FKI_PROPERTY.get(clazz);
|
||||||
ImmutableList<ForeignKeyIndex<E>> indexes =
|
ImmutableList<ForeignKeyIndex<E>> indexes =
|
||||||
|
@ -276,7 +276,7 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||||
ImmutableSet<VKey<ForeignKeyIndex<?>>> typedKeys = ImmutableSet.copyOf(keys);
|
ImmutableSet<VKey<ForeignKeyIndex<?>>> typedKeys = ImmutableSet.copyOf(keys);
|
||||||
ImmutableMap<String, ? extends ForeignKeyIndex<? extends EppResource>> existingFkis =
|
ImmutableMap<String, ? extends ForeignKeyIndex<? extends EppResource>> existingFkis =
|
||||||
loadIndexesFromStore(resourceClass, foreignKeys, false);
|
loadIndexesFromStore(resourceClass, foreignKeys, false);
|
||||||
// ofy() omits keys that don't have values in Datastore, so re-add them in
|
// ofy omits keys that don't have values in Datastore, so re-add them in
|
||||||
// here with Optional.empty() values.
|
// here with Optional.empty() values.
|
||||||
return Maps.asMap(
|
return Maps.asMap(
|
||||||
typedKeys,
|
typedKeys,
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Arrays;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Deleter that forwards to {@code ofy().delete()}, but can be augmented via subclassing to
|
* A Deleter that forwards to {@code auditedOfy().delete()}, but can be augmented via subclassing to
|
||||||
* do custom processing on the keys to be deleted prior to their deletion.
|
* do custom processing on the keys to be deleted prior to their deletion.
|
||||||
*/
|
*/
|
||||||
abstract class AugmentedDeleter implements Deleter {
|
abstract class AugmentedDeleter implements Deleter {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.collect.DiscreteDomain.integers;
|
import static com.google.common.collect.DiscreteDomain.integers;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static google.registry.config.RegistryConfig.getCommitLogBucketCount;
|
import static google.registry.config.RegistryConfig.getCommitLogBucketCount;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.collect.ContiguousSet;
|
import com.google.common.collect.ContiguousSet;
|
||||||
|
@ -118,7 +118,7 @@ public class CommitLogBucket extends ImmutableObject implements Buildable, Datas
|
||||||
|
|
||||||
/** Returns the loaded bucket for the given key, or a new object if the bucket doesn't exist. */
|
/** Returns the loaded bucket for the given key, or a new object if the bucket doesn't exist. */
|
||||||
public static CommitLogBucket loadBucket(Key<CommitLogBucket> bucketKey) {
|
public static CommitLogBucket loadBucket(Key<CommitLogBucket> bucketKey) {
|
||||||
CommitLogBucket bucket = ofy().load().key(bucketKey).now();
|
CommitLogBucket bucket = auditedOfy().load().key(bucketKey).now();
|
||||||
return (bucket == null)
|
return (bucket == null)
|
||||||
? new CommitLogBucket.Builder().setBucketNum(bucketKey.getId()).build()
|
? new CommitLogBucket.Builder().setBucketNum(bucketKey.getId()).build()
|
||||||
: bucket;
|
: bucket;
|
||||||
|
@ -126,7 +126,7 @@ public class CommitLogBucket extends ImmutableObject implements Buildable, Datas
|
||||||
|
|
||||||
/** Returns the set of all loaded commit log buckets, filling in missing buckets with new ones. */
|
/** Returns the set of all loaded commit log buckets, filling in missing buckets with new ones. */
|
||||||
public static ImmutableSet<CommitLogBucket> loadAllBuckets() {
|
public static ImmutableSet<CommitLogBucket> loadAllBuckets() {
|
||||||
ofy().load().keys(getAllBucketKeys()); // Load all buckets into session cache at once.
|
auditedOfy().load().keys(getAllBucketKeys()); // Load all buckets into session cache at once.
|
||||||
ImmutableSet.Builder<CommitLogBucket> allBuckets = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<CommitLogBucket> allBuckets = new ImmutableSet.Builder<>();
|
||||||
for (Key<CommitLogBucket> key : getAllBucketKeys()) {
|
for (Key<CommitLogBucket> key : getAllBucketKeys()) {
|
||||||
allBuckets.add(loadBucket(key));
|
allBuckets.add(loadBucket(key));
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package google.registry.model.ofy;
|
package google.registry.model.ofy;
|
||||||
|
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
|
@ -49,7 +49,7 @@ public class CommitLogCheckpointRoot extends ImmutableObject implements Datastor
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommitLogCheckpointRoot loadRoot() {
|
public static CommitLogCheckpointRoot loadRoot() {
|
||||||
CommitLogCheckpointRoot root = ofy().load().key(getKey()).now();
|
CommitLogCheckpointRoot root = auditedOfy().load().key(getKey()).now();
|
||||||
return root == null ? new CommitLogCheckpointRoot() : root;
|
return root == null ? new CommitLogCheckpointRoot() : root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
|
|
||||||
package google.registry.model.ofy;
|
package google.registry.model.ofy;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.appengine.api.datastore.EntityTranslator.convertToPb;
|
import static com.google.appengine.api.datastore.EntityTranslator.convertToPb;
|
||||||
import static com.google.appengine.api.datastore.EntityTranslator.createFromPbBytes;
|
import static com.google.appengine.api.datastore.EntityTranslator.createFromPbBytes;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.KeyFactory;
|
import com.google.appengine.api.datastore.KeyFactory;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -66,7 +67,7 @@ public class CommitLogMutation extends ImmutableObject implements DatastoreOnlyE
|
||||||
* converted to a raw Datastore Entity, serialized to bytes, and stored within the mutation.
|
* converted to a raw Datastore Entity, serialized to bytes, and stored within the mutation.
|
||||||
*/
|
*/
|
||||||
public static CommitLogMutation create(Key<CommitLogManifest> parent, Object entity) {
|
public static CommitLogMutation create(Key<CommitLogManifest> parent, Object entity) {
|
||||||
return createFromRaw(parent, ofy().save().toEntity(entity));
|
return createFromRaw(parent, auditedOfy().save().toEntity(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@ import static com.google.common.collect.Maps.filterKeys;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static com.google.common.collect.Sets.union;
|
import static com.google.common.collect.Sets.union;
|
||||||
import static google.registry.model.ofy.CommitLogBucket.loadBucket;
|
import static google.registry.model.ofy.CommitLogBucket.loadBucket;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -134,7 +134,7 @@ class CommitLoggedWork<R> implements Runnable {
|
||||||
// asynchronous save and delete operations that haven't been reaped, but that's ok because we
|
// asynchronous save and delete operations that haven't been reaped, but that's ok because we
|
||||||
// already logged all of those keys in {@link TransactionInfo} and now just need to figure out
|
// already logged all of those keys in {@link TransactionInfo} and now just need to figure out
|
||||||
// what was loaded.
|
// what was loaded.
|
||||||
ImmutableSet<Key<?>> keysInSessionCache = ofy().getSessionKeys();
|
ImmutableSet<Key<?>> keysInSessionCache = auditedOfy().getSessionKeys();
|
||||||
Map<Key<BackupGroupRoot>, BackupGroupRoot> rootsForTouchedKeys =
|
Map<Key<BackupGroupRoot>, BackupGroupRoot> rootsForTouchedKeys =
|
||||||
getBackupGroupRoots(touchedKeys);
|
getBackupGroupRoots(touchedKeys);
|
||||||
Map<Key<BackupGroupRoot>, BackupGroupRoot> rootsForUntouchedKeys =
|
Map<Key<BackupGroupRoot>, BackupGroupRoot> rootsForUntouchedKeys =
|
||||||
|
@ -153,14 +153,16 @@ class CommitLoggedWork<R> implements Runnable {
|
||||||
.stream()
|
.stream()
|
||||||
.map(entity -> (ImmutableObject) CommitLogMutation.create(manifestKey, entity))
|
.map(entity -> (ImmutableObject) CommitLogMutation.create(manifestKey, entity))
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
ofy().saveWithoutBackup()
|
auditedOfy()
|
||||||
.entities(new ImmutableSet.Builder<>()
|
.saveWithoutBackup()
|
||||||
.add(manifest)
|
.entities(
|
||||||
.add(bucket.asBuilder().setLastWrittenTime(info.transactionTime).build())
|
new ImmutableSet.Builder<>()
|
||||||
.addAll(mutations)
|
.add(manifest)
|
||||||
.addAll(untouchedRootsWithTouchedChildren)
|
.add(bucket.asBuilder().setLastWrittenTime(info.transactionTime).build())
|
||||||
.build())
|
.addAll(mutations)
|
||||||
.now();
|
.addAll(untouchedRootsWithTouchedChildren)
|
||||||
|
.build())
|
||||||
|
.now();
|
||||||
ReplayQueue.addInTests(info);
|
ReplayQueue.addInTests(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +187,8 @@ class CommitLoggedWork<R> implements Runnable {
|
||||||
Set<Key<BackupGroupRoot>> rootKeys = new HashSet<>();
|
Set<Key<BackupGroupRoot>> rootKeys = new HashSet<>();
|
||||||
for (Key<?> key : keys) {
|
for (Key<?> key : keys) {
|
||||||
while (key != null
|
while (key != null
|
||||||
&& !BackupGroupRoot.class
|
&& !BackupGroupRoot.class.isAssignableFrom(
|
||||||
.isAssignableFrom(ofy().factory().getMetadata(key).getEntityClass())) {
|
auditedOfy().factory().getMetadata(key).getEntityClass())) {
|
||||||
key = key.getParent();
|
key = key.getParent();
|
||||||
}
|
}
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
|
@ -195,6 +197,6 @@ class CommitLoggedWork<R> implements Runnable {
|
||||||
rootKeys.add(rootKey);
|
rootKeys.add(rootKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ImmutableMap.copyOf(ofy().load().keys(rootKeys));
|
return ImmutableMap.copyOf(auditedOfy().load().keys(rootKeys));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
|
@ -64,7 +64,7 @@ public class DatastoreTransactionManager implements TransactionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Ofy getOfy() {
|
private Ofy getOfy() {
|
||||||
return injectedOfy == null ? ofy() : injectedOfy;
|
return injectedOfy == null ? auditedOfy() : injectedOfy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -247,7 +247,7 @@ public class DatastoreTransactionManager implements TransactionManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T loadByEntity(T entity) {
|
public <T> T loadByEntity(T entity) {
|
||||||
return (T) toSqlEntity(ofy().load().entity(toDatastoreEntity(entity)).now());
|
return (T) toSqlEntity(auditedOfy().load().entity(toDatastoreEntity(entity)).now());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -409,7 +409,7 @@ public class DatastoreTransactionManager implements TransactionManager {
|
||||||
|
|
||||||
Query<T> buildQuery() {
|
Query<T> buildQuery() {
|
||||||
checkOnlyOneInequalityField();
|
checkOnlyOneInequalityField();
|
||||||
Query<T> result = ofy().load().type(entityClass);
|
Query<T> result = auditedOfy().load().type(entityClass);
|
||||||
for (WhereClause pred : predicates) {
|
for (WhereClause pred : predicates) {
|
||||||
result = result.filter(pred.fieldName + pred.comparator.getDatastoreString(), pred.value);
|
result = result.filter(pred.fieldName + pred.comparator.getDatastoreString(), pred.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.model.ofy;
|
package google.registry.model.ofy;
|
||||||
|
|
||||||
import static google.registry.model.ofy.EntityWritePriorities.getEntityPriority;
|
import static google.registry.model.ofy.EntityWritePriorities.getEntityPriority;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -53,7 +53,7 @@ public class ReplayQueue {
|
||||||
// not been applied. Converting the object to an entity and then back again performs
|
// not been applied. Converting the object to an entity and then back again performs
|
||||||
// those transformations so that we persist the same values to SQL that we have in
|
// those transformations so that we persist the same values to SQL that we have in
|
||||||
// Datastore.
|
// Datastore.
|
||||||
builder.put(entry.getKey(), ofy().toPojo(ofy().toEntity(entry.getValue())));
|
builder.put(entry.getKey(), auditedOfy().toPojo(auditedOfy().toEntity(entry.getValue())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.add(builder.build());
|
queue.add(builder.build());
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.common.collect.Maps.filterValues;
|
import static com.google.common.collect.Maps.filterValues;
|
||||||
import static com.google.common.collect.Maps.toMap;
|
import static com.google.common.collect.Maps.toMap;
|
||||||
import static google.registry.model.ofy.CommitLogBucket.getArbitraryBucketId;
|
import static google.registry.model.ofy.CommitLogBucket.getArbitraryBucketId;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -57,7 +57,7 @@ public class TransactionInfo {
|
||||||
|
|
||||||
TransactionInfo(DateTime now) {
|
TransactionInfo(DateTime now) {
|
||||||
this.transactionTime = now;
|
this.transactionTime = now;
|
||||||
ofy().load().key(bucketKey); // Asynchronously load value into session cache.
|
auditedOfy().load().key(bucketKey); // Asynchronously load value into session cache.
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionInfo setReadOnly() {
|
TransactionInfo setReadOnly() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static com.google.common.io.BaseEncoding.base64;
|
||||||
import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServer;
|
import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServer;
|
||||||
import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
|
import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.registry.Registries.assertTldsExist;
|
import static google.registry.model.registry.Registries.assertTldsExist;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
@ -648,7 +648,7 @@ public class Registrar extends ImmutableObject
|
||||||
|
|
||||||
private Iterable<RegistrarContact> getContactsIterable() {
|
private Iterable<RegistrarContact> getContactsIterable() {
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
return ofy().load().type(RegistrarContact.class).ancestor(Registrar.this);
|
return auditedOfy().load().type(RegistrarContact.class).ancestor(Registrar.this);
|
||||||
} else {
|
} else {
|
||||||
return tm().transact(
|
return tm().transact(
|
||||||
() ->
|
() ->
|
||||||
|
|
|
@ -21,7 +21,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static com.google.common.io.BaseEncoding.base64;
|
import static com.google.common.io.BaseEncoding.base64;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.registrar.Registrar.checkValidEmail;
|
import static google.registry.model.registrar.Registrar.checkValidEmail;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
@ -207,7 +207,11 @@ public class RegistrarContact extends ImmutableObject
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
ImmutableSet<Key<RegistrarContact>> existingKeys =
|
ImmutableSet<Key<RegistrarContact>> existingKeys =
|
||||||
ImmutableSet.copyOf(
|
ImmutableSet.copyOf(
|
||||||
ofy().load().type(RegistrarContact.class).ancestor(registrar).keys());
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.type(RegistrarContact.class)
|
||||||
|
.ancestor(registrar)
|
||||||
|
.keys());
|
||||||
tm().delete(
|
tm().delete(
|
||||||
difference(
|
difference(
|
||||||
existingKeys,
|
existingKeys,
|
||||||
|
|
|
@ -23,7 +23,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.common.collect.Maps.filterValues;
|
import static com.google.common.collect.Maps.filterValues;
|
||||||
import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
|
import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.util.CollectionUtils.entriesToImmutableMap;
|
import static google.registry.util.CollectionUtils.entriesToImmutableMap;
|
||||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
|
@ -60,7 +60,7 @@ public final class Registries {
|
||||||
() -> {
|
() -> {
|
||||||
ImmutableSet<String> tlds =
|
ImmutableSet<String> tlds =
|
||||||
tm().isOfy()
|
tm().isOfy()
|
||||||
? ofy()
|
? auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(Registry.class)
|
.type(Registry.class)
|
||||||
.ancestor(getCrossTldKey())
|
.ancestor(getCrossTldKey())
|
||||||
|
|
|
@ -21,7 +21,7 @@ import static google.registry.config.RegistryConfig.getDomainLabelListCacheDurat
|
||||||
import static google.registry.config.RegistryConfig.getSingletonCachePersistDuration;
|
import static google.registry.config.RegistryConfig.getSingletonCachePersistDuration;
|
||||||
import static google.registry.config.RegistryConfig.getStaticPremiumListMaxCachedEntries;
|
import static google.registry.config.RegistryConfig.getStaticPremiumListMaxCachedEntries;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.BLOOM_FILTER_NEGATIVE;
|
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.BLOOM_FILTER_NEGATIVE;
|
||||||
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_NEGATIVE;
|
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_NEGATIVE;
|
||||||
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_POSITIVE;
|
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_POSITIVE;
|
||||||
|
@ -117,7 +117,8 @@ public class PremiumListDatastoreDao {
|
||||||
new CacheLoader<Key<PremiumListRevision>, PremiumListRevision>() {
|
new CacheLoader<Key<PremiumListRevision>, PremiumListRevision>() {
|
||||||
@Override
|
@Override
|
||||||
public PremiumListRevision load(final Key<PremiumListRevision> revisionKey) {
|
public PremiumListRevision load(final Key<PremiumListRevision> revisionKey) {
|
||||||
return ofyTm().doTransactionless(() -> ofy().load().key(revisionKey).now());
|
return ofyTm()
|
||||||
|
.doTransactionless(() -> auditedOfy().load().key(revisionKey).now());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -158,7 +159,8 @@ public class PremiumListDatastoreDao {
|
||||||
@Override
|
@Override
|
||||||
public Optional<PremiumListEntry> load(final Key<PremiumListEntry> entryKey) {
|
public Optional<PremiumListEntry> load(final Key<PremiumListEntry> entryKey) {
|
||||||
return ofyTm()
|
return ofyTm()
|
||||||
.doTransactionless(() -> Optional.ofNullable(ofy().load().key(entryKey).now()));
|
.doTransactionless(
|
||||||
|
() -> Optional.ofNullable(auditedOfy().load().key(entryKey).now()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -232,7 +234,7 @@ public class PremiumListDatastoreDao {
|
||||||
|
|
||||||
// Save the new child entities in a series of transactions.
|
// Save the new child entities in a series of transactions.
|
||||||
for (final List<PremiumListEntry> batch : partition(parentedEntries, TRANSACTION_BATCH_SIZE)) {
|
for (final List<PremiumListEntry> batch : partition(parentedEntries, TRANSACTION_BATCH_SIZE)) {
|
||||||
ofyTm().transactNew(() -> ofy().save().entities(batch));
|
ofyTm().transactNew(() -> auditedOfy().save().entities(batch));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the new PremiumList and revision itself.
|
// Save the new PremiumList and revision itself.
|
||||||
|
@ -254,25 +256,29 @@ public class PremiumListDatastoreDao {
|
||||||
oldPremiumList.isPresent() ? oldPremiumList.get().creationTime : now)
|
oldPremiumList.isPresent() ? oldPremiumList.get().creationTime : now)
|
||||||
.setRevision(newRevisionKey)
|
.setRevision(newRevisionKey)
|
||||||
.build();
|
.build();
|
||||||
ofy().save().entities(newList, newRevision);
|
auditedOfy().save().entities(newList, newRevision);
|
||||||
premiumListCache.invalidate(premiumList.getName());
|
premiumListCache.invalidate(premiumList.getName());
|
||||||
return newList;
|
return newList;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void delete(PremiumList premiumList) {
|
public static void delete(PremiumList premiumList) {
|
||||||
ofyTm().transactNew(() -> ofy().delete().entity(premiumList));
|
ofyTm().transactNew(() -> auditedOfy().delete().entity(premiumList));
|
||||||
if (premiumList.getRevisionKey() == null) {
|
if (premiumList.getRevisionKey() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (final List<Key<PremiumListEntry>> batch :
|
for (final List<Key<PremiumListEntry>> batch :
|
||||||
partition(
|
partition(
|
||||||
ofy().load().type(PremiumListEntry.class).ancestor(premiumList.revisionKey).keys(),
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.type(PremiumListEntry.class)
|
||||||
|
.ancestor(premiumList.revisionKey)
|
||||||
|
.keys(),
|
||||||
TRANSACTION_BATCH_SIZE)) {
|
TRANSACTION_BATCH_SIZE)) {
|
||||||
ofyTm().transactNew(() -> ofy().delete().keys(batch));
|
ofyTm().transactNew(() -> auditedOfy().delete().keys(batch));
|
||||||
batch.forEach(premiumListEntriesCache::invalidate);
|
batch.forEach(premiumListEntriesCache::invalidate);
|
||||||
}
|
}
|
||||||
ofyTm().transactNew(() -> ofy().delete().key(premiumList.getRevisionKey()));
|
ofyTm().transactNew(() -> auditedOfy().delete().key(premiumList.getRevisionKey()));
|
||||||
premiumListCache.invalidate(premiumList.getName());
|
premiumListCache.invalidate(premiumList.getName());
|
||||||
premiumListRevisionsCache.invalidate(premiumList.getRevisionKey());
|
premiumListRevisionsCache.invalidate(premiumList.getRevisionKey());
|
||||||
}
|
}
|
||||||
|
@ -292,12 +298,16 @@ public class PremiumListDatastoreDao {
|
||||||
* <p>This is an expensive operation and should only be used when the entire list is required.
|
* <p>This is an expensive operation and should only be used when the entire list is required.
|
||||||
*/
|
*/
|
||||||
public static Iterable<PremiumListEntry> loadPremiumListEntriesUncached(PremiumList premiumList) {
|
public static Iterable<PremiumListEntry> loadPremiumListEntriesUncached(PremiumList premiumList) {
|
||||||
return ofy().load().type(PremiumListEntry.class).ancestor(premiumList.revisionKey).iterable();
|
return auditedOfy()
|
||||||
|
.load()
|
||||||
|
.type(PremiumListEntry.class)
|
||||||
|
.ancestor(premiumList.revisionKey)
|
||||||
|
.iterable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<PremiumList> getLatestRevisionUncached(String name) {
|
private static Optional<PremiumList> getLatestRevisionUncached(String name) {
|
||||||
return Optional.ofNullable(
|
return Optional.ofNullable(
|
||||||
ofy().load().key(Key.create(getCrossTldKey(), PremiumList.class, name)).now());
|
auditedOfy().load().key(Key.create(getCrossTldKey(), PremiumList.class, name)).now());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkOfyFieldsEqual(
|
private static void checkOfyFieldsEqual(
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.model.reporting;
|
package google.registry.model.reporting;
|
||||||
|
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
|
@ -53,7 +53,7 @@ public class HistoryEntryDao {
|
||||||
DateTime afterTime, DateTime beforeTime) {
|
DateTime afterTime, DateTime beforeTime) {
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
return Streams.stream(
|
return Streams.stream(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(HistoryEntry.class)
|
.type(HistoryEntry.class)
|
||||||
.order("modificationTime")
|
.order("modificationTime")
|
||||||
|
@ -87,7 +87,7 @@ public class HistoryEntryDao {
|
||||||
VKey<? extends EppResource> parentKey, DateTime afterTime, DateTime beforeTime) {
|
VKey<? extends EppResource> parentKey, DateTime afterTime, DateTime beforeTime) {
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
return Streams.stream(
|
return Streams.stream(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(HistoryEntry.class)
|
.type(HistoryEntry.class)
|
||||||
.ancestor(parentKey.getOfyKey())
|
.ancestor(parentKey.getOfyKey())
|
||||||
|
@ -106,7 +106,7 @@ public class HistoryEntryDao {
|
||||||
public static Iterable<? extends HistoryEntry> loadHistoryObjectsByRegistrars(
|
public static Iterable<? extends HistoryEntry> loadHistoryObjectsByRegistrars(
|
||||||
ImmutableCollection<String> registrarIds) {
|
ImmutableCollection<String> registrarIds) {
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
return ofy()
|
return auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(HistoryEntry.class)
|
.type(HistoryEntry.class)
|
||||||
.filter("clientId in", registrarIds)
|
.filter("clientId in", registrarIds)
|
||||||
|
|
|
@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.base.Throwables.throwIfUnchecked;
|
import static com.google.common.base.Throwables.throwIfUnchecked;
|
||||||
import static com.google.common.base.Verify.verify;
|
import static com.google.common.base.Verify.verify;
|
||||||
import static google.registry.model.ofy.ObjectifyService.allocateId;
|
import static google.registry.model.ofy.ObjectifyService.allocateId;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.ofyTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.ofyTm;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public class ClaimsListShard extends ImmutableObject implements NonReplicatedEnt
|
||||||
DateTime creationTime = START_OF_TIME;
|
DateTime creationTime = START_OF_TIME;
|
||||||
// Grab all of the keys for the shards that belong to the current revision.
|
// Grab all of the keys for the shards that belong to the current revision.
|
||||||
final List<Key<ClaimsListShard>> shardKeys =
|
final List<Key<ClaimsListShard>> shardKeys =
|
||||||
ofy().load().type(ClaimsListShard.class).ancestor(revisionKey).keys().list();
|
auditedOfy().load().type(ClaimsListShard.class).ancestor(revisionKey).keys().list();
|
||||||
|
|
||||||
List<ClaimsListShard> shards;
|
List<ClaimsListShard> shards;
|
||||||
try {
|
try {
|
||||||
|
@ -160,7 +160,7 @@ public class ClaimsListShard extends ImmutableObject implements NonReplicatedEnt
|
||||||
ofyTm()
|
ofyTm()
|
||||||
.transactNewReadOnly(
|
.transactNewReadOnly(
|
||||||
() -> {
|
() -> {
|
||||||
ClaimsListShard claimsListShard = ofy().load().key(key).now();
|
ClaimsListShard claimsListShard = auditedOfy().load().key(key).now();
|
||||||
checkState(
|
checkState(
|
||||||
claimsListShard != null,
|
claimsListShard != null,
|
||||||
"Key not found when loading claims list shards.");
|
"Key not found when loading claims list shards.");
|
||||||
|
@ -251,7 +251,7 @@ public class ClaimsListShard extends ImmutableObject implements NonReplicatedEnt
|
||||||
ClaimsListShard shard = create(creationTime, labelsToKeysShard);
|
ClaimsListShard shard = create(creationTime, labelsToKeysShard);
|
||||||
shard.isShard = true;
|
shard.isShard = true;
|
||||||
shard.parent = parentKey;
|
shard.parent = parentKey;
|
||||||
ofy().saveWithoutBackup().entity(shard);
|
auditedOfy().saveWithoutBackup().entity(shard);
|
||||||
return shard;
|
return shard;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -263,12 +263,17 @@ public class ClaimsListShard extends ImmutableObject implements NonReplicatedEnt
|
||||||
(getCurrentRevision() == null && oldRevision == null)
|
(getCurrentRevision() == null && oldRevision == null)
|
||||||
|| getCurrentRevision().equals(oldRevision),
|
|| getCurrentRevision().equals(oldRevision),
|
||||||
"Registries' ClaimsList was updated by someone else while attempting to update.");
|
"Registries' ClaimsList was updated by someone else while attempting to update.");
|
||||||
ofy().saveWithoutBackup().entity(ClaimsListSingleton.create(parentKey));
|
auditedOfy().saveWithoutBackup().entity(ClaimsListSingleton.create(parentKey));
|
||||||
// Delete the old ClaimsListShard entities.
|
// Delete the old ClaimsListShard entities.
|
||||||
if (oldRevision != null) {
|
if (oldRevision != null) {
|
||||||
ofy()
|
auditedOfy()
|
||||||
.deleteWithoutBackup()
|
.deleteWithoutBackup()
|
||||||
.keys(ofy().load().type(ClaimsListShard.class).ancestor(oldRevision).keys());
|
.keys(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.type(ClaimsListShard.class)
|
||||||
|
.ancestor(oldRevision)
|
||||||
|
.keys());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -345,7 +350,7 @@ public class ClaimsListShard extends ImmutableObject implements NonReplicatedEnt
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Key<ClaimsListRevision> getCurrentRevision() {
|
public static Key<ClaimsListRevision> getCurrentRevision() {
|
||||||
ClaimsListSingleton singleton = ofy().load().entity(new ClaimsListSingleton()).now();
|
ClaimsListSingleton singleton = auditedOfy().load().entity(new ClaimsListSingleton()).now();
|
||||||
return singleton == null ? null : singleton.activeRevision;
|
return singleton == null ? null : singleton.activeRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model.translators;
|
||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static google.registry.config.RegistryConfig.getCommitLogDatastoreRetention;
|
import static google.registry.config.RegistryConfig.getCommitLogDatastoreRetention;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public final class CommitLogRevisionsTranslatorFactory
|
||||||
DateTime preThresholdTime = firstNonNull(revisions.floorKey(threshold), START_OF_TIME);
|
DateTime preThresholdTime = firstNonNull(revisions.floorKey(threshold), START_OF_TIME);
|
||||||
return new ImmutableSortedMap.Builder<DateTime, Key<CommitLogManifest>>(Ordering.natural())
|
return new ImmutableSortedMap.Builder<DateTime, Key<CommitLogManifest>>(Ordering.natural())
|
||||||
.putAll(revisions.subMap(preThresholdTime, true, now.withTimeAtStartOfDay(), false))
|
.putAll(revisions.subMap(preThresholdTime, true, now.withTimeAtStartOfDay(), false))
|
||||||
.put(now, ofy().getCommitLogManifestKey())
|
.put(now, auditedOfy().getCommitLogManifestKey())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.rde;
|
||||||
import static com.google.common.base.Strings.nullToEmpty;
|
import static com.google.common.base.Strings.nullToEmpty;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static google.registry.model.EppResourceUtils.loadAtPointInTime;
|
import static google.registry.model.EppResourceUtils.loadAtPointInTime;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
|
||||||
import com.google.appengine.tools.mapreduce.Mapper;
|
import com.google.appengine.tools.mapreduce.Mapper;
|
||||||
|
@ -154,7 +153,7 @@ public final class RdeStagingMapper extends Mapper<EppResource, PendingDeposit,
|
||||||
getContext().incrementCounter("fragmenter resources found", fragmenter.resourcesFound);
|
getContext().incrementCounter("fragmenter resources found", fragmenter.resourcesFound);
|
||||||
|
|
||||||
// Avoid running out of memory.
|
// Avoid running out of memory.
|
||||||
ofy().clearSessionCache();
|
tm().clearSessionCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Loading cache that turns a resource into XML for the various points in time and modes. */
|
/** Loading cache that turns a resource into XML for the various points in time and modes. */
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.base.MoreObjects.toStringHelper;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.Streams.stream;
|
import static com.google.common.collect.Streams.stream;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||||
|
@ -321,11 +321,15 @@ public class AuthenticatedRegistrarAccessor {
|
||||||
// Find all registrars that have a registrar contact with this user's ID.
|
// Find all registrars that have a registrar contact with this user's ID.
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
ImmutableList<Key<Registrar>> accessibleClientIds =
|
ImmutableList<Key<Registrar>> accessibleClientIds =
|
||||||
stream(ofy().load().type(RegistrarContact.class).filter("gaeUserId", user.getUserId()))
|
stream(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.type(RegistrarContact.class)
|
||||||
|
.filter("gaeUserId", user.getUserId()))
|
||||||
.map(RegistrarContact::getParent)
|
.map(RegistrarContact::getParent)
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
// Filter out disabled registrars (note that pending registrars still allow console login).
|
// Filter out disabled registrars (note that pending registrars still allow console login).
|
||||||
ofy().load().keys(accessibleClientIds).values().stream()
|
auditedOfy().load().keys(accessibleClientIds).values().stream()
|
||||||
.filter(registrar -> registrar.getState() != State.DISABLED)
|
.filter(registrar -> registrar.getState() != State.DISABLED)
|
||||||
.forEach(registrar -> builder.put(registrar.getClientId(), Role.OWNER));
|
.forEach(registrar -> builder.put(registrar.getClientId(), Role.OWNER));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.schema.replay;
|
package google.registry.schema.replay;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
|
@ -64,8 +64,8 @@ public class LastSqlTransaction extends ImmutableObject implements DatastoreOnly
|
||||||
* <p>Creates a new instance of the singleton if it is not already present in Cloud Datastore,
|
* <p>Creates a new instance of the singleton if it is not already present in Cloud Datastore,
|
||||||
*/
|
*/
|
||||||
static LastSqlTransaction load() {
|
static LastSqlTransaction load() {
|
||||||
ofy().assertInTransaction();
|
auditedOfy().assertInTransaction();
|
||||||
LastSqlTransaction result = ofy().load().key(KEY).now();
|
LastSqlTransaction result = auditedOfy().load().key(KEY).now();
|
||||||
return result == null ? new LastSqlTransaction() : result;
|
return result == null ? new LastSqlTransaction() : result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package google.registry.schema.replay;
|
package google.registry.schema.replay;
|
||||||
|
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.ofyTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.ofyTm;
|
||||||
import static google.registry.request.Action.Method.GET;
|
import static google.registry.request.Action.Method.GET;
|
||||||
|
@ -113,7 +113,7 @@ class ReplicateToDatastoreAction implements Runnable {
|
||||||
|
|
||||||
// Write the updated last transaction id to datastore as part of this datastore
|
// Write the updated last transaction id to datastore as part of this datastore
|
||||||
// transaction.
|
// transaction.
|
||||||
ofy().save().entity(lastSqlTxn.cloneWithNewTransactionId(nextTxnId));
|
auditedOfy().save().entity(lastSqlTxn.cloneWithNewTransactionId(nextTxnId));
|
||||||
logger.atInfo().log(
|
logger.atInfo().log(
|
||||||
"Finished applying single transaction Cloud SQL -> Cloud Datastore");
|
"Finished applying single transaction Cloud SQL -> Cloud Datastore");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.tools.server;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.request.Action.Method.POST;
|
import static google.registry.request.Action.Method.POST;
|
||||||
|
|
||||||
import com.google.appengine.tools.mapreduce.Input;
|
import com.google.appengine.tools.mapreduce.Input;
|
||||||
|
@ -98,7 +98,7 @@ public class KillAllCommitLogsAction implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void map(Key<?> bucketOrRoot) {
|
public void map(Key<?> bucketOrRoot) {
|
||||||
for (Key<Object> key : ofy().load().ancestor(bucketOrRoot).keys()) {
|
for (Key<Object> key : auditedOfy().load().ancestor(bucketOrRoot).keys()) {
|
||||||
emit(bucketOrRoot, key);
|
emit(bucketOrRoot, key);
|
||||||
getContext().incrementCounter("entities emitted");
|
getContext().incrementCounter("entities emitted");
|
||||||
getContext().incrementCounter(String.format("%s emitted", key.getKind()));
|
getContext().incrementCounter(String.format("%s emitted", key.getKind()));
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.whois;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
||||||
|
@ -54,7 +54,7 @@ final class NameserverLookupByIpCommand implements WhoisCommand {
|
||||||
Iterable<HostResource> hostsFromDb;
|
Iterable<HostResource> hostsFromDb;
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
hostsFromDb =
|
hostsFromDb =
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(HostResource.class)
|
.type(HostResource.class)
|
||||||
.filter("inetAddresses", ipAddress)
|
.filter("inetAddresses", ipAddress)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.backup;
|
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.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
|
@ -63,18 +63,20 @@ public class DeleteOldCommitLogsActionTest
|
||||||
action.maxAge = maxAge;
|
action.maxAge = maxAge;
|
||||||
action.run();
|
action.run();
|
||||||
executeTasksUntilEmpty("mapreduce");
|
executeTasksUntilEmpty("mapreduce");
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mutateContact(String email) {
|
private void mutateContact(String email) {
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
ContactResource contact = ofy().load()
|
ContactResource contact =
|
||||||
.type(ContactResource.class)
|
auditedOfy()
|
||||||
.first()
|
.load()
|
||||||
.now()
|
.type(ContactResource.class)
|
||||||
.asBuilder()
|
.first()
|
||||||
.setEmailAddress(email)
|
.now()
|
||||||
.build();
|
.asBuilder()
|
||||||
|
.setEmailAddress(email)
|
||||||
|
.build();
|
||||||
DatabaseHelper.persistResourceWithCommitLog(contact);
|
DatabaseHelper.persistResourceWithCommitLog(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,22 +87,22 @@ public class DeleteOldCommitLogsActionTest
|
||||||
String email = String.format("pumpkin_%d@cat.test", i);
|
String email = String.format("pumpkin_%d@cat.test", i);
|
||||||
mutateContact(email);
|
mutateContact(email);
|
||||||
}
|
}
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
|
|
||||||
contact = ofy().load().type(ContactResource.class).first().now();
|
contact = auditedOfy().load().type(ContactResource.class).first().now();
|
||||||
|
|
||||||
// The following value might change if {@link CommitLogRevisionsTranslatorFactory} changes.
|
// The following value might change if {@link CommitLogRevisionsTranslatorFactory} changes.
|
||||||
assertThat(contact.getRevisions().size()).isEqualTo(6);
|
assertThat(contact.getRevisions().size()).isEqualTo(6);
|
||||||
|
|
||||||
// Before deleting the unneeded manifests - we have 11 of them (one for the first
|
// Before deleting the unneeded manifests - we have 11 of them (one for the first
|
||||||
// creation, and 10 more for the mutateContacts)
|
// creation, and 10 more for the mutateContacts)
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).count()).isEqualTo(11);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).count()).isEqualTo(11);
|
||||||
// And each DatabaseHelper.persistResourceWithCommitLog creates 3 mutations
|
// And each DatabaseHelper.persistResourceWithCommitLog creates 3 mutations
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class).count()).isEqualTo(33);
|
assertThat(auditedOfy().load().type(CommitLogMutation.class).count()).isEqualTo(33);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> ImmutableList<T> ofyLoadType(Class<T> clazz) {
|
private <T> ImmutableList<T> ofyLoadType(Class<T> clazz) {
|
||||||
return ImmutableList.copyOf(ofy().load().type(clazz).iterable());
|
return ImmutableList.copyOf(auditedOfy().load().type(clazz).iterable());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check that with very short maxAge, only the referenced elements remain. */
|
/** Check that with very short maxAge, only the referenced elements remain. */
|
||||||
|
@ -108,7 +110,9 @@ public class DeleteOldCommitLogsActionTest
|
||||||
void test_shortMaxAge() throws Exception {
|
void test_shortMaxAge() throws Exception {
|
||||||
runMapreduce(Duration.millis(1));
|
runMapreduce(Duration.millis(1));
|
||||||
|
|
||||||
assertThat(ImmutableList.copyOf(ofy().load().type(CommitLogManifest.class).keys().iterable()))
|
assertThat(
|
||||||
|
ImmutableList.copyOf(
|
||||||
|
auditedOfy().load().type(CommitLogManifest.class).keys().iterable()))
|
||||||
.containsExactlyElementsIn(contact.getRevisions().values());
|
.containsExactlyElementsIn(contact.getRevisions().values());
|
||||||
|
|
||||||
// And each DatabaseHelper.persistResourceWithCommitLog creates 3 mutations
|
// And each DatabaseHelper.persistResourceWithCommitLog creates 3 mutations
|
||||||
|
|
|
@ -24,7 +24,7 @@ import static google.registry.backup.BackupUtils.serializeEntity;
|
||||||
import static google.registry.backup.ExportCommitLogDiffAction.DIFF_FILE_PREFIX;
|
import static google.registry.backup.ExportCommitLogDiffAction.DIFF_FILE_PREFIX;
|
||||||
import static google.registry.model.ofy.CommitLogBucket.getBucketIds;
|
import static google.registry.model.ofy.CommitLogBucket.getBucketIds;
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.DatastoreServiceFactory;
|
import com.google.appengine.api.datastore.DatastoreServiceFactory;
|
||||||
|
@ -89,7 +89,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRestore_multipleDiffFiles() throws Exception {
|
void testRestore_multipleDiffFiles() throws Exception {
|
||||||
ofy()
|
auditedOfy()
|
||||||
.saveWithoutBackup()
|
.saveWithoutBackup()
|
||||||
.entities(TestObject.create("previous to keep"), TestObject.create("previous to delete"))
|
.entities(TestObject.create("previous to keep"), TestObject.create("previous to delete"))
|
||||||
.now();
|
.now();
|
||||||
|
@ -134,7 +134,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
CommitLogMutation.create(manifest2Key, TestObject.create("f")));
|
CommitLogMutation.create(manifest2Key, TestObject.create("f")));
|
||||||
action.fromTime = now.minusMinutes(1).minusMillis(1);
|
action.fromTime = now.minusMinutes(1).minusMillis(1);
|
||||||
action.run();
|
action.run();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertExpectedIds("previous to keep", "b", "d", "e", "f");
|
assertExpectedIds("previous to keep", "b", "d", "e", "f");
|
||||||
assertInDatastore(file1CommitLogs);
|
assertInDatastore(file1CommitLogs);
|
||||||
assertInDatastore(file2CommitLogs);
|
assertInDatastore(file2CommitLogs);
|
||||||
|
@ -144,11 +144,11 @@ public class RestoreCommitLogsActionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRestore_noManifests() throws Exception {
|
void testRestore_noManifests() throws Exception {
|
||||||
ofy().saveWithoutBackup().entity(TestObject.create("previous to keep")).now();
|
auditedOfy().saveWithoutBackup().entity(TestObject.create("previous to keep")).now();
|
||||||
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
||||||
Iterable<ImmutableObject> commitLogs = saveDiffFile(gcsService, createCheckpoint(now));
|
Iterable<ImmutableObject> commitLogs = saveDiffFile(gcsService, createCheckpoint(now));
|
||||||
action.run();
|
action.run();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertExpectedIds("previous to keep");
|
assertExpectedIds("previous to keep");
|
||||||
assertInDatastore(commitLogs);
|
assertInDatastore(commitLogs);
|
||||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||||
|
@ -157,7 +157,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRestore_manifestWithNoDeletions() throws Exception {
|
void testRestore_manifestWithNoDeletions() throws Exception {
|
||||||
ofy().saveWithoutBackup().entity(TestObject.create("previous to keep")).now();
|
auditedOfy().saveWithoutBackup().entity(TestObject.create("previous to keep")).now();
|
||||||
Key<CommitLogBucket> bucketKey = getBucketKey(1);
|
Key<CommitLogBucket> bucketKey = getBucketKey(1);
|
||||||
Key<CommitLogManifest> manifestKey = CommitLogManifest.createKey(bucketKey, now);
|
Key<CommitLogManifest> manifestKey = CommitLogManifest.createKey(bucketKey, now);
|
||||||
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
||||||
|
@ -169,7 +169,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
CommitLogMutation.create(manifestKey, TestObject.create("a")),
|
CommitLogMutation.create(manifestKey, TestObject.create("a")),
|
||||||
CommitLogMutation.create(manifestKey, TestObject.create("b")));
|
CommitLogMutation.create(manifestKey, TestObject.create("b")));
|
||||||
action.run();
|
action.run();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertExpectedIds("previous to keep", "a", "b");
|
assertExpectedIds("previous to keep", "a", "b");
|
||||||
assertInDatastore(commitLogs);
|
assertInDatastore(commitLogs);
|
||||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||||
|
@ -178,7 +178,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRestore_manifestWithNoMutations() throws Exception {
|
void testRestore_manifestWithNoMutations() throws Exception {
|
||||||
ofy()
|
auditedOfy()
|
||||||
.saveWithoutBackup()
|
.saveWithoutBackup()
|
||||||
.entities(TestObject.create("previous to keep"), TestObject.create("previous to delete"))
|
.entities(TestObject.create("previous to keep"), TestObject.create("previous to delete"))
|
||||||
.now();
|
.now();
|
||||||
|
@ -192,7 +192,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
now,
|
now,
|
||||||
ImmutableSet.of(Key.create(TestObject.create("previous to delete")))));
|
ImmutableSet.of(Key.create(TestObject.create("previous to delete")))));
|
||||||
action.run();
|
action.run();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertExpectedIds("previous to keep");
|
assertExpectedIds("previous to keep");
|
||||||
assertInDatastore(commitLogs);
|
assertInDatastore(commitLogs);
|
||||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||||
|
@ -202,7 +202,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
// This is a pathological case that shouldn't be possible, but we should be robust to it.
|
// This is a pathological case that shouldn't be possible, but we should be robust to it.
|
||||||
@Test
|
@Test
|
||||||
void testRestore_manifestWithNoMutationsOrDeletions() throws Exception {
|
void testRestore_manifestWithNoMutationsOrDeletions() throws Exception {
|
||||||
ofy().saveWithoutBackup().entities(TestObject.create("previous to keep")).now();
|
auditedOfy().saveWithoutBackup().entities(TestObject.create("previous to keep")).now();
|
||||||
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
||||||
Iterable<ImmutableObject> commitLogs =
|
Iterable<ImmutableObject> commitLogs =
|
||||||
saveDiffFile(
|
saveDiffFile(
|
||||||
|
@ -210,7 +210,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
createCheckpoint(now),
|
createCheckpoint(now),
|
||||||
CommitLogManifest.create(getBucketKey(1), now, null));
|
CommitLogManifest.create(getBucketKey(1), now, null));
|
||||||
action.run();
|
action.run();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertExpectedIds("previous to keep");
|
assertExpectedIds("previous to keep");
|
||||||
assertInDatastore(commitLogs);
|
assertInDatastore(commitLogs);
|
||||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||||
|
@ -219,7 +219,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRestore_mutateExistingEntity() throws Exception {
|
void testRestore_mutateExistingEntity() throws Exception {
|
||||||
ofy().saveWithoutBackup().entity(TestObject.create("existing", "a")).now();
|
auditedOfy().saveWithoutBackup().entity(TestObject.create("existing", "a")).now();
|
||||||
Key<CommitLogManifest> manifestKey = CommitLogManifest.createKey(getBucketKey(1), now);
|
Key<CommitLogManifest> manifestKey = CommitLogManifest.createKey(getBucketKey(1), now);
|
||||||
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
||||||
Iterable<ImmutableObject> commitLogs =
|
Iterable<ImmutableObject> commitLogs =
|
||||||
|
@ -229,8 +229,9 @@ public class RestoreCommitLogsActionTest {
|
||||||
CommitLogManifest.create(getBucketKey(1), now, null),
|
CommitLogManifest.create(getBucketKey(1), now, null),
|
||||||
CommitLogMutation.create(manifestKey, TestObject.create("existing", "b")));
|
CommitLogMutation.create(manifestKey, TestObject.create("existing", "b")));
|
||||||
action.run();
|
action.run();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(ofy().load().entity(TestObject.create("existing")).now().getField()).isEqualTo("b");
|
assertThat(auditedOfy().load().entity(TestObject.create("existing")).now().getField())
|
||||||
|
.isEqualTo("b");
|
||||||
assertInDatastore(commitLogs);
|
assertInDatastore(commitLogs);
|
||||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||||
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
||||||
|
@ -239,7 +240,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
// This should be harmless; deletes are idempotent.
|
// This should be harmless; deletes are idempotent.
|
||||||
@Test
|
@Test
|
||||||
void testRestore_deleteMissingEntity() throws Exception {
|
void testRestore_deleteMissingEntity() throws Exception {
|
||||||
ofy().saveWithoutBackup().entity(TestObject.create("previous to keep", "a")).now();
|
auditedOfy().saveWithoutBackup().entity(TestObject.create("previous to keep", "a")).now();
|
||||||
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
saveDiffFileNotToRestore(gcsService, now.minusMinutes(1));
|
||||||
Iterable<ImmutableObject> commitLogs =
|
Iterable<ImmutableObject> commitLogs =
|
||||||
saveDiffFile(
|
saveDiffFile(
|
||||||
|
@ -250,7 +251,7 @@ public class RestoreCommitLogsActionTest {
|
||||||
now,
|
now,
|
||||||
ImmutableSet.of(Key.create(TestObject.create("previous to delete")))));
|
ImmutableSet.of(Key.create(TestObject.create("previous to delete")))));
|
||||||
action.run();
|
action.run();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertExpectedIds("previous to keep");
|
assertExpectedIds("previous to keep");
|
||||||
assertInDatastore(commitLogs);
|
assertInDatastore(commitLogs);
|
||||||
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
||||||
|
@ -290,22 +291,24 @@ public class RestoreCommitLogsActionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertExpectedIds(String... ids) {
|
private void assertExpectedIds(String... ids) {
|
||||||
assertThat(transform(ofy().load().type(TestObject.class), TestObject::getId))
|
assertThat(transform(auditedOfy().load().type(TestObject.class), TestObject::getId))
|
||||||
.containsExactly((Object[]) ids);
|
.containsExactly((Object[]) ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertInDatastore(ImmutableObject entity) {
|
private void assertInDatastore(ImmutableObject entity) {
|
||||||
assertThat(ofy().load().entity(entity).now()).isEqualTo(entity);
|
assertThat(auditedOfy().load().entity(entity).now()).isEqualTo(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertInDatastore(Iterable<? extends ImmutableObject> entities) {
|
private void assertInDatastore(Iterable<? extends ImmutableObject> entities) {
|
||||||
assertThat(ofy().load().entities(entities).values()).containsExactlyElementsIn(entities);
|
assertThat(auditedOfy().load().entities(entities).values()).containsExactlyElementsIn(entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCommitLogBuckets(Map<Integer, DateTime> bucketIdsAndTimestamps) {
|
private void assertCommitLogBuckets(Map<Integer, DateTime> bucketIdsAndTimestamps) {
|
||||||
Map<Long, CommitLogBucket> buckets = ofy().load()
|
Map<Long, CommitLogBucket> buckets =
|
||||||
.type(CommitLogBucket.class)
|
auditedOfy()
|
||||||
.ids(Longs.asList(Longs.toArray(CommitLogBucket.getBucketIds())));
|
.load()
|
||||||
|
.type(CommitLogBucket.class)
|
||||||
|
.ids(Longs.asList(Longs.toArray(CommitLogBucket.getBucketIds())));
|
||||||
assertThat(buckets).hasSize(bucketIdsAndTimestamps.size());
|
assertThat(buckets).hasSize(bucketIdsAndTimestamps.size());
|
||||||
for (Entry<Integer, DateTime> bucketIdAndTimestamp : bucketIdsAndTimestamps.entrySet()) {
|
for (Entry<Integer, DateTime> bucketIdAndTimestamp : bucketIdsAndTimestamps.entrySet()) {
|
||||||
assertThat(buckets.get((long) bucketIdAndTimestamp.getKey()).getLastWrittenTime())
|
assertThat(buckets.get((long) bucketIdAndTimestamp.getKey()).getLastWrittenTime())
|
||||||
|
|
|
@ -22,7 +22,7 @@ import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_DELETE;
|
||||||
import static google.registry.batch.AsyncTaskMetrics.OperationResult.STALE;
|
import static google.registry.batch.AsyncTaskMetrics.OperationResult.STALE;
|
||||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||||
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
|
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE;
|
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE_FAILURE;
|
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_DELETE_FAILURE;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_TRANSFER_REQUEST;
|
import static google.registry.model.reporting.HistoryEntry.Type.CONTACT_TRANSFER_REQUEST;
|
||||||
|
@ -132,7 +132,7 @@ public class DeleteContactsAndHostsActionTest
|
||||||
executeTasksUntilEmpty("mapreduce", clock);
|
executeTasksUntilEmpty("mapreduce", clock);
|
||||||
sleeper.sleep(millis(50));
|
sleeper.sleep(millis(50));
|
||||||
clock.advanceBy(standardSeconds(5));
|
clock.advanceBy(standardSeconds(5));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Kicks off, but does not run, the mapreduce tasks. Useful for testing validation/setup. */
|
/** Kicks off, but does not run, the mapreduce tasks. Useful for testing validation/setup. */
|
||||||
|
@ -140,7 +140,7 @@ public class DeleteContactsAndHostsActionTest
|
||||||
clock.advanceBy(standardSeconds(5));
|
clock.advanceBy(standardSeconds(5));
|
||||||
action.run();
|
action.run();
|
||||||
clock.advanceBy(standardSeconds(5));
|
clock.advanceBy(standardSeconds(5));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
@ -258,7 +258,7 @@ public class DeleteContactsAndHostsActionTest
|
||||||
false);
|
false);
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
assertThat(loadByForeignKey(ContactResource.class, "jim919", clock.nowUtc())).isEmpty();
|
assertThat(loadByForeignKey(ContactResource.class, "jim919", clock.nowUtc())).isEmpty();
|
||||||
ContactResource contactAfterDeletion = ofy().load().entity(contact).now();
|
ContactResource contactAfterDeletion = auditedOfy().load().entity(contact).now();
|
||||||
assertAboutContacts()
|
assertAboutContacts()
|
||||||
.that(contactAfterDeletion)
|
.that(contactAfterDeletion)
|
||||||
.isNotActiveAt(clock.nowUtc())
|
.isNotActiveAt(clock.nowUtc())
|
||||||
|
@ -299,7 +299,7 @@ public class DeleteContactsAndHostsActionTest
|
||||||
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
||||||
false);
|
false);
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
ContactResource contactAfterDeletion = ofy().load().entity(contact).now();
|
ContactResource contactAfterDeletion = auditedOfy().load().entity(contact).now();
|
||||||
assertThat(contactAfterDeletion.getTransferData()).isEqualTo(ContactTransferData.EMPTY);
|
assertThat(contactAfterDeletion.getTransferData()).isEqualTo(ContactTransferData.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ public class DeleteContactsAndHostsActionTest
|
||||||
true);
|
true);
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
assertThat(loadByForeignKey(ContactResource.class, "nate007", clock.nowUtc())).isEmpty();
|
assertThat(loadByForeignKey(ContactResource.class, "nate007", clock.nowUtc())).isEmpty();
|
||||||
ContactResource contactAfterDeletion = ofy().load().entity(contact).now();
|
ContactResource contactAfterDeletion = auditedOfy().load().entity(contact).now();
|
||||||
assertAboutContacts()
|
assertAboutContacts()
|
||||||
.that(contactAfterDeletion)
|
.that(contactAfterDeletion)
|
||||||
.isNotActiveAt(clock.nowUtc())
|
.isNotActiveAt(clock.nowUtc())
|
||||||
|
@ -579,8 +579,8 @@ public class DeleteContactsAndHostsActionTest
|
||||||
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
||||||
false);
|
false);
|
||||||
enqueueMapreduceOnly();
|
enqueueMapreduceOnly();
|
||||||
assertThat(ofy().load().entity(contactDeleted).now()).isEqualTo(contactDeleted);
|
assertThat(auditedOfy().load().entity(contactDeleted).now()).isEqualTo(contactDeleted);
|
||||||
assertThat(ofy().load().entity(hostDeleted).now()).isEqualTo(hostDeleted);
|
assertThat(auditedOfy().load().entity(hostDeleted).now()).isEqualTo(hostDeleted);
|
||||||
assertNoTasksEnqueued(QUEUE_ASYNC_DELETE);
|
assertNoTasksEnqueued(QUEUE_ASYNC_DELETE);
|
||||||
assertThat(acquireLock()).isPresent();
|
assertThat(acquireLock()).isPresent();
|
||||||
}
|
}
|
||||||
|
@ -844,12 +844,12 @@ public class DeleteContactsAndHostsActionTest
|
||||||
}
|
}
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
for (EppResource resource : ImmutableList.<EppResource>of(c1, c2, c3, h1, h2, h3)) {
|
for (EppResource resource : ImmutableList.<EppResource>of(c1, c2, c3, h1, h2, h3)) {
|
||||||
EppResource loaded = ofy().load().entity(resource).now();
|
EppResource loaded = auditedOfy().load().entity(resource).now();
|
||||||
assertThat(loaded.getDeletionTime()).isLessThan(DateTime.now(UTC));
|
assertThat(loaded.getDeletionTime()).isLessThan(DateTime.now(UTC));
|
||||||
assertThat(loaded.getStatusValues()).doesNotContain(PENDING_DELETE);
|
assertThat(loaded.getStatusValues()).doesNotContain(PENDING_DELETE);
|
||||||
}
|
}
|
||||||
for (EppResource resource : ImmutableList.<EppResource>of(c4, h4)) {
|
for (EppResource resource : ImmutableList.<EppResource>of(c4, h4)) {
|
||||||
EppResource loaded = ofy().load().entity(resource).now();
|
EppResource loaded = auditedOfy().load().entity(resource).now();
|
||||||
assertThat(loaded.getDeletionTime()).isEqualTo(END_OF_TIME);
|
assertThat(loaded.getDeletionTime()).isEqualTo(END_OF_TIME);
|
||||||
assertThat(loaded.getStatusValues()).doesNotContain(PENDING_DELETE);
|
assertThat(loaded.getStatusValues()).doesNotContain(PENDING_DELETE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.batch;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||||
|
@ -195,7 +195,8 @@ class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataActio
|
||||||
DateTime timeAfterDeletion = DateTime.now(UTC);
|
DateTime timeAfterDeletion = DateTime.now(UTC);
|
||||||
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion))
|
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion))
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion);
|
assertThat(auditedOfy().load().entity(domain).now().getDeletionTime())
|
||||||
|
.isLessThan(timeAfterDeletion);
|
||||||
assertDnsTasksEnqueued("blah.ib-any.test");
|
assertDnsTasksEnqueued("blah.ib-any.test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +213,8 @@ class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataActio
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion))
|
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion))
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion);
|
assertThat(auditedOfy().load().entity(domain).now().getDeletionTime())
|
||||||
|
.isLessThan(timeAfterDeletion);
|
||||||
assertDnsTasksEnqueued("blah.ib-any.test");
|
assertDnsTasksEnqueued("blah.ib-any.test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +241,7 @@ class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataActio
|
||||||
.build());
|
.build());
|
||||||
action.isDryRun = true;
|
action.isDryRun = true;
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
assertThat(ofy().load().entity(domain).now().getDeletionTime()).isEqualTo(END_OF_TIME);
|
assertThat(auditedOfy().load().entity(domain).now().getDeletionTime()).isEqualTo(END_OF_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -255,8 +257,8 @@ class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataActio
|
||||||
.build(),
|
.build(),
|
||||||
DateTime.now(UTC).minusYears(1));
|
DateTime.now(UTC).minusYears(1));
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
assertThat(ofy().load().entity(domainWithSubord).now()).isNotNull();
|
assertThat(auditedOfy().load().entity(domainWithSubord).now()).isNotNull();
|
||||||
assertThat(ofy().load().entity(nakedDomain).now()).isNull();
|
assertThat(auditedOfy().load().entity(nakedDomain).now()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -303,7 +305,7 @@ class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataActio
|
||||||
ForeignKeyIndex<DomainBase> fki =
|
ForeignKeyIndex<DomainBase> fki =
|
||||||
ForeignKeyIndex.load(DomainBase.class, fqdn, START_OF_TIME);
|
ForeignKeyIndex.load(DomainBase.class, fqdn, START_OF_TIME);
|
||||||
EppResourceIndex eppIndex =
|
EppResourceIndex eppIndex =
|
||||||
ofy().load().entity(EppResourceIndex.create(Key.create(domain))).now();
|
auditedOfy().load().entity(EppResourceIndex.create(Key.create(domain))).now();
|
||||||
return ImmutableSet.of(
|
return ImmutableSet.of(
|
||||||
domain, historyEntry, billingEvent, pollMessage, fki, eppIndex);
|
domain, historyEntry, billingEvent, pollMessage, fki, eppIndex);
|
||||||
}
|
}
|
||||||
|
@ -318,13 +320,13 @@ class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataActio
|
||||||
|
|
||||||
private static void assertNotDeleted(Iterable<ImmutableObject> entities) {
|
private static void assertNotDeleted(Iterable<ImmutableObject> entities) {
|
||||||
for (ImmutableObject entity : entities) {
|
for (ImmutableObject entity : entities) {
|
||||||
assertThat(ofy().load().entity(entity).now()).isNotNull();
|
assertThat(auditedOfy().load().entity(entity).now()).isNotNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertDeleted(Iterable<ImmutableObject> entities) {
|
private static void assertDeleted(Iterable<ImmutableObject> entities) {
|
||||||
for (ImmutableObject entity : entities) {
|
for (ImmutableObject entity : entities) {
|
||||||
assertThat(ofy().load().entity(entity).now()).isNull();
|
assertThat(auditedOfy().load().entity(entity).now()).isNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.batch;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.common.Cursor.CursorType.RECURRING_BILLING;
|
import static google.registry.model.common.Cursor.CursorType.RECURRING_BILLING;
|
||||||
import static google.registry.model.domain.Period.Unit.YEARS;
|
import static google.registry.model.domain.Period.Unit.YEARS;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_AUTORENEW;
|
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_AUTORENEW;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.testing.DatabaseHelper.assertBillingEvents;
|
import static google.registry.testing.DatabaseHelper.assertBillingEvents;
|
||||||
|
@ -108,11 +108,11 @@ public class ExpandRecurringBillingEventsActionTest
|
||||||
action.response = new FakeResponse();
|
action.response = new FakeResponse();
|
||||||
action.run();
|
action.run();
|
||||||
executeTasksUntilEmpty("mapreduce", clock);
|
executeTasksUntilEmpty("mapreduce", clock);
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCursorAt(DateTime expectedCursorTime) {
|
private void assertCursorAt(DateTime expectedCursorTime) {
|
||||||
Cursor cursor = ofy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now();
|
Cursor cursor = auditedOfy().load().key(Cursor.createGlobalKey(RECURRING_BILLING)).now();
|
||||||
assertThat(cursor).isNotNull();
|
assertThat(cursor).isNotNull();
|
||||||
assertThat(cursor.getCursorTime()).isEqualTo(expectedCursorTime);
|
assertThat(cursor.getCursorTime()).isEqualTo(expectedCursorTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.batch;
|
package google.registry.batch;
|
||||||
|
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer;
|
import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
@ -47,11 +47,11 @@ class ResaveAllEppResourcesActionTest extends MapreduceTestCase<ResaveAllEppReso
|
||||||
void test_mapreduceSuccessfullyResavesEntity() throws Exception {
|
void test_mapreduceSuccessfullyResavesEntity() throws Exception {
|
||||||
ContactResource contact = persistActiveContact("test123");
|
ContactResource contact = persistActiveContact("test123");
|
||||||
DateTime creationTime = contact.getUpdateTimestamp().getTimestamp();
|
DateTime creationTime = contact.getUpdateTimestamp().getTimestamp();
|
||||||
assertThat(ofy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
assertThat(auditedOfy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
||||||
.isEqualTo(creationTime);
|
.isEqualTo(creationTime);
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
assertThat(ofy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
assertThat(auditedOfy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
||||||
.isGreaterThan(creationTime);
|
.isGreaterThan(creationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ class ResaveAllEppResourcesActionTest extends MapreduceTestCase<ResaveAllEppReso
|
||||||
void test_fastMode_doesNotResaveEntityWithNoChanges() throws Exception {
|
void test_fastMode_doesNotResaveEntityWithNoChanges() throws Exception {
|
||||||
ContactResource contact = persistActiveContact("test123");
|
ContactResource contact = persistActiveContact("test123");
|
||||||
DateTime creationTime = contact.getUpdateTimestamp().getTimestamp();
|
DateTime creationTime = contact.getUpdateTimestamp().getTimestamp();
|
||||||
assertThat(ofy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
assertThat(auditedOfy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
||||||
.isEqualTo(creationTime);
|
.isEqualTo(creationTime);
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
action.isFast = true;
|
action.isFast = true;
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
assertThat(ofy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
assertThat(auditedOfy().load().entity(contact).now().getUpdateTimestamp().getTimestamp())
|
||||||
.isEqualTo(creationTime);
|
.isEqualTo(creationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ class ResaveAllEppResourcesActionTest extends MapreduceTestCase<ResaveAllEppReso
|
||||||
assertThat(contact.getTransferData().getTransferStatus()).isEqualTo(TransferStatus.PENDING);
|
assertThat(contact.getTransferData().getTransferStatus()).isEqualTo(TransferStatus.PENDING);
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
|
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
// The transfer should be effective after the contact is re-saved, as it should've been
|
// The transfer should be effective after the contact is re-saved, as it should've been
|
||||||
// projected to the current time.
|
// projected to the current time.
|
||||||
ContactResource resavedContact = ofy().load().entity(contact).now();
|
ContactResource resavedContact = auditedOfy().load().entity(contact).now();
|
||||||
assertThat(resavedContact.getTransferData().getTransferStatus())
|
assertThat(resavedContact.getTransferData().getTransferStatus())
|
||||||
.isEqualTo(TransferStatus.SERVER_APPROVED);
|
.isEqualTo(TransferStatus.SERVER_APPROVED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.beam.initsql;
|
package google.registry.beam.initsql;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.DatastoreService;
|
import com.google.appengine.api.datastore.DatastoreService;
|
||||||
|
@ -76,8 +76,8 @@ public final class BackupTestStore implements AutoCloseable {
|
||||||
long timestamp = fakeClock.nowUtc().getMillis();
|
long timestamp = fakeClock.nowUtc().getMillis();
|
||||||
tm().transact(
|
tm().transact(
|
||||||
() -> {
|
() -> {
|
||||||
ofy().delete().entities(deletes);
|
auditedOfy().delete().entities(deletes);
|
||||||
ofy().save().entities(newOrUpdated);
|
auditedOfy().save().entities(newOrUpdated);
|
||||||
});
|
});
|
||||||
fakeClock.advanceOneMilli();
|
fakeClock.advanceOneMilli();
|
||||||
return timestamp;
|
return timestamp;
|
||||||
|
@ -90,7 +90,7 @@ public final class BackupTestStore implements AutoCloseable {
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long insertOrUpdate(Object... entities) {
|
public final long insertOrUpdate(Object... entities) {
|
||||||
long timestamp = fakeClock.nowUtc().getMillis();
|
long timestamp = fakeClock.nowUtc().getMillis();
|
||||||
tm().transact(() -> ofy().save().entities(entities).now());
|
tm().transact(() -> auditedOfy().save().entities(entities).now());
|
||||||
fakeClock.advanceOneMilli();
|
fakeClock.advanceOneMilli();
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public final class BackupTestStore implements AutoCloseable {
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long delete(Object... entities) {
|
public final long delete(Object... entities) {
|
||||||
long timestamp = fakeClock.nowUtc().getMillis();
|
long timestamp = fakeClock.nowUtc().getMillis();
|
||||||
tm().transact(() -> ofy().delete().entities(entities).now());
|
tm().transact(() -> auditedOfy().delete().entities(entities).now());
|
||||||
fakeClock.advanceOneMilli();
|
fakeClock.advanceOneMilli();
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public final class BackupTestStore implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public Object loadAsOfyEntity(Object ofyEntity) {
|
public Object loadAsOfyEntity(Object ofyEntity) {
|
||||||
try {
|
try {
|
||||||
return ofy().load().fromEntity(datastoreService.get(Key.create(ofyEntity).getRaw()));
|
return auditedOfy().load().fromEntity(datastoreService.get(Key.create(ofyEntity).getRaw()));
|
||||||
} catch (EntityNotFoundException e) {
|
} catch (EntityNotFoundException e) {
|
||||||
throw new NoSuchElementException(e.getMessage());
|
throw new NoSuchElementException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -161,10 +161,10 @@ public final class BackupTestStore implements AutoCloseable {
|
||||||
private void exportOneKind(File perKindFile, Class<?> pojoType, Set<Key<?>> excludes)
|
private void exportOneKind(File perKindFile, Class<?> pojoType, Set<Key<?>> excludes)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(perKindFile);
|
LevelDbFileBuilder builder = new LevelDbFileBuilder(perKindFile);
|
||||||
for (Object pojo : ofy().load().type(pojoType).iterable()) {
|
for (Object pojo : auditedOfy().load().type(pojoType).iterable()) {
|
||||||
if (!excludes.contains(Key.create(pojo))) {
|
if (!excludes.contains(Key.create(pojo))) {
|
||||||
try {
|
try {
|
||||||
// Must preserve UpdateTimestamp. Do not use ofy().save().toEntity(pojo)!
|
// Must preserve UpdateTimestamp. Do not use auditedOfy().save().toEntity(pojo)!
|
||||||
builder.addEntity(datastoreService.get(Key.create(pojo).getRaw()));
|
builder.addEntity(datastoreService.get(Key.create(pojo).getRaw()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.beam.initsql;
|
package google.registry.beam.initsql;
|
||||||
|
|
||||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
|
import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
|
@ -166,7 +166,7 @@ public class DomainBaseUtilTest {
|
||||||
"registrar",
|
"registrar",
|
||||||
null))
|
null))
|
||||||
.build()));
|
.build()));
|
||||||
domainEntity = tm().transact(() -> ofy().toEntity(domain));
|
domainEntity = tm().transact(() -> auditedOfy().toEntity(domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -182,7 +182,7 @@ public class DomainBaseUtilTest {
|
||||||
.setGracePeriods(ImmutableSet.of())
|
.setGracePeriods(ImmutableSet.of())
|
||||||
.build();
|
.build();
|
||||||
DomainBase domainTransformedByUtil =
|
DomainBase domainTransformedByUtil =
|
||||||
(DomainBase) ofy().toPojo(DomainBaseUtil.removeBillingAndPollAndHosts(domainEntity));
|
(DomainBase) auditedOfy().toPojo(DomainBaseUtil.removeBillingAndPollAndHosts(domainEntity));
|
||||||
// Compensates for the missing INACTIVE status.
|
// Compensates for the missing INACTIVE status.
|
||||||
domainTransformedByUtil = domainTransformedByUtil.asBuilder().build();
|
domainTransformedByUtil = domainTransformedByUtil.asBuilder().build();
|
||||||
assertAboutImmutableObjects()
|
assertAboutImmutableObjects()
|
||||||
|
@ -202,9 +202,10 @@ public class DomainBaseUtilTest {
|
||||||
.setTransferData(null)
|
.setTransferData(null)
|
||||||
.setGracePeriods(ImmutableSet.of())
|
.setGracePeriods(ImmutableSet.of())
|
||||||
.build();
|
.build();
|
||||||
Entity entityWithoutFkeys = tm().transact(() -> ofy().toEntity(domainWithoutFKeys));
|
Entity entityWithoutFkeys = tm().transact(() -> auditedOfy().toEntity(domainWithoutFKeys));
|
||||||
DomainBase domainTransformedByUtil =
|
DomainBase domainTransformedByUtil =
|
||||||
(DomainBase) ofy().toPojo(DomainBaseUtil.removeBillingAndPollAndHosts(entityWithoutFkeys));
|
(DomainBase)
|
||||||
|
auditedOfy().toPojo(DomainBaseUtil.removeBillingAndPollAndHosts(entityWithoutFkeys));
|
||||||
// Compensates for the missing INACTIVE status.
|
// Compensates for the missing INACTIVE status.
|
||||||
domainTransformedByUtil = domainTransformedByUtil.asBuilder().build();
|
domainTransformedByUtil = domainTransformedByUtil.asBuilder().build();
|
||||||
assertAboutImmutableObjects()
|
assertAboutImmutableObjects()
|
||||||
|
@ -215,7 +216,7 @@ public class DomainBaseUtilTest {
|
||||||
@Test
|
@Test
|
||||||
void removeBillingAndPollAndHosts_notDomainBase() {
|
void removeBillingAndPollAndHosts_notDomainBase() {
|
||||||
Entity contactEntity =
|
Entity contactEntity =
|
||||||
tm().transact(() -> ofy().toEntity(DatabaseHelper.newContactResource("contact")));
|
tm().transact(() -> auditedOfy().toEntity(DatabaseHelper.newContactResource("contact")));
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.beam.initsql;
|
package google.registry.beam.initsql;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static org.apache.beam.sdk.values.TypeDescriptors.kvs;
|
import static org.apache.beam.sdk.values.TypeDescriptors.kvs;
|
||||||
import static org.apache.beam.sdk.values.TypeDescriptors.strings;
|
import static org.apache.beam.sdk.values.TypeDescriptors.strings;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public final class InitSqlTestUtils {
|
||||||
|
|
||||||
/** Converts a Datastore {@link Entity} to an Objectify entity. */
|
/** Converts a Datastore {@link Entity} to an Objectify entity. */
|
||||||
public static Object datastoreToOfyEntity(Entity entity) {
|
public static Object datastoreToOfyEntity(Entity entity) {
|
||||||
return ofy().load().fromEntity(entity);
|
return auditedOfy().load().fromEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Serializes a Datastore {@link Entity} to byte array. */
|
/** Serializes a Datastore {@link Entity} to byte array. */
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.flows;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.EppResourceUtils.loadAtPointInTime;
|
import static google.registry.model.EppResourceUtils.loadAtPointInTime;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveHost;
|
import static google.registry.testing.DatabaseHelper.persistActiveHost;
|
||||||
|
@ -95,64 +95,64 @@ class EppCommitLogsTest {
|
||||||
clock.setTo(timeAtCreate);
|
clock.setTo(timeAtCreate);
|
||||||
eppLoader = new EppLoader(this, "domain_create.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
eppLoader = new EppLoader(this, "domain_create.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||||
runFlow();
|
runFlow();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
Key<DomainBase> key = Key.create(ofy().load().type(DomainBase.class).first().now());
|
Key<DomainBase> key = Key.create(auditedOfy().load().type(DomainBase.class).first().now());
|
||||||
DomainBase domainAfterCreate = ofy().load().key(key).now();
|
DomainBase domainAfterCreate = auditedOfy().load().key(key).now();
|
||||||
assertThat(domainAfterCreate.getDomainName()).isEqualTo("example.tld");
|
assertThat(domainAfterCreate.getDomainName()).isEqualTo("example.tld");
|
||||||
|
|
||||||
clock.advanceBy(standardDays(2));
|
clock.advanceBy(standardDays(2));
|
||||||
DateTime timeAtFirstUpdate = clock.nowUtc();
|
DateTime timeAtFirstUpdate = clock.nowUtc();
|
||||||
eppLoader = new EppLoader(this, "domain_update_dsdata_add.xml");
|
eppLoader = new EppLoader(this, "domain_update_dsdata_add.xml");
|
||||||
runFlow();
|
runFlow();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
|
|
||||||
DomainBase domainAfterFirstUpdate = ofy().load().key(key).now();
|
DomainBase domainAfterFirstUpdate = auditedOfy().load().key(key).now();
|
||||||
assertThat(domainAfterCreate).isNotEqualTo(domainAfterFirstUpdate);
|
assertThat(domainAfterCreate).isNotEqualTo(domainAfterFirstUpdate);
|
||||||
|
|
||||||
clock.advanceOneMilli(); // same day as first update
|
clock.advanceOneMilli(); // same day as first update
|
||||||
DateTime timeAtSecondUpdate = clock.nowUtc();
|
DateTime timeAtSecondUpdate = clock.nowUtc();
|
||||||
eppLoader = new EppLoader(this, "domain_update_dsdata_rem.xml");
|
eppLoader = new EppLoader(this, "domain_update_dsdata_rem.xml");
|
||||||
runFlow();
|
runFlow();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
DomainBase domainAfterSecondUpdate = ofy().load().key(key).now();
|
DomainBase domainAfterSecondUpdate = auditedOfy().load().key(key).now();
|
||||||
|
|
||||||
clock.advanceBy(standardDays(2));
|
clock.advanceBy(standardDays(2));
|
||||||
DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends
|
DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends
|
||||||
eppLoader = new EppLoader(this, "domain_delete.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
eppLoader = new EppLoader(this, "domain_delete.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||||
runFlow();
|
runFlow();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
|
|
||||||
assertThat(domainAfterFirstUpdate).isNotEqualTo(domainAfterSecondUpdate);
|
assertThat(domainAfterFirstUpdate).isNotEqualTo(domainAfterSecondUpdate);
|
||||||
|
|
||||||
// Point-in-time can only rewind an object from the current version, not roll forward.
|
// Point-in-time can only rewind an object from the current version, not roll forward.
|
||||||
DomainBase latest = ofy().load().key(key).now();
|
DomainBase latest = auditedOfy().load().key(key).now();
|
||||||
|
|
||||||
// Creation time has millisecond granularity due to isActive() check.
|
// Creation time has millisecond granularity due to isActive() check.
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtCreate.minusMillis(1)).now()).isNull();
|
assertThat(loadAtPointInTime(latest, timeAtCreate.minusMillis(1)).now()).isNull();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtCreate).now()).isNotNull();
|
assertThat(loadAtPointInTime(latest, timeAtCreate).now()).isNotNull();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtCreate.plusMillis(1)).now()).isNotNull();
|
assertThat(loadAtPointInTime(latest, timeAtCreate.plusMillis(1)).now()).isNotNull();
|
||||||
|
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtCreate.plusDays(1)).now())
|
assertThat(loadAtPointInTime(latest, timeAtCreate.plusDays(1)).now())
|
||||||
.isEqualTo(domainAfterCreate);
|
.isEqualTo(domainAfterCreate);
|
||||||
|
|
||||||
// Both updates happened on the same day. Since the revisions field has day granularity, the
|
// Both updates happened on the same day. Since the revisions field has day granularity, the
|
||||||
// key to the first update should have been overwritten by the second, and its timestamp rolled
|
// key to the first update should have been overwritten by the second, and its timestamp rolled
|
||||||
// forward. So we have to fall back to the last revision before midnight.
|
// forward. So we have to fall back to the last revision before midnight.
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtFirstUpdate).now()).isEqualTo(domainAfterCreate);
|
assertThat(loadAtPointInTime(latest, timeAtFirstUpdate).now()).isEqualTo(domainAfterCreate);
|
||||||
|
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtSecondUpdate).now())
|
assertThat(loadAtPointInTime(latest, timeAtSecondUpdate).now())
|
||||||
.isEqualTo(domainAfterSecondUpdate);
|
.isEqualTo(domainAfterSecondUpdate);
|
||||||
|
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtSecondUpdate.plusDays(1)).now())
|
assertThat(loadAtPointInTime(latest, timeAtSecondUpdate.plusDays(1)).now())
|
||||||
.isEqualTo(domainAfterSecondUpdate);
|
.isEqualTo(domainAfterSecondUpdate);
|
||||||
|
|
||||||
// Deletion time has millisecond granularity due to isActive() check.
|
// Deletion time has millisecond granularity due to isActive() check.
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtDelete.minusMillis(1)).now()).isNotNull();
|
assertThat(loadAtPointInTime(latest, timeAtDelete.minusMillis(1)).now()).isNotNull();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtDelete).now()).isNull();
|
assertThat(loadAtPointInTime(latest, timeAtDelete).now()).isNull();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtDelete.plusMillis(1)).now()).isNull();
|
assertThat(loadAtPointInTime(latest, timeAtDelete.plusMillis(1)).now()).isNull();
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
|
@ -137,14 +137,14 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
||||||
}
|
}
|
||||||
ImmutableList<EppResourceIndex> indices =
|
ImmutableList<EppResourceIndex> indices =
|
||||||
Streams.stream(
|
Streams.stream(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(EppResourceIndex.class)
|
.type(EppResourceIndex.class)
|
||||||
.filter("kind", Key.getKind(resource.getClass())))
|
.filter("kind", Key.getKind(resource.getClass())))
|
||||||
.filter(
|
.filter(
|
||||||
index ->
|
index ->
|
||||||
Key.create(resource).equals(index.getKey())
|
Key.create(resource).equals(index.getKey())
|
||||||
&& ofy().load().key(index.getKey()).now().equals(resource))
|
&& auditedOfy().load().key(index.getKey()).now().equals(resource))
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
assertThat(indices).hasSize(1);
|
assertThat(indices).hasSize(1);
|
||||||
assertThat(indices.get(0).getBucket())
|
assertThat(indices.get(0).getBucket())
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -135,7 +135,7 @@ public abstract class EntityTestCase {
|
||||||
try {
|
try {
|
||||||
// Objectify happily filters on an unindexed field, and just returns zero results.
|
// Objectify happily filters on an unindexed field, and just returns zero results.
|
||||||
// Do a query for that value and verify that the expected number of results are returned.
|
// Do a query for that value and verify that the expected number of results are returned.
|
||||||
Query<?> query = ofy().load().type(obj.getClass());
|
Query<?> query = auditedOfy().load().type(obj.getClass());
|
||||||
int results = query.filter(fieldPath, fieldValue).count();
|
int results = query.filter(fieldPath, fieldValue).count();
|
||||||
assertWithMessage(String.format("%s was %sindexed", fieldPath, indexed ? "not " : ""))
|
assertWithMessage(String.format("%s was %sindexed", fieldPath, indexed ? "not " : ""))
|
||||||
.that(indexed)
|
.that(indexed)
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model.billing;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerUtil.ofyTmOrDoNothing;
|
import static google.registry.persistence.transaction.TransactionManagerUtil.ofyTmOrDoNothing;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
|
@ -197,21 +197,32 @@ public class BillingEventTest extends EntityTestCase {
|
||||||
void testParenting() {
|
void testParenting() {
|
||||||
// Note that these are all tested separately because BillingEvent is an abstract base class that
|
// Note that these are all tested separately because BillingEvent is an abstract base class that
|
||||||
// lacks the @Entity annotation, and thus we cannot call .type(BillingEvent.class)
|
// lacks the @Entity annotation, and thus we cannot call .type(BillingEvent.class)
|
||||||
assertThat(ofy().load().type(BillingEvent.OneTime.class).ancestor(domain).list())
|
assertThat(auditedOfy().load().type(BillingEvent.OneTime.class).ancestor(domain).list())
|
||||||
.containsExactly(oneTime, oneTimeSynthetic);
|
.containsExactly(oneTime, oneTimeSynthetic);
|
||||||
assertThat(ofy().load().type(BillingEvent.Recurring.class).ancestor(domain).list())
|
assertThat(auditedOfy().load().type(BillingEvent.Recurring.class).ancestor(domain).list())
|
||||||
.containsExactly(recurring);
|
.containsExactly(recurring);
|
||||||
assertThat(ofy().load().type(BillingEvent.Cancellation.class).ancestor(domain).list())
|
assertThat(auditedOfy().load().type(BillingEvent.Cancellation.class).ancestor(domain).list())
|
||||||
.containsExactly(cancellationOneTime, cancellationRecurring);
|
.containsExactly(cancellationOneTime, cancellationRecurring);
|
||||||
assertThat(ofy().load().type(BillingEvent.Modification.class).ancestor(domain).list())
|
assertThat(auditedOfy().load().type(BillingEvent.Modification.class).ancestor(domain).list())
|
||||||
.containsExactly(modification);
|
.containsExactly(modification);
|
||||||
assertThat(ofy().load().type(BillingEvent.OneTime.class).ancestor(domainHistory).list())
|
assertThat(auditedOfy().load().type(BillingEvent.OneTime.class).ancestor(domainHistory).list())
|
||||||
.containsExactly(oneTime, oneTimeSynthetic);
|
.containsExactly(oneTime, oneTimeSynthetic);
|
||||||
assertThat(ofy().load().type(BillingEvent.Recurring.class).ancestor(domainHistory).list())
|
assertThat(
|
||||||
|
auditedOfy().load().type(BillingEvent.Recurring.class).ancestor(domainHistory).list())
|
||||||
.containsExactly(recurring);
|
.containsExactly(recurring);
|
||||||
assertThat(ofy().load().type(BillingEvent.Cancellation.class).ancestor(domainHistory2).list())
|
assertThat(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.type(BillingEvent.Cancellation.class)
|
||||||
|
.ancestor(domainHistory2)
|
||||||
|
.list())
|
||||||
.containsExactly(cancellationOneTime, cancellationRecurring);
|
.containsExactly(cancellationOneTime, cancellationRecurring);
|
||||||
assertThat(ofy().load().type(BillingEvent.Modification.class).ancestor(domainHistory2).list())
|
assertThat(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.type(BillingEvent.Modification.class)
|
||||||
|
.ancestor(domainHistory2)
|
||||||
|
.list())
|
||||||
.containsExactly(modification);
|
.containsExactly(modification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.model.common;
|
package google.registry.model.common;
|
||||||
|
|
||||||
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.persistence.transaction.TransactionManagerFactory.ofyTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
|
@ -32,7 +32,7 @@ public class GaeUserIdConverterTest {
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void verifyNoLingeringEntities() {
|
void verifyNoLingeringEntities() {
|
||||||
assertThat(ofy().load().type(GaeUserIdConverter.class).count()).isEqualTo(0);
|
assertThat(ofyTm().loadAllOf(GaeUserIdConverter.class)).hasSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -43,8 +43,7 @@ public class GaeUserIdConverterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSuccess_inTransaction() {
|
void testSuccess_inTransaction() {
|
||||||
tm()
|
tm().transactNew(
|
||||||
.transactNew(
|
|
||||||
() ->
|
() ->
|
||||||
assertThat(GaeUserIdConverter.convertEmailAddressToGaeUserId("example@example.com"))
|
assertThat(GaeUserIdConverter.convertEmailAddressToGaeUserId("example@example.com"))
|
||||||
.matches("[0-9]+"));
|
.matches("[0-9]+"));
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.model.ofy;
|
package google.registry.model.ofy;
|
||||||
|
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
|
|
||||||
|
@ -86,6 +86,6 @@ public class CommitLogMutationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Entity convertToEntityInTxn(final ImmutableObject object) {
|
private static Entity convertToEntityInTxn(final ImmutableObject object) {
|
||||||
return tm().transact(() -> ofy().save().toEntity(object));
|
return tm().transact(() -> auditedOfy().save().toEntity(object));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.appengine.api.datastore.EntityTranslator.convertToPb;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
@ -61,94 +61,96 @@ public class OfyCommitLogTest {
|
||||||
@Test
|
@Test
|
||||||
void testTransact_doesNothing_noCommitLogIsSaved() {
|
void testTransact_doesNothing_noCommitLogIsSaved() {
|
||||||
tm().transact(() -> {});
|
tm().transact(() -> {});
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogManifest.class)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransact_savesDataAndCommitLog() {
|
void testTransact_savesDataAndCommitLog() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())).now());
|
||||||
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
|
assertThat(auditedOfy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
|
||||||
.isEqualTo("value");
|
.isEqualTo("value");
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class)).hasSize(1);
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class)).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogMutation.class)).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransact_saveWithoutBackup_noCommitLogIsSaved() {
|
void testTransact_saveWithoutBackup_noCommitLogIsSaved() {
|
||||||
tm().transact(() -> ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
|
tm().transact(
|
||||||
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
|
() -> auditedOfy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
|
||||||
|
assertThat(auditedOfy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
|
||||||
.isEqualTo("value");
|
.isEqualTo("value");
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogManifest.class)).isEmpty();
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class)).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogMutation.class)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransact_deleteWithoutBackup_noCommitLogIsSaved() {
|
void testTransact_deleteWithoutBackup_noCommitLogIsSaved() {
|
||||||
tm().transact(() -> ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
|
tm().transact(
|
||||||
tm().transact(() -> ofy().deleteWithoutBackup().key(Key.create(Root.class, 1)));
|
() -> auditedOfy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
|
||||||
assertThat(ofy().load().key(Key.create(Root.class, 1)).now()).isNull();
|
tm().transact(() -> auditedOfy().deleteWithoutBackup().key(Key.create(Root.class, 1)));
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class)).isEmpty();
|
assertThat(auditedOfy().load().key(Key.create(Root.class, 1)).now()).isNull();
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class)).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogManifest.class)).isEmpty();
|
||||||
|
assertThat(auditedOfy().load().type(CommitLogMutation.class)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransact_savesEntity_itsProtobufFormIsStoredInCommitLog() {
|
void testTransact_savesEntity_itsProtobufFormIsStoredInCommitLog() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())).now());
|
||||||
final byte[] entityProtoBytes =
|
final byte[] entityProtoBytes =
|
||||||
ofy().load().type(CommitLogMutation.class).first().now().entityProtoBytes;
|
auditedOfy().load().type(CommitLogMutation.class).first().now().entityProtoBytes;
|
||||||
// This transaction is needed so that save().toEntity() can access ofy().getTransactionTime()
|
// This transaction is needed so that save().toEntity() can access
|
||||||
|
// auditedOfy().getTransactionTime()
|
||||||
// when it attempts to set the update timestamp.
|
// when it attempts to set the update timestamp.
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() ->
|
() ->
|
||||||
assertThat(entityProtoBytes)
|
assertThat(entityProtoBytes)
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
convertToPb(ofy().save().toEntity(Root.create(1, getCrossTldKey())))
|
convertToPb(auditedOfy().save().toEntity(Root.create(1, getCrossTldKey())))
|
||||||
.toByteArray()));
|
.toByteArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransact_savesEntity_mutationIsChildOfManifest() {
|
void testTransact_savesEntity_mutationIsChildOfManifest() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())).now());
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(CommitLogMutation.class)
|
.type(CommitLogMutation.class)
|
||||||
.ancestor(ofy().load().type(CommitLogManifest.class).first().now()))
|
.ancestor(auditedOfy().load().type(CommitLogManifest.class).first().now()))
|
||||||
.hasSize(1);
|
.hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransactNew_savesDataAndCommitLog() {
|
void testTransactNew_savesDataAndCommitLog() {
|
||||||
tm().transactNew(() -> ofy().save().entity(Root.create(1, getCrossTldKey())).now());
|
tm().transactNew(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())).now());
|
||||||
assertThat(ofy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
|
assertThat(auditedOfy().load().key(Key.create(getCrossTldKey(), Root.class, 1)).now().value)
|
||||||
.isEqualTo("value");
|
.isEqualTo("value");
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class)).hasSize(1);
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class)).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogMutation.class)).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransact_multipleSaves_logsMultipleMutations() {
|
void testTransact_multipleSaves_logsMultipleMutations() {
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(Root.create(1, getCrossTldKey())).now();
|
auditedOfy().save().entity(Root.create(1, getCrossTldKey())).now();
|
||||||
ofy().save().entity(Root.create(2, getCrossTldKey())).now();
|
auditedOfy().save().entity(Root.create(2, getCrossTldKey())).now();
|
||||||
});
|
});
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class)).hasSize(1);
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class)).hasSize(2);
|
assertThat(auditedOfy().load().type(CommitLogMutation.class)).hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTransact_deletion_deletesAndLogsWithoutMutation() {
|
void testTransact_deletion_deletesAndLogsWithoutMutation() {
|
||||||
tm().transact(() -> ofy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
|
tm().transact(
|
||||||
|
() -> auditedOfy().saveWithoutBackup().entity(Root.create(1, getCrossTldKey())).now());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
final Key<Root> otherTldKey = Key.create(getCrossTldKey(), Root.class, 1);
|
final Key<Root> otherTldKey = Key.create(getCrossTldKey(), Root.class, 1);
|
||||||
tm().transact(() -> ofy().delete().key(otherTldKey));
|
tm().transact(() -> auditedOfy().delete().key(otherTldKey));
|
||||||
assertThat(ofy().load().key(otherTldKey).now()).isNull();
|
assertThat(auditedOfy().load().key(otherTldKey).now()).isNull();
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class)).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class)).hasSize(1);
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class)).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogMutation.class)).isEmpty();
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).first().now().getDeletions())
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).first().now().getDeletions())
|
||||||
.containsExactly(otherTldKey);
|
.containsExactly(otherTldKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +161,7 @@ public class OfyCommitLogTest {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> tm().transactNew(() -> ofy().delete().entity(backupsArentAllowedOnMe)));
|
() -> tm().transactNew(() -> auditedOfy().delete().entity(backupsArentAllowedOnMe)));
|
||||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @NotBackedUp");
|
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @NotBackedUp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +172,7 @@ public class OfyCommitLogTest {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> tm().transactNew(() -> ofy().save().entity(backupsArentAllowedOnMe)));
|
() -> tm().transactNew(() -> auditedOfy().save().entity(backupsArentAllowedOnMe)));
|
||||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @NotBackedUp");
|
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @NotBackedUp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +182,7 @@ public class OfyCommitLogTest {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> tm().transactNew(() -> ofy().delete().key(virtualEntityKey)));
|
() -> tm().transactNew(() -> auditedOfy().delete().key(virtualEntityKey)));
|
||||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +192,7 @@ public class OfyCommitLogTest {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> tm().transactNew(() -> ofy().save().entity(virtualEntity)));
|
() -> tm().transactNew(() -> auditedOfy().save().entity(virtualEntity)));
|
||||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +202,7 @@ public class OfyCommitLogTest {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> ofy().deleteWithoutBackup().key(virtualEntityKey));
|
() -> auditedOfy().deleteWithoutBackup().key(virtualEntityKey));
|
||||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +211,8 @@ public class OfyCommitLogTest {
|
||||||
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
|
final TestVirtualObject virtualEntity = TestVirtualObject.create("virtual");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class, () -> ofy().saveWithoutBackup().entity(virtualEntity));
|
IllegalArgumentException.class,
|
||||||
|
() -> auditedOfy().saveWithoutBackup().entity(virtualEntity));
|
||||||
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
assertThat(thrown).hasMessageThat().contains("Can't save/delete a @VirtualEntity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,11 +222,10 @@ public class OfyCommitLogTest {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(Root.create(1, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(1, getCrossTldKey()));
|
||||||
ofy().save().entity(Root.create(1, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(1, getCrossTldKey()));
|
||||||
}));
|
}));
|
||||||
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
||||||
}
|
}
|
||||||
|
@ -234,21 +236,20 @@ public class OfyCommitLogTest {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(Root.create(1, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(1, getCrossTldKey()));
|
||||||
ofy().delete().entity(Root.create(1, getCrossTldKey()));
|
auditedOfy().delete().entity(Root.create(1, getCrossTldKey()));
|
||||||
}));
|
}));
|
||||||
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSavingRootAndChild_updatesTimestampOnBackupGroupRoot() {
|
void testSavingRootAndChild_updatesTimestampOnBackupGroupRoot() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -256,15 +257,14 @@ public class OfyCommitLogTest {
|
||||||
.getTimestamp())
|
.getTimestamp())
|
||||||
.isEqualTo(clock.nowUtc());
|
.isEqualTo(clock.nowUtc());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(Root.create(1, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(1, getCrossTldKey()));
|
||||||
ofy().save().entity(new Child());
|
auditedOfy().save().entity(new Child());
|
||||||
});
|
});
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -275,10 +275,10 @@ public class OfyCommitLogTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSavingOnlyChild_updatesTimestampOnBackupGroupRoot() {
|
void testSavingOnlyChild_updatesTimestampOnBackupGroupRoot() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -286,10 +286,10 @@ public class OfyCommitLogTest {
|
||||||
.getTimestamp())
|
.getTimestamp())
|
||||||
.isEqualTo(clock.nowUtc());
|
.isEqualTo(clock.nowUtc());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
tm().transact(() -> ofy().save().entity(new Child()));
|
tm().transact(() -> auditedOfy().save().entity(new Child()));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -300,10 +300,10 @@ public class OfyCommitLogTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDeletingChild_updatesTimestampOnBackupGroupRoot() {
|
void testDeletingChild_updatesTimestampOnBackupGroupRoot() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -312,10 +312,10 @@ public class OfyCommitLogTest {
|
||||||
.isEqualTo(clock.nowUtc());
|
.isEqualTo(clock.nowUtc());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
// The fact that the child was never persisted is irrelevant.
|
// The fact that the child was never persisted is irrelevant.
|
||||||
tm().transact(() -> ofy().delete().entity(new Child()));
|
tm().transact(() -> auditedOfy().delete().entity(new Child()));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -326,10 +326,10 @@ public class OfyCommitLogTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testReadingRoot_doesntUpdateTimestamp() {
|
void testReadingRoot_doesntUpdateTimestamp() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -337,17 +337,16 @@ public class OfyCommitLogTest {
|
||||||
.getTimestamp())
|
.getTimestamp())
|
||||||
.isEqualTo(clock.nowUtc());
|
.isEqualTo(clock.nowUtc());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
// Don't remove this line, as without saving *something* the commit log code will
|
// Don't remove this line, as without saving *something* the commit log code will
|
||||||
// never be invoked and the test will trivially pass.
|
// never be invoked and the test will trivially pass.
|
||||||
ofy().save().entity(Root.create(2, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(2, getCrossTldKey()));
|
||||||
ofy().load().entity(Root.create(1, getCrossTldKey()));
|
auditedOfy().load().entity(Root.create(1, getCrossTldKey()));
|
||||||
});
|
});
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -358,10 +357,10 @@ public class OfyCommitLogTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testReadingChild_doesntUpdateTimestampOnBackupGroupRoot() {
|
void testReadingChild_doesntUpdateTimestampOnBackupGroupRoot() {
|
||||||
tm().transact(() -> ofy().save().entity(Root.create(1, getCrossTldKey())));
|
tm().transact(() -> auditedOfy().save().entity(Root.create(1, getCrossTldKey())));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -369,17 +368,16 @@ public class OfyCommitLogTest {
|
||||||
.getTimestamp())
|
.getTimestamp())
|
||||||
.isEqualTo(clock.nowUtc());
|
.isEqualTo(clock.nowUtc());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
// Don't remove this line, as without saving *something* the commit log code will
|
// Don't remove this line, as without saving *something* the commit log code will
|
||||||
// never be invoked and the test will trivially pass
|
// never be invoked and the test will trivially pass
|
||||||
ofy().save().entity(Root.create(2, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(2, getCrossTldKey()));
|
||||||
ofy().load().entity(new Child()); // All Child objects are under Root(1).
|
auditedOfy().load().entity(new Child()); // All Child objects are under Root(1).
|
||||||
});
|
});
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -391,17 +389,16 @@ public class OfyCommitLogTest {
|
||||||
@Test
|
@Test
|
||||||
void testSavingAcrossBackupGroupRoots_updatesCorrectTimestamps() {
|
void testSavingAcrossBackupGroupRoots_updatesCorrectTimestamps() {
|
||||||
// Create three roots.
|
// Create three roots.
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(Root.create(1, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(1, getCrossTldKey()));
|
||||||
ofy().save().entity(Root.create(2, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(2, getCrossTldKey()));
|
||||||
ofy().save().entity(Root.create(3, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(3, getCrossTldKey()));
|
||||||
});
|
});
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i <= 3; i++) {
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, i))
|
.key(Key.create(getCrossTldKey(), Root.class, i))
|
||||||
.now()
|
.now()
|
||||||
|
@ -411,16 +408,15 @@ public class OfyCommitLogTest {
|
||||||
}
|
}
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
// Mutate one root, and a child of a second, ignoring the third.
|
// Mutate one root, and a child of a second, ignoring the third.
|
||||||
tm()
|
tm().transact(
|
||||||
.transact(
|
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(new Child()); // All Child objects are under Root(1).
|
auditedOfy().save().entity(new Child()); // All Child objects are under Root(1).
|
||||||
ofy().save().entity(Root.create(2, getCrossTldKey()));
|
auditedOfy().save().entity(Root.create(2, getCrossTldKey()));
|
||||||
});
|
});
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
// Child was touched.
|
// Child was touched.
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
.key(Key.create(getCrossTldKey(), Root.class, 1))
|
||||||
.now()
|
.now()
|
||||||
|
@ -429,7 +425,7 @@ public class OfyCommitLogTest {
|
||||||
.isEqualTo(clock.nowUtc());
|
.isEqualTo(clock.nowUtc());
|
||||||
// Directly touched.
|
// Directly touched.
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 2))
|
.key(Key.create(getCrossTldKey(), Root.class, 2))
|
||||||
.now()
|
.now()
|
||||||
|
@ -438,7 +434,7 @@ public class OfyCommitLogTest {
|
||||||
.isEqualTo(clock.nowUtc());
|
.isEqualTo(clock.nowUtc());
|
||||||
// Wasn't touched.
|
// Wasn't touched.
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Key.create(getCrossTldKey(), Root.class, 3))
|
.key(Key.create(getCrossTldKey(), Root.class, 3))
|
||||||
.now()
|
.now()
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.appengine.api.datastore.DatastoreServiceFactory.getData
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
|
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
|
||||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.ofy.Ofy.getBaseEntityClassFromEntityOrKey;
|
import static google.registry.model.ofy.Ofy.getBaseEntityClassFromEntityOrKey;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
|
@ -82,7 +82,7 @@ public class OfyTest {
|
||||||
|
|
||||||
private void doBackupGroupRootTimestampInversionTest(Runnable runnable) {
|
private void doBackupGroupRootTimestampInversionTest(Runnable runnable) {
|
||||||
DateTime groupTimestamp =
|
DateTime groupTimestamp =
|
||||||
ofy().load().key(someObject.getParent()).now().getUpdateTimestamp().getTimestamp();
|
auditedOfy().load().key(someObject.getParent()).now().getUpdateTimestamp().getTimestamp();
|
||||||
// Set the clock in Ofy to the same time as the backup group root's save time.
|
// Set the clock in Ofy to the same time as the backup group root's save time.
|
||||||
Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
|
Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
|
||||||
TimestampInversionException thrown =
|
TimestampInversionException thrown =
|
||||||
|
@ -98,12 +98,12 @@ public class OfyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testBackupGroupRootTimestampsMustIncreaseOnSave() {
|
void testBackupGroupRootTimestampsMustIncreaseOnSave() {
|
||||||
doBackupGroupRootTimestampInversionTest(() -> ofy().save().entity(someObject));
|
doBackupGroupRootTimestampInversionTest(() -> auditedOfy().save().entity(someObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testBackupGroupRootTimestampsMustIncreaseOnDelete() {
|
void testBackupGroupRootTimestampsMustIncreaseOnDelete() {
|
||||||
doBackupGroupRootTimestampInversionTest(() -> ofy().delete().entity(someObject));
|
doBackupGroupRootTimestampInversionTest(() -> auditedOfy().delete().entity(someObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -114,8 +114,8 @@ public class OfyTest {
|
||||||
() ->
|
() ->
|
||||||
tm().transact(
|
tm().transact(
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(someObject);
|
auditedOfy().save().entity(someObject);
|
||||||
ofy().save().entity(someObject);
|
auditedOfy().save().entity(someObject);
|
||||||
}));
|
}));
|
||||||
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,8 @@ public class OfyTest {
|
||||||
() ->
|
() ->
|
||||||
tm().transact(
|
tm().transact(
|
||||||
() -> {
|
() -> {
|
||||||
ofy().delete().entity(someObject);
|
auditedOfy().delete().entity(someObject);
|
||||||
ofy().delete().entity(someObject);
|
auditedOfy().delete().entity(someObject);
|
||||||
}));
|
}));
|
||||||
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
||||||
}
|
}
|
||||||
|
@ -142,8 +142,8 @@ public class OfyTest {
|
||||||
() ->
|
() ->
|
||||||
tm().transact(
|
tm().transact(
|
||||||
() -> {
|
() -> {
|
||||||
ofy().save().entity(someObject);
|
auditedOfy().save().entity(someObject);
|
||||||
ofy().delete().entity(someObject);
|
auditedOfy().delete().entity(someObject);
|
||||||
}));
|
}));
|
||||||
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
||||||
}
|
}
|
||||||
|
@ -156,8 +156,8 @@ public class OfyTest {
|
||||||
() ->
|
() ->
|
||||||
tm().transact(
|
tm().transact(
|
||||||
() -> {
|
() -> {
|
||||||
ofy().delete().entity(someObject);
|
auditedOfy().delete().entity(someObject);
|
||||||
ofy().save().entity(someObject);
|
auditedOfy().save().entity(someObject);
|
||||||
}));
|
}));
|
||||||
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
assertThat(thrown).hasMessageThat().contains("Multiple entries with same key");
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ public class OfyTest {
|
||||||
void testSavingKeyTwiceInOneCall() {
|
void testSavingKeyTwiceInOneCall() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> tm().transact(() -> ofy().save().entities(someObject, someObject)));
|
() -> tm().transact(() -> auditedOfy().save().entities(someObject, someObject)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Simple entity class with lifecycle callbacks. */
|
/** Simple entity class with lifecycle callbacks. */
|
||||||
|
@ -194,21 +194,21 @@ public class OfyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLifecycleCallbacks_loadFromEntity() {
|
void testLifecycleCallbacks_loadFromEntity() {
|
||||||
ofy().factory().register(LifecycleObject.class);
|
auditedOfy().factory().register(LifecycleObject.class);
|
||||||
LifecycleObject object = new LifecycleObject();
|
LifecycleObject object = new LifecycleObject();
|
||||||
Entity entity = ofy().save().toEntity(object);
|
Entity entity = auditedOfy().save().toEntity(object);
|
||||||
assertThat(object.onSaveCalled).isTrue();
|
assertThat(object.onSaveCalled).isTrue();
|
||||||
assertThat(ofy().load().<LifecycleObject>fromEntity(entity).onLoadCalled).isTrue();
|
assertThat(auditedOfy().load().<LifecycleObject>fromEntity(entity).onLoadCalled).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLifecycleCallbacks_loadFromDatastore() {
|
void testLifecycleCallbacks_loadFromDatastore() {
|
||||||
ofy().factory().register(LifecycleObject.class);
|
auditedOfy().factory().register(LifecycleObject.class);
|
||||||
final LifecycleObject object = new LifecycleObject();
|
final LifecycleObject object = new LifecycleObject();
|
||||||
tm().transact(() -> ofy().save().entity(object).now());
|
tm().transact(() -> auditedOfy().save().entity(object).now());
|
||||||
assertThat(object.onSaveCalled).isTrue();
|
assertThat(object.onSaveCalled).isTrue();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(ofy().load().entity(object).now().onLoadCalled).isTrue();
|
assertThat(auditedOfy().load().entity(object).now().onLoadCalled).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Avoid regressions of b/21309102 where transaction time did not change on each retry. */
|
/** Avoid regressions of b/21309102 where transaction time did not change on each retry. */
|
||||||
|
@ -287,7 +287,7 @@ public class OfyTest {
|
||||||
public Integer get() {
|
public Integer get() {
|
||||||
// There will be something in the manifest now, but it won't be committed if
|
// There will be something in the manifest now, but it won't be committed if
|
||||||
// we throw.
|
// we throw.
|
||||||
ofy().save().entity(someObject);
|
auditedOfy().save().entity(someObject);
|
||||||
count++;
|
count++;
|
||||||
if (count == 3) {
|
if (count == 3) {
|
||||||
return count;
|
return count;
|
||||||
|
@ -309,7 +309,7 @@ public class OfyTest {
|
||||||
public Void get() {
|
public Void get() {
|
||||||
if (firstCallToVrun) {
|
if (firstCallToVrun) {
|
||||||
firstCallToVrun = false;
|
firstCallToVrun = false;
|
||||||
ofy().save().entity(someObject);
|
auditedOfy().save().entity(someObject);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
fail("Shouldn't have retried.");
|
fail("Shouldn't have retried.");
|
||||||
|
@ -332,7 +332,7 @@ public class OfyTest {
|
||||||
};
|
};
|
||||||
// Despite the DatastoreTimeoutException in the first call to getResult(), this should succeed
|
// Despite the DatastoreTimeoutException in the first call to getResult(), this should succeed
|
||||||
// without retrying. If a retry is triggered, the test should fail due to the call to fail().
|
// without retrying. If a retry is triggered, the test should fail due to the call to fail().
|
||||||
ofy().transactCommitLoggedWork(commitLoggedWork);
|
auditedOfy().transactCommitLoggedWork(commitLoggedWork);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doReadOnlyRetryTest(final RuntimeException e) {
|
void doReadOnlyRetryTest(final RuntimeException e) {
|
||||||
|
@ -408,23 +408,24 @@ public class OfyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_doWithFreshSessionCache() {
|
void test_doWithFreshSessionCache() {
|
||||||
ofy().saveWithoutBackup().entity(someObject).now();
|
auditedOfy().saveWithoutBackup().entity(someObject).now();
|
||||||
final HistoryEntry modifiedObject =
|
final HistoryEntry modifiedObject =
|
||||||
someObject.asBuilder().setModificationTime(END_OF_TIME).build();
|
someObject.asBuilder().setModificationTime(END_OF_TIME).build();
|
||||||
// Mutate the saved objected, bypassing the Objectify session cache.
|
// Mutate the saved objected, bypassing the Objectify session cache.
|
||||||
getDatastoreService().put(ofy().saveWithoutBackup().toEntity(modifiedObject));
|
getDatastoreService().put(auditedOfy().saveWithoutBackup().toEntity(modifiedObject));
|
||||||
// Normal loading should come from the session cache and shouldn't reflect the mutation.
|
// Normal loading should come from the session cache and shouldn't reflect the mutation.
|
||||||
assertThat(ofy().load().entity(someObject).now()).isEqualTo(someObject);
|
assertThat(auditedOfy().load().entity(someObject).now()).isEqualTo(someObject);
|
||||||
// Loading inside doWithFreshSessionCache() should reflect the mutation.
|
// Loading inside doWithFreshSessionCache() should reflect the mutation.
|
||||||
boolean ran =
|
boolean ran =
|
||||||
ofy()
|
auditedOfy()
|
||||||
.doWithFreshSessionCache(
|
.doWithFreshSessionCache(
|
||||||
() -> {
|
() -> {
|
||||||
assertThat(ofy().load().entity(someObject).now()).isEqualTo(modifiedObject);
|
assertThat(auditedOfy().load().entity(someObject).now())
|
||||||
|
.isEqualTo(modifiedObject);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
assertThat(ran).isTrue();
|
assertThat(ran).isTrue();
|
||||||
// Test the normal loading again to verify that we've restored the original session unchanged.
|
// Test the normal loading again to verify that we've restored the original session unchanged.
|
||||||
assertThat(ofy().load().entity(someObject).now()).isEqualTo(someObject);
|
assertThat(auditedOfy().load().entity(someObject).now()).isEqualTo(someObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.model.registrar;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.testing.CertificateSamples.SAMPLE_CERT;
|
import static google.registry.testing.CertificateSamples.SAMPLE_CERT;
|
||||||
import static google.registry.testing.CertificateSamples.SAMPLE_CERT2;
|
import static google.registry.testing.CertificateSamples.SAMPLE_CERT2;
|
||||||
|
@ -569,14 +569,14 @@ class RegistrarTest extends EntityTestCase {
|
||||||
assertThat(Registrar.loadByClientIdCached("registrar")).isPresent();
|
assertThat(Registrar.loadByClientIdCached("registrar")).isPresent();
|
||||||
// Load something as a control to make sure we are seeing loaded keys in the
|
// Load something as a control to make sure we are seeing loaded keys in the
|
||||||
// session cache.
|
// session cache.
|
||||||
ofy().load().entity(abuseAdminContact).now();
|
auditedOfy().load().entity(abuseAdminContact).now();
|
||||||
assertThat(ofy().getSessionKeys()).contains(Key.create(abuseAdminContact));
|
assertThat(auditedOfy().getSessionKeys()).contains(Key.create(abuseAdminContact));
|
||||||
assertThat(ofy().getSessionKeys()).doesNotContain(Key.create(registrar));
|
assertThat(auditedOfy().getSessionKeys()).doesNotContain(Key.create(registrar));
|
||||||
});
|
});
|
||||||
tm().clearSessionCache();
|
tm().clearSessionCache();
|
||||||
// Conversely, loads outside of a transaction should end up in the session cache.
|
// Conversely, loads outside of a transaction should end up in the session cache.
|
||||||
assertThat(Registrar.loadByClientIdCached("registrar")).isPresent();
|
assertThat(Registrar.loadByClientIdCached("registrar")).isPresent();
|
||||||
assertThat(ofy().getSessionKeys()).contains(Key.create(registrar));
|
assertThat(auditedOfy().getSessionKeys()).contains(Key.create(registrar));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOfyAndSql
|
@TestOfyAndSql
|
||||||
|
|
|
@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static com.google.monitoring.metrics.contrib.DistributionMetricSubject.assertThat;
|
import static com.google.monitoring.metrics.contrib.DistributionMetricSubject.assertThat;
|
||||||
import static com.google.monitoring.metrics.contrib.LongMetricSubject.assertThat;
|
import static com.google.monitoring.metrics.contrib.LongMetricSubject.assertThat;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.BLOOM_FILTER_NEGATIVE;
|
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.BLOOM_FILTER_NEGATIVE;
|
||||||
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_NEGATIVE;
|
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_NEGATIVE;
|
||||||
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_POSITIVE;
|
import static google.registry.model.registry.label.DomainLabelMetrics.PremiumListCheckOutcome.CACHED_POSITIVE;
|
||||||
|
@ -173,10 +173,10 @@ public class PremiumListDatastoreDaoTest {
|
||||||
// Remove one of the premium list entries from behind the Bloom filter's back.
|
// Remove one of the premium list entries from behind the Bloom filter's back.
|
||||||
tm().transactNew(
|
tm().transactNew(
|
||||||
() ->
|
() ->
|
||||||
ofy()
|
auditedOfy()
|
||||||
.delete()
|
.delete()
|
||||||
.keys(Key.create(pl.getRevisionKey(), PremiumListEntry.class, "rich")));
|
.keys(Key.create(pl.getRevisionKey(), PremiumListEntry.class, "rich")));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
|
|
||||||
assertThat(PremiumListDatastoreDao.getPremiumPrice("tld", "rich", "tld")).isEmpty();
|
assertThat(PremiumListDatastoreDao.getPremiumPrice("tld", "rich", "tld")).isEmpty();
|
||||||
assertThat(PremiumListDatastoreDao.getPremiumPrice("tld", "rich", "tld")).isEmpty();
|
assertThat(PremiumListDatastoreDao.getPremiumPrice("tld", "rich", "tld")).isEmpty();
|
||||||
|
@ -203,7 +203,7 @@ public class PremiumListDatastoreDaoTest {
|
||||||
assertThat(PremiumListDatastoreDao.getPremiumPrice("tld", "dolt", "tld"))
|
assertThat(PremiumListDatastoreDao.getPremiumPrice("tld", "dolt", "tld"))
|
||||||
.hasValue(Money.parse("JPY 1000"));
|
.hasValue(Money.parse("JPY 1000"));
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(PremiumListEntry.class)
|
.type(PremiumListEntry.class)
|
||||||
.parent(pl.getRevisionKey())
|
.parent(pl.getRevisionKey())
|
||||||
|
@ -279,7 +279,7 @@ public class PremiumListDatastoreDaoTest {
|
||||||
assertThat(entries.keySet()).containsExactly("test");
|
assertThat(entries.keySet()).containsExactly("test");
|
||||||
// Save again with no changes, and clear the cache to force a re-load from Datastore.
|
// Save again with no changes, and clear the cache to force a re-load from Datastore.
|
||||||
PremiumList resaved = PremiumListDatastoreDao.save("tld", ImmutableList.of("test,USD 1"));
|
PremiumList resaved = PremiumListDatastoreDao.save("tld", ImmutableList.of("test,USD 1"));
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
Map<String, PremiumListEntry> entriesReloaded =
|
Map<String, PremiumListEntry> entriesReloaded =
|
||||||
Streams.stream(PremiumListDatastoreDao.loadPremiumListEntriesUncached(resaved))
|
Streams.stream(PremiumListDatastoreDao.loadPremiumListEntriesUncached(resaved))
|
||||||
.collect(toImmutableMap(PremiumListEntry::getLabel, Function.identity()));
|
.collect(toImmutableMap(PremiumListEntry::getLabel, Function.identity()));
|
||||||
|
@ -296,7 +296,7 @@ public class PremiumListDatastoreDaoTest {
|
||||||
Key<PremiumListRevision> parent = gtld1.get().getRevisionKey();
|
Key<PremiumListRevision> parent = gtld1.get().getRevisionKey();
|
||||||
PremiumListDatastoreDao.delete(gtld1.get());
|
PremiumListDatastoreDao.delete(gtld1.get());
|
||||||
assertThat(PremiumListDatastoreDao.getLatestRevision("gtld1")).isEmpty();
|
assertThat(PremiumListDatastoreDao.getLatestRevision("gtld1")).isEmpty();
|
||||||
assertThat(ofy().load().type(PremiumListEntry.class).ancestor(parent).list()).isEmpty();
|
assertThat(auditedOfy().load().type(PremiumListEntry.class).ancestor(parent).list()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model.tmch;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
@ -54,7 +54,7 @@ public class ClaimsListShardTest {
|
||||||
tm().getTransactionTime(), ImmutableMap.of("a", "b"));
|
tm().getTransactionTime(), ImmutableMap.of("a", "b"));
|
||||||
claimsList.id = 1; // Without an id this won't save anyways.
|
claimsList.id = 1; // Without an id this won't save anyways.
|
||||||
claimsList.parent = ClaimsListRevision.createKey();
|
claimsList.parent = ClaimsListRevision.createKey();
|
||||||
ofy().saveWithoutBackup().entity(claimsList).now();
|
auditedOfy().saveWithoutBackup().entity(claimsList).now();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class ClaimsListShardTest {
|
||||||
unsharded.saveToDatastore(shardSize);
|
unsharded.saveToDatastore(shardSize);
|
||||||
assertThat(ClaimsListShard.getFromDatastore().get().labelsToKeys)
|
assertThat(ClaimsListShard.getFromDatastore().get().labelsToKeys)
|
||||||
.isEqualTo(unsharded.labelsToKeys);
|
.isEqualTo(unsharded.labelsToKeys);
|
||||||
List<ClaimsListShard> shards1 = ofy().load().type(ClaimsListShard.class).list();
|
List<ClaimsListShard> shards1 = auditedOfy().load().type(ClaimsListShard.class).list();
|
||||||
assertThat(shards1).hasSize(4);
|
assertThat(shards1).hasSize(4);
|
||||||
assertThat(ClaimsListShard.getFromDatastore().get().getClaimKey("1")).hasValue("1");
|
assertThat(ClaimsListShard.getFromDatastore().get().getClaimKey("1")).hasValue("1");
|
||||||
assertThat(ClaimsListShard.getFromDatastore().get().getClaimKey("a")).isEmpty();
|
assertThat(ClaimsListShard.getFromDatastore().get().getClaimKey("a")).isEmpty();
|
||||||
|
@ -89,12 +89,12 @@ public class ClaimsListShardTest {
|
||||||
}
|
}
|
||||||
unsharded = ClaimsListShard.create(now.plusDays(1), ImmutableMap.copyOf(labelsToKeys));
|
unsharded = ClaimsListShard.create(now.plusDays(1), ImmutableMap.copyOf(labelsToKeys));
|
||||||
unsharded.saveToDatastore(shardSize);
|
unsharded.saveToDatastore(shardSize);
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(ClaimsListShard.getFromDatastore().get().labelsToKeys)
|
assertThat(ClaimsListShard.getFromDatastore().get().labelsToKeys)
|
||||||
.hasSize(unsharded.labelsToKeys.size());
|
.hasSize(unsharded.labelsToKeys.size());
|
||||||
assertThat(ClaimsListShard.getFromDatastore().get().labelsToKeys)
|
assertThat(ClaimsListShard.getFromDatastore().get().labelsToKeys)
|
||||||
.isEqualTo(unsharded.labelsToKeys);
|
.isEqualTo(unsharded.labelsToKeys);
|
||||||
List<ClaimsListShard> shards2 = ofy().load().type(ClaimsListShard.class).list();
|
List<ClaimsListShard> shards2 = auditedOfy().load().type(ClaimsListShard.class).list();
|
||||||
assertThat(shards2).hasSize(2);
|
assertThat(shards2).hasSize(2);
|
||||||
|
|
||||||
// Expect that the old revision is deleted.
|
// Expect that the old revision is deleted.
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.model.translators;
|
package google.registry.model.translators;
|
||||||
|
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static org.joda.time.Duration.standardDays;
|
import static org.joda.time.Duration.standardDays;
|
||||||
import static org.joda.time.Duration.standardHours;
|
import static org.joda.time.Duration.standardHours;
|
||||||
|
@ -65,12 +65,12 @@ public class CommitLogRevisionsTranslatorFactoryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save(final TestObject object) {
|
private void save(final TestObject object) {
|
||||||
tm().transact(() -> ofy().save().entity(object));
|
tm().transact(() -> auditedOfy().save().entity(object));
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestObject reload() {
|
private TestObject reload() {
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
return ofy().load().entity(new TestObject()).now();
|
return auditedOfy().load().entity(new TestObject()).now();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -87,7 +87,8 @@ public class CommitLogRevisionsTranslatorFactoryTest {
|
||||||
TestObject object = reload();
|
TestObject object = reload();
|
||||||
assertThat(object.revisions).hasSize(1);
|
assertThat(object.revisions).hasSize(1);
|
||||||
assertThat(object.revisions).containsKey(START_TIME);
|
assertThat(object.revisions).containsKey(START_TIME);
|
||||||
CommitLogManifest commitLogManifest = ofy().load().key(object.revisions.get(START_TIME)).now();
|
CommitLogManifest commitLogManifest =
|
||||||
|
auditedOfy().load().key(object.revisions.get(START_TIME)).now();
|
||||||
assertThat(commitLogManifest.getCommitTime()).isEqualTo(START_TIME);
|
assertThat(commitLogManifest.getCommitTime()).isEqualTo(START_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ public class CommitLogRevisionsTranslatorFactoryTest {
|
||||||
save(new TestObject());
|
save(new TestObject());
|
||||||
clock.advanceBy(standardDays(1));
|
clock.advanceBy(standardDays(1));
|
||||||
com.google.appengine.api.datastore.Entity entity =
|
com.google.appengine.api.datastore.Entity entity =
|
||||||
tm().transactNewReadOnly(() -> ofy().save().toEntity(reload()));
|
tm().transactNewReadOnly(() -> auditedOfy().save().toEntity(reload()));
|
||||||
assertThat(entity.getProperties().keySet()).containsExactly("revisions.key", "revisions.value");
|
assertThat(entity.getProperties().keySet()).containsExactly("revisions.key", "revisions.value");
|
||||||
assertThat(entity.getProperties())
|
assertThat(entity.getProperties())
|
||||||
.containsEntry(
|
.containsEntry(
|
||||||
|
@ -162,16 +163,16 @@ public class CommitLogRevisionsTranslatorFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLoad_neverSaved_returnsNull() {
|
void testLoad_neverSaved_returnsNull() {
|
||||||
assertThat(ofy().load().entity(new TestObject()).now()).isNull();
|
assertThat(auditedOfy().load().entity(new TestObject()).now()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLoad_missingRevisionRawProperties_createsEmptyObject() {
|
void testLoad_missingRevisionRawProperties_createsEmptyObject() {
|
||||||
com.google.appengine.api.datastore.Entity entity =
|
com.google.appengine.api.datastore.Entity entity =
|
||||||
tm().transactNewReadOnly(() -> ofy().save().toEntity(new TestObject()));
|
tm().transactNewReadOnly(() -> auditedOfy().save().toEntity(new TestObject()));
|
||||||
entity.removeProperty("revisions.key");
|
entity.removeProperty("revisions.key");
|
||||||
entity.removeProperty("revisions.value");
|
entity.removeProperty("revisions.value");
|
||||||
TestObject object = ofy().load().fromEntity(entity);
|
TestObject object = auditedOfy().load().fromEntity(entity);
|
||||||
assertThat(object.revisions).isNotNull();
|
assertThat(object.revisions).isNotNull();
|
||||||
assertThat(object.revisions).isEmpty();
|
assertThat(object.revisions).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
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.BRDA;
|
||||||
import static google.registry.model.common.Cursor.CursorType.RDE_STAGING;
|
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.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.rde.RdeFixtures.makeContactResource;
|
import static google.registry.rde.RdeFixtures.makeContactResource;
|
||||||
import static google.registry.rde.RdeFixtures.makeDomainBase;
|
import static google.registry.rde.RdeFixtures.makeDomainBase;
|
||||||
|
@ -421,13 +421,18 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
action.run();
|
action.run();
|
||||||
executeTasksUntilEmpty("mapreduce", clock);
|
executeTasksUntilEmpty("mapreduce", clock);
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
.now()
|
.now()
|
||||||
.getCursorTime())
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("2000-01-02TZ"));
|
.isEqualTo(DateTime.parse("2000-01-02TZ"));
|
||||||
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("lol"))).now().getCursorTime())
|
assertThat(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(BRDA, Registry.get("lol")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("2000-01-04TZ"));
|
.isEqualTo(DateTime.parse("2000-01-04TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,13 +447,18 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
action.run();
|
action.run();
|
||||||
executeTasksUntilEmpty("mapreduce", clock);
|
executeTasksUntilEmpty("mapreduce", clock);
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
.now()
|
.now()
|
||||||
.getCursorTime())
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("2000-01-05TZ"));
|
.isEqualTo(DateTime.parse("2000-01-05TZ"));
|
||||||
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("lol"))).now().getCursorTime())
|
assertThat(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(BRDA, Registry.get("lol")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("2000-01-11TZ"));
|
.isEqualTo(DateTime.parse("2000-01-11TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,11 +510,19 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy().load().key(Cursor.createKey(RDE_STAGING, Registry.get("fop"))).now()
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("fop")))
|
||||||
|
.now()
|
||||||
.getCursorTime())
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("1971-01-02TZ"));
|
.isEqualTo(DateTime.parse("1971-01-02TZ"));
|
||||||
|
|
||||||
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get("fop"))).now().getCursorTime())
|
assertThat(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(BRDA, Registry.get("fop")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("1971-01-12TZ"));
|
.isEqualTo(DateTime.parse("1971-01-12TZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,7 +720,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
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(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
.now()
|
.now()
|
||||||
|
@ -719,7 +737,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
assertThat(secondDeposit).doesNotContain("dead:beef::cafe");
|
assertThat(secondDeposit).doesNotContain("dead:beef::cafe");
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
.now()
|
.now()
|
||||||
|
@ -735,7 +753,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
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(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
.key(Cursor.createKey(RDE_STAGING, Registry.get("lol")))
|
||||||
.now()
|
.now()
|
||||||
|
@ -782,13 +800,18 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
||||||
"manual/test/" + tld + "_2000-01-02_thin_S1_R" + revision + ".xml.length");
|
"manual/test/" + tld + "_2000-01-02_thin_S1_R" + revision + ".xml.length");
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
ofy()
|
auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.key(Cursor.createKey(RDE_STAGING, Registry.get(tld)))
|
.key(Cursor.createKey(RDE_STAGING, Registry.get(tld)))
|
||||||
.now()
|
.now()
|
||||||
.getCursorTime())
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("1999-01-01TZ"));
|
.isEqualTo(DateTime.parse("1999-01-01TZ"));
|
||||||
assertThat(ofy().load().key(Cursor.createKey(BRDA, Registry.get(tld))).now().getCursorTime())
|
assertThat(
|
||||||
|
auditedOfy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(BRDA, Registry.get(tld)))
|
||||||
|
.now()
|
||||||
|
.getCursorTime())
|
||||||
.isEqualTo(DateTime.parse("2001-01-01TZ"));
|
.isEqualTo(DateTime.parse("2001-01-01TZ"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
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.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
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.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
@ -215,11 +215,15 @@ class RdeStagingReducerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DateTime loadCursorTime(CursorType type) {
|
private static DateTime loadCursorTime(CursorType type) {
|
||||||
return ofy().load().key(Cursor.createKey(type, Registry.get("soy"))).now().getCursorTime();
|
return auditedOfy()
|
||||||
|
.load()
|
||||||
|
.key(Cursor.createKey(type, Registry.get("soy")))
|
||||||
|
.now()
|
||||||
|
.getCursorTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int loadRevision(RdeMode mode) {
|
private static int loadRevision(RdeMode mode) {
|
||||||
return ofy()
|
return auditedOfy()
|
||||||
.load()
|
.load()
|
||||||
.type(RdeRevision.class)
|
.type(RdeRevision.class)
|
||||||
.id("soy_2000-01-01_" + mode.getFilenameComponent())
|
.id("soy_2000-01-01_" + mode.getFilenameComponent())
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.testing;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.io.Files.asCharSink;
|
import static com.google.common.io.Files.asCharSink;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||||
import static google.registry.testing.DualDatabaseTestInvocationContextProvider.injectTmForDualDatabaseTest;
|
import static google.registry.testing.DualDatabaseTestInvocationContextProvider.injectTmForDualDatabaseTest;
|
||||||
|
@ -410,7 +410,7 @@ public final class AppEngineExtension implements BeforeEachCallback, AfterEachCa
|
||||||
TimedTransitionProperty.fromValueMap(
|
TimedTransitionProperty.fromValueMap(
|
||||||
ImmutableSortedMap.of(START_OF_TIME, PrimaryDatabase.CLOUD_SQL),
|
ImmutableSortedMap.of(START_OF_TIME, PrimaryDatabase.CLOUD_SQL),
|
||||||
PrimaryDatabaseTransition.class));
|
PrimaryDatabaseTransition.class));
|
||||||
tm().transactNew(() -> ofy().saveWithoutBackup().entity(schedule).now());
|
tm().transactNew(() -> auditedOfy().saveWithoutBackup().entity(schedule).now());
|
||||||
if (withCloudSql && !withJpaUnitTest && !withoutCannedData) {
|
if (withCloudSql && !withJpaUnitTest && !withoutCannedData) {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static google.registry.model.EppResourceUtils.createRepoId;
|
||||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||||
import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence;
|
import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence;
|
||||||
import static google.registry.model.ResourceTransferUtils.createTransferResponse;
|
import static google.registry.model.ResourceTransferUtils.createTransferResponse;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
|
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
|
||||||
import static google.registry.model.registry.label.PremiumListDatastoreDao.parentPremiumListEntriesOnRevision;
|
import static google.registry.model.registry.label.PremiumListDatastoreDao.parentPremiumListEntriesOnRevision;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
|
@ -1226,7 +1226,9 @@ public class DatabaseHelper {
|
||||||
public static <R> R cloneAndSetAutoTimestamps(final R resource) {
|
public static <R> R cloneAndSetAutoTimestamps(final R resource) {
|
||||||
R result;
|
R result;
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
result = tm().transact(() -> ofy().load().fromEntity(ofy().save().toEntity(resource)));
|
result =
|
||||||
|
tm().transact(
|
||||||
|
() -> auditedOfy().load().fromEntity(auditedOfy().save().toEntity(resource)));
|
||||||
} else {
|
} else {
|
||||||
// We have to separate the read and write operation into different transactions
|
// We have to separate the read and write operation into different transactions
|
||||||
// otherwise JPA would just return the input entity instead of actually creating a
|
// otherwise JPA would just return the input entity instead of actually creating a
|
||||||
|
@ -1263,7 +1265,7 @@ public class DatabaseHelper {
|
||||||
*/
|
*/
|
||||||
public static List<Object> loadAllEntities() {
|
public static List<Object> loadAllEntities() {
|
||||||
if (tm().isOfy()) {
|
if (tm().isOfy()) {
|
||||||
return ofy().load().list();
|
return auditedOfy().load().list();
|
||||||
} else {
|
} else {
|
||||||
return jpaTm()
|
return jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.testing.mapreduce;
|
package google.registry.testing.mapreduce;
|
||||||
|
|
||||||
import static google.registry.config.RegistryConfig.getEppResourceIndexBucketCount;
|
import static google.registry.config.RegistryConfig.getEppResourceIndexBucketCount;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public abstract class MapreduceTestCase<T> {
|
||||||
for (int numTasksDeleted = 0;
|
for (int numTasksDeleted = 0;
|
||||||
!maxTasks.isPresent() || (numTasksDeleted < maxTasks.get());
|
!maxTasks.isPresent() || (numTasksDeleted < maxTasks.get());
|
||||||
numTasksDeleted++) {
|
numTasksDeleted++) {
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
// We have to re-acquire task list every time, because local implementation returns a copy.
|
// We have to re-acquire task list every time, because local implementation returns a copy.
|
||||||
List<QueueStateInfo.TaskStateInfo> taskInfo =
|
List<QueueStateInfo.TaskStateInfo> taskInfo =
|
||||||
taskQueue.getQueueStateInfo().get(queueName).getTaskInfo();
|
taskQueue.getQueueStateInfo().get(queueName).getTaskInfo();
|
||||||
|
|
|
@ -16,7 +16,7 @@ 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.ImmutableObjectSubject.assertAboutImmutableObjects;
|
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||||
|
@ -176,14 +176,14 @@ class DedupeRecurringBillingEventIdsCommandTest
|
||||||
if (newRecurring.getTargetId().equals("foo.tld")) {
|
if (newRecurring.getTargetId().equals("foo.tld")) {
|
||||||
assertSameRecurringEntityExceptId(newRecurring, recurring1);
|
assertSameRecurringEntityExceptId(newRecurring, recurring1);
|
||||||
|
|
||||||
BillingEvent.OneTime persistedOneTime = ofy().load().entity(oneTime).now();
|
BillingEvent.OneTime persistedOneTime = auditedOfy().load().entity(oneTime).now();
|
||||||
assertAboutImmutableObjects()
|
assertAboutImmutableObjects()
|
||||||
.that(persistedOneTime)
|
.that(persistedOneTime)
|
||||||
.isEqualExceptFields(oneTime, "cancellationMatchingBillingEvent");
|
.isEqualExceptFields(oneTime, "cancellationMatchingBillingEvent");
|
||||||
assertThat(persistedOneTime.getCancellationMatchingBillingEvent())
|
assertThat(persistedOneTime.getCancellationMatchingBillingEvent())
|
||||||
.isEqualTo(newRecurring.createVKey());
|
.isEqualTo(newRecurring.createVKey());
|
||||||
|
|
||||||
DomainBase persistedDomain = ofy().load().entity(domain1).now();
|
DomainBase persistedDomain = auditedOfy().load().entity(domain1).now();
|
||||||
assertAboutImmutableObjects()
|
assertAboutImmutableObjects()
|
||||||
.that(persistedDomain)
|
.that(persistedDomain)
|
||||||
.isEqualExceptFields(
|
.isEqualExceptFields(
|
||||||
|
@ -219,7 +219,7 @@ class DedupeRecurringBillingEventIdsCommandTest
|
||||||
|
|
||||||
private static void assertNotInDatastore(ImmutableObject... entities) {
|
private static void assertNotInDatastore(ImmutableObject... entities) {
|
||||||
for (ImmutableObject entity : entities) {
|
for (ImmutableObject entity : entities) {
|
||||||
assertThat(ofy().load().entity(entity).now()).isNull();
|
assertThat(auditedOfy().load().entity(entity).now()).isNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ class DedupeRecurringBillingEventIdsCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImmutableList<BillingEvent.Recurring> loadAllRecurrings() {
|
private static ImmutableList<BillingEvent.Recurring> loadAllRecurrings() {
|
||||||
return ImmutableList.copyOf(ofy().load().type(BillingEvent.Recurring.class));
|
return ImmutableList.copyOf(auditedOfy().load().type(BillingEvent.Recurring.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getKeyPathLiteral(Object... entities) {
|
private static String getKeyPathLiteral(Object... entities) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.Entity;
|
import com.google.appengine.api.datastore.Entity;
|
||||||
|
@ -96,7 +96,7 @@ public class LevelDbFileBuilderTest {
|
||||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
||||||
|
|
||||||
ContactResource contact = DatabaseHelper.newContactResource("contact");
|
ContactResource contact = DatabaseHelper.newContactResource("contact");
|
||||||
builder.addEntity(tm().transact(() -> ofy().save().toEntity(contact)));
|
builder.addEntity(tm().transact(() -> auditedOfy().save().toEntity(contact)));
|
||||||
builder.build();
|
builder.build();
|
||||||
|
|
||||||
ImmutableList<byte[]> records = ImmutableList.copyOf(LevelDbLogReader.from(logFile.getPath()));
|
ImmutableList<byte[]> records = ImmutableList.copyOf(LevelDbLogReader.from(logFile.getPath()));
|
||||||
|
@ -112,6 +112,6 @@ public class LevelDbFileBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T rawRecordToOfyEntity(byte[] record, Class<T> expectedType) {
|
private static <T> T rawRecordToOfyEntity(byte[] record, Class<T> expectedType) {
|
||||||
return expectedType.cast(ofy().load().fromEntity(rawRecordToEntity(record)));
|
return expectedType.cast(auditedOfy().load().fromEntity(rawRecordToEntity(record)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ 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.ImmutableObjectSubject.immutableObjectCorrespondence;
|
import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
||||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||||
|
@ -62,7 +62,7 @@ public class RemoveRegistryOneKeyCommandTest extends CommandTestCase<RemoveRegis
|
||||||
"--key_paths_file",
|
"--key_paths_file",
|
||||||
writeToNamedTmpFile("keypath.txt", getKeyPathLiteral(domain)));
|
writeToNamedTmpFile("keypath.txt", getKeyPathLiteral(domain)));
|
||||||
|
|
||||||
DomainBase persisted = ofy().load().key(domain.createVKey().getOfyKey()).now();
|
DomainBase persisted = auditedOfy().load().key(domain.createVKey().getOfyKey()).now();
|
||||||
assertThat(ImmutableList.of(persisted))
|
assertThat(ImmutableList.of(persisted))
|
||||||
.comparingElementsUsing(getDomainBaseCorrespondence())
|
.comparingElementsUsing(getDomainBaseCorrespondence())
|
||||||
.containsExactly(origin);
|
.containsExactly(origin);
|
||||||
|
@ -86,7 +86,7 @@ public class RemoveRegistryOneKeyCommandTest extends CommandTestCase<RemoveRegis
|
||||||
"--key_paths_file",
|
"--key_paths_file",
|
||||||
writeToNamedTmpFile("keypath.txt", getKeyPathLiteral(domain)));
|
writeToNamedTmpFile("keypath.txt", getKeyPathLiteral(domain)));
|
||||||
|
|
||||||
DomainBase persisted = ofy().load().key(domain.createVKey().getOfyKey()).now();
|
DomainBase persisted = auditedOfy().load().key(domain.createVKey().getOfyKey()).now();
|
||||||
assertThat(ImmutableList.of(persisted))
|
assertThat(ImmutableList.of(persisted))
|
||||||
.comparingElementsUsing(getDomainBaseCorrespondence())
|
.comparingElementsUsing(getDomainBaseCorrespondence())
|
||||||
.containsExactly(origin);
|
.containsExactly(origin);
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.tools;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.transform;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.KeyFactory;
|
import com.google.appengine.api.datastore.KeyFactory;
|
||||||
|
@ -35,27 +35,27 @@ class ResaveEntitiesCommandTest extends CommandTestCase<ResaveEntitiesCommand> {
|
||||||
ContactResource contact1 = persistActiveContact("contact1");
|
ContactResource contact1 = persistActiveContact("contact1");
|
||||||
ContactResource contact2 = persistActiveContact("contact2");
|
ContactResource contact2 = persistActiveContact("contact2");
|
||||||
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
KeyFactory.keyToString(Key.create(contact1).getRaw()),
|
KeyFactory.keyToString(Key.create(contact1).getRaw()),
|
||||||
KeyFactory.keyToString(Key.create(contact2).getRaw()));
|
KeyFactory.keyToString(Key.create(contact2).getRaw()));
|
||||||
|
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).keys()).hasSize(1);
|
||||||
Iterable<ImmutableObject> savedEntities =
|
Iterable<ImmutableObject> savedEntities =
|
||||||
transform(
|
transform(
|
||||||
ofy().load().type(CommitLogMutation.class).list(),
|
auditedOfy().load().type(CommitLogMutation.class).list(),
|
||||||
mutation -> ofy().load().fromEntity(mutation.getEntity()));
|
mutation -> auditedOfy().load().fromEntity(mutation.getEntity()));
|
||||||
// Reload the contacts before asserting, since their update times will have changed.
|
// Reload the contacts before asserting, since their update times will have changed.
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(savedEntities)
|
assertThat(savedEntities)
|
||||||
.containsExactlyElementsIn(ofy().load().entities(contact1, contact2).values());
|
.containsExactlyElementsIn(auditedOfy().load().entities(contact1, contact2).values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
private static void deleteEntitiesOfTypes(Class<? extends ImmutableObject>... types) {
|
private static void deleteEntitiesOfTypes(Class<? extends ImmutableObject>... types) {
|
||||||
for (Class<? extends ImmutableObject> type : types) {
|
for (Class<? extends ImmutableObject> type : types) {
|
||||||
ofy().deleteWithoutBackup().keys(ofy().load().type(type).keys()).now();
|
auditedOfy().deleteWithoutBackup().keys(auditedOfy().load().type(type).keys()).now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.tools;
|
||||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
import static com.google.common.collect.Iterables.transform;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||||
|
|
||||||
|
@ -44,25 +44,25 @@ class ResaveEnvironmentEntitiesCommandTest
|
||||||
CommitLogManifest.class,
|
CommitLogManifest.class,
|
||||||
CommitLogMutation.class);
|
CommitLogMutation.class);
|
||||||
runCommand();
|
runCommand();
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSuccess_createsCommitLogs() throws Exception {
|
void testSuccess_createsCommitLogs() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
||||||
runCommand();
|
runCommand();
|
||||||
|
|
||||||
// There are 5 entities that have been re-saved at this point (in 3 transactions, one for each
|
// There are 5 entities that have been re-saved at this point (in 3 transactions, one for each
|
||||||
// type), so expect 3 manifests and 5 mutations.
|
// type), so expect 3 manifests and 5 mutations.
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).hasSize(3);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).keys()).hasSize(3);
|
||||||
Iterable<ImmutableObject> savedEntities =
|
Iterable<ImmutableObject> savedEntities =
|
||||||
transform(
|
transform(
|
||||||
ofy().load().type(CommitLogMutation.class).list(),
|
auditedOfy().load().type(CommitLogMutation.class).list(),
|
||||||
mutation -> ofy().load().fromEntity(mutation.getEntity()));
|
mutation -> auditedOfy().load().fromEntity(mutation.getEntity()));
|
||||||
ImmutableSortedSet<RegistrarContact> theRegistrarContacts =
|
ImmutableSortedSet<RegistrarContact> theRegistrarContacts =
|
||||||
loadRegistrar("TheRegistrar").getContacts();
|
loadRegistrar("TheRegistrar").getContacts();
|
||||||
assertThat(savedEntities)
|
assertThat(savedEntities)
|
||||||
|
@ -79,7 +79,7 @@ class ResaveEnvironmentEntitiesCommandTest
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
private static void deleteEntitiesOfTypes(Class<? extends ImmutableObject>... types) {
|
private static void deleteEntitiesOfTypes(Class<? extends ImmutableObject>... types) {
|
||||||
for (Class<? extends ImmutableObject> type : types) {
|
for (Class<? extends ImmutableObject> type : types) {
|
||||||
ofy().deleteWithoutBackup().keys(ofy().load().type(type).keys()).now();
|
auditedOfy().deleteWithoutBackup().keys(auditedOfy().load().type(type).keys()).now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||||
|
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
|
@ -31,23 +31,23 @@ class ResaveEppResourcesCommandTest extends CommandTestCase<ResaveEppResourceCom
|
||||||
void testSuccess_createsCommitLogs() throws Exception {
|
void testSuccess_createsCommitLogs() throws Exception {
|
||||||
ContactResource contact = persistActiveContact("contact");
|
ContactResource contact = persistActiveContact("contact");
|
||||||
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
assertThat(auditedOfy().load().type(CommitLogMutation.class).keys()).isEmpty();
|
||||||
runCommandForced("--type=CONTACT", "--id=contact");
|
runCommandForced("--type=CONTACT", "--id=contact");
|
||||||
|
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogManifest.class).keys()).hasSize(1);
|
||||||
assertThat(ofy().load().type(CommitLogMutation.class).keys()).hasSize(1);
|
assertThat(auditedOfy().load().type(CommitLogMutation.class).keys()).hasSize(1);
|
||||||
CommitLogMutation mutation = ofy().load().type(CommitLogMutation.class).first().now();
|
CommitLogMutation mutation = auditedOfy().load().type(CommitLogMutation.class).first().now();
|
||||||
// Reload the contact before asserting, since its update time will have changed.
|
// Reload the contact before asserting, since its update time will have changed.
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
assertThat(ofy().load().<Object>fromEntity(mutation.getEntity()))
|
assertThat(auditedOfy().load().<Object>fromEntity(mutation.getEntity()))
|
||||||
.isEqualTo(ofy().load().entity(contact).now());
|
.isEqualTo(auditedOfy().load().entity(contact).now());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
private static void deleteEntitiesOfTypes(Class<? extends ImmutableObject>... types) {
|
private static void deleteEntitiesOfTypes(Class<? extends ImmutableObject>... types) {
|
||||||
for (Class<? extends ImmutableObject> type : types) {
|
for (Class<? extends ImmutableObject> type : types) {
|
||||||
ofy().deleteWithoutBackup().keys(ofy().load().type(type).keys()).now();
|
auditedOfy().deleteWithoutBackup().keys(auditedOfy().load().type(type).keys()).now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.tools.server;
|
||||||
import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService;
|
import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.googlecode.objectify.Key.create;
|
import static com.googlecode.objectify.Key.create;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import com.google.appengine.api.datastore.Entity;
|
import com.google.appengine.api.datastore.Entity;
|
||||||
|
@ -49,7 +49,7 @@ class DeleteEntityActionTest {
|
||||||
@Test
|
@Test
|
||||||
void test_deleteSingleRegisteredEntitySuccessfully() {
|
void test_deleteSingleRegisteredEntitySuccessfully() {
|
||||||
ReservedList ofyEntity = new ReservedList.Builder().setName("foo").build();
|
ReservedList ofyEntity = new ReservedList.Builder().setName("foo").build();
|
||||||
ofy().saveWithoutBackup().entity(ofyEntity).now();
|
auditedOfy().saveWithoutBackup().entity(ofyEntity).now();
|
||||||
new DeleteEntityAction(KeyFactory.keyToString(create(ofyEntity).getRaw()), response).run();
|
new DeleteEntityAction(KeyFactory.keyToString(create(ofyEntity).getRaw()), response).run();
|
||||||
assertThat(response.getPayload()).isEqualTo("Deleted 0 raw entities and 1 registered entities");
|
assertThat(response.getPayload()).isEqualTo("Deleted 0 raw entities and 1 registered entities");
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class DeleteEntityActionTest {
|
||||||
getDatastoreService().put(entity);
|
getDatastoreService().put(entity);
|
||||||
String rawKey = KeyFactory.keyToString(entity.getKey());
|
String rawKey = KeyFactory.keyToString(entity.getKey());
|
||||||
ReservedList ofyEntity = new ReservedList.Builder().setName("registered").build();
|
ReservedList ofyEntity = new ReservedList.Builder().setName("registered").build();
|
||||||
ofy().saveWithoutBackup().entity(ofyEntity).now();
|
auditedOfy().saveWithoutBackup().entity(ofyEntity).now();
|
||||||
String ofyKey = KeyFactory.keyToString(create(ofyEntity).getRaw());
|
String ofyKey = KeyFactory.keyToString(create(ofyEntity).getRaw());
|
||||||
new DeleteEntityAction(String.format("%s,%s", rawKey, ofyKey), response).run();
|
new DeleteEntityAction(String.format("%s,%s", rawKey, ofyKey), response).run();
|
||||||
assertThat(response.getPayload()).isEqualTo("Deleted 1 raw entities and 1 registered entities");
|
assertThat(response.getPayload()).isEqualTo("Deleted 1 raw entities and 1 registered entities");
|
||||||
|
@ -88,7 +88,7 @@ class DeleteEntityActionTest {
|
||||||
@Test
|
@Test
|
||||||
void test_deleteOneEntityAndNonExistentEntityRepliesWithError() {
|
void test_deleteOneEntityAndNonExistentEntityRepliesWithError() {
|
||||||
ReservedList ofyEntity = new ReservedList.Builder().setName("first_registered").build();
|
ReservedList ofyEntity = new ReservedList.Builder().setName("first_registered").build();
|
||||||
ofy().saveWithoutBackup().entity(ofyEntity).now();
|
auditedOfy().saveWithoutBackup().entity(ofyEntity).now();
|
||||||
String ofyKey = KeyFactory.keyToString(create(ofyEntity).getRaw());
|
String ofyKey = KeyFactory.keyToString(create(ofyEntity).getRaw());
|
||||||
String rawKey = KeyFactory.keyToString(new Entity("non", "existent").getKey());
|
String rawKey = KeyFactory.keyToString(new Entity("non", "existent").getKey());
|
||||||
BadRequestException thrown =
|
BadRequestException thrown =
|
||||||
|
|
|
@ -20,6 +20,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.Iterables.filter;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.newContactResource;
|
import static google.registry.testing.DatabaseHelper.newContactResource;
|
||||||
|
@ -80,16 +81,18 @@ class KillAllCommitLogsActionTest extends MapreduceTestCase<KillAllCommitLogsAct
|
||||||
assertWithMessage("entities of type " + clazz).that(ofy().load().type(clazz)).isNotEmpty();
|
assertWithMessage("entities of type " + clazz).that(ofy().load().type(clazz)).isNotEmpty();
|
||||||
}
|
}
|
||||||
ImmutableList<?> otherStuff =
|
ImmutableList<?> otherStuff =
|
||||||
Streams.stream(ofy().load())
|
Streams.stream(auditedOfy().load())
|
||||||
.filter(obj -> !AFFECTED_TYPES.contains(obj.getClass()))
|
.filter(obj -> !AFFECTED_TYPES.contains(obj.getClass()))
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
assertThat(otherStuff).isNotEmpty();
|
assertThat(otherStuff).isNotEmpty();
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
for (Class<?> clazz : AFFECTED_TYPES) {
|
for (Class<?> clazz : AFFECTED_TYPES) {
|
||||||
assertWithMessage("entities of type " + clazz).that(ofy().load().type(clazz)).isEmpty();
|
assertWithMessage("entities of type " + clazz)
|
||||||
|
.that(auditedOfy().load().type(clazz))
|
||||||
|
.isEmpty();
|
||||||
}
|
}
|
||||||
// Filter out raw Entity objects created by the mapreduce.
|
// Filter out raw Entity objects created by the mapreduce.
|
||||||
assertThat(filter(ofy().load(), not(instanceOf(Entity.class))))
|
assertThat(filter(auditedOfy().load(), not(instanceOf(Entity.class))))
|
||||||
.containsExactlyElementsIn(otherStuff);
|
.containsExactlyElementsIn(otherStuff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.common.collect.Multimaps.filterKeys;
|
import static com.google.common.collect.Multimaps.filterKeys;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||||
|
@ -130,7 +130,7 @@ class KillAllEppResourcesActionTest extends MapreduceTestCase<KillAllEppResource
|
||||||
assertThat(beforeContents.keySet()).containsAtLeastElementsIn(AFFECTED_KINDS);
|
assertThat(beforeContents.keySet()).containsAtLeastElementsIn(AFFECTED_KINDS);
|
||||||
assertThat(difference(beforeContents.keySet(), AFFECTED_KINDS)).isNotEmpty();
|
assertThat(difference(beforeContents.keySet(), AFFECTED_KINDS)).isNotEmpty();
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
ImmutableMultimap<String, Object> afterContents = getDatastoreContents();
|
ImmutableMultimap<String, Object> afterContents = getDatastoreContents();
|
||||||
assertThat(afterContents.keySet()).containsNoneIn(AFFECTED_KINDS);
|
assertThat(afterContents.keySet()).containsNoneIn(AFFECTED_KINDS);
|
||||||
assertThat(afterContents)
|
assertThat(afterContents)
|
||||||
|
@ -140,7 +140,7 @@ class KillAllEppResourcesActionTest extends MapreduceTestCase<KillAllEppResource
|
||||||
private ImmutableMultimap<String, Object> getDatastoreContents() {
|
private ImmutableMultimap<String, Object> getDatastoreContents() {
|
||||||
ImmutableMultimap.Builder<String, Object> contentsBuilder = new ImmutableMultimap.Builder<>();
|
ImmutableMultimap.Builder<String, Object> contentsBuilder = new ImmutableMultimap.Builder<>();
|
||||||
// Filter out raw Entity objects created by the mapreduce.
|
// Filter out raw Entity objects created by the mapreduce.
|
||||||
for (Object obj : Iterables.filter(ofy().load(), not(instanceOf(Entity.class)))) {
|
for (Object obj : Iterables.filter(auditedOfy().load(), not(instanceOf(Entity.class)))) {
|
||||||
contentsBuilder.put(Key.getKind(obj.getClass()), obj);
|
contentsBuilder.put(Key.getKind(obj.getClass()), obj);
|
||||||
}
|
}
|
||||||
return contentsBuilder.build();
|
return contentsBuilder.build();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.tools.server;
|
package google.registry.tools.server;
|
||||||
|
|
||||||
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.model.ofy.ObjectifyService.auditedOfy;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||||
|
@ -55,9 +55,9 @@ class ResaveAllHistoryEntriesActionTest extends MapreduceTestCase<ResaveAllHisto
|
||||||
DomainBase domain = persistActiveDomain("test.tld");
|
DomainBase domain = persistActiveDomain("test.tld");
|
||||||
ContactResource contact = persistActiveContact("humanBeing");
|
ContactResource contact = persistActiveContact("humanBeing");
|
||||||
Entity domainEntry =
|
Entity domainEntry =
|
||||||
ofy().save().toEntity(new HistoryEntry.Builder().setParent(domain).build());
|
auditedOfy().save().toEntity(new HistoryEntry.Builder().setParent(domain).build());
|
||||||
Entity contactEntry =
|
Entity contactEntry =
|
||||||
ofy().save().toEntity(new HistoryEntry.Builder().setParent(contact).build());
|
auditedOfy().save().toEntity(new HistoryEntry.Builder().setParent(contact).build());
|
||||||
|
|
||||||
// Set raw properties outside the Objectify schema, which will be deleted upon re-save.
|
// Set raw properties outside the Objectify schema, which will be deleted upon re-save.
|
||||||
domainEntry.setProperty("clientId", "validId");
|
domainEntry.setProperty("clientId", "validId");
|
||||||
|
@ -66,7 +66,7 @@ class ResaveAllHistoryEntriesActionTest extends MapreduceTestCase<ResaveAllHisto
|
||||||
contactEntry.setProperty("alsoShouldBeDeleted", "456nah");
|
contactEntry.setProperty("alsoShouldBeDeleted", "456nah");
|
||||||
datastoreService.put(domainEntry);
|
datastoreService.put(domainEntry);
|
||||||
datastoreService.put(contactEntry);
|
datastoreService.put(contactEntry);
|
||||||
ofy().clearSessionCache();
|
auditedOfy().clearSessionCache();
|
||||||
runMapreduce();
|
runMapreduce();
|
||||||
|
|
||||||
Entity updatedDomainEntry = datastoreService.get(domainEntry.getKey());
|
Entity updatedDomainEntry = datastoreService.get(domainEntry.getKey());
|
||||||
|
|
Loading…
Add table
Reference in a new issue