Skip to content

LocalDnsHelper should add the default change upon creating a zone. #746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,15 @@ Response createZone(String projectId, ManagedZone zone, String... fields) {
completeZone.setId(BigInteger.valueOf(Math.abs(ID_GENERATOR.nextLong() % Long.MAX_VALUE)));
completeZone.setNameServers(randomNameservers());
ZoneContainer zoneContainer = new ZoneContainer(completeZone);
zoneContainer.dnsRecords().set(defaultRecords(completeZone));
ImmutableSortedMap<String, ResourceRecordSet> defaultsRecords = defaultRecords(completeZone);
zoneContainer.dnsRecords().set(defaultsRecords);
Change change = new Change();
change.setAdditions(ImmutableList.copyOf(defaultsRecords.values()));
change.setStatus("done");
change.setId("0");
change.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC()
.print(System.currentTimeMillis()));
zoneContainer.changes().add(change);
ProjectContainer projectContainer = findProject(projectId);
ZoneContainer oldValue = projectContainer.zones().putIfAbsent(
completeZone.getName(), zoneContainer);
Expand Down Expand Up @@ -718,8 +726,9 @@ Response createChange(String projectId, String zoneName, Change change, String..
completeChange.setDeletions(ImmutableList.copyOf(change.getDeletions()));
}
/* We need to set ID for the change. We are working in concurrent environment. We know that the
element fell on an index between 0 and maxId, so we will reset all IDs in this range (all of
them are valid for the respective objects). */
element fell on an index between 1 and maxId (index 0 is the default change which creates SOA
and NS), so we will reset all IDs between 0 and maxId (all of them are valid for the respective
objects). */
ConcurrentLinkedQueue<Change> changeSequence = zoneContainer.changes();
changeSequence.add(completeChange);
int maxId = changeSequence.size();
Expand All @@ -728,7 +737,7 @@ Response createChange(String projectId, String zoneName, Change change, String..
if (index == maxId) {
break;
}
c.setId(String.valueOf(++index));
c.setId(String.valueOf(index++));
}
completeChange.setStatus("pending");
completeChange.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,14 +850,14 @@ public void testListChanges() {
RPC.create(ZONE1, EMPTY_RPC_OPTIONS);
Iterable<Change> results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results();
ImmutableList<Change> changes = ImmutableList.copyOf(results);
assertEquals(0, changes.size());
assertEquals(1, changes.size());
// zone has changes
RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS);
RPC.applyChangeRequest(ZONE1.getName(), CHANGE2, EMPTY_RPC_OPTIONS);
RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS);
results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results();
changes = ImmutableList.copyOf(results);
assertEquals(3, changes.size());
assertEquals(4, changes.size());
// error in options
Map<DnsRpc.Option, Object> options = new HashMap<>();
options.put(DnsRpc.Option.PAGE_SIZE, 0);
Expand All @@ -881,14 +881,14 @@ public void testListChanges() {
options.put(DnsRpc.Option.PAGE_SIZE, 15);
results = RPC.listChangeRequests(ZONE1.getName(), options).results();
changes = ImmutableList.copyOf(results);
assertEquals(3, changes.size());
assertEquals(4, changes.size());
options = new HashMap<>();
options.put(DnsRpc.Option.SORTING_ORDER, "descending");
results = RPC.listChangeRequests(ZONE1.getName(), options).results();
ImmutableList<Change> descending = ImmutableList.copyOf(results);
results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results();
ImmutableList<Change> ascending = ImmutableList.copyOf(results);
int size = 3;
int size = 4;
assertEquals(size, descending.size());
for (int i = 0; i < size; i++) {
assertEquals(descending.get(i), ascending.get(size - i - 1));
Expand Down