Skip to content
Merged
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 @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand All @@ -228,29 +230,26 @@ public void testContainerDownload() throws Exception {

// Create containers
long containerId = ContainerTestHelper.getTestContainerID();
int count = 5;
List<Long> 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<ContainerTokenIdentifier> 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<ContainerTokenIdentifier> 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<DatanodeDetails> sourceDatanodes = new ArrayList<>();
sourceDatanodes.add(dn);
Expand Down