Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update Job cleanup code to wait until jobs can be deleted.

Add counters for loops in Job integration tests, to prevent rogue jobs from makeing test runs hang.
  • Loading branch information...
commit 63cc5630cf176f6dd62a230edaf1d238129f84d2 1 parent d09c8f0
@jcookems jcookems authored
View
19 ...zure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java
@@ -166,11 +166,19 @@ private static void removeAllTestJobs() {
// Job can't be deleted when it's state is
// canceling, scheduled,queued or processing
try {
- if (job.getState() == JobState.Scheduled || job.getState() == JobState.Queued
- || job.getState() == JobState.Processing) {
+ if (isJobBusy(job.getState())) {
service.action(Job.cancel(job.getId()));
+ job = service.get(Job.get(job.getId()));
}
- else if (job.getState() != JobState.Canceling) {
+
+ int retryCounter = 0;
+ while (isJobBusy(job.getState()) && retryCounter < 10) {
+ Thread.sleep(2000);
+ job = service.get(Job.get(job.getId()));
+ retryCounter++;
+ }
+
+ if (!isJobBusy(job.getState())) {
service.delete(Job.delete(job.getId()));
}
else {
@@ -188,6 +196,11 @@ else if (job.getState() != JobState.Canceling) {
}
}
+ private static boolean isJobBusy(JobState state) {
+ return state == JobState.Canceling || state == JobState.Scheduled || state == JobState.Queued
+ || state == JobState.Processing;
+ }
+
interface ComponentDelegate {
void verifyEquals(String message, Object expected, Object actual);
}
View
10 ...azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java
@@ -231,9 +231,11 @@ public void deleteJobSuccess() throws ServiceException, InterruptedException {
JobInfo jobInfo = createJob(testJobPrefix + "deleteJobSuccess");
service.action(Job.cancel(jobInfo.getId()));
JobInfo cancellingJobInfo = service.get(Job.get(jobInfo.getId()));
- while (cancellingJobInfo.getState() == JobState.Canceling) {
+ int retryCounter = 0;
+ while (cancellingJobInfo.getState() == JobState.Canceling && retryCounter < 10) {
Thread.sleep(2000);
cancellingJobInfo = service.get(Job.get(jobInfo.getId()));
+ retryCounter++;
}
// Act
@@ -296,9 +298,11 @@ public void canGetErrorDetailsFromTask() throws Exception {
.addTaskCreator(getTaskCreator(0)));
JobInfo currentJobInfo = actualJob;
- while (currentJobInfo.getState().getCode() < 3) {
+ int retryCounter = 0;
+ while (currentJobInfo.getState().getCode() < 3 && retryCounter < 10) {
+ Thread.sleep(10000);
currentJobInfo = service.get(Job.get(actualJob.getId()));
- Thread.sleep(3000);
+ retryCounter++;
}
ListResult<TaskInfo> tasks = service.list(Task.list(actualJob.getTasksLink()));
Please sign in to comment.
Something went wrong with that request. Please try again.