mirror of
https://github.com/google/nomulus.git
synced 2025-07-30 22:46:26 +02:00
Dual-read RegistryCursor prior to Cursor cutover
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125057857
This commit is contained in:
parent
5a4877805b
commit
3e0963dfdb
2 changed files with 55 additions and 2 deletions
|
@ -23,6 +23,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
|||
import com.googlecode.objectify.VoidWork;
|
||||
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.common.Cursor;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
@ -31,7 +32,7 @@ import org.junit.Test;
|
|||
public class RegistryCursorTest extends EntityTestCase {
|
||||
|
||||
@Test
|
||||
public void test_persistence() {
|
||||
public void testPersistence() {
|
||||
createTld("tld");
|
||||
clock.advanceOneMilli();
|
||||
final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z");
|
||||
|
@ -43,4 +44,43 @@ public class RegistryCursorTest extends EntityTestCase {
|
|||
assertThat(RegistryCursor.load(Registry.get("tld"), BRDA)).isAbsent();
|
||||
assertThat(RegistryCursor.load(Registry.get("tld"), RDE_UPLOAD)).hasValue(time);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_dualRead_newOverOld() {
|
||||
createTld("tld");
|
||||
final DateTime newCursorTime = DateTime.parse("2012-07-12T03:30:00.000Z");
|
||||
final DateTime oldCursorTime = DateTime.parse("2012-07-11T03:30:00.000Z");
|
||||
ofy().transact(
|
||||
new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
ofy()
|
||||
.save()
|
||||
.entities(
|
||||
// We can't use RegistryCursor.save() since dual-writing happens there.
|
||||
RegistryCursor.create(Registry.get("tld"), RDE_UPLOAD, oldCursorTime),
|
||||
Cursor.create(
|
||||
Cursor.CursorType.RDE_UPLOAD, newCursorTime, Registry.get("tld")))
|
||||
.now();
|
||||
}
|
||||
});
|
||||
assertThat(RegistryCursor.load(Registry.get("tld"), RDE_UPLOAD)).hasValue(newCursorTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_dualRead_onlyOld() {
|
||||
createTld("tld");
|
||||
final DateTime oldCursorTime = DateTime.parse("2012-07-11T03:30:00.000Z");
|
||||
ofy().transact(
|
||||
new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
ofy()
|
||||
.save()
|
||||
.entity(RegistryCursor.create(Registry.get("tld"), RDE_UPLOAD, oldCursorTime))
|
||||
.now();
|
||||
}
|
||||
});
|
||||
assertThat(RegistryCursor.load(Registry.get("tld"), RDE_UPLOAD)).hasValue(oldCursorTime);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue