Cut over to batched async deletion for contacts/hosts

Also consolidates the DNS refresh functionality in AsyncFlowUtils that was
being used by HostUpdateFlow into AsyncFlowEnqueuer.

TESTED=I threw together some batch scripts to create dozens of contacts on
alpha and then request their deletion, and the [] ran fine and
successfully deleted them in batches.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133714691
This commit is contained in:
mcilwain 2016-09-20 09:29:39 -07:00 committed by Ben McIlwain
parent 65ff6b45d1
commit 2dcac3ca68
11 changed files with 74 additions and 190 deletions

View file

@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
@ -34,8 +35,10 @@ import google.registry.model.index.EppResourceIndexBucket;
import google.registry.model.tmch.ClaimsListShard.ClaimsListRevision;
import google.registry.model.tmch.ClaimsListShard.ClaimsListSingleton;
import google.registry.testing.ExceptionRule;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import google.registry.util.TypeUtils.TypeInstantiator;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.Rule;
import org.junit.Test;
@ -136,4 +139,18 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
assertThat(indices.get(0).getBucket())
.isEqualTo(EppResourceIndexBucket.getBucketKey(Key.create(resource)));
}
/** Asserts the presence of a single enqueued async contact or host deletion */
protected static <T extends EppResource> void assertAsyncDeletionTaskEnqueued(
T resource, String requestingClientId, boolean isSuperuser) throws Exception {
String expectedPayload =
String.format(
"resourceKey=%s&requestingClientId=%s&isSuperuser=%s",
Key.create(resource).getString(), requestingClientId, Boolean.toString(isSuperuser));
assertTasksEnqueued(
"async-delete-pull",
new TaskMatcher()
.etaDelta(Duration.standardSeconds(75), Duration.standardSeconds(105)) // expected: 90
.payload(expectedPayload));
}
}