mirror of
https://github.com/google/nomulus.git
synced 2025-05-28 16:30:12 +02:00
Add asynchronous scheduled actions to re-save entities
This is used in the domain transfer and delete flows, both of which are asynchronous flows that have implicit default actions that will be taken at some point in the future. This CL adds scheduled re-saves to take place soon after those default actions would become effective, so that they can be re-saved quickly if so. Unfortunately the redemption grace period on our TLDs is 35 days, which exceeds the 30 day maximum task ETA in App Engine, so these won't actually fire. That's fine though; the deletion is actually effective as of 5 days, and this is just removing the grace period. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=201345274
This commit is contained in:
parent
87d1a1c2a3
commit
6f2e663b72
20 changed files with 573 additions and 103 deletions
83
javatests/google/registry/batch/ResaveEntityActionTest.java
Normal file
83
javatests/google/registry/batch/ResaveEntityActionTest.java
Normal file
|
@ -0,0 +1,83 @@
|
|||
// Copyright 2018 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.batch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistDomainWithDependentResources;
|
||||
import static google.registry.testing.DatastoreHelper.persistDomainWithPendingTransfer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.ShardableTestCase;
|
||||
import google.registry.util.Clock;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link ResaveEntityAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ResaveEntityActionTest extends ShardableTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastore().withTaskQueue().build();
|
||||
|
||||
private final Clock clock = new FakeClock(DateTime.parse("2016-02-11T10:00:00Z"));
|
||||
private final Response response = mock(Response.class);
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
createTld("tld");
|
||||
}
|
||||
|
||||
private void runAction(Key<ImmutableObject> resourceKey, DateTime requestedTime) {
|
||||
ResaveEntityAction action = new ResaveEntityAction(resourceKey, requestedTime, clock, response);
|
||||
action.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_domainPendingTransfer_isResavedAndTransferCompleted() {
|
||||
DomainResource domain =
|
||||
persistDomainWithPendingTransfer(
|
||||
persistDomainWithDependentResources(
|
||||
"domain",
|
||||
"tld",
|
||||
persistActiveContact("jd1234"),
|
||||
DateTime.parse("2016-02-06T10:00:00Z"),
|
||||
DateTime.parse("2016-02-06T10:00:00Z"),
|
||||
DateTime.parse("2017-01-02T10:11:00Z")),
|
||||
DateTime.parse("2016-02-06T10:00:00Z"),
|
||||
DateTime.parse("2016-02-11T10:00:00Z"),
|
||||
DateTime.parse("2017-01-02T10:11:00Z"),
|
||||
DateTime.parse("2016-02-06T10:00:00Z"));
|
||||
assertThat(domain.getCurrentSponsorClientId()).isEqualTo("TheRegistrar");
|
||||
runAction(Key.create(domain), DateTime.parse("2016-02-06T10:00:01Z"));
|
||||
DomainResource resavedDomain = ofy().load().entity(domain).now();
|
||||
assertThat(resavedDomain.getCurrentSponsorClientId()).isEqualTo("NewRegistrar");
|
||||
verify(response).setPayload("Entity re-saved.");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue