Skip to content

Commit

Permalink
Adjusted clear not to collide when parallel test are running.
Browse files Browse the repository at this point in the history
  • Loading branch information
mderka committed Mar 4, 2016
1 parent 8684506 commit 76a5cf3
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,21 @@ public class ITDnsTest {
.delete(A_RECORD_ZONE1)
.delete(AAAA_RECORD_ZONE1)
.build();
public static final List<String> ZONE_NAMES = ImmutableList.of(ZONE_NAME1,
ZONE_NAME_EMPTY_DESCRIPTION);

public static void clear() {
Page<Zone> zones = DNS.listZones();
Iterator<Zone> zoneIterator = zones.iterateAll();
while (zoneIterator.hasNext()) {
Zone zone = zoneIterator.next();
for (String zoneName : ZONE_NAMES) {
Zone zone = DNS.getZone(zoneName);
List<DnsRecord> toDelete = new LinkedList<>();
if (zone.name().startsWith(PREFIX)) {
Iterator<DnsRecord> dnsRecordIterator = zone.listDnsRecords().iterateAll();
while (dnsRecordIterator.hasNext()) {
DnsRecord record = dnsRecordIterator.next();
if (zone != null) {
Iterator<ChangeRequest> iterator = zone.listChangeRequests().iterateAll();
while (iterator.hasNext()) {
waitUntilComplete(zoneName, iterator.next().id());
}
Iterator<DnsRecord> recordIterator = zone.listDnsRecords().iterateAll();
while (recordIterator.hasNext()) {
DnsRecord record = recordIterator.next();
if (!ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA).contains(record.type())) {
toDelete.add(record);
}
Expand All @@ -130,7 +134,7 @@ private static List<Zone> filter(Iterator<Zone> iterator) {
List<Zone> result = new LinkedList<>();
while (iterator.hasNext()) {
Zone zone = iterator.next();
if (zone.name().startsWith(PREFIX)) {
if (ZONE_NAMES.contains(zone.name())) {
result.add(zone);
}
}
Expand Down

0 comments on commit 76a5cf3

Please sign in to comment.