adutra commented on code in PR #4790:
URL: https://github.com/apache/polaris/pull/4790#discussion_r3418720881
##########
runtime/service/src/intTest/java/org/apache/polaris/service/it/RestCatalogMinIOSpecialIT.java:
##########
@@ -124,27 +136,24 @@ public class RestCatalogMinIOSpecialIT {
private PrincipalWithCredentials principalCredentials;
private String catalogName;
- @BeforeAll
- static void setup(
- PolarisApiEndpoints apiEndpoints,
- @Minio(accessKey = ACCESS_KEY, secretKey = SECRET_KEY) MinioAccess
minioAccess,
- ClientCredentials credentials) {
- s3Client = minioAccess.s3Client();
- endpoints = apiEndpoints;
- client = polarisClient(endpoints);
- adminToken = client.obtainToken(credentials);
- managementApi = client.managementApi(adminToken);
- storageBase = minioAccess.s3BucketUri(BUCKET_URI_PREFIX);
- endpoint = minioAccess.s3endpoint();
- }
-
@AfterAll
static void close() throws Exception {
client.close();
}
@BeforeEach
- public void before(TestInfo testInfo) {
+ public void before(
+ TestInfo testInfo, PolarisApiEndpoints apiEndpoints, ClientCredentials
credentials) {
+ if (initialized.compareAndSet(false, true)) {
Review Comment:
You can achieve a better design by using
`@TestInstance(TestInstance.Lifecycle.PER_CLASS)`:
```java
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class RestCatalogMinIOSpecialIT {
// ...
@Minio MinioAccess minioAccess;
private PolarisApiEndpoints endpoints;
private PolarisClient client;
private String adminToken;
private ManagementApi managementApi;
private URI storageBase;
private String endpoint;
private S3Client s3Client;
private CatalogApi catalogApi;
private String principalRoleName;
private PrincipalWithCredentials principalCredentials;
private String catalogName;
@AfterAll
void close() throws Exception {
client.close();
}
@BeforeAll
public void beforeAll(PolarisApiEndpoints apiEndpoints, ClientCredentials
credentials) {
endpoints = apiEndpoints;
s3Client = minioAccess.s3Client();
client = polarisClient(endpoints);
adminToken = client.obtainToken(credentials);
managementApi = client.managementApi(adminToken);
storageBase = minioAccess.s3BucketUri(BUCKET_URI_PREFIX);
endpoint = minioAccess.s3endpoint();
}
@BeforeEach
public void before(TestInfo testInfo) {
String principalName = client.newEntityName("test-user");
principalRoleName = client.newEntityName("test-admin");
principalCredentials =
managementApi.createPrincipalWithRole(principalName, principalRoleName);
String principalToken = client.obtainToken(principalCredentials);
catalogApi = client.catalogApi(principalToken);
catalogName =
client.newEntityName(testInfo.getTestMethod().orElseThrow().getName());
}
```
##########
runtime/service/src/intTest/java/org/apache/polaris/service/it/RestCatalogRustFSSpecialIT.java:
##########
@@ -112,6 +121,9 @@ public class RestCatalogRustFSSpecialIT {
required(1, "id", Types.IntegerType.get(), "doc"),
optional(2, "data", Types.StringType.get()));
+ @Rustfs static RustfsAccess rustfsAccess;
+
+ private static final AtomicBoolean initialized = new AtomicBoolean(false);
Review Comment:
Same here: `@TestInstance(TestInstance.Lifecycle.PER_CLASS)` is probably
better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]