File tree Expand file tree Collapse file tree 13 files changed +69
-74
lines changed
hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs Expand file tree Collapse file tree 13 files changed +69
-74
lines changed Original file line number Diff line number Diff line change 2929import org .apache .hadoop .fs .contract .AbstractFSContract ;
3030import org .apache .hadoop .fs .s3a .S3ATestUtils ;
3131
32- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_CREATE_PERFORMANCE ;
33- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_PERFORMANCE_FLAGS ;
34- import static org .apache .hadoop .fs .s3a .S3ATestUtils .removeBaseAndBucketOverrides ;
32+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
3533
3634/**
3735 * S3A contract tests creating files.
@@ -70,11 +68,9 @@ protected AbstractFSContract createContract(Configuration conf) {
7068
7169 @ Override
7270 protected Configuration createConfiguration () {
73- final Configuration conf = super .createConfiguration ();
74- removeBaseAndBucketOverrides (conf ,
75- FS_S3A_CREATE_PERFORMANCE ,
76- FS_S3A_PERFORMANCE_FLAGS );
77- conf .setBoolean (FS_S3A_CREATE_PERFORMANCE , createPerformance );
71+ final Configuration conf = setPerformanceFlags (
72+ super .createConfiguration (),
73+ createPerformance ? "create" : "" );
7874 S3ATestUtils .disableFilesystemCaching (conf );
7975 return conf ;
8076 }
Original file line number Diff line number Diff line change 2222import org .apache .hadoop .fs .contract .AbstractContractMkdirTest ;
2323import org .apache .hadoop .fs .contract .AbstractFSContract ;
2424
25- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_CREATE_PERFORMANCE ;
26- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_PERFORMANCE_FLAGS ;
27- import static org .apache .hadoop .fs .s3a .S3ATestUtils .removeBaseAndBucketOverrides ;
25+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
2826
2927/**
3028 * Test dir operations on S3A.
@@ -33,13 +31,9 @@ public class ITestS3AContractMkdir extends AbstractContractMkdirTest {
3331
3432 @ Override
3533 protected Configuration createConfiguration () {
36- Configuration conf = super .createConfiguration ();
37- removeBaseAndBucketOverrides (
38- conf ,
39- FS_S3A_CREATE_PERFORMANCE ,
40- FS_S3A_PERFORMANCE_FLAGS );
41- conf .set (FS_S3A_PERFORMANCE_FLAGS , "" );
42- return conf ;
34+ return setPerformanceFlags (
35+ super .createConfiguration (),
36+ "" );
4337 }
4438
4539 @ Override
Original file line number Diff line number Diff line change 2929
3030import static org .apache .hadoop .fs .contract .ContractTestUtils .createFile ;
3131import static org .apache .hadoop .fs .contract .ContractTestUtils .dataset ;
32- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_CREATE_PERFORMANCE ;
33- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_PERFORMANCE_FLAGS ;
34- import static org .apache .hadoop .fs .s3a .S3ATestUtils .removeBaseAndBucketOverrides ;
32+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
3533
3634/**
3735 * Test mkdir operations on S3A with create performance mode.
@@ -40,14 +38,9 @@ public class ITestS3AContractMkdirWithCreatePerf extends AbstractContractMkdirTe
4038
4139 @ Override
4240 protected Configuration createConfiguration () {
43- Configuration conf = super .createConfiguration ();
44- removeBaseAndBucketOverrides (
45- conf ,
46- FS_S3A_CREATE_PERFORMANCE ,
47- FS_S3A_PERFORMANCE_FLAGS );
48- conf .setStrings (FS_S3A_PERFORMANCE_FLAGS ,
41+ return setPerformanceFlags (
42+ super .createConfiguration (),
4943 "create,mkdir" );
50- return conf ;
5144 }
5245
5346 @ Override
Original file line number Diff line number Diff line change 3131
3232import static org .apache .hadoop .fs .s3a .S3ATestUtils .createTestPath ;
3333import static org .apache .hadoop .fs .s3a .S3ATestUtils .isCreatePerformanceEnabled ;
34+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
3435
3536/**
3637 * S3A Test suite for the FSMainOperationsBaseTest tests.
@@ -46,7 +47,10 @@ public ITestS3AFSMainOperations() {
4647
4748 @ Override
4849 protected FileSystem createFileSystem () throws Exception {
49- contract = new S3AContract (new Configuration ());
50+ Configuration conf = setPerformanceFlags (
51+ new Configuration (),
52+ "" );
53+ contract = new S3AContract (conf );
5054 contract .init ();
5155 return contract .getTestFileSystem ();
5256 }
Original file line number Diff line number Diff line change 4040
4141
4242import static org .apache .hadoop .fs .contract .ContractTestUtils .*;
43- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_CREATE_PERFORMANCE ;
44- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_PERFORMANCE_FLAGS ;
45- import static org .apache .hadoop .fs .s3a .S3ATestUtils .removeBaseAndBucketOverrides ;
43+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
4644import static org .apache .hadoop .fs .s3a .Statistic .*;
4745import static org .apache .hadoop .fs .s3a .performance .OperationCost .*;
4846import static org .apache .hadoop .test .GenericTestUtils .getTestDir ;
@@ -80,12 +78,9 @@ public ITestS3AFileOperationCost(
8078
8179 @ Override
8280 public Configuration createConfiguration () {
83- final Configuration conf = super .createConfiguration ();
84- removeBaseAndBucketOverrides (conf ,
85- FS_S3A_CREATE_PERFORMANCE ,
86- FS_S3A_PERFORMANCE_FLAGS );
87- conf .setBoolean (FS_S3A_CREATE_PERFORMANCE , isKeepingMarkers ());
88- return conf ;
81+ return setPerformanceFlags (
82+ super .createConfiguration (),
83+ isKeepingMarkers () ? "create" : "" );
8984 }
9085
9186 /**
Original file line number Diff line number Diff line change 3535
3636import static org .apache .hadoop .fs .contract .ContractTestUtils .skip ;
3737import static org .apache .hadoop .fs .s3a .S3ATestUtils .isCreatePerformanceEnabled ;
38+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
3839import static org .apache .hadoop .test .LambdaTestUtils .intercept ;
3940import static org .junit .Assume .*;
4041import static org .junit .Assert .*;
@@ -65,7 +66,9 @@ protected int getGlobalTimeout() {
6566 @ Before
6667 public void setUp () throws Exception {
6768 nameThread ();
68- Configuration conf = new Configuration ();
69+ Configuration conf = setPerformanceFlags (
70+ new Configuration (),
71+ "" );
6972
7073 fs = S3ATestUtils .createTestFileSystem (conf );
7174 assumeNotNull (fs );
Original file line number Diff line number Diff line change @@ -1127,6 +1127,25 @@ public static void assumeStoreAwsHosted(final FileSystem fs) {
11271127 .getTrimmed (ENDPOINT , DEFAULT_ENDPOINT )));
11281128 }
11291129
1130+ /**
1131+ * Modify the config by setting the performance flags and return the modified config.
1132+ *
1133+ * @param conf The configuration object.
1134+ * @param flagStr The performance flag string.
1135+ * @return The modified configuration object.
1136+ */
1137+ public static Configuration setPerformanceFlags (final Configuration conf ,
1138+ final String flagStr ) {
1139+ removeBaseAndBucketOverrides (
1140+ conf ,
1141+ FS_S3A_CREATE_PERFORMANCE ,
1142+ FS_S3A_PERFORMANCE_FLAGS );
1143+ if (flagStr != null ) {
1144+ conf .set (FS_S3A_PERFORMANCE_FLAGS , flagStr );
1145+ }
1146+ return conf ;
1147+ }
1148+
11301149 /**
11311150 * Helper class to do diffs of metrics.
11321151 */
Original file line number Diff line number Diff line change 1818import org .apache .hadoop .fs .s3a .S3ATestUtils ;
1919import org .junit .Before ;
2020
21- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_CREATE_PERFORMANCE ;
22- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_PERFORMANCE_FLAGS ;
23- import static org .apache .hadoop .fs .s3a .S3ATestUtils .removeBaseAndBucketOverrides ;
21+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
2422
2523/**
2624 * Extends FileContextCreateMkdirBaseTest for a S3a FileContext.
@@ -30,11 +28,9 @@ public class ITestS3AFileContextCreateMkdir
3028
3129 @ Before
3230 public void setUp () throws Exception {
33- Configuration conf = new Configuration ();
34- removeBaseAndBucketOverrides (
35- conf ,
36- FS_S3A_CREATE_PERFORMANCE ,
37- FS_S3A_PERFORMANCE_FLAGS );
31+ Configuration conf = setPerformanceFlags (
32+ new Configuration (),
33+ null );
3834 fc = S3ATestUtils .createTestFileContext (conf );
3935 super .setUp ();
4036 }
Original file line number Diff line number Diff line change 2020import org .apache .hadoop .fs .FileContextCreateMkdirBaseTest ;
2121import org .apache .hadoop .fs .s3a .S3ATestUtils ;
2222
23- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_CREATE_PERFORMANCE ;
24- import static org .apache .hadoop .fs .s3a .Constants .FS_S3A_PERFORMANCE_FLAGS ;
25- import static org .apache .hadoop .fs .s3a .S3ATestUtils .removeBaseAndBucketOverrides ;
23+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
2624import static org .apache .hadoop .test .LambdaTestUtils .intercept ;
2725
2826/**
@@ -34,12 +32,8 @@ public class ITestS3AFileContextCreateMkdirCreatePerf
3432
3533 @ Before
3634 public void setUp () throws Exception {
37- Configuration conf = new Configuration ();
38- removeBaseAndBucketOverrides (
39- conf ,
40- FS_S3A_CREATE_PERFORMANCE ,
41- FS_S3A_PERFORMANCE_FLAGS );
42- conf .setStrings (FS_S3A_PERFORMANCE_FLAGS ,
35+ Configuration conf = setPerformanceFlags (
36+ new Configuration (),
4337 "mkdir" );
4438 fc = S3ATestUtils .createTestFileContext (conf );
4539 super .setUp ();
Original file line number Diff line number Diff line change 2727import org .apache .hadoop .fs .Path ;
2828import org .apache .hadoop .fs .s3a .S3ATestUtils ;
2929
30+ import static org .apache .hadoop .fs .s3a .S3ATestUtils .setPerformanceFlags ;
31+
3032/**
3133 * S3A implementation of FileContextMainOperationsBaseTest.
3234 */
@@ -36,7 +38,10 @@ public class ITestS3AFileContextMainOperations
3638
3739 @ Before
3840 public void setUp () throws IOException , Exception {
39- Configuration conf = new Configuration ();
41+ Configuration conf = setPerformanceFlags (
42+ new Configuration (),
43+ "" );
44+
4045 fc = S3ATestUtils .createTestFileContext (conf );
4146 super .setUp ();
4247 }
You can’t perform that action at this time.
0 commit comments