This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new db4e8790a9 HDDS-10119. Assertions on object creationTime fail with
Java 17 (#6008)
db4e8790a9 is described below
commit db4e8790a91a9156f6c857e28efa5b8a0f3cd036
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Wed Jan 17 08:26:36 2024 +0100
HDDS-10119. Assertions on object creationTime fail with Java 17 (#6008)
---
.../main/java/org/apache/ozone/test/GenericTestUtils.java | 13 +++++++++++++
.../org/apache/hadoop/ozone/client/TestOzoneClient.java | 5 +++--
.../ozone/client/rpc/TestOzoneAtRestEncryption.java | 7 ++++---
.../ozone/client/rpc/TestOzoneRpcClientAbstract.java | 15 ++++++++-------
.../hadoop/ozone/client/rpc/TestSecureOzoneRpcClient.java | 3 ++-
.../hadoop/ozone/scm/TestStorageContainerManagerHA.java | 3 ++-
6 files changed, 32 insertions(+), 14 deletions(-)
diff --git
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
index 406a58768a..92e059296c 100644
---
a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
+++
b/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/GenericTestUtils.java
@@ -24,6 +24,7 @@ import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
+import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
@@ -73,6 +74,18 @@ public abstract class GenericTestUtils {
"target" + File.separator + "test" + File.separator + "data";
}
+ /**
+ * Return current time in millis as an {@code Instant}. This may be
+ * before {@link Instant#now()}, since the latter includes nanoseconds, too.
+ * This is needed for some tests that verify volume/bucket creation time,
+ * which also uses {@link Instant#ofEpochMilli(long)}.
+ *
+ * @return current time as {@code Instant};
+ */
+ public static Instant getTestStartTime() {
+ return Instant.ofEpochMilli(System.currentTimeMillis());
+ }
+
/**
* Get the (created) base directory for tests.
*
diff --git
a/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneClient.java
b/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneClient.java
index 42b9d80767..fc10143a47 100644
---
a/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneClient.java
+++
b/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneClient.java
@@ -47,6 +47,7 @@ import java.util.UUID;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.hdds.client.ReplicationFactor.ONE;
+import static org.apache.ozone.test.GenericTestUtils.getTestStartTime;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -138,7 +139,7 @@ public class TestOzoneClient {
@Test
public void testCreateBucket()
throws IOException {
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
store.createVolume(volumeName);
@@ -152,7 +153,7 @@ public class TestOzoneClient {
@Test
public void testPutKeyRatisOneNode() throws IOException {
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String value = "sample value";
OzoneBucket bucket = getOzoneBucket();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java
index ab09bc2433..08df9c9411 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java
@@ -78,6 +78,7 @@ import org.apache.ozone.test.GenericTestUtils;
import static org.apache.hadoop.hdds.HddsConfigKeys.OZONE_METADATA_DIRS;
import static org.apache.hadoop.hdds.client.ReplicationFactor.ONE;
import static org.apache.hadoop.hdds.client.ReplicationType.RATIS;
+import static org.apache.ozone.test.GenericTestUtils.getTestStartTime;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -229,7 +230,7 @@ class TestOzoneAtRestEncryption {
static void createAndVerifyStreamKeyData(OzoneBucket bucket)
throws Exception {
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String keyName = UUID.randomUUID().toString();
String value = "sample value";
try (OzoneDataStreamOutput out = bucket.createStreamKey(keyName,
@@ -242,7 +243,7 @@ class TestOzoneAtRestEncryption {
}
static void createAndVerifyKeyData(OzoneBucket bucket) throws Exception {
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String keyName = UUID.randomUUID().toString();
String value = "sample value";
try (OzoneOutputStream out = bucket.createKey(keyName,
@@ -318,7 +319,7 @@ class TestOzoneAtRestEncryption {
//Step 1
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String value = "sample value";
store.createVolume(volumeName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
index 4e0c9bbf5b..05c957d782 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
@@ -144,6 +144,7 @@ import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentity
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.READ;
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.WRITE;
+import static org.apache.ozone.test.GenericTestUtils.getTestStartTime;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -583,7 +584,7 @@ public abstract class TestOzoneRpcClientAbstract {
@Test
public void testCreateBucket()
throws IOException {
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
store.createVolume(volumeName);
@@ -598,7 +599,7 @@ public abstract class TestOzoneRpcClientAbstract {
@Test
public void testCreateS3Bucket()
throws IOException {
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String bucketName = UUID.randomUUID().toString();
store.createS3Bucket(bucketName);
OzoneBucket bucket = store.getS3Bucket(bucketName);
@@ -610,7 +611,7 @@ public abstract class TestOzoneRpcClientAbstract {
@Test
public void testDeleteS3Bucket()
throws Exception {
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String bucketName = UUID.randomUUID().toString();
store.createS3Bucket(bucketName);
OzoneBucket bucket = store.getS3Bucket(bucketName);
@@ -1005,7 +1006,7 @@ public abstract class TestOzoneRpcClientAbstract {
public void testPutKey() throws IOException {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String value = "sample value";
store.createVolume(volumeName);
@@ -1545,7 +1546,7 @@ public abstract class TestOzoneRpcClientAbstract {
public void testPutKeyRatisOneNode() throws IOException {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String value = "sample value";
store.createVolume(volumeName);
@@ -1580,7 +1581,7 @@ public abstract class TestOzoneRpcClientAbstract {
public void testPutKeyRatisThreeNodes() throws IOException {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
String value = "sample value";
store.createVolume(volumeName);
@@ -1617,7 +1618,7 @@ public abstract class TestOzoneRpcClientAbstract {
InterruptedException {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
store.createVolume(volumeName);
OzoneVolume volume = store.getVolume(volumeName);
volume.createBucket(bucketName);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestSecureOzoneRpcClient.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestSecureOzoneRpcClient.java
index e8aece20f4..548b1b3035 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestSecureOzoneRpcClient.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestSecureOzoneRpcClient.java
@@ -76,6 +76,7 @@ import java.util.UUID;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.hdds.HddsConfigKeys.OZONE_METADATA_DIRS;
+import static org.apache.ozone.test.GenericTestUtils.getTestStartTime;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -166,7 +167,7 @@ public class TestSecureOzoneRpcClient extends
TestOzoneRpcClient {
BucketLayout bucketLayout) throws Exception {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
String value = "sample value";
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManagerHA.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManagerHA.java
index a0f5bc7834..323db6605a 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManagerHA.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManagerHA.java
@@ -60,6 +60,7 @@ import java.util.concurrent.TimeoutException;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.hdds.client.ReplicationFactor.ONE;
import static org.apache.hadoop.hdds.client.ReplicationType.RATIS;
+import static org.apache.ozone.test.GenericTestUtils.getTestStartTime;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -175,7 +176,7 @@ public class TestStorageContainerManagerHA {
private void doPutKey() throws Exception {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
- Instant testStartTime = Instant.now();
+ Instant testStartTime = getTestStartTime();
try (OzoneClient client = cluster.newClient()) {
ObjectStore store = client.getObjectStore();
String value = "sample value";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]