diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java index 861f7ca8c4c4..8897e308976a 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java @@ -59,6 +59,8 @@ import java.nio.file.Path; import java.security.cert.CertificateExpiredException; import java.time.Duration; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -99,7 +101,7 @@ public class TestOzoneContainerWithTLS { private ContainerTokenSecretManager secretManager; private CertificateClientTestImpl caClient; private boolean containerTokenEnabled; - private int certLifetime = 10 * 1000; // 10s + private int certLifetime = 15 * 1000; // 15s public TestOzoneContainerWithTLS(boolean enableToken) { this.containerTokenEnabled = enableToken; @@ -152,12 +154,13 @@ public void setup() throws Exception { @Test(expected = CertificateExpiredException.class) public void testCertificateLifetime() throws Exception { // Sleep to wait for certificate expire - Thread.sleep(certLifetime); - caClient.getCertificate().checkValidity(); + LocalDateTime now = LocalDateTime.now(); + now = now.plusSeconds(certLifetime / 1000); + caClient.getCertificate().checkValidity(Date.from( + now.atZone(ZoneId.systemDefault()).toInstant())); } @Test - @org.junit.Ignore("HDDS-7628") public void testCreateOzoneContainer() throws Exception { LOG.info("testCreateOzoneContainer with TLS and containerToken enabled: {}", containerTokenEnabled); @@ -203,7 +206,6 @@ public void testCreateOzoneContainer() throws Exception { } @Test - @org.junit.Ignore("HDDS-7628") public void testContainerDownload() throws Exception { DatanodeDetails dn = MockDatanodeDetails.createDatanodeDetails( UUID.randomUUID().toString(), "localhost", "0.0.0.0", @@ -228,29 +230,26 @@ public void testContainerDownload() throws Exception { // Create containers long containerId = ContainerTestHelper.getTestContainerID(); - int count = 5; List containerIdList = new ArrayList<>(); XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf, Collections.singletonList(caClient.getCACertificate())); client.connect(); - for (int i = 0; i < count; i++, containerId++) { - if (containerTokenEnabled) { - Token token = secretManager.generateToken( - UserGroupInformation.getCurrentUser().getUserName(), - ContainerID.valueOf(containerId)); - createSecureContainer(client, containerId, token); - closeSecureContainer(client, containerId, token); - } else { - createContainer(client, containerId); - closeContainer(client, containerId); - } - containerIdList.add(containerId); + if (containerTokenEnabled) { + Token token = secretManager.generateToken( + UserGroupInformation.getCurrentUser().getUserName(), + ContainerID.valueOf(containerId)); + createSecureContainer(client, containerId, token); + closeSecureContainer(client, containerId, token); + } else { + createContainer(client, containerId); + closeContainer(client, containerId); } + containerIdList.add(containerId++); // Wait certificate to expire GenericTestUtils.waitFor(() -> caClient.getCertificate().getNotAfter().before(new Date()), - 500, certLifetime); + 100, certLifetime); List sourceDatanodes = new ArrayList<>(); sourceDatanodes.add(dn);