mirror of
https://github.com/google/nomulus.git
synced 2025-07-03 01:33:29 +02:00
Make DnsWriter truly atomic
Right now - if there's an error during DnsWriter.publish*, all the publish from before that error will be committed, while all the publish after that error will not. More than that - in some writers partial publishes can be committed, depending on implementation. This defines a new contract that publish* are only committed when .commit is called. That way any error will simply mean no publish is committed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=165708063
This commit is contained in:
parent
fcb554947c
commit
d5ac03aae4
8 changed files with 204 additions and 90 deletions
|
@ -174,7 +174,7 @@ public class CloudDnsWriterTest {
|
|||
|
||||
private void verifyZone(ImmutableSet<ResourceRecordSet> expectedRecords) throws Exception {
|
||||
// Trigger zone changes
|
||||
writer.close();
|
||||
writer.commit();
|
||||
|
||||
assertThat(stubZone).containsExactlyElementsIn(expectedRecords);
|
||||
}
|
||||
|
@ -416,12 +416,12 @@ public class CloudDnsWriterTest {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void retryMutateZoneOnError() throws Exception {
|
||||
try (CloudDnsWriter spyWriter = spy(writer)) {
|
||||
when(mutateZoneCallable.call()).thenThrow(ZoneStateException.class).thenReturn(null);
|
||||
when(spyWriter.getMutateZoneCallback(
|
||||
Matchers.<ImmutableMap<String, ImmutableSet<ResourceRecordSet>>>any()))
|
||||
.thenReturn(mutateZoneCallable);
|
||||
}
|
||||
CloudDnsWriter spyWriter = spy(writer);
|
||||
when(mutateZoneCallable.call()).thenThrow(ZoneStateException.class).thenReturn(null);
|
||||
when(spyWriter.getMutateZoneCallback(
|
||||
Matchers.<ImmutableMap<String, ImmutableSet<ResourceRecordSet>>>any()))
|
||||
.thenReturn(mutateZoneCallable);
|
||||
spyWriter.commit();
|
||||
|
||||
verify(mutateZoneCallable, times(2)).call();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue