Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,19 @@ private <T extends HasMetadata> void createOrUpdateResource(
try {
cf.get(TestFrameConstants.GLOBAL_TIMEOUT_MEDIUM, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
LOGGER.error("Timeout waiting for resource to be ready", e);
throw new RuntimeException(e);
LOGGER.error("Timeout waiting for resource {}/{} to be ready",
resource.getMetadata().getNamespace(),
resource.getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Exception during wait for resources to be ready", e);
throw new RuntimeException(e);
LOGGER.error("Exception during wait for resource {}/{} to be ready",
resource.getMetadata().getNamespace(),
resource.getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
}
}
}
Expand All @@ -540,11 +548,19 @@ private <T extends HasMetadata> void createOrUpdateResource(
try {
cf.get(type.getTimeoutForResourceReadiness(), TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
LOGGER.error("Timeout waiting for resource to be ready", e);
throw new RuntimeException(e);
LOGGER.error("Timeout waiting for resource {}/{} to be ready",
resource.getMetadata().getNamespace(),
resource.getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Exception during wait for resource to be ready", e);
throw new RuntimeException(e);
LOGGER.error("Exception during wait for resource {}/{} to be ready",
resource.getMetadata().getNamespace(),
resource.getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
}
}
}
Expand All @@ -556,7 +572,7 @@ private <T extends HasMetadata> void createOrUpdateResource(
CompletableFuture.allOf(waiters.toArray(new CompletableFuture[0])).get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Exception during wait for resources to be ready", e);
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -820,7 +836,7 @@ public void deleteResources(boolean async) {
try {
item.throwableRunner().run();
} catch (Exception e) {
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage(), e);
}
}, EXECUTOR);
if (async) {
Expand All @@ -829,11 +845,19 @@ public void deleteResources(boolean async) {
try {
cf.get(TestFrameConstants.GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
LOGGER.error("Timeout waiting for deletion of resource", e);
throw new RuntimeException(e);
LOGGER.error("Timeout waiting for deletion of resource {}/{}",
item.resource().getMetadata().getNamespace(),
item.resource().getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Exception during deletion or wait for resource to be deleted", e);
throw new RuntimeException(e);
LOGGER.error("Exception during deletion or wait for resource {}/{} to be deleted",
item.resource().getMetadata().getNamespace(),
item.resource().getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
}
}
count.decrementAndGet();
Expand All @@ -860,10 +884,10 @@ public void deleteResources(boolean async) {
.get(TestFrameConstants.GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
LOGGER.error("Timeout exception during wait for resources to be deleted");
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage(), e);
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Exception during wait for resources to be deleted", e);
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -915,7 +939,7 @@ private void writeResourceAsYaml(HasMetadata res) {
(res.getMetadata().getNamespace() == null ? "" : res.getMetadata().getNamespace() + "-") +
res.getMetadata().getName() + ".yaml"), yaml, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage(), e);
}
}
}
Expand All @@ -931,11 +955,19 @@ private void writeResourceAsYaml(HasMetadata res) {
try {
cf.get(TestFrameConstants.GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
LOGGER.error("Timeout waiting for deletion of resource", e);
throw new RuntimeException(e);
LOGGER.error("Timeout waiting for deletion of resource {}/{}",
res.getMetadata().getNamespace(),
res.getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Exception during wait for resource to be deleted", e);
throw new RuntimeException(e);
LOGGER.error("Exception during wait for resource {}/{} to be deleted",
res.getMetadata().getNamespace(),
res.getMetadata().getName(),
e
);
throw new RuntimeException(e.getMessage(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ void testHandleAsyncDeletionBeingCalled() {
@Test
void testHandleAsyncDeletionThrowsException() {
CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
throw new RuntimeException();
throw new RuntimeException("This is test exception");
});

assertThrows(RuntimeException.class, () -> kubeResourceManager.handleAsyncDeletion(List.of(cf)));
RuntimeException runtimeException = assertThrows(RuntimeException.class,
() -> kubeResourceManager.handleAsyncDeletion(List.of(cf)));
assertTrue(runtimeException.getMessage().contains("This is test exception"));
}
}
Loading