forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#3024] improvement(IT): close containers and upload container …
…log after all tests are finished (apache#3197) ### What changes were proposed in this pull request? close containers and upload container log after all tests are finished ### Why are the changes needed? Fix: apache#3024 ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? existing ITs --------- Co-authored-by: zhanghan18 <[email protected]> Co-authored-by: Qi Yu <[email protected]>
- Loading branch information
Showing
5 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...src/test/java/com/datastrato/gravitino/integration/test/util/CloseContainerExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.integration.test.util; | ||
|
||
import com.datastrato.gravitino.integration.test.container.ContainerSuite; | ||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This is an extension for juint 5, which aims to perform certain operations (such as resource | ||
* recycling, etc.) after all test executions are completed (regardless of success or failure). You | ||
* can Refer to {@link AbstractIT} for more information. | ||
*/ | ||
public class CloseContainerExtension implements BeforeAllCallback { | ||
@Override | ||
public void beforeAll(ExtensionContext extensionContext) { | ||
synchronized (CloseContainerExtension.class) { | ||
extensionContext | ||
.getRoot() | ||
.getStore(ExtensionContext.Namespace.GLOBAL) | ||
.getOrComputeIfAbsent(CloseableContainer.class); | ||
} | ||
} | ||
|
||
private static class CloseableContainer implements ExtensionContext.Store.CloseableResource { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(CloseableContainer.class); | ||
private static final ContainerSuite CONTAINER_SUITE = ContainerSuite.getInstance(); | ||
|
||
@Override | ||
public void close() { | ||
try { | ||
CONTAINER_SUITE.close(); | ||
LOGGER.info("Containers were closed successfully"); | ||
} catch (Exception e) { | ||
LOGGER.warn("Containers were not closed as expected", e); | ||
} | ||
} | ||
} | ||
} |