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 @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

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;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void testCreateVolumeWithMetadata()
@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);
Expand All @@ -152,7 +153,7 @@ public void testCreateBucket()

@Test
public void testPutKeyRatisOneNode() throws IOException {
Instant testStartTime = Instant.now();
Instant testStartTime = getTestStartTime();
String value = "sample value";
OzoneBucket bucket = getOzoneBucket();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
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;
Expand Down Expand Up @@ -229,7 +230,7 @@ void testLinkEncryptedBuckets(BucketLayout bucketLayout) throws Exception {

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,
Expand All @@ -242,7 +243,7 @@ static void createAndVerifyStreamKeyData(OzoneBucket bucket)
}

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,
Expand Down Expand Up @@ -318,7 +319,7 @@ void testKeyWithEncryptionAndGdpr(BucketLayout bucketLayout)
//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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
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;
Expand Down Expand Up @@ -583,7 +584,7 @@ public void testCreateBucketWithMetadata()
@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);
Expand All @@ -598,7 +599,7 @@ public void testCreateBucket()
@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);
Expand All @@ -610,7 +611,7 @@ public void testCreateS3Bucket()
@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);
Expand Down Expand Up @@ -1005,7 +1006,7 @@ public void testPutKeyWithReplicationConfig(String replicationValue,
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);
Expand Down Expand Up @@ -1545,7 +1546,7 @@ public void testValidateBlockLengthWithCommitKey() throws IOException {
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);
Expand Down Expand Up @@ -1580,7 +1581,7 @@ public void testPutKeyRatisOneNode() throws IOException {
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);
Expand Down Expand Up @@ -1617,7 +1618,7 @@ public void testPutKeyRatisThreeNodesParallel() throws IOException,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

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;
Expand Down Expand Up @@ -166,7 +167,7 @@ private void testPutKeySuccessWithBlockTokenWithBucketLayout(
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
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;
Expand Down Expand Up @@ -175,7 +176,7 @@ void testAllSCMAreRunning() throws Exception {
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";
Expand Down