Replace VKey.fromWebsafeKey() with VKey.create(string) (#1414)

* Replace with stringify() and VKey.create(string)

* Convert implicit cases of VKey.fromWebsafeKey(string)

* Convert from Key to VKey to use stringify()

* Modify existing code to show correct string representation of a key

* Use VKey.create(websafeKey) to get ofy key in ResaveEntitiesCommand

* Add TODO note in CommitLogMutation and determine if key string should be modified

* Revert from stringify() to getOfyKey().getString()

* Add bug ids to TODOs
This commit is contained in:
Rachel Guan 2021-11-24 12:14:13 -05:00 committed by GitHub
parent e4fb083f8a
commit 25d5d3d25e
20 changed files with 54 additions and 55 deletions

View file

@ -24,10 +24,8 @@ import com.google.appengine.api.taskqueue.TransientFailureException;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.RegistryLock; import google.registry.model.domain.RegistryLock;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
@ -84,8 +82,7 @@ public final class AsyncTaskEnqueuer {
} }
/** Enqueues a task to asynchronously re-save an entity at some point in the future. */ /** Enqueues a task to asynchronously re-save an entity at some point in the future. */
public void enqueueAsyncResave( public void enqueueAsyncResave(VKey<?> entityToResave, DateTime now, DateTime whenToResave) {
ImmutableObject entityToResave, DateTime now, DateTime whenToResave) {
enqueueAsyncResave(entityToResave, now, ImmutableSortedSet.of(whenToResave)); enqueueAsyncResave(entityToResave, now, ImmutableSortedSet.of(whenToResave));
} }
@ -96,10 +93,9 @@ public final class AsyncTaskEnqueuer {
* itself to run at the next time if there are remaining re-saves scheduled. * itself to run at the next time if there are remaining re-saves scheduled.
*/ */
public void enqueueAsyncResave( public void enqueueAsyncResave(
ImmutableObject entityToResave, DateTime now, ImmutableSortedSet<DateTime> whenToResave) { VKey<?> entityKey, DateTime now, ImmutableSortedSet<DateTime> whenToResave) {
DateTime firstResave = whenToResave.first(); DateTime firstResave = whenToResave.first();
checkArgument(isBeforeOrAt(now, firstResave), "Can't enqueue a resave to run in the past"); checkArgument(isBeforeOrAt(now, firstResave), "Can't enqueue a resave to run in the past");
Key<ImmutableObject> entityKey = Key.create(entityToResave);
Duration etaDuration = new Duration(now, firstResave); Duration etaDuration = new Duration(now, firstResave);
if (etaDuration.isLongerThan(MAX_ASYNC_ETA)) { if (etaDuration.isLongerThan(MAX_ASYNC_ETA)) {
logger.atInfo().log( logger.atInfo().log(
@ -114,7 +110,7 @@ public final class AsyncTaskEnqueuer {
.method(Method.POST) .method(Method.POST)
.header("Host", backendHostname) .header("Host", backendHostname)
.countdownMillis(etaDuration.getMillis()) .countdownMillis(etaDuration.getMillis())
.param(PARAM_RESOURCE_KEY, entityKey.getString()) .param(PARAM_RESOURCE_KEY, entityKey.getOfyKey().getString())
.param(PARAM_REQUESTED_TIME, now.toString()); .param(PARAM_REQUESTED_TIME, now.toString());
if (whenToResave.size() > 1) { if (whenToResave.size() > 1) {
task.param(PARAM_RESAVE_TIMES, Joiner.on(',').join(whenToResave.tailSet(firstResave, false))); task.param(PARAM_RESAVE_TIMES, Joiner.on(',').join(whenToResave.tailSet(firstResave, false)));
@ -129,14 +125,13 @@ public final class AsyncTaskEnqueuer {
String requestingRegistrarId, String requestingRegistrarId,
Trid trid, Trid trid,
boolean isSuperuser) { boolean isSuperuser) {
Key<EppResource> resourceKey = Key.create(resourceToDelete);
logger.atInfo().log( logger.atInfo().log(
"Enqueuing async deletion of %s on behalf of registrar %s.", "Enqueuing async deletion of %s on behalf of registrar %s.",
resourceKey, requestingRegistrarId); resourceToDelete.getRepoId(), requestingRegistrarId);
TaskOptions task = TaskOptions task =
TaskOptions.Builder.withMethod(Method.PULL) TaskOptions.Builder.withMethod(Method.PULL)
.countdownMillis(asyncDeleteDelay.getMillis()) .countdownMillis(asyncDeleteDelay.getMillis())
.param(PARAM_RESOURCE_KEY, resourceKey.getString()) .param(PARAM_RESOURCE_KEY, resourceToDelete.createVKey().getOfyKey().getString())
.param(PARAM_REQUESTING_CLIENT_ID, requestingRegistrarId) .param(PARAM_REQUESTING_CLIENT_ID, requestingRegistrarId)
.param(PARAM_SERVER_TRANSACTION_ID, trid.getServerTransactionId()) .param(PARAM_SERVER_TRANSACTION_ID, trid.getServerTransactionId())
.param(PARAM_IS_SUPERUSER, Boolean.toString(isSuperuser)) .param(PARAM_IS_SUPERUSER, Boolean.toString(isSuperuser))

View file

@ -79,6 +79,7 @@ public class BatchModule {
@Provides @Provides
@Parameter(PARAM_RESOURCE_KEY) @Parameter(PARAM_RESOURCE_KEY)
// TODO(b/207363014): figure out if this needs to be modified for vkey string replacement
static Key<ImmutableObject> provideResourceKey(HttpServletRequest req) { static Key<ImmutableObject> provideResourceKey(HttpServletRequest req) {
return Key.create(extractRequiredParameter(req, PARAM_RESOURCE_KEY)); return Key.create(extractRequiredParameter(req, PARAM_RESOURCE_KEY));
} }

View file

@ -523,18 +523,19 @@ public class DeleteContactsAndHostsAction implements Runnable {
static DeletionRequest createFromTask(TaskHandle task, DateTime now) static DeletionRequest createFromTask(TaskHandle task, DateTime now)
throws Exception { throws Exception {
ImmutableMap<String, String> params = ImmutableMap.copyOf(task.extractParams()); ImmutableMap<String, String> params = ImmutableMap.copyOf(task.extractParams());
Key<EppResource> resourceKey = VKey<EppResource> resourceKey =
Key.create( VKey.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( checkNotNull(
auditedOfy().load().key(resourceKey).now(), "Resource to delete doesn't exist"); auditedOfy().load().key(resourceKey.getOfyKey()).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",
resource.getClass().getSimpleName()); resource.getClass().getSimpleName());
return new AutoValue_DeleteContactsAndHostsAction_DeletionRequest.Builder() return new AutoValue_DeleteContactsAndHostsAction_DeletionRequest.Builder()
.setKey(resourceKey) .setKey(resourceKey.getOfyKey())
.setLastUpdateTime(resource.getUpdateTimestamp().getTimestamp()) .setLastUpdateTime(resource.getUpdateTimestamp().getTimestamp())
.setRequestingClientId( .setRequestingClientId(
checkNotNull( checkNotNull(

View file

@ -353,8 +353,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
static DnsRefreshRequest createFromTask(TaskHandle task, DateTime now) throws Exception { static DnsRefreshRequest createFromTask(TaskHandle task, DateTime now) throws Exception {
ImmutableMap<String, String> params = ImmutableMap.copyOf(task.extractParams()); ImmutableMap<String, String> params = ImmutableMap.copyOf(task.extractParams());
VKey<HostResource> hostKey = VKey<HostResource> hostKey =
VKey.fromWebsafeKey( VKey.create(checkNotNull(params.get(PARAM_HOST_KEY), "Host to refresh not specified"));
checkNotNull(params.get(PARAM_HOST_KEY), "Host to refresh not specified"));
HostResource host = HostResource host =
tm().transact(() -> tm().loadByKeyIfPresent(hostKey)) tm().transact(() -> tm().loadByKeyIfPresent(hostKey))
.orElseThrow(() -> new NoSuchElementException("Host to refresh doesn't exist")); .orElseThrow(() -> new NoSuchElementException("Host to refresh doesn't exist"));

View file

@ -76,13 +76,15 @@ public class ResaveEntityAction implements Runnable {
"Re-saving entity %s which was enqueued at %s.", resourceKey, requestedTime); "Re-saving entity %s which was enqueued at %s.", resourceKey, requestedTime);
tm().transact( tm().transact(
() -> { () -> {
// TODO(/207363014): figure out if this should modified for vkey string replacement
ImmutableObject entity = tm().loadByKey(VKey.from(resourceKey)); ImmutableObject entity = tm().loadByKey(VKey.from(resourceKey));
tm().put( tm().put(
(entity instanceof EppResource) (entity instanceof EppResource)
? ((EppResource) entity).cloneProjectedAtTime(tm().getTransactionTime()) ? ((EppResource) entity).cloneProjectedAtTime(tm().getTransactionTime())
: entity); : entity);
if (!resaveTimes.isEmpty()) { if (!resaveTimes.isEmpty()) {
asyncTaskEnqueuer.enqueueAsyncResave(entity, requestedTime, resaveTimes); asyncTaskEnqueuer.enqueueAsyncResave(
VKey.from(resourceKey), requestedTime, resaveTimes);
} }
}); });
response.setPayload("Entity re-saved."); response.setPayload("Entity re-saved.");

View file

@ -187,7 +187,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
} else { } else {
DateTime redemptionTime = now.plus(redemptionGracePeriodLength); DateTime redemptionTime = now.plus(redemptionGracePeriodLength);
asyncTaskEnqueuer.enqueueAsyncResave( asyncTaskEnqueuer.enqueueAsyncResave(
existingDomain, now, ImmutableSortedSet.of(redemptionTime, deletionTime)); existingDomain.createVKey(), now, ImmutableSortedSet.of(redemptionTime, deletionTime));
builder builder
.setDeletionTime(deletionTime) .setDeletionTime(deletionTime)
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))

View file

@ -235,7 +235,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
.build(); .build();
DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now, period); DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now, period);
asyncTaskEnqueuer.enqueueAsyncResave(newDomain, now, automaticTransferTime); asyncTaskEnqueuer.enqueueAsyncResave(newDomain.createVKey(), now, automaticTransferTime);
tm().putAll( tm().putAll(
new ImmutableSet.Builder<>() new ImmutableSet.Builder<>()
.add(newDomain, domainHistory, requestPollMessage) .add(newDomain, domainHistory, requestPollMessage)

View file

@ -64,6 +64,7 @@ public class EppResourceIndex extends BackupGroupRoot implements DatastoreOnlyEn
EppResourceIndex instance = instantiate(EppResourceIndex.class); EppResourceIndex instance = instantiate(EppResourceIndex.class);
instance.reference = resourceKey; instance.reference = resourceKey;
instance.kind = resourceKey.getKind(); instance.kind = resourceKey.getKind();
// TODO(b/207368050): figure out if this value has ever been used other than test cases
instance.id = resourceKey.getString(); // creates a web-safe key string instance.id = resourceKey.getString(); // creates a web-safe key string
instance.bucket = bucket; instance.bucket = bucket;
return instance; return instance;

View file

@ -82,6 +82,7 @@ public class CommitLogMutation extends ImmutableObject implements DatastoreOnlyE
com.google.appengine.api.datastore.Entity rawEntity) { com.google.appengine.api.datastore.Entity rawEntity) {
CommitLogMutation instance = new CommitLogMutation(); CommitLogMutation instance = new CommitLogMutation();
instance.parent = checkNotNull(parent); instance.parent = checkNotNull(parent);
// TODO(b/207516684): figure out if this should be converted to a vkey string via stringify()
// Creates a web-safe key string. // Creates a web-safe key string.
instance.entityKey = KeyFactory.keyToString(rawEntity.getKey()); instance.entityKey = KeyFactory.keyToString(rawEntity.getKey());
instance.entityProtoBytes = convertToPb(rawEntity).toByteArray(); instance.entityProtoBytes = convertToPb(rawEntity).toByteArray();
@ -91,6 +92,8 @@ public class CommitLogMutation extends ImmutableObject implements DatastoreOnlyE
/** Returns the key of a mutation based on the {@code entityKey} of the entity it stores. */ /** Returns the key of a mutation based on the {@code entityKey} of the entity it stores. */
public static public static
Key<CommitLogMutation> createKey(Key<CommitLogManifest> parent, Key<?> entityKey) { Key<CommitLogMutation> createKey(Key<CommitLogManifest> parent, Key<?> entityKey) {
// TODO(b/207516684): figure out if the return type needs to be VKey and
// if the string used to create a key should remain the same
return Key.create(parent, CommitLogMutation.class, entityKey.getString()); return Key.create(parent, CommitLogMutation.class, entityKey.getString());
} }
} }

View file

@ -19,7 +19,6 @@ import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.googlecode.objectify.Key;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import java.util.Optional; import java.util.Optional;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -56,7 +55,7 @@ abstract class GetEppResourceCommand implements CommandWithRemoteApi {
? String.format( ? String.format(
"%s\n\nWebsafe key: %s", "%s\n\nWebsafe key: %s",
expand ? resource.get().toHydratedString() : resource.get(), expand ? resource.get().toHydratedString() : resource.get(),
Key.create(resource.get()).getString()) resource.get().createVKey().getOfyKey().getString())
: String.format("%s '%s' does not exist or is deleted\n", resourceType, uniqueId)); : String.format("%s '%s' does not exist or is deleted\n", resourceType, uniqueId));
} }

View file

@ -19,8 +19,8 @@ import static google.registry.model.ofy.ObjectifyService.auditedOfy;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.googlecode.objectify.Key;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.persistence.VKey;
import java.util.List; import java.util.List;
/** /**
@ -40,15 +40,15 @@ final class GetResourceByKeyCommand implements CommandWithRemoteApi {
boolean expand; boolean expand;
@Override @Override
public void run() { public void run() throws Exception {
for (String keyString : mainParameters) { for (String keyString : mainParameters) {
System.out.println("\n"); System.out.println("\n");
Key<EppResource> resourceKey = VKey<EppResource> resourceKey =
checkNotNull(Key.create(keyString), "Could not parse key string: " + keyString); checkNotNull(VKey.create(keyString), "Could not parse key string: " + keyString);
EppResource resource = EppResource resource =
checkNotNull( checkNotNull(
auditedOfy().load().key(resourceKey).now(), auditedOfy().load().key(resourceKey.getOfyKey()).now(),
"Could not load resource for key: " + resourceKey); "Could not load resource for key: " + resourceKey.getOfyKey());
System.out.println(expand ? resource.toHydratedString() : resource.toString()); System.out.println(expand ? resource.toHydratedString() : resource.toString());
} }
} }

View file

@ -19,8 +19,8 @@ import static google.registry.model.ofy.ObjectifyService.auditedOfy;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.googlecode.objectify.Key;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.persistence.VKey;
import java.util.List; import java.util.List;
/** /**
@ -37,15 +37,16 @@ public final class ResaveEntitiesCommand extends MutatingCommand {
/** The number of resaves to do in a single transaction. */ /** The number of resaves to do in a single transaction. */
private static final int BATCH_SIZE = 10; private static final int BATCH_SIZE = 10;
// TODO(b/207376744): figure out if there's a guide that shows how a websafe key should look like
@Parameter(description = "Websafe keys", required = true) @Parameter(description = "Websafe keys", required = true)
List<String> mainParameters; List<String> mainParameters;
@Override @Override
protected void init() { protected void init() throws Exception {
for (List<String> batch : partition(mainParameters, BATCH_SIZE)) { for (List<String> batch : partition(mainParameters, BATCH_SIZE)) {
for (String websafeKey : batch) { for (String websafeKey : batch) {
ImmutableObject entity = ImmutableObject entity =
auditedOfy().load().key(Key.<ImmutableObject>create(websafeKey)).now(); (ImmutableObject) auditedOfy().load().key(VKey.create(websafeKey).getOfyKey()).now();
stageEntityChange(entity, entity); stageEntityChange(entity, entity);
} }
flushTransaction(); flushTransaction();

View file

@ -35,7 +35,6 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.flogger.LoggerConfig; import com.google.common.flogger.LoggerConfig;
import com.googlecode.objectify.Key;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.RegistryLock; import google.registry.model.domain.RegistryLock;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
@ -95,7 +94,8 @@ public class AsyncTaskEnqueuerTest {
@Test @Test
void test_enqueueAsyncResave_success() { void test_enqueueAsyncResave_success() {
ContactResource contact = persistActiveContact("jd23456"); ContactResource contact = persistActiveContact("jd23456");
asyncTaskEnqueuer.enqueueAsyncResave(contact, clock.nowUtc(), clock.nowUtc().plusDays(5)); asyncTaskEnqueuer.enqueueAsyncResave(
contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(5));
assertTasksEnqueued( assertTasksEnqueued(
QUEUE_ASYNC_ACTIONS, QUEUE_ASYNC_ACTIONS,
new TaskMatcher() new TaskMatcher()
@ -103,7 +103,7 @@ public class AsyncTaskEnqueuerTest {
.method("POST") .method("POST")
.header("Host", "backend.hostname.fake") .header("Host", "backend.hostname.fake")
.header("content-type", "application/x-www-form-urlencoded") .header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, Key.create(contact).getString()) .param(PARAM_RESOURCE_KEY, contact.createVKey().getOfyKey().getString())
.param(PARAM_REQUESTED_TIME, clock.nowUtc().toString()) .param(PARAM_REQUESTED_TIME, clock.nowUtc().toString())
.etaDelta( .etaDelta(
standardDays(5).minus(standardSeconds(30)), standardDays(5).minus(standardSeconds(30)),
@ -115,7 +115,7 @@ public class AsyncTaskEnqueuerTest {
ContactResource contact = persistActiveContact("jd23456"); ContactResource contact = persistActiveContact("jd23456");
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
asyncTaskEnqueuer.enqueueAsyncResave( asyncTaskEnqueuer.enqueueAsyncResave(
contact, contact.createVKey(),
now, now,
ImmutableSortedSet.of(now.plusHours(24), now.plusHours(50), now.plusHours(75))); ImmutableSortedSet.of(now.plusHours(24), now.plusHours(50), now.plusHours(75)));
assertTasksEnqueued( assertTasksEnqueued(
@ -125,7 +125,7 @@ public class AsyncTaskEnqueuerTest {
.method("POST") .method("POST")
.header("Host", "backend.hostname.fake") .header("Host", "backend.hostname.fake")
.header("content-type", "application/x-www-form-urlencoded") .header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, Key.create(contact).getString()) .param(PARAM_RESOURCE_KEY, contact.createVKey().getOfyKey().getString())
.param(PARAM_REQUESTED_TIME, now.toString()) .param(PARAM_REQUESTED_TIME, now.toString())
.param(PARAM_RESAVE_TIMES, "2015-05-20T14:34:56.000Z,2015-05-21T15:34:56.000Z") .param(PARAM_RESAVE_TIMES, "2015-05-20T14:34:56.000Z,2015-05-21T15:34:56.000Z")
.etaDelta( .etaDelta(
@ -137,7 +137,8 @@ public class AsyncTaskEnqueuerTest {
@Test @Test
void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() { void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() {
ContactResource contact = persistActiveContact("jd23456"); ContactResource contact = persistActiveContact("jd23456");
asyncTaskEnqueuer.enqueueAsyncResave(contact, clock.nowUtc(), clock.nowUtc().plusDays(31)); asyncTaskEnqueuer.enqueueAsyncResave(
contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(31));
assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS); assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
assertLogMessage(logHandler, Level.INFO, "Ignoring async re-save"); assertLogMessage(logHandler, Level.INFO, "Ignoring async re-save");
} }

View file

@ -64,7 +64,6 @@ import com.google.appengine.api.taskqueue.TaskOptions.Method;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.googlecode.objectify.Key;
import google.registry.batch.AsyncTaskMetrics.OperationResult; import google.registry.batch.AsyncTaskMetrics.OperationResult;
import google.registry.batch.AsyncTaskMetrics.OperationType; import google.registry.batch.AsyncTaskMetrics.OperationType;
import google.registry.batch.DeleteContactsAndHostsAction.DeleteEppResourceReducer; import google.registry.batch.DeleteContactsAndHostsAction.DeleteEppResourceReducer;
@ -497,7 +496,7 @@ public class DeleteContactsAndHostsActionTest
QUEUE_ASYNC_DELETE, QUEUE_ASYNC_DELETE,
new TaskMatcher() new TaskMatcher()
.etaDelta(standardHours(23), standardHours(25)) .etaDelta(standardHours(23), standardHours(25))
.param("resourceKey", Key.create(contactNotSaved).getString()) .param("resourceKey", contactNotSaved.createVKey().getOfyKey().getString())
.param("requestingClientId", "TheRegistrar") .param("requestingClientId", "TheRegistrar")
.param("clientTransactionId", "fakeClientTrid") .param("clientTransactionId", "fakeClientTrid")
.param("serverTransactionId", "fakeServerTrid") .param("serverTransactionId", "fakeServerTrid")
@ -505,7 +504,7 @@ public class DeleteContactsAndHostsActionTest
.param("requestedTime", timeBeforeRun.toString()), .param("requestedTime", timeBeforeRun.toString()),
new TaskMatcher() new TaskMatcher()
.etaDelta(standardHours(23), standardHours(25)) .etaDelta(standardHours(23), standardHours(25))
.param("resourceKey", Key.create(hostNotSaved).getString()) .param("resourceKey", hostNotSaved.createVKey().getOfyKey().getString())
.param("requestingClientId", "TheRegistrar") .param("requestingClientId", "TheRegistrar")
.param("clientTransactionId", "fakeClientTrid") .param("clientTransactionId", "fakeClientTrid")
.param("serverTransactionId", "fakeServerTrid") .param("serverTransactionId", "fakeServerTrid")

View file

@ -44,7 +44,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import com.googlecode.objectify.Key;
import google.registry.batch.AsyncTaskMetrics.OperationResult; import google.registry.batch.AsyncTaskMetrics.OperationResult;
import google.registry.batch.RefreshDnsOnHostRenameAction.RefreshDnsOnHostRenameReducer; import google.registry.batch.RefreshDnsOnHostRenameAction.RefreshDnsOnHostRenameReducer;
import google.registry.dns.DnsQueue; import google.registry.dns.DnsQueue;
@ -238,7 +237,7 @@ public class RefreshDnsOnHostRenameActionTest
QUEUE_ASYNC_HOST_RENAME, QUEUE_ASYNC_HOST_RENAME,
new TaskMatcher() new TaskMatcher()
.etaDelta(standardHours(23), standardHours(25)) .etaDelta(standardHours(23), standardHours(25))
.param("hostKey", Key.create(host).getString())); .param("hostKey", host.createVKey().getOfyKey().getString()));
assertThat(acquireLock()).isPresent(); assertThat(acquireLock()).isPresent();
} }

View file

@ -148,7 +148,7 @@ public class ResaveEntityActionTest {
.method("POST") .method("POST")
.header("Host", "backend.hostname.fake") .header("Host", "backend.hostname.fake")
.header("content-type", "application/x-www-form-urlencoded") .header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, Key.create(resavedDomain).getString()) .param(PARAM_RESOURCE_KEY, resavedDomain.createVKey().getOfyKey().getString())
.param(PARAM_REQUESTED_TIME, requestedTime.toString()) .param(PARAM_REQUESTED_TIME, requestedTime.toString())
.etaDelta( .etaDelta(
standardDays(5).minus(standardSeconds(30)), standardDays(5).minus(standardSeconds(30)),

View file

@ -154,13 +154,14 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
/** Asserts the presence of a single enqueued async contact or host deletion */ /** Asserts the presence of a single enqueued async contact or host deletion */
protected <T extends EppResource> void assertAsyncDeletionTaskEnqueued( protected <T extends EppResource> void assertAsyncDeletionTaskEnqueued(
T resource, String requestingClientId, Trid trid, boolean isSuperuser) { T resource, String requestingClientId, Trid trid, boolean isSuperuser) {
TaskMatcher expected = new TaskMatcher() TaskMatcher expected =
.etaDelta(Duration.standardSeconds(75), Duration.standardSeconds(105)) // expected: 90 new TaskMatcher()
.param("resourceKey", Key.create(resource).getString()) .etaDelta(Duration.standardSeconds(75), Duration.standardSeconds(105)) // expected: 90
.param("requestingClientId", requestingClientId) .param("resourceKey", resource.createVKey().getOfyKey().getString())
.param("serverTransactionId", trid.getServerTransactionId()) .param("requestingClientId", requestingClientId)
.param("isSuperuser", Boolean.toString(isSuperuser)) .param("serverTransactionId", trid.getServerTransactionId())
.param("requestedTime", clock.nowUtc().toString()); .param("isSuperuser", Boolean.toString(isSuperuser))
.param("requestedTime", clock.nowUtc().toString());
trid.getClientTransactionId() trid.getClientTransactionId()
.ifPresent(clTrid -> expected.param("clientTransactionId", clTrid)); .ifPresent(clTrid -> expected.param("clientTransactionId", clTrid));
assertTasksEnqueued("async-delete-pull", expected); assertTasksEnqueued("async-delete-pull", expected);

View file

@ -66,7 +66,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key;
import google.registry.batch.ResaveEntityAction; import google.registry.batch.ResaveEntityAction;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.EppException.UnimplementedExtensionException; import google.registry.flows.EppException.UnimplementedExtensionException;
@ -311,7 +310,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.method("POST") .method("POST")
.header("Host", "backend.hostname.fake") .header("Host", "backend.hostname.fake")
.header("content-type", "application/x-www-form-urlencoded") .header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, Key.create(domain).getString()) .param(PARAM_RESOURCE_KEY, domain.createVKey().getOfyKey().getString())
.param(PARAM_REQUESTED_TIME, clock.nowUtc().toString()) .param(PARAM_REQUESTED_TIME, clock.nowUtc().toString())
.param(PARAM_RESAVE_TIMES, clock.nowUtc().plusDays(5).toString()) .param(PARAM_RESAVE_TIMES, clock.nowUtc().plusDays(5).toString())
.etaDelta(when.minus(standardSeconds(30)), when.plus(standardSeconds(30)))); .etaDelta(when.minus(standardSeconds(30)), when.plus(standardSeconds(30))));

View file

@ -58,7 +58,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.googlecode.objectify.Key;
import google.registry.batch.ResaveEntityAction; import google.registry.batch.ResaveEntityAction;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.EppRequestSource; import google.registry.flows.EppRequestSource;
@ -518,7 +517,7 @@ class DomainTransferRequestFlowTest
.method("POST") .method("POST")
.header("Host", "backend.hostname.fake") .header("Host", "backend.hostname.fake")
.header("content-type", "application/x-www-form-urlencoded") .header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, Key.create(domain).getString()) .param(PARAM_RESOURCE_KEY, domain.createVKey().getOfyKey().getString())
.param(PARAM_REQUESTED_TIME, clock.nowUtc().toString()) .param(PARAM_REQUESTED_TIME, clock.nowUtc().toString())
.etaDelta( .etaDelta(
registry.getAutomaticTransferLength().minus(standardSeconds(30)), registry.getAutomaticTransferLength().minus(standardSeconds(30)),

View file

@ -46,7 +46,6 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.googlecode.objectify.Key;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.EppRequestSource; import google.registry.flows.EppRequestSource;
import google.registry.flows.ResourceFlowTestCase; import google.registry.flows.ResourceFlowTestCase;
@ -220,7 +219,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
assertTasksEnqueued( assertTasksEnqueued(
QUEUE_ASYNC_HOST_RENAME, QUEUE_ASYNC_HOST_RENAME,
new TaskMatcher() new TaskMatcher()
.param("hostKey", Key.create(renamedHost).getString()) .param("hostKey", renamedHost.createVKey().getOfyKey().getString())
.param("requestedTime", clock.nowUtc().toString())); .param("requestedTime", clock.nowUtc().toString()));
} }