Skip to content

Commit

Permalink
Rephrased doc and improved IT.
Browse files Browse the repository at this point in the history
  • Loading branch information
mderka committed Apr 4, 2016
1 parent 0f3dc9a commit 74a4cf6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ public ChangeRequest reload(Dns.ChangeRequestOption... options) {
}

/**
* Returns {@code true} if the change request has been completed. The function makes an API call
* to Google Cloud DNS in order to request the status update only if the status of the change
* request is {@link Status#PENDING}. If the status is already {@link Status#DONE}, the method
* returns {@code true} without an API call.
* Returns {@code true} if the change request has been completed. If the status is not {@link
* Status#DONE} already, the method makes an API call to Google Cloud DNS to update the change
* request first.
*
* @throws DnsException upon failure of the API call or if the associated zone was not found
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ private static void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRe
private static void waitForChangeToComplete(String zoneName, String changeId) {
ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId,
Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS));
waitForChangeToComplete(changeRequest);
}

private static void waitForChangeToComplete(ChangeRequest changeRequest) {
while (!changeRequest.isDone()) {
try {
Thread.sleep(500);
Expand Down Expand Up @@ -526,9 +530,9 @@ public void testCreateChange() {
assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE)
.contains(created.status()));
assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1"));
waitForChangeToComplete(ZONE1.name(), "1");
DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(ZONE1.name(), "2");
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(created);
// with options
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1,
Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID));
Expand All @@ -537,29 +541,29 @@ public void testCreateChange() {
assertTrue(created.deletions().isEmpty());
assertEquals("3", created.generatedId());
assertNull(created.status());
waitForChangeToComplete(ZONE1.name(), "3");
DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(ZONE1.name(), "4");
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1,
Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS));
assertTrue(created.additions().isEmpty());
assertNull(created.startTimeMillis());
assertTrue(created.deletions().isEmpty());
assertEquals("5", created.generatedId());
assertNotNull(created.status());
waitForChangeToComplete(ZONE1.name(), "5");
DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(ZONE1.name(), "6");
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1,
Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME));
assertTrue(created.additions().isEmpty());
assertNotNull(created.startTimeMillis());
assertTrue(created.deletions().isEmpty());
assertEquals("7", created.generatedId());
assertNull(created.status());
waitForChangeToComplete(ZONE1.name(), "7");
DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(ZONE1.name(), "8");
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1);
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1,
Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS));
assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions());
Expand All @@ -568,16 +572,16 @@ public void testCreateChange() {
assertEquals("9", created.generatedId());
assertNull(created.status());
// finishes with delete otherwise we cannot delete the zone
waitForChangeToComplete(ZONE1.name(), "9");
waitForChangeToComplete(created);
created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1,
Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS));
waitForChangeToComplete(ZONE1.name(), "10");
waitForChangeToComplete(created);
assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions());
assertNull(created.startTimeMillis());
assertTrue(created.additions().isEmpty());
assertEquals("10", created.generatedId());
assertNull(created.status());
waitForChangeToComplete(ZONE1.name(), "10");
waitForChangeToComplete(created);
} finally {
clear();
}
Expand Down

0 comments on commit 74a4cf6

Please sign in to comment.