Skip to content

Commit c82011b

Browse files
authored
feat: Add option to control resource cleanup failure for IT (#35287)
1 parent 2a499b6 commit c82011b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

it/common/src/main/java/org/apache/beam/it/common/utils/ResourceManagerUtils.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ public static void checkValidProjectId(String idToCheck) {
137137
* @param managers Varargs of the managers to clean
138138
*/
139139
public static void cleanResources(ResourceManager... managers) {
140+
cleanResources(false, managers);
141+
}
142+
143+
/**
144+
* Cleanup Resources from the given ResourceManagers. It will guarantee that all the cleanups are
145+
* invoked, but still throws / bubbles the first exception at the end if something went wrong.
146+
*
147+
* @param failOnCleanup Throw exception if cleanup fails.
148+
* @param managers Varargs of the managers to clean
149+
*/
150+
public static void cleanResources(boolean failOnCleanup, ResourceManager... managers) {
140151

141152
if (managers == null || managers.length == 0) {
142153
return;
@@ -159,8 +170,12 @@ public static void cleanResources(ResourceManager... managers) {
159170
}
160171
}
161172

162-
if (bubbleException != null) {
173+
if (bubbleException != null && failOnCleanup) {
163174
throw new RuntimeException("Error cleaning up resources", bubbleException);
175+
} else if (bubbleException != null) {
176+
LOG.warn(
177+
"Error cleaning up resources. This is not configured to fail the test: {}",
178+
bubbleException.getMessage());
164179
}
165180
}
166181

0 commit comments

Comments
 (0)