Sfoglia il codice sorgente

HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake Part2. (#7757)

* HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake Part2.

Co-authored-by: Anuj Modi <anujmodi2011@gmail.com>
Co-authored-by: Hualong Zhang <hualong.z@hotmail.com>
Reviewed-by: Anuj Modi <anujmodi2011@gmail.com>
Reviewed-by: Hualong Zhang <hualong.z@hotmail.com>
slfan1989 3 giorni fa
parent
commit
950d8767e9

+ 0 - 60
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/common/Parallelized.java

@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.hadoop.fs.adl.common;
-
-import org.junit.runners.Parameterized;
-import org.junit.runners.model.RunnerScheduler;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Provided for convenience to execute parametrized test cases concurrently.
- */
-public class Parallelized extends Parameterized {
-
-  public Parallelized(Class classObj) throws Throwable {
-    super(classObj);
-    setScheduler(new ThreadPoolScheduler());
-  }
-
-  private static class ThreadPoolScheduler implements RunnerScheduler {
-    private ExecutorService executor;
-
-    ThreadPoolScheduler() {
-      int numThreads = 10;
-      executor = Executors.newFixedThreadPool(numThreads);
-    }
-
-    public void finished() {
-      executor.shutdown();
-      try {
-        executor.awaitTermination(10, TimeUnit.MINUTES);
-      } catch (InterruptedException exc) {
-        throw new RuntimeException(exc);
-      }
-    }
-
-    public void schedule(Runnable childStatement) {
-      executor.submit(childStatement);
-    }
-  }
-}

+ 23 - 18
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlPermissionLive.java

@@ -24,12 +24,11 @@ import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.adl.common.Parallelized;
 import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.junit.*;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
@@ -38,10 +37,13 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.UUID;
 import java.util.UUID;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
 /**
 /**
  * Test ACL permission on file/folder on Adl file system.
  * Test ACL permission on file/folder on Adl file system.
  */
  */
-@RunWith(Parallelized.class)
 public class TestAdlPermissionLive {
 public class TestAdlPermissionLive {
 
 
   private static Path testRoot = new Path("/test");
   private static Path testRoot = new Path("/test");
@@ -49,11 +51,11 @@ public class TestAdlPermissionLive {
   private Path path;
   private Path path;
   private FileSystem adlStore;
   private FileSystem adlStore;
 
 
-  public TestAdlPermissionLive(FsPermission testPermission) {
-    permission = testPermission;
+  public void initTestAdlPermissionLive(FsPermission pTestPermission) throws Exception {
+    permission = pTestPermission;
+    setUp();
   }
   }
 
 
-  @Parameterized.Parameters(name = "{0}")
   public static Collection adlCreateNonRecursiveTestData()
   public static Collection adlCreateNonRecursiveTestData()
       throws UnsupportedEncodingException {
       throws UnsupportedEncodingException {
     /*
     /*
@@ -71,22 +73,23 @@ public class TestAdlPermissionLive {
     return datas;
     return datas;
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanUp() throws IOException, URISyntaxException {
   public static void cleanUp() throws IOException, URISyntaxException {
     if (AdlStorageConfiguration.isContractTestEnabled()) {
     if (AdlStorageConfiguration.isContractTestEnabled()) {
-      Assert.assertTrue(AdlStorageConfiguration.createStorageConnector()
+      assertTrue(AdlStorageConfiguration.createStorageConnector()
           .delete(testRoot, true));
           .delete(testRoot, true));
     }
     }
   }
   }
 
 
-  @Before
   public void setUp() throws Exception {
   public void setUp() throws Exception {
-    Assume.assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
+    assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
     adlStore = AdlStorageConfiguration.createStorageConnector();
     adlStore = AdlStorageConfiguration.createStorageConnector();
   }
   }
 
 
-  @Test
-  public void testFilePermission() throws IOException {
+  @ParameterizedTest(name = "{0}")
+  @MethodSource("adlCreateNonRecursiveTestData")
+  public void testFilePermission(FsPermission pTestPermission) throws Exception {
+    initTestAdlPermissionLive(pTestPermission);
     path = new Path(testRoot, UUID.randomUUID().toString());
     path = new Path(testRoot, UUID.randomUUID().toString());
     adlStore.getConf()
     adlStore.getConf()
         .set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "000");
         .set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "000");
@@ -97,11 +100,13 @@ public class TestAdlPermissionLive {
 
 
     adlStore.create(path, permission, true, 1024, (short) 1, 1023, null);
     adlStore.create(path, permission, true, 1024, (short) 1, 1023, null);
     FileStatus status = adlStore.getFileStatus(path);
     FileStatus status = adlStore.getFileStatus(path);
-    Assert.assertEquals(permission, status.getPermission());
+    assertEquals(permission, status.getPermission());
   }
   }
 
 
-  @Test
-  public void testFolderPermission() throws IOException {
+  @ParameterizedTest(name = "{0}")
+  @MethodSource("adlCreateNonRecursiveTestData")
+  public void testFolderPermission(FsPermission pTestPermission) throws Exception {
+    initTestAdlPermissionLive(pTestPermission);
     path = new Path(testRoot, UUID.randomUUID().toString());
     path = new Path(testRoot, UUID.randomUUID().toString());
     adlStore.getConf()
     adlStore.getConf()
         .set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "000");
         .set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "000");
@@ -111,6 +116,6 @@ public class TestAdlPermissionLive {
 
 
     adlStore.mkdirs(path, permission);
     adlStore.mkdirs(path, permission);
     FileStatus status = adlStore.getFileStatus(path);
     FileStatus status = adlStore.getFileStatus(path);
-    Assert.assertEquals(permission, status.getPermission());
+    assertEquals(permission, status.getPermission());
   }
   }
 }
 }