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
12 changes: 0 additions & 12 deletions hadoop-tools/hadoop-azure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,6 @@
<scope>provided</scope>
</dependency>

<!-- dependencies use for test only -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
Expand Down Expand Up @@ -367,11 +360,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Base class for any Wasb test with timeouts & named threads.
Expand Down Expand Up @@ -69,10 +69,10 @@ protected int getTestTimeoutMillis() {
}

public static void assumeNotNull(Object objects) {
assumeTrue(objects != null);
assumeThat(objects).isNotNull();
}

public static void assumeNotNull(Object objects, String message) {
assumeTrue(objects != null, message);
assumeThat(objects).as(message).isNotNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.fs.azure;

import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.assertj.core.api.Assumptions.assumeThat;

import java.io.FileNotFoundException;
import java.util.EnumSet;
Expand Down Expand Up @@ -169,7 +169,7 @@ public String call() throws Exception {
@Test
public void testContainerChecksWithSas() throws Exception {

assumeFalse(runningInSASMode);
assumeThat(runningInSASMode).isFalse();
testAccount = AzureBlobStorageTestAccount.create("",
EnumSet.of(CreateOptions.UseSas));
assumeNotNull(testAccount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.apache.hadoop.fs.azure.integration.AzureTestUtils;
import org.apache.hadoop.fs.contract.ContractTestUtils;

import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Test list performance.
Expand Down Expand Up @@ -99,7 +99,7 @@ protected AzureBlobStorageTestAccount createTestAccount() throws Exception {

@Test
public void test_0101_CreateDirectoryWithFiles() throws Exception {
assumeFalse(fs.exists(TEST_DIR_PATH), "Test path exists; skipping");
assumeThat(fs.exists(TEST_DIR_PATH)).as("Test path exists; skipping").isFalse();

ExecutorService executorService = Executors.newFixedThreadPool(threads);
CloudBlobContainer container = testAccount.getRealContainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.fs.azure;

import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.assertj.core.api.Assumptions.assumeThat;

import org.apache.hadoop.fs.FileSystemContractBaseTest;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -50,7 +50,9 @@ public void setUp() throws Exception {
if (testAccount != null) {
fs = testAccount.getFileSystem();
}
assumeTrue(fs != null);
assumeThat(fs)
.as("FileSystem must not be null for this test")
.isNotNull();
basePath = fs.makeQualified(
AzureTestUtils.createTestPath(
new Path("ITestNativeAzureFileSystemContractEmulator")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.fs.azure;

import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.assertj.core.api.Assumptions.assumeThat;

import org.apache.hadoop.fs.FileSystemContractBaseTest;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -53,7 +53,7 @@ public void setUp() throws Exception {
if (testAccount != null) {
fs = testAccount.getFileSystem();
}
assumeTrue(fs != null);
assumeThat(fs).isNotNull();
basePath = fs.makeQualified(
AzureTestUtils.createTestPath(
new Path("NativeAzureFileSystemContractLive")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.fs.azure;

import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.assertj.core.api.Assumptions.assumeThat;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystemContractBaseTest;
Expand Down Expand Up @@ -63,7 +63,7 @@ private AzureBlobStorageTestAccount createTestAccount()
@BeforeEach
public void setUp() throws Exception {
testAccount = createTestAccount();
assumeTrue(testAccount != null);
assumeThat(testAccount).isNotNull();
fs = testAccount.getFileSystem();
basePath = AzureTestUtils.pathForTests(fs, "filesystemcontractpageblob");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.times;

import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Test class to hold all WasbRemoteCallHelper tests.
Expand All @@ -72,8 +72,9 @@ public void setUp() throws Exception {
boolean useSecureMode = fs.getConf().getBoolean(KEY_USE_SECURE_MODE, false);
boolean useAuthorization = fs.getConf()
.getBoolean(NativeAzureFileSystem.KEY_AZURE_AUTHORIZATION, false);
assumeTrue(useSecureMode && useAuthorization,
"Test valid when both SecureMode and Authorization are enabled .. skipping");
assumeThat(useSecureMode && useAuthorization)
.as("Test valid when both SecureMode and Authorization are enabled .. skipping")
.isTrue();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
import static org.apache.hadoop.fs.azure.NativeAzureFileSystem.RETURN_URI_AS_CANONICAL_SERVICE_NAME_PROPERTY_NAME;
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.assertj.core.api.Assumptions.assumeThat;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
Expand Down Expand Up @@ -132,7 +132,7 @@ public void testConnectUsingKey() throws Exception {
@Test
public void testConnectUsingSAS() throws Exception {

assumeFalse(runningInSASMode);
assumeThat(runningInSASMode).isFalse();
// Create the test account with SAS credentials.
testAccount = AzureBlobStorageTestAccount.create("",
EnumSet.of(CreateOptions.UseSas, CreateOptions.CreateContainer));
Expand All @@ -148,7 +148,7 @@ public void testConnectUsingSAS() throws Exception {
@Test
public void testConnectUsingSASReadonly() throws Exception {

assumeFalse(runningInSASMode);
assumeThat(runningInSASMode).isFalse();
// Create the test account with SAS credentials.
testAccount = AzureBlobStorageTestAccount.create("", EnumSet.of(
CreateOptions.UseSas, CreateOptions.CreateContainer,
Expand Down Expand Up @@ -378,7 +378,7 @@ public void testDefaultKeyProvider() throws Exception {
public void testCredsFromCredentialProvider(@TempDir java.nio.file.Path tempDir)
throws Exception {

assumeFalse(runningInSASMode);
assumeThat(runningInSASMode).isFalse();
String account = "testacct";
String key = "testkey";
// set up conf to have a cred provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.util.StringUtils;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -48,7 +47,7 @@
import static org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.KEY_USE_SECURE_MODE;
import static org.apache.hadoop.fs.azure.CachingAuthorizer.KEY_AUTH_SERVICE_CACHING_ENABLE;
import static org.apache.hadoop.fs.contract.ContractTestUtils.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Test class to hold all WASB authorization tests.
Expand Down Expand Up @@ -92,8 +91,9 @@ public void setUp() throws Exception {
super.setUp();
boolean useSecureMode = fs.getConf().getBoolean(KEY_USE_SECURE_MODE, false);
boolean useAuthorization = fs.getConf().getBoolean(NativeAzureFileSystem.KEY_AZURE_AUTHORIZATION, false);
assumeTrue((useSecureMode && useAuthorization),
"Test valid when both SecureMode and Authorization are enabled .. skipping");
assumeThat((useSecureMode && useAuthorization))
.as("Test valid when both SecureMode and Authorization are enabled .. skipping")
.isTrue();

authorizer = new MockWasbAuthorizerImpl(fs);
authorizer.init(fs.getConf());
Expand Down Expand Up @@ -1544,8 +1544,9 @@ public void testSetOwnerSucceedsForAuthorisedUsers() throws Throwable {
ContractTestUtils.assertPathExists(fs, "test path does not exist", testPath);

String owner = fs.getFileStatus(testPath).getOwner();
assumeTrue(!StringUtils.equalsIgnoreCase(owner, newOwner),
"changing owner requires original and new owner to be different");
assumeThat(owner)
.as("changing owner requires original and new owner to be different")
.isNotEqualToIgnoringCase(newOwner);

authorisedUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override
Expand Down Expand Up @@ -1587,8 +1588,9 @@ public void testSetOwnerSucceedsForAnyUserWhenWildCardIsSpecified() throws Throw
ContractTestUtils.assertPathExists(fs, "test path does not exist", testPath);

String owner = fs.getFileStatus(testPath).getOwner();
assumeTrue(!StringUtils.equalsIgnoreCase(owner, newOwner),
"changing owner requires original and new owner to be different");
assumeThat(owner)
.as("changing owner requires original and new owner to be different")
.isNotEqualToIgnoringCase(newOwner);

user.doAs(new PrivilegedExceptionAction<Void>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.List;

import org.junit.jupiter.api.Assertions;
import org.junit.Assume;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -42,15 +41,14 @@
import org.apache.hadoop.fs.azure.AzureBlobStorageTestAccount;
import org.apache.hadoop.fs.azure.NativeAzureFileSystem;

import static org.junit.jupiter.api.Assumptions.assumeTrue;

import static org.apache.hadoop.fs.azure.AzureBlobStorageTestAccount.WASB_ACCOUNT_NAME_DOMAIN_SUFFIX_REGEX;
import static org.apache.hadoop.fs.azure.AzureBlobStorageTestAccount.WASB_TEST_ACCOUNT_NAME_WITH_DOMAIN;
import static org.apache.hadoop.fs.azure.integration.AzureTestConstants.*;
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT;
import static org.apache.hadoop.test.MetricsAsserts.getLongCounter;
import static org.apache.hadoop.test.MetricsAsserts.getLongGauge;
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
import static org.assertj.core.api.Assumptions.assumeThat;

/**
* Utilities for the Azure tests. Based on {@code S3ATestUtils}, so
Expand Down Expand Up @@ -394,7 +392,7 @@ public static void assume(String message, boolean condition) {
if (!condition) {
LOG.warn(message);
}
Assume.assumeTrue(message, condition);
assumeThat(condition).as(message).isTrue();
}

/**
Expand Down Expand Up @@ -495,8 +493,10 @@ public static String verifyWasbAccountNameInConfig(Configuration conf) {
if (accountName == null) {
accountName = conf.get(WASB_TEST_ACCOUNT_NAME_WITH_DOMAIN);
}
assumeTrue(accountName != null && !accountName.endsWith(WASB_ACCOUNT_NAME_DOMAIN_SUFFIX_REGEX),
"Account for WASB is missing or it is not in correct format");
assumeThat(accountName)
.as("Account for WASB is missing or it is not in correct format")
.isNotNull()
.doesNotEndWith(WASB_ACCOUNT_NAME_DOMAIN_SUFFIX_REGEX);
return accountName;
}

Expand Down Expand Up @@ -550,7 +550,8 @@ public static String readStringFromStream(FSDataInputStream inputStream) throws
* Assume hierarchical namespace is disabled for test account.
*/
public static void assumeNamespaceDisabled(Configuration conf) {
Assume.assumeFalse("Hierarchical namespace is enabled for test account.",
conf.getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, false));
assumeThat(conf.getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, false))
.as("Hierarchical namespace is enabled for test account.")
.isFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import static org.apache.hadoop.fs.azure.integration.AzureTestUtils.*;
import static org.apache.hadoop.fs.contract.ContractTestUtils.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.assertj.core.api.Assumptions.assumeThat;


/**
Expand Down Expand Up @@ -153,8 +153,10 @@ FileStatus assumeHugeFileExists() throws IOException {
assertPathExists(getFileSystem(), "huge file not created", hugefile);
try {
FileStatus status = getFileSystem().getFileStatus(hugefile);
assumeTrue(status.isFile(), "Not a file: " + status);
assumeTrue(status.getLen() > 0, "File " + hugefile + " is empty");
assumeThat(status.isFile()).as("Not a file: " + status).isTrue();
assumeThat(status.getLen())
.as("File " + hugefile + " is empty")
.isPositive();
return status;
} catch (FileNotFoundException e) {
skip("huge file not created: " + hugefile);
Expand Down
Loading