Skip to content

Commit 36b57b0

Browse files
authored
test(teardown): refactored teardown section of test (#254)
1 parent 70ecdfd commit 36b57b0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

aiplatform/snippets/src/test/java/aiplatform/CreateTrainingPipelineCustomJobSampleTest.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static junit.framework.TestCase.assertNotNull;
2121

22+
import io.grpc.StatusRuntimeException;
2223
import java.io.ByteArrayOutputStream;
2324
import java.io.IOException;
2425
import java.io.PrintStream;
@@ -75,7 +76,22 @@ public void tearDown()
7576
TimeUnit.MINUTES.sleep(2);
7677

7778
// Delete the Training Pipeline
78-
DeleteTrainingPipelineSample.deleteTrainingPipelineSample(PROJECT, trainingPipelineId);
79+
int retryCount = 3;
80+
while (retryCount > 0) {
81+
retryCount--;
82+
try {
83+
DeleteTrainingPipelineSample.deleteTrainingPipelineSample(PROJECT, trainingPipelineId);
84+
// if delete operation is successful, break out of the loop and continue
85+
break;
86+
} catch (StatusRuntimeException | ExecutionException ex) {
87+
// wait for another 1 minute, then retry
88+
System.out.println("Retrying (due to unfinished cancellation operation)...");
89+
TimeUnit.MINUTES.sleep(1);
90+
} catch (Exception otherExceptions) {
91+
// other exception, let them throw
92+
throw otherExceptions;
93+
}
94+
}
7995

8096
// Assert
8197
String deleteResponse = bout.toString();

0 commit comments

Comments
 (0)