Skip to content

Commit c27908f

Browse files
author
fanshilun
committed
HADOOP-19416. Fix CheckStyle & Junit Test.
1 parent 72e9c7e commit c27908f

16 files changed

+265
-190
lines changed

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEncryptionWithDefaultS3Settings.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import java.io.IOException;
2222
import java.util.Optional;
2323

24-
import org.junit.Ignore;
2524
import org.junit.jupiter.api.BeforeEach;
25+
import org.junit.jupiter.api.Disabled;
2626
import org.junit.jupiter.api.Test;
2727

2828
import org.apache.commons.lang3.StringUtils;
@@ -119,13 +119,13 @@ public void testEncryptionFileAttributes() throws Exception {
119119

120120

121121
@Override
122-
@Ignore
122+
@Disabled
123123
@Test
124124
public void testEncryptionSettingPropagation() throws Throwable {
125125
}
126126

127127
@Override
128-
@Ignore
128+
@Disabled
129129
@Test
130130
public void testEncryption() throws Throwable {
131131
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3APrefetchingLruEviction.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
import java.util.concurrent.TimeUnit;
2929

3030
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
31-
import org.junit.jupiter.api.Test;
32-
import org.junit.runner.RunWith;
33-
import org.junit.runners.Parameterized;
31+
import org.junit.jupiter.params.ParameterizedTest;
32+
import org.junit.jupiter.params.provider.MethodSource;
3433
import org.slf4j.Logger;
3534
import org.slf4j.LoggerFactory;
3635

@@ -55,21 +54,19 @@
5554
/**
5655
* Test the prefetching input stream with LRU cache eviction on S3ACachingInputStream.
5756
*/
58-
@RunWith(Parameterized.class)
5957
public class ITestS3APrefetchingLruEviction extends AbstractS3ACostTest {
6058

61-
private final String maxBlocks;
59+
private String maxBlocks;
6260

63-
@Parameterized.Parameters(name = "max-blocks-{0}")
6461
public static Collection<Object[]> params() {
6562
return Arrays.asList(new Object[][]{
6663
{"1"},
6764
{"2"}
6865
});
6966
}
7067

71-
public ITestS3APrefetchingLruEviction(final String maxBlocks) {
72-
this.maxBlocks = maxBlocks;
68+
public void initITestS3APrefetchingLruEviction(final String pMaxBlocks) {
69+
this.maxBlocks = pMaxBlocks;
7370
}
7471

7572
private static final Logger LOG =
@@ -95,8 +92,10 @@ public Configuration createConfiguration() {
9592
return conf;
9693
}
9794

98-
@Test
99-
public void testSeeksWithLruEviction() throws Throwable {
95+
@MethodSource("params")
96+
@ParameterizedTest(name = "max-blocks-{0}")
97+
public void testSeeksWithLruEviction(String pMaxBlocks) throws Throwable {
98+
initITestS3APrefetchingLruEviction(pMaxBlocks);
10099
IOStatistics ioStats;
101100
byte[] data = ContractTestUtils.dataset(SMALL_FILE_SIZE, 'x', 26);
102101
// Path for file which should have length > block size so S3ACachingInputStream is used

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AStorageClass.java

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
import java.util.Map;
2525

2626
import org.assertj.core.api.Assertions;
27-
import org.junit.jupiter.api.Test;
28-
import org.junit.runner.RunWith;
29-
import org.junit.runners.Parameterized;
27+
import org.junit.jupiter.params.ParameterizedTest;
28+
import org.junit.jupiter.params.provider.MethodSource;
3029

3130
import org.apache.hadoop.conf.Configuration;
3231
import org.apache.hadoop.fs.FileSystem;
@@ -50,25 +49,23 @@
5049
/**
5150
* Tests of storage class.
5251
*/
53-
@RunWith(Parameterized.class)
5452
public class ITestS3AStorageClass extends AbstractS3ATestBase {
5553

5654
/**
5755
* HADOOP-18339. Parameterized the test for different fast upload buffer types
5856
* to ensure the storage class configuration works with all of them.
5957
*/
60-
@Parameterized.Parameters(name = "fast-upload-buffer-{0}")
6158
public static Collection<Object[]> params() {
6259
return Arrays.asList(new Object[][]{
6360
{FAST_UPLOAD_BUFFER_DISK},
6461
{FAST_UPLOAD_BUFFER_ARRAY}
6562
});
6663
}
6764

68-
private final String fastUploadBufferType;
65+
private String fastUploadBufferType;
6966

70-
public ITestS3AStorageClass(String fastUploadBufferType) {
71-
this.fastUploadBufferType = fastUploadBufferType;
67+
public void initITestS3AStorageClass(String pFastUploadBufferType) {
68+
this.fastUploadBufferType = pFastUploadBufferType;
7269
}
7370

7471
@Override
@@ -86,8 +83,11 @@ protected Configuration createConfiguration() {
8683
* This test ensures the default storage class configuration (no config or null)
8784
* works well with create and copy operations
8885
*/
89-
@Test
90-
public void testCreateAndCopyObjectWithStorageClassDefault() throws Throwable {
86+
@MethodSource("params")
87+
@ParameterizedTest(name = "fast-upload-buffer-{0}")
88+
public void testCreateAndCopyObjectWithStorageClassDefault(
89+
String pFastUploadBufferType) throws Throwable {
90+
initITestS3AStorageClass(pFastUploadBufferType);
9191
Configuration conf = this.createConfiguration();
9292
S3AContract contract = (S3AContract) createContract(conf);
9393
contract.init();
@@ -108,8 +108,11 @@ public void testCreateAndCopyObjectWithStorageClassDefault() throws Throwable {
108108
* Verify object can be created and copied correctly
109109
* with specified storage class
110110
*/
111-
@Test
112-
public void testCreateAndCopyObjectWithStorageClassReducedRedundancy() throws Throwable {
111+
@MethodSource("params")
112+
@ParameterizedTest(name = "fast-upload-buffer-{0}")
113+
public void testCreateAndCopyObjectWithStorageClassReducedRedundancy(
114+
String pFastUploadBufferType) throws Throwable {
115+
initITestS3AStorageClass(pFastUploadBufferType);
113116
Configuration conf = this.createConfiguration();
114117
conf.set(STORAGE_CLASS, STORAGE_CLASS_REDUCED_REDUNDANCY);
115118
S3AContract contract = (S3AContract) createContract(conf);
@@ -133,8 +136,11 @@ public void testCreateAndCopyObjectWithStorageClassReducedRedundancy() throws Th
133136
* Archive storage classes have different behavior
134137
* from general storage classes
135138
*/
136-
@Test
137-
public void testCreateAndCopyObjectWithStorageClassGlacier() throws Throwable {
139+
@MethodSource("params")
140+
@ParameterizedTest(name = "fast-upload-buffer-{0}")
141+
public void testCreateAndCopyObjectWithStorageClassGlacier(
142+
String pFastUploadBufferType) throws Throwable {
143+
initITestS3AStorageClass(pFastUploadBufferType);
138144
Configuration conf = this.createConfiguration();
139145
conf.set(STORAGE_CLASS, STORAGE_CLASS_GLACIER);
140146
S3AContract contract = (S3AContract) createContract(conf);
@@ -162,8 +168,11 @@ public void testCreateAndCopyObjectWithStorageClassGlacier() throws Throwable {
162168
* Verify object can be created and copied correctly
163169
* with completely invalid storage class
164170
*/
165-
@Test
166-
public void testCreateAndCopyObjectWithStorageClassInvalid() throws Throwable {
171+
@MethodSource("params")
172+
@ParameterizedTest(name = "fast-upload-buffer-{0}")
173+
public void testCreateAndCopyObjectWithStorageClassInvalid(
174+
String pFastUploadBufferType) throws Throwable {
175+
initITestS3AStorageClass(pFastUploadBufferType);
167176
Configuration conf = this.createConfiguration();
168177
conf.set(STORAGE_CLASS, "testing");
169178
S3AContract contract = (S3AContract) createContract(conf);
@@ -187,8 +196,11 @@ public void testCreateAndCopyObjectWithStorageClassInvalid() throws Throwable {
187196
* Verify object can be created and copied correctly
188197
* with empty string configuration
189198
*/
190-
@Test
191-
public void testCreateAndCopyObjectWithStorageClassEmpty() throws Throwable {
199+
@MethodSource("params")
200+
@ParameterizedTest(name = "fast-upload-buffer-{0}")
201+
public void testCreateAndCopyObjectWithStorageClassEmpty(
202+
String pFastUploadBufferType) throws Throwable {
203+
initITestS3AStorageClass(pFastUploadBufferType);
192204
Configuration conf = this.createConfiguration();
193205
conf.set(STORAGE_CLASS, "");
194206
S3AContract contract = (S3AContract) createContract(conf);

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/ITestCustomSigner.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@
2828
import java.util.concurrent.atomic.AtomicInteger;
2929

3030
import org.junit.jupiter.api.AfterEach;
31-
import org.junit.jupiter.api.BeforeEach;
32-
import org.junit.runner.RunWith;
33-
import org.junit.runners.Parameterized;
31+
import org.junit.jupiter.params.ParameterizedTest;
32+
import org.junit.jupiter.params.provider.MethodSource;
3433
import software.amazon.awssdk.auth.signer.Aws4Signer;
3534
import software.amazon.awssdk.auth.signer.AwsS3V4Signer;
3635
import software.amazon.awssdk.auth.signer.internal.AbstractAwsS3V4Signer;
3736
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
3837
import software.amazon.awssdk.core.signer.Signer;
3938
import software.amazon.awssdk.http.SdkHttpFullRequest;
4039
import org.assertj.core.api.Assertions;
41-
import org.junit.jupiter.api.Test;
4240
import org.slf4j.Logger;
4341
import org.slf4j.LoggerFactory;
4442

@@ -67,7 +65,6 @@
6765
* Because the v2 sdk has had some problems with bulk delete
6866
* and custom signing, this suite is parameterized.
6967
*/
70-
@RunWith(Parameterized.class)
7168
public class ITestCustomSigner extends AbstractS3ATestBase {
7269

7370
private static final Logger LOG = LoggerFactory
@@ -79,15 +76,14 @@ public class ITestCustomSigner extends AbstractS3ATestBase {
7976
/**
8077
* Parameterization.
8178
*/
82-
@Parameterized.Parameters(name = "{0}")
8379
public static Collection<Object[]> params() {
8480
return Arrays.asList(new Object[][]{
8581
{"bulk delete", true},
8682
{"simple-delete", false},
8783
});
8884
}
8985

90-
private final boolean bulkDelete;
86+
private boolean bulkDelete;
9187

9288
private final UserGroupInformation ugi1 = UserGroupInformation.createRemoteUser("user1");
9389

@@ -97,13 +93,13 @@ public static Collection<Object[]> params() {
9793

9894
private String endpoint;
9995

100-
public ITestCustomSigner(
96+
public void initITestCustomSigner(
10197
final String ignored,
102-
final boolean bulkDelete) {
98+
final boolean bulkDelete) throws Exception {
10399
this.bulkDelete = bulkDelete;
100+
setup();
104101
}
105102

106-
@BeforeEach
107103
@Override
108104
public void setup() throws Exception {
109105
super.setup();
@@ -131,10 +127,11 @@ public void teardown() throws Exception {
131127
FileSystem.closeAllForUGI(ugi2);
132128
}
133129

134-
@Test
135-
public void testCustomSignerAndInitializer()
136-
throws IOException, InterruptedException {
137-
130+
@MethodSource("params")
131+
@ParameterizedTest(name = "{0}")
132+
public void testCustomSignerAndInitializer(final String ignored,
133+
final boolean bulkDelete) throws Exception {
134+
initITestCustomSigner(ignored, bulkDelete);
138135
final Path basePath = path(getMethodName());
139136
FileSystem fs1 = runStoreOperationsAndVerify(ugi1,
140137
new Path(basePath, "customsignerpath1"), "id1");

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/commit/ITestS3ACommitterFactory.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Arrays;
2323
import java.util.Collection;
2424

25-
import org.junit.jupiter.api.BeforeEach;
2625
import org.junit.jupiter.params.ParameterizedTest;
2726
import org.junit.jupiter.params.provider.MethodSource;
2827
import org.slf4j.Logger;
@@ -176,7 +175,6 @@ private static void maybeSetCommitterName(final Configuration conf, final String
176175
}
177176
}
178177

179-
@BeforeEach
180178
@Override
181179
public void setup() throws Exception {
182180
// destroy all filesystems from previous runs.

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/commit/integration/ITestS3ACommitterMRJob.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ public static Collection<Object[]> params() {
167167
* @param pCommitterTestBinding binding for the test.
168168
*/
169169
public void initITestS3ACommitterMRJob(
170-
final CommitterTestBinding pCommitterTestBinding) {
170+
final CommitterTestBinding pCommitterTestBinding) throws Exception {
171171
this.committerTestBinding = pCommitterTestBinding;
172+
setup();
172173
}
173174

174-
@BeforeEach
175175
@Override
176176
public void setup() throws Exception {
177177
super.setup();

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/commit/magic/ITestMagicCommitProtocol.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ protected String getCommitterName() {
7373
return CommitConstants.COMMITTER_NAME_MAGIC;
7474
}
7575

76-
@BeforeEach
7776
@Override
7877
public void setup() throws Exception {
7978
super.setup();

0 commit comments

Comments
 (0)