Quellcode durchsuchen

YARN-11761. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-services-core. (#7374)

Co-authored-by: Ayush Saxena <ayushsaxena@apache.org>
Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Ayush Saxena <ayushsaxena@apache.org>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 vor 2 Monaten
Ursprung
Commit
14b71596d4
27 geänderte Dateien mit 670 neuen und 639 gelöschten Zeilen
  1. 21 12
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/ServiceTestUtils.java
  2. 11 12
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestDefaultUpgradeComponentsFinder.java
  3. 43 43
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceAM.java
  4. 61 47
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceManager.java
  5. 122 113
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestYarnNativeServices.java
  6. 9 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/client/TestBuildExternalComponents.java
  7. 45 40
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/client/TestServiceCLI.java
  8. 24 22
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/client/TestServiceClient.java
  9. 57 57
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/TestComponent.java
  10. 16 19
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/TestComponentDecommissionInstances.java
  11. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/TestComponentRestartPolicy.java
  12. 46 53
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/instance/TestComponentInstance.java
  13. 21 18
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/conf/TestAppJsonResolve.java
  14. 11 14
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/conf/TestLoadExampleAppJson.java
  15. 4 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/conf/TestValidateServiceNames.java
  16. 5 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/containerlaunch/TestAbstractLauncher.java
  17. 10 9
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/monitor/TestServiceMonitor.java
  18. 29 31
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/monitor/probe/TestDefaultProbe.java
  19. 15 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/provider/TestAbstractProviderService.java
  20. 6 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/provider/TestProviderUtils.java
  21. 12 12
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/providers/TestAbstractClientProvider.java
  22. 6 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/providers/TestDefaultClientProvider.java
  23. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/providers/TestProviderFactory.java
  24. 6 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/timelineservice/TestServiceTimelinePublisher.java
  25. 8 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/utils/TestCoreFileSystem.java
  26. 19 22
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/utils/TestFilterUtils.java
  27. 59 56
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/utils/TestServiceApiUtil.java

+ 21 - 12
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/ServiceTestUtils.java

@@ -51,8 +51,9 @@ import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.util.LinuxResourceCalculatorPlugin;
 import org.apache.hadoop.yarn.util.LinuxResourceCalculatorPlugin;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -393,17 +394,22 @@ public class ServiceTestUtils {
    * Watcher to initialize yarn service base path under target and deletes the
    * Watcher to initialize yarn service base path under target and deletes the
    * the test directory when finishes.
    * the test directory when finishes.
    */
    */
-  public static class ServiceFSWatcher extends TestWatcher {
+  public static class ServiceFSWatcher implements BeforeEachCallback, AfterEachCallback {
     private YarnConfiguration conf;
     private YarnConfiguration conf;
     private SliderFileSystem fs;
     private SliderFileSystem fs;
     private java.nio.file.Path serviceBasePath;
     private java.nio.file.Path serviceBasePath;
 
 
     @Override
     @Override
-    protected void starting(Description description) {
+    public void afterEach(ExtensionContext context) throws Exception {
+      delete(context);
+    }
+
+    @Override
+    public void beforeEach(ExtensionContext context) throws Exception {
       conf = new YarnConfiguration();
       conf = new YarnConfiguration();
-      delete(description);
+      delete(context);
       serviceBasePath = Paths.get("target",
       serviceBasePath = Paths.get("target",
-          description.getClassName(), description.getMethodName());
+          getClassName(context), getMethodName(context));
       conf.set(YARN_SERVICE_BASE_PATH, serviceBasePath.toString());
       conf.set(YARN_SERVICE_BASE_PATH, serviceBasePath.toString());
       try {
       try {
         Files.createDirectories(serviceBasePath);
         Files.createDirectories(serviceBasePath);
@@ -415,14 +421,17 @@ public class ServiceTestUtils {
       }
       }
     }
     }
 
 
-    @Override
-    protected void finished(Description description) {
-      delete(description);
+    private void delete(ExtensionContext context) {
+      FileUtils.deleteQuietly(Paths.get("target", getClassName(context)).toFile());
+    }
+
+    private String getClassName(ExtensionContext context) {
+      Class<?> requiredTestClass = context.getRequiredTestClass();
+      return requiredTestClass.getName();
     }
     }
 
 
-    private void delete(Description description) {
-      FileUtils.deleteQuietly(Paths.get("target",
-          description.getClassName()).toFile());
+    private String getMethodName(ExtensionContext context) {
+      return context.getTestMethod().get().getName();
     }
     }
 
 
     /**
     /**

+ 11 - 12
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestDefaultUpgradeComponentsFinder.java

@@ -22,12 +22,12 @@ import org.apache.hadoop.yarn.service.api.records.Component;
 import org.apache.hadoop.yarn.service.api.records.ConfigFile;
 import org.apache.hadoop.yarn.service.api.records.ConfigFile;
 import org.apache.hadoop.yarn.service.api.records.Configuration;
 import org.apache.hadoop.yarn.service.api.records.Configuration;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.Service;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.*;
 import java.util.*;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Tests for {@link UpgradeComponentsFinder.DefaultUpgradeComponentsFinder}.
  * Tests for {@link UpgradeComponentsFinder.DefaultUpgradeComponentsFinder}.
@@ -44,9 +44,9 @@ public class TestDefaultUpgradeComponentsFinder {
     targetDef.getComponents().forEach(x -> x.setArtifact(
     targetDef.getComponents().forEach(x -> x.setArtifact(
         TestServiceManager.createTestArtifact("v1")));
         TestServiceManager.createTestArtifact("v1")));
 
 
-    assertEquals("all components need upgrade",
-        targetDef.getComponents(), finder.findTargetComponentSpecs(currentDef,
-            targetDef));
+    assertEquals(targetDef.getComponents(),
+        finder.findTargetComponentSpecs(currentDef,
+        targetDef), "all components need upgrade");
   }
   }
 
 
   @Test
   @Test
@@ -60,7 +60,7 @@ public class TestDefaultUpgradeComponentsFinder {
 
 
     try {
     try {
       finder.findTargetComponentSpecs(currentDef, targetDef);
       finder.findTargetComponentSpecs(currentDef, targetDef);
-      Assert.fail("Expected error since component does not exist in service "
+      fail("Expected error since component does not exist in service "
           + "definition");
           + "definition");
     } catch (UnsupportedOperationException usoe) {
     } catch (UnsupportedOperationException usoe) {
       assertEquals(
       assertEquals(
@@ -83,9 +83,8 @@ public class TestDefaultUpgradeComponentsFinder {
     List<Component> expected = new ArrayList<>();
     List<Component> expected = new ArrayList<>();
     expected.add(targetDef.getComponents().get(0));
     expected.add(targetDef.getComponents().get(0));
 
 
-    assertEquals("single components needs upgrade",
-        expected, finder.findTargetComponentSpecs(currentDef,
-            targetDef));
+    assertEquals(expected, finder.findTargetComponentSpecs(currentDef,
+        targetDef), "single components needs upgrade");
   }
   }
 
 
   @Test
   @Test
@@ -117,7 +116,7 @@ public class TestDefaultUpgradeComponentsFinder {
     List<Component> expected = new ArrayList<>();
     List<Component> expected = new ArrayList<>();
     expected.addAll(targetDef.getComponents());
     expected.addAll(targetDef.getComponents());
 
 
-    assertEquals("all components needs upgrade",
-        expected, finder.findTargetComponentSpecs(currentDef, targetDef));
+    assertEquals(expected, finder.findTargetComponentSpecs(currentDef, targetDef),
+        "all components needs upgrade");
   }
   }
 }
 }

+ 43 - 43
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceAM.java

@@ -51,11 +51,11 @@ import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceState;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
 import org.apache.hadoop.yarn.util.DockerClientConfigHandler;
 import org.apache.hadoop.yarn.util.DockerClientConfigHandler;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
@@ -71,7 +71,9 @@ import java.util.List;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.TimeoutException;
 
 
 import static org.apache.hadoop.registry.client.api.RegistryConstants.KEY_REGISTRY_ZK_QUORUM;
 import static org.apache.hadoop.registry.client.api.RegistryConstants.KEY_REGISTRY_ZK_QUORUM;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verify;
 
 
@@ -83,11 +85,11 @@ public class TestServiceAM extends ServiceTestUtils{
   private File basedir;
   private File basedir;
   YarnConfiguration conf = new YarnConfiguration();
   YarnConfiguration conf = new YarnConfiguration();
   TestingCluster zkCluster;
   TestingCluster zkCluster;
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     basedir = new File("target", "apps");
     basedir = new File("target", "apps");
     if (basedir.exists()) {
     if (basedir.exists()) {
@@ -101,7 +103,7 @@ public class TestServiceAM extends ServiceTestUtils{
     LOG.info("ZK cluster: {}", zkCluster.getConnectString());
     LOG.info("ZK cluster: {}", zkCluster.getConnectString());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     if (basedir != null) {
     if (basedir != null) {
       FileUtils.deleteDirectory(basedir);
       FileUtils.deleteDirectory(basedir);
@@ -147,15 +149,15 @@ public class TestServiceAM extends ServiceTestUtils{
 
 
     am.waitForCompInstanceState(compa0, ComponentInstanceState.INIT);
     am.waitForCompInstanceState(compa0, ComponentInstanceState.INIT);
     // still 1 pending instance
     // still 1 pending instance
-    Assert.assertEquals(1,
-        am.getComponent("compa").getPendingInstances().size());
+    assertEquals(1, am.getComponent("compa").getPendingInstances().size());
     am.stop();
     am.stop();
   }
   }
 
 
   // Test to verify that the containers of previous attempt are not prematurely
   // Test to verify that the containers of previous attempt are not prematurely
   // released. These containers are sent by the RM to the AM in the
   // released. These containers are sent by the RM to the AM in the
   // heartbeat response.
   // heartbeat response.
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testContainersFromPreviousAttemptsWithRMRestart()
   public void testContainersFromPreviousAttemptsWithRMRestart()
       throws Exception {
       throws Exception {
     ApplicationId applicationId = ApplicationId.newInstance(
     ApplicationId applicationId = ApplicationId.newInstance(
@@ -182,23 +184,23 @@ public class TestServiceAM extends ServiceTestUtils{
     am.waitForCompInstanceState(comp10, ComponentInstanceState.STARTED);
     am.waitForCompInstanceState(comp10, ComponentInstanceState.STARTED);
 
 
     // 0 pending instance
     // 0 pending instance
-    Assert.assertEquals(0,
+    assertEquals(0,
         am.getComponent(comp1Name).getPendingInstances().size());
         am.getComponent(comp1Name).getPendingInstances().size());
 
 
     GenericTestUtils.waitFor(() -> am.getCompInstance(comp1Name, comp1InstName)
     GenericTestUtils.waitFor(() -> am.getCompInstance(comp1Name, comp1InstName)
         .getContainerStatus() != null, 2000, 200000);
         .getContainerStatus() != null, 2000, 200000);
 
 
-    Assert.assertEquals("container state",
-        org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
+    assertEquals(org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
         am.getCompInstance(comp1Name, comp1InstName).getContainerStatus()
         am.getCompInstance(comp1Name, comp1InstName).getContainerStatus()
-            .getState());
+        .getState(), "container state");
     am.stop();
     am.stop();
   }
   }
 
 
   // Test to verify that the containers of previous attempt are released and the
   // Test to verify that the containers of previous attempt are released and the
   // component instance is added to the pending queue when the recovery wait
   // component instance is added to the pending queue when the recovery wait
   // time interval elapses.
   // time interval elapses.
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testContainersReleasedWhenExpired()
   public void testContainersReleasedWhenExpired()
       throws Exception {
       throws Exception {
     ApplicationId applicationId = ApplicationId.newInstance(
     ApplicationId applicationId = ApplicationId.newInstance(
@@ -225,22 +227,22 @@ public class TestServiceAM extends ServiceTestUtils{
         .equals(ComponentState.FLEXING), 100, 2000);
         .equals(ComponentState.FLEXING), 100, 2000);
 
 
     // 1 pending instance
     // 1 pending instance
-    Assert.assertEquals(1, am.getComponent(comp1Name).getPendingInstances()
+    assertEquals(1, am.getComponent(comp1Name).getPendingInstances()
         .size());
         .size());
 
 
     am.feedContainerToComp(exampleApp, 2, comp1Name);
     am.feedContainerToComp(exampleApp, 2, comp1Name);
 
 
     GenericTestUtils.waitFor(() -> am.getCompInstance(comp1Name, comp1InstName)
     GenericTestUtils.waitFor(() -> am.getCompInstance(comp1Name, comp1InstName)
         .getContainerStatus() != null, 2000, 200000);
         .getContainerStatus() != null, 2000, 200000);
-    Assert.assertEquals("container state",
-        org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
+    assertEquals(org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
         am.getCompInstance(comp1Name, comp1InstName).getContainerStatus()
         am.getCompInstance(comp1Name, comp1InstName).getContainerStatus()
-            .getState());
+        .getState(), "container state");
   }
   }
 
 
   // Test to verify that the AM doesn't wait for containers of a different app
   // Test to verify that the AM doesn't wait for containers of a different app
   // even though it corresponds to the same service.
   // even though it corresponds to the same service.
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testContainersFromDifferentApp()
   public void testContainersFromDifferentApp()
       throws Exception {
       throws Exception {
     ApplicationId applicationId = ApplicationId.newInstance(
     ApplicationId applicationId = ApplicationId.newInstance(
@@ -268,17 +270,16 @@ public class TestServiceAM extends ServiceTestUtils{
     am.start();
     am.start();
     // 1 pending instance since the container in registry belongs to a different
     // 1 pending instance since the container in registry belongs to a different
     // app.
     // app.
-    Assert.assertEquals(1,
+    assertEquals(1,
         am.getComponent(comp1Name).getPendingInstances().size());
         am.getComponent(comp1Name).getPendingInstances().size());
 
 
     am.feedContainerToComp(exampleApp, 1, comp1Name);
     am.feedContainerToComp(exampleApp, 1, comp1Name);
     GenericTestUtils.waitFor(() -> am.getCompInstance(comp1Name, comp1InstName)
     GenericTestUtils.waitFor(() -> am.getCompInstance(comp1Name, comp1InstName)
         .getContainerStatus() != null, 2000, 200000);
         .getContainerStatus() != null, 2000, 200000);
 
 
-    Assert.assertEquals("container state",
-        org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
+    assertEquals(org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
         am.getCompInstance(comp1Name, comp1InstName).getContainerStatus()
         am.getCompInstance(comp1Name, comp1InstName).getContainerStatus()
-            .getState());
+        .getState(), "container state");
     am.stop();
     am.stop();
   }
   }
 
 
@@ -314,13 +315,12 @@ public class TestServiceAM extends ServiceTestUtils{
 
 
     Collection<AMRMClient.ContainerRequest> rr =
     Collection<AMRMClient.ContainerRequest> rr =
         amrmClientAsync.getMatchingRequests(0);
         amrmClientAsync.getMatchingRequests(0);
-    Assert.assertEquals(1, rr.size());
+    assertEquals(1, rr.size());
 
 
     org.apache.hadoop.yarn.api.records.Resource capability =
     org.apache.hadoop.yarn.api.records.Resource capability =
         rr.iterator().next().getCapability();
         rr.iterator().next().getCapability();
-    Assert.assertEquals(3333L, capability.getResourceValue("resource-1"));
-    Assert.assertEquals("Gi",
-        capability.getResourceInformation("resource-1").getUnits());
+    assertEquals(3333L, capability.getResourceValue("resource-1"));
+    assertEquals("Gi", capability.getResourceInformation("resource-1").getUnits());
 
 
     am.stop();
     am.stop();
   }
   }
@@ -432,8 +432,7 @@ public class TestServiceAM extends ServiceTestUtils{
 
 
     assertEquals(2, amCreds.numberOfTokens());
     assertEquals(2, amCreds.numberOfTokens());
     for (Token<? extends TokenIdentifier> tk : amCreds.getAllTokens()) {
     for (Token<? extends TokenIdentifier> tk : amCreds.getAllTokens()) {
-      Assert.assertTrue(
-          tk.getKind().equals(DockerCredentialTokenIdentifier.KIND));
+      assertTrue(tk.getKind().equals(DockerCredentialTokenIdentifier.KIND));
     }
     }
 
 
     am.stop();
     am.stop();
@@ -463,7 +462,7 @@ public class TestServiceAM extends ServiceTestUtils{
     GenericTestUtils.waitFor(() -> comp1inst0.getContainerStatus() != null,
     GenericTestUtils.waitFor(() -> comp1inst0.getContainerStatus() != null,
         2000, 200000);
         2000, 200000);
     // first host status will match the container nodeId
     // first host status will match the container nodeId
-    Assert.assertEquals("localhost",
+    assertEquals("localhost",
         comp1inst0.getContainerStatus().getHost());
         comp1inst0.getContainerStatus().getHost());
 
 
     LOG.info("Change the IP and host");
     LOG.info("Change the IP and host");
@@ -491,7 +490,8 @@ public class TestServiceAM extends ServiceTestUtils{
    In case the id is set to null or unset so it is effectively null,
    In case the id is set to null or unset so it is effectively null,
    Path.checkPathArg throws an IllegalArgumentException.
    Path.checkPathArg throws an IllegalArgumentException.
   **/
   **/
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testContainersReleasedWhenPreLaunchFails()
   public void testContainersReleasedWhenPreLaunchFails()
       throws Exception {
       throws Exception {
     ApplicationId applicationId = ApplicationId.newInstance(
     ApplicationId applicationId = ApplicationId.newInstance(
@@ -522,12 +522,12 @@ public class TestServiceAM extends ServiceTestUtils{
         am.getComponent(compA.getName()).getPendingInstances()
         am.getComponent(compA.getName()).getPendingInstances()
         .contains(compAinst0), 2000, 30000);
         .contains(compAinst0), 2000, 30000);
 
 
-    Assert.assertEquals(1,
-        am.getComponent("compa").getPendingInstances().size());
+    assertEquals(1, am.getComponent("compa").getPendingInstances().size());
     am.stop();
     am.stop();
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testSyncSysFS() {
   public void testSyncSysFS() {
     ApplicationId applicationId = ApplicationId.newInstance(
     ApplicationId applicationId = ApplicationId.newInstance(
         System.currentTimeMillis(), 1);
         System.currentTimeMillis(), 1);
@@ -554,7 +554,7 @@ public class TestServiceAM extends ServiceTestUtils{
       am.close();
       am.close();
     } catch (Exception e) {
     } catch (Exception e) {
       LOG.error("Fail to sync sysfs.", e);
       LOG.error("Fail to sync sysfs.", e);
-      Assert.fail("Fail to sync sysfs.");
+      fail("Fail to sync sysfs.");
     }
     }
   }
   }
 
 
@@ -593,14 +593,14 @@ public class TestServiceAM extends ServiceTestUtils{
 
 
     Collection<AMRMClient.ContainerRequest> rr =
     Collection<AMRMClient.ContainerRequest> rr =
         amrmClientAsync.getMatchingRequests(0);
         amrmClientAsync.getMatchingRequests(0);
-    Assert.assertEquals(1, rr.size());
+    assertEquals(1, rr.size());
 
 
     org.apache.hadoop.yarn.api.records.Resource capability =
     org.apache.hadoop.yarn.api.records.Resource capability =
         rr.iterator().next().getCapability();
         rr.iterator().next().getCapability();
-    Assert.assertEquals(1234L, capability.getResourceValue("test-resource"));
-    Assert.assertEquals("Gi",
+    assertEquals(1234L, capability.getResourceValue("test-resource"));
+    assertEquals("Gi",
         capability.getResourceInformation("test-resource").getUnits());
         capability.getResourceInformation("test-resource").getUnits());
-    Assert.assertEquals(2, capability.getResourceInformation("test-resource")
+    assertEquals(2, capability.getResourceInformation("test-resource")
         .getAttributes().size());
         .getAttributes().size());
     am.stop();
     am.stop();
   }
   }

+ 61 - 47
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestServiceManager.java

@@ -32,33 +32,40 @@ import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEvent;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEventType;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEventType;
 import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.List;
 import java.util.List;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.TimeoutException;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 /**
 /**
  * Tests for {@link ServiceManager}.
  * Tests for {@link ServiceManager}.
  */
  */
 public class TestServiceManager {
 public class TestServiceManager {
 
 
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
-  @Test (timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testUpgrade() throws Exception {
   public void testUpgrade() throws Exception {
     ServiceContext context = createServiceContext("testUpgrade");
     ServiceContext context = createServiceContext("testUpgrade");
     initUpgrade(context, "v2", false, false, false);
     initUpgrade(context, "v2", false, false, false);
-    Assert.assertEquals("service not upgraded", ServiceState.UPGRADING,
-        context.getServiceManager().getServiceSpec().getState());
+    assertEquals(ServiceState.UPGRADING,
+        context.getServiceManager().getServiceSpec().getState(), "service not upgraded");
   }
   }
 
 
-  @Test (timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testRestartNothingToUpgrade()
   public void testRestartNothingToUpgrade()
       throws Exception {
       throws Exception {
     ServiceContext context = createServiceContext(
     ServiceContext context = createServiceContext(
@@ -73,11 +80,12 @@ public class TestServiceManager {
     GenericTestUtils.waitFor(()->
     GenericTestUtils.waitFor(()->
         context.service.getState().equals(ServiceState.STABLE),
         context.service.getState().equals(ServiceState.STABLE),
         CHECK_EVERY_MILLIS, TIMEOUT);
         CHECK_EVERY_MILLIS, TIMEOUT);
-    Assert.assertEquals("service not re-started", ServiceState.STABLE,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.STABLE,
+        manager.getServiceSpec().getState(), "service not re-started");
   }
   }
 
 
-  @Test(timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testAutoFinalizeNothingToUpgrade() throws Exception {
   public void testAutoFinalizeNothingToUpgrade() throws Exception {
     ServiceContext context = createServiceContext(
     ServiceContext context = createServiceContext(
         "testAutoFinalizeNothingToUpgrade");
         "testAutoFinalizeNothingToUpgrade");
@@ -89,11 +97,12 @@ public class TestServiceManager {
     GenericTestUtils.waitFor(()->
     GenericTestUtils.waitFor(()->
         context.service.getState().equals(ServiceState.STABLE),
         context.service.getState().equals(ServiceState.STABLE),
         CHECK_EVERY_MILLIS, TIMEOUT);
         CHECK_EVERY_MILLIS, TIMEOUT);
-    Assert.assertEquals("service stable", ServiceState.STABLE,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.STABLE,
+        manager.getServiceSpec().getState(), "service stable");
   }
   }
 
 
-  @Test(timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testRestartWithPendingUpgrade()
   public void testRestartWithPendingUpgrade()
       throws Exception {
       throws Exception {
     ServiceContext context = createServiceContext("testRestart");
     ServiceContext context = createServiceContext("testRestart");
@@ -103,17 +112,18 @@ public class TestServiceManager {
     context.scheduler.getDispatcher().getEventHandler().handle(
     context.scheduler.getDispatcher().getEventHandler().handle(
         new ServiceEvent(ServiceEventType.START));
         new ServiceEvent(ServiceEventType.START));
     context.scheduler.getDispatcher().stop();
     context.scheduler.getDispatcher().stop();
-    Assert.assertEquals("service should still be upgrading",
-        ServiceState.UPGRADING, manager.getServiceSpec().getState());
+    assertEquals(ServiceState.UPGRADING,
+        manager.getServiceSpec().getState(), "service should still be upgrading");
   }
   }
 
 
-  @Test(timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testFinalize() throws Exception {
   public void testFinalize() throws Exception {
     ServiceContext context = createServiceContext("testCheckState");
     ServiceContext context = createServiceContext("testCheckState");
     initUpgrade(context, "v2", true, false, false);
     initUpgrade(context, "v2", true, false, false);
     ServiceManager manager = context.getServiceManager();
     ServiceManager manager = context.getServiceManager();
-    Assert.assertEquals("service not upgrading", ServiceState.UPGRADING,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.UPGRADING,
+        manager.getServiceSpec().getState(), "service not upgrading");
 
 
     //make components stable by upgrading all instances
     //make components stable by upgrading all instances
     upgradeAndReadyAllInstances(context);
     upgradeAndReadyAllInstances(context);
@@ -124,13 +134,14 @@ public class TestServiceManager {
     GenericTestUtils.waitFor(()->
     GenericTestUtils.waitFor(()->
         context.service.getState().equals(ServiceState.STABLE),
         context.service.getState().equals(ServiceState.STABLE),
         CHECK_EVERY_MILLIS, TIMEOUT);
         CHECK_EVERY_MILLIS, TIMEOUT);
-    Assert.assertEquals("service not re-started", ServiceState.STABLE,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.STABLE,
+        manager.getServiceSpec().getState(), "service not re-started");
 
 
     validateUpgradeFinalization(manager.getName(), "v2");
     validateUpgradeFinalization(manager.getName(), "v2");
   }
   }
 
 
-  @Test(timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testAutoFinalize() throws Exception {
   public void testAutoFinalize() throws Exception {
     ServiceContext context = createServiceContext("testCheckStateAutoFinalize");
     ServiceContext context = createServiceContext("testCheckStateAutoFinalize");
     ServiceManager manager = context.getServiceManager();
     ServiceManager manager = context.getServiceManager();
@@ -144,8 +155,8 @@ public class TestServiceManager {
     GenericTestUtils.waitFor(() ->
     GenericTestUtils.waitFor(() ->
         context.service.getState().equals(ServiceState.STABLE),
         context.service.getState().equals(ServiceState.STABLE),
         CHECK_EVERY_MILLIS, TIMEOUT);
         CHECK_EVERY_MILLIS, TIMEOUT);
-    Assert.assertEquals("service not stable",
-        ServiceState.STABLE, manager.getServiceSpec().getState());
+    assertEquals(ServiceState.STABLE,
+        manager.getServiceSpec().getState(), "service not stable");
 
 
     validateUpgradeFinalization(manager.getName(), "v2");
     validateUpgradeFinalization(manager.getName(), "v2");
   }
   }
@@ -165,13 +176,14 @@ public class TestServiceManager {
     try {
     try {
       manager.processUpgradeRequest("v2", true, false);
       manager.processUpgradeRequest("v2", true, false);
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.assertTrue(ex instanceof UnsupportedOperationException);
+      assertTrue(ex instanceof UnsupportedOperationException);
       return;
       return;
     }
     }
-    Assert.fail();
+    fail();
   }
   }
 
 
-  @Test(timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testExpressUpgrade() throws Exception {
   public void testExpressUpgrade() throws Exception {
     ServiceContext context = createServiceContext("testExpressUpgrade");
     ServiceContext context = createServiceContext("testExpressUpgrade");
     ServiceManager manager = context.getServiceManager();
     ServiceManager manager = context.getServiceManager();
@@ -191,19 +203,20 @@ public class TestServiceManager {
             context.service.getState().equals(ServiceState.STABLE),
             context.service.getState().equals(ServiceState.STABLE),
         CHECK_EVERY_MILLIS, TIMEOUT);
         CHECK_EVERY_MILLIS, TIMEOUT);
 
 
-    Assert.assertEquals("service not stable",
-        ServiceState.STABLE, manager.getServiceSpec().getState());
+    assertEquals(ServiceState.STABLE, manager.getServiceSpec().getState(),
+        "service not stable");
     validateUpgradeFinalization(manager.getName(), "v2");
     validateUpgradeFinalization(manager.getName(), "v2");
   }
   }
 
 
-  @Test(timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testCancelUpgrade() throws Exception {
   public void testCancelUpgrade() throws Exception {
     ServiceContext context = createServiceContext("testCancelUpgrade");
     ServiceContext context = createServiceContext("testCancelUpgrade");
     writeInitialDef(context.service);
     writeInitialDef(context.service);
     initUpgrade(context, "v2", true, false, false);
     initUpgrade(context, "v2", true, false, false);
     ServiceManager manager = context.getServiceManager();
     ServiceManager manager = context.getServiceManager();
-    Assert.assertEquals("service not upgrading", ServiceState.UPGRADING,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.UPGRADING,
+        manager.getServiceSpec().getState(), "service not upgrading");
 
 
     List<String> comps = ServiceApiUtil.resolveCompsDependency(context.service);
     List<String> comps = ServiceApiUtil.resolveCompsDependency(context.service);
     // wait till instances of first component are upgraded and ready
     // wait till instances of first component are upgraded and ready
@@ -220,20 +233,21 @@ public class TestServiceManager {
     GenericTestUtils.waitFor(()->
     GenericTestUtils.waitFor(()->
             context.service.getState().equals(ServiceState.STABLE),
             context.service.getState().equals(ServiceState.STABLE),
         CHECK_EVERY_MILLIS, TIMEOUT);
         CHECK_EVERY_MILLIS, TIMEOUT);
-    Assert.assertEquals("service upgrade not cancelled", ServiceState.STABLE,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.STABLE,
+        manager.getServiceSpec().getState(), "service upgrade not cancelled");
 
 
     validateUpgradeFinalization(manager.getName(), "v1");
     validateUpgradeFinalization(manager.getName(), "v1");
   }
   }
 
 
-  @Test(timeout = TIMEOUT)
+  @Test
+  @Timeout(value = TIMEOUT)
   public void testCancelUpgradeAfterInitiate() throws Exception {
   public void testCancelUpgradeAfterInitiate() throws Exception {
     ServiceContext context = createServiceContext("testCancelUpgrade");
     ServiceContext context = createServiceContext("testCancelUpgrade");
     writeInitialDef(context.service);
     writeInitialDef(context.service);
     initUpgrade(context, "v2", true, false, false);
     initUpgrade(context, "v2", true, false, false);
     ServiceManager manager = context.getServiceManager();
     ServiceManager manager = context.getServiceManager();
-    Assert.assertEquals("service not upgrading", ServiceState.UPGRADING,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.UPGRADING,
+        manager.getServiceSpec().getState(), "service not upgrading");
 
 
     // cancel upgrade
     // cancel upgrade
     context.scheduler.getDispatcher().getEventHandler().handle(
     context.scheduler.getDispatcher().getEventHandler().handle(
@@ -241,8 +255,8 @@ public class TestServiceManager {
     GenericTestUtils.waitFor(()->
     GenericTestUtils.waitFor(()->
             context.service.getState().equals(ServiceState.STABLE),
             context.service.getState().equals(ServiceState.STABLE),
         CHECK_EVERY_MILLIS, TIMEOUT);
         CHECK_EVERY_MILLIS, TIMEOUT);
-    Assert.assertEquals("service upgrade not cancelled", ServiceState.STABLE,
-        manager.getServiceSpec().getState());
+    assertEquals(ServiceState.STABLE,
+        manager.getServiceSpec().getState(), "service upgrade not cancelled");
 
 
     validateUpgradeFinalization(manager.getName(), "v1");
     validateUpgradeFinalization(manager.getName(), "v1");
   }
   }
@@ -250,14 +264,14 @@ public class TestServiceManager {
   private void validateUpgradeFinalization(String serviceName,
   private void validateUpgradeFinalization(String serviceName,
       String expectedVersion) throws IOException {
       String expectedVersion) throws IOException {
     Service savedSpec = ServiceApiUtil.loadService(rule.getFs(), serviceName);
     Service savedSpec = ServiceApiUtil.loadService(rule.getFs(), serviceName);
-    Assert.assertEquals("service def not re-written", expectedVersion,
-        savedSpec.getVersion());
-    Assert.assertNotNull("app id not present", savedSpec.getId());
-    Assert.assertEquals("state not stable", ServiceState.STABLE,
-        savedSpec.getState());
+    assertEquals(expectedVersion,
+        savedSpec.getVersion(), "service def not re-written");
+    assertNotNull(savedSpec.getId(), "app id not present");
+    assertEquals(ServiceState.STABLE,
+        savedSpec.getState(), "state not stable");
     savedSpec.getComponents().forEach(compSpec ->
     savedSpec.getComponents().forEach(compSpec ->
-        Assert.assertEquals("comp not stable", ComponentState.STABLE,
-        compSpec.getState()));
+        assertEquals(ComponentState.STABLE,
+            compSpec.getState(), "comp not stable"));
   }
   }
 
 
   private void initUpgrade(ServiceContext context, String version,
   private void initUpgrade(ServiceContext context, String version,

+ 122 - 113
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestYarnNativeServices.java

@@ -49,13 +49,10 @@ import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 
 
-import org.hamcrest.CoreMatchers;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -67,6 +64,11 @@ import java.util.*;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.TimeoutException;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.apache.hadoop.yarn.api.records.YarnApplicationState.FINISHED;
 import static org.apache.hadoop.yarn.api.records.YarnApplicationState.FINISHED;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.*;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.*;
 import static org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes.EXIT_COMMAND_ARGUMENT_ERROR;
 import static org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes.EXIT_COMMAND_ARGUMENT_ERROR;
@@ -81,16 +83,13 @@ public class TestYarnNativeServices extends ServiceTestUtils {
   private static final Logger LOG =
   private static final Logger LOG =
       LoggerFactory.getLogger(TestYarnNativeServices.class);
       LoggerFactory.getLogger(TestYarnNativeServices.class);
 
 
-  @Rule
-  public TemporaryFolder tmpFolder = new TemporaryFolder();
-
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     File tmpYarnDir = new File("target", "tmp");
     File tmpYarnDir = new File("target", "tmp");
     FileUtils.deleteQuietly(tmpYarnDir);
     FileUtils.deleteQuietly(tmpYarnDir);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     shutdown();
     shutdown();
   }
   }
@@ -102,7 +101,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
   // 4. Flex up each component to 2 containers and check the component instance names
   // 4. Flex up each component to 2 containers and check the component instance names
   // 5. Stop the service
   // 5. Stop the service
   // 6. Destroy the service
   // 6. Destroy the service
-  @Test (timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testCreateFlexStopDestroyService() throws Exception {
   public void testCreateFlexStopDestroyService() throws Exception {
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     ServiceClient client = createClient(getConf());
     ServiceClient client = createClient(getConf());
@@ -111,7 +111,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     SliderFileSystem fileSystem = new SliderFileSystem(getConf());
     SliderFileSystem fileSystem = new SliderFileSystem(getConf());
     Path appDir = fileSystem.buildClusterDirPath(exampleApp.getName());
     Path appDir = fileSystem.buildClusterDirPath(exampleApp.getName());
     // check app.json is persisted.
     // check app.json is persisted.
-    Assert.assertTrue(
+    assertTrue(
         getFS().exists(new Path(appDir, exampleApp.getName() + ".json")));
         getFS().exists(new Path(appDir, exampleApp.getName() + ".json")));
     waitForServiceToBeStable(client, exampleApp);
     waitForServiceToBeStable(client, exampleApp);
 
 
@@ -140,35 +140,36 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     ApplicationReport report = client.getYarnClient()
     ApplicationReport report = client.getYarnClient()
         .getApplicationReport(ApplicationId.fromString(exampleApp.getId()));
         .getApplicationReport(ApplicationId.fromString(exampleApp.getId()));
     // AM unregisters with RM successfully
     // AM unregisters with RM successfully
-    Assert.assertEquals(FINISHED, report.getYarnApplicationState());
-    Assert.assertEquals(FinalApplicationStatus.ENDED,
+    assertEquals(FINISHED, report.getYarnApplicationState());
+    assertEquals(FinalApplicationStatus.ENDED,
         report.getFinalApplicationStatus());
         report.getFinalApplicationStatus());
     String serviceZKPath = RegistryUtils.servicePath(RegistryUtils
     String serviceZKPath = RegistryUtils.servicePath(RegistryUtils
         .currentUser(), YarnServiceConstants.APP_TYPE, exampleApp.getName());
         .currentUser(), YarnServiceConstants.APP_TYPE, exampleApp.getName());
-    Assert.assertFalse("Registry ZK service path still exists after stop",
-        getCuratorService().zkPathExists(serviceZKPath));
+    assertFalse(getCuratorService().zkPathExists(serviceZKPath),
+        "Registry ZK service path still exists after stop");
 
 
     LOG.info("Destroy the service");
     LOG.info("Destroy the service");
     // destroy the service and check the app dir is deleted from fs.
     // destroy the service and check the app dir is deleted from fs.
-    Assert.assertEquals(0, client.actionDestroy(exampleApp.getName()));
+    assertEquals(0, client.actionDestroy(exampleApp.getName()));
     // check the service dir on hdfs (in this case, local fs) are deleted.
     // check the service dir on hdfs (in this case, local fs) are deleted.
-    Assert.assertFalse(getFS().exists(appDir));
+    assertFalse(getFS().exists(appDir));
 
 
     // check that destroying again does not succeed
     // check that destroying again does not succeed
-    Assert.assertEquals(EXIT_NOT_FOUND, client.actionDestroy(exampleApp.getName()));
+    assertEquals(EXIT_NOT_FOUND, client.actionDestroy(exampleApp.getName()));
   }
   }
 
 
   // Save a service without starting it and ensure that stop does not NPE and
   // Save a service without starting it and ensure that stop does not NPE and
   // that service can be successfully destroyed
   // that service can be successfully destroyed
-  @Test (timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testStopDestroySavedService() throws Exception {
   public void testStopDestroySavedService() throws Exception {
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     ServiceClient client = createClient(getConf());
     ServiceClient client = createClient(getConf());
     Service exampleApp = createExampleApplication();
     Service exampleApp = createExampleApplication();
     client.actionBuild(exampleApp);
     client.actionBuild(exampleApp);
-    Assert.assertEquals(EXIT_COMMAND_ARGUMENT_ERROR, client.actionStop(
+    assertEquals(EXIT_COMMAND_ARGUMENT_ERROR, client.actionStop(
         exampleApp.getName()));
         exampleApp.getName()));
-    Assert.assertEquals(0, client.actionDestroy(exampleApp.getName()));
+    assertEquals(0, client.actionDestroy(exampleApp.getName()));
   }
   }
 
 
   // Create compa with 2 containers
   // Create compa with 2 containers
@@ -176,7 +177,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
   // Create compc with 2 containers which depends on compb
   // Create compc with 2 containers which depends on compb
   // Check containers for compa started before containers for compb before
   // Check containers for compa started before containers for compb before
   // containers for compc
   // containers for compc
-  @Test (timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testComponentStartOrder() throws Exception {
   public void testComponentStartOrder() throws Exception {
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     ServiceClient client = createClient(getConf());
     ServiceClient client = createClient(getConf());
@@ -206,7 +208,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     client.actionDestroy(exampleApp.getName());
     client.actionDestroy(exampleApp.getName());
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testCreateServiceSameNameDifferentUser() throws Exception {
   public void testCreateServiceSameNameDifferentUser() throws Exception {
     String sameAppName = "same-name";
     String sameAppName = "same-name";
     String userA = "usera";
     String userA = "usera";
@@ -239,8 +242,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
       getConf().set(YARN_SERVICE_BASE_PATH, userBBasePath.getAbsolutePath());
       getConf().set(YARN_SERVICE_BASE_PATH, userBBasePath.getAbsolutePath());
       client.actionBuild(userBApp);
       client.actionBuild(userBApp);
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert
-          .fail("Exception should not be thrown - " + e.getLocalizedMessage());
+      fail("Exception should not be thrown - " + e.getLocalizedMessage());
     } finally {
     } finally {
       if (userABasePath != null) {
       if (userABasePath != null) {
         getConf().set(YARN_SERVICE_BASE_PATH, userABasePath.getAbsolutePath());
         getConf().set(YARN_SERVICE_BASE_PATH, userABasePath.getAbsolutePath());
@@ -258,7 +260,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     // Need to test create followed by create.
     // Need to test create followed by create.
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testCreateServiceSameNameSameUser() throws Exception {
   public void testCreateServiceSameNameSameUser() throws Exception {
     String sameAppName = "same-name";
     String sameAppName = "same-name";
     String user = UserGroupInformation.getCurrentUser().getUserName();
     String user = UserGroupInformation.getCurrentUser().getUserName();
@@ -283,10 +286,9 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     } catch (Exception e) {
     } catch (Exception e) {
       String expectedMsg = "Service Instance dir already exists:";
       String expectedMsg = "Service Instance dir already exists:";
       if (e.getLocalizedMessage() != null) {
       if (e.getLocalizedMessage() != null) {
-        Assert.assertThat(e.getLocalizedMessage(),
-            CoreMatchers.containsString(expectedMsg));
+        assertThat(e.getLocalizedMessage()).contains(expectedMsg);
       } else {
       } else {
-        Assert.fail("Message cannot be null. It has to say - " + expectedMsg);
+        fail("Message cannot be null. It has to say - " + expectedMsg);
       }
       }
     } finally {
     } finally {
       // cleanup
       // cleanup
@@ -303,10 +305,9 @@ public class TestYarnNativeServices extends ServiceTestUtils {
       String expectedMsg = "Failed to create service " + sameAppName
       String expectedMsg = "Failed to create service " + sameAppName
           + ", because it already exists.";
           + ", because it already exists.";
       if (e.getLocalizedMessage() != null) {
       if (e.getLocalizedMessage() != null) {
-        Assert.assertThat(e.getLocalizedMessage(),
-            CoreMatchers.containsString(expectedMsg));
+        assertThat(e.getLocalizedMessage()).contains(expectedMsg);
       } else {
       } else {
-        Assert.fail("Message cannot be null. It has to say - " + expectedMsg);
+        fail("Message cannot be null. It has to say - " + expectedMsg);
       }
       }
     } finally {
     } finally {
       // cleanup
       // cleanup
@@ -320,7 +321,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
   // 2. Restart RM.
   // 2. Restart RM.
   // 3. Fail the application attempt.
   // 3. Fail the application attempt.
   // 4. Verify ServiceMaster recovers.
   // 4. Verify ServiceMaster recovers.
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testRecoverComponentsAfterRMRestart() throws Exception {
   public void testRecoverComponentsAfterRMRestart() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
     conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
@@ -348,8 +350,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     GenericTestUtils.waitFor(() ->
     GenericTestUtils.waitFor(() ->
         getYarnCluster().getResourceManager().getServiceState() ==
         getYarnCluster().getResourceManager().getServiceState() ==
             org.apache.hadoop.service.Service.STATE.STARTED, 2000, 200000);
             org.apache.hadoop.service.Service.STATE.STARTED, 2000, 200000);
-    Assert.assertTrue("node managers connected",
-        getYarnCluster().waitForNodeManagersToConnect(5000));
+    assertTrue(getYarnCluster().waitForNodeManagersToConnect(5000),
+        "node managers connected");
 
 
     ApplicationId exampleAppId = ApplicationId.fromString(exampleApp.getId());
     ApplicationId exampleAppId = ApplicationId.fromString(exampleApp.getId());
     ApplicationAttemptId applicationAttemptId = client.getYarnClient()
     ApplicationAttemptId applicationAttemptId = client.getYarnClient()
@@ -372,10 +374,10 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     Multimap<String, String> containersAfterFailure = waitForAllCompToBeReady(
     Multimap<String, String> containersAfterFailure = waitForAllCompToBeReady(
         client, exampleApp);
         client, exampleApp);
     containersBeforeFailure.keys().forEach(compName -> {
     containersBeforeFailure.keys().forEach(compName -> {
-      Assert.assertEquals("num containers after by restart for " + compName,
-          containersBeforeFailure.get(compName).size(),
+      assertEquals(containersBeforeFailure.get(compName).size(),
           containersAfterFailure.get(compName) == null ? 0 :
           containersAfterFailure.get(compName) == null ? 0 :
-              containersAfterFailure.get(compName).size());
+          containersAfterFailure.get(compName).size(),
+          "num containers after by restart for " + compName);
     });
     });
 
 
     LOG.info("Stop/destroy service {}", exampleApp);
     LOG.info("Stop/destroy service {}", exampleApp);
@@ -383,7 +385,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     client.actionDestroy(exampleApp.getName());
     client.actionDestroy(exampleApp.getName());
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testUpgrade() throws Exception {
   public void testUpgrade() throws Exception {
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
     getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
@@ -405,8 +408,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     SliderFileSystem fs = new SliderFileSystem(getConf());
     SliderFileSystem fs = new SliderFileSystem(getConf());
     Service fromFs = ServiceApiUtil.loadServiceUpgrade(fs,
     Service fromFs = ServiceApiUtil.loadServiceUpgrade(fs,
         service.getName(), service.getVersion());
         service.getName(), service.getVersion());
-    Assert.assertEquals(service.getName(), fromFs.getName());
-    Assert.assertEquals(service.getVersion(), fromFs.getVersion());
+    assertEquals(service.getName(), fromFs.getName());
+    assertEquals(service.getVersion(), fromFs.getVersion());
 
 
     // upgrade containers
     // upgrade containers
     Service liveService = client.getStatus(service.getName());
     Service liveService = client.getStatus(service.getName());
@@ -418,17 +421,17 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     client.actionStart(service.getName());
     client.actionStart(service.getName());
     waitForServiceToBeStable(client, service);
     waitForServiceToBeStable(client, service);
     Service active = client.getStatus(service.getName());
     Service active = client.getStatus(service.getName());
-    Assert.assertEquals("component not stable", ComponentState.STABLE,
-        active.getComponent(component.getName()).getState());
-    Assert.assertEquals("comp does not have new env", "val1",
-        active.getComponent(component.getName()).getConfiguration()
-            .getEnv("key1"));
+    assertEquals(ComponentState.STABLE,
+        active.getComponent(component.getName()).getState(), "component not stable");
+    assertEquals("val1", active.getComponent(component.getName()).getConfiguration()
+        .getEnv("key1"), "comp does not have new env");
     LOG.info("Stop/destroy service {}", service);
     LOG.info("Stop/destroy service {}", service);
     client.actionStop(service.getName(), true);
     client.actionStop(service.getName(), true);
     client.actionDestroy(service.getName());
     client.actionDestroy(service.getName());
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testExpressUpgrade() throws Exception {
   public void testExpressUpgrade() throws Exception {
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
     getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
@@ -452,22 +455,21 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     // wait for upgrade to complete
     // wait for upgrade to complete
     waitForServiceToBeStable(client, service);
     waitForServiceToBeStable(client, service);
     Service active = client.getStatus(service.getName());
     Service active = client.getStatus(service.getName());
-    Assert.assertEquals("version mismatch", service.getVersion(),
-        active.getVersion());
-    Assert.assertEquals("component not stable", ComponentState.STABLE,
-        active.getComponent(component.getName()).getState());
-    Assert.assertEquals("compa does not have new env", "val1",
-        active.getComponent(component.getName()).getConfiguration()
-            .getEnv("key1"));
-    Assert.assertEquals("compb does not have new env", "val2",
-        active.getComponent(component2.getName()).getConfiguration()
-            .getEnv("key2"));
+    assertEquals(service.getVersion(),
+        active.getVersion(), "version mismatch");
+    assertEquals(ComponentState.STABLE,
+        active.getComponent(component.getName()).getState(), "component not stable");
+    assertEquals("val1", active.getComponent(component.getName()).getConfiguration()
+        .getEnv("key1"), "compa does not have new env");
+    assertEquals("val2", active.getComponent(component2.getName()).getConfiguration()
+        .getEnv("key2"), "compb does not have new env");
     LOG.info("Stop/destroy service {}", service);
     LOG.info("Stop/destroy service {}", service);
     client.actionStop(service.getName(), true);
     client.actionStop(service.getName(), true);
     client.actionDestroy(service.getName());
     client.actionDestroy(service.getName());
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testCancelUpgrade() throws Exception {
   public void testCancelUpgrade() throws Exception {
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
     getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
@@ -500,11 +502,11 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     client.actionCancelUpgrade(service.getName());
     client.actionCancelUpgrade(service.getName());
     waitForServiceToBeStable(client, service);
     waitForServiceToBeStable(client, service);
     Service active = client.getStatus(service.getName());
     Service active = client.getStatus(service.getName());
-    Assert.assertEquals("component not stable", ComponentState.STABLE,
-        active.getComponent(component.getName()).getState());
-    Assert.assertEquals("comp does not have new env", "val0",
+    assertEquals(ComponentState.STABLE,
+        active.getComponent(component.getName()).getState(), "component not stable");
+    assertEquals("val0",
         active.getComponent(component.getName()).getConfiguration()
         active.getComponent(component.getName()).getConfiguration()
-            .getEnv("key1"));
+        .getEnv("key1"), "comp does not have new env");
     LOG.info("Stop/destroy service {}", service);
     LOG.info("Stop/destroy service {}", service);
     client.actionStop(service.getName(), true);
     client.actionStop(service.getName(), true);
     client.actionDestroy(service.getName());
     client.actionDestroy(service.getName());
@@ -518,7 +520,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
   // 4. Flex the component to 4 containers
   // 4. Flex the component to 4 containers
   // 5. Verify that the 4th container does not even get allocated since there
   // 5. Verify that the 4th container does not even get allocated since there
   //    are only 3 NMs
   //    are only 3 NMs
-  @Test (timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testCreateServiceWithPlacementPolicy() throws Exception {
   public void testCreateServiceWithPlacementPolicy() throws Exception {
     // We need to enable scheduler placement-constraint at the cluster level to
     // We need to enable scheduler placement-constraint at the cluster level to
     // let apps use placement policies.
     // let apps use placement policies.
@@ -549,10 +552,10 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     // Check service is stable and all 3 containers are running
     // Check service is stable and all 3 containers are running
     Service service = client.getStatus(exampleApp.getName());
     Service service = client.getStatus(exampleApp.getName());
     Component component = service.getComponent("compa");
     Component component = service.getComponent("compa");
-    Assert.assertEquals("Service state should be STABLE", ServiceState.STABLE,
-        service.getState());
-    Assert.assertEquals("3 containers are expected to be running", 3,
-        component.getContainers().size());
+    assertEquals(ServiceState.STABLE,
+        service.getState(), "Service state should be STABLE");
+    assertEquals(3,
+        component.getContainers().size(), "3 containers are expected to be running");
     // Prepare a map of non-AM containers for later lookup
     // Prepare a map of non-AM containers for later lookup
     Set<String> nonAMContainerIdSet = new HashSet<>();
     Set<String> nonAMContainerIdSet = new HashSet<>();
     for (Container cont : component.getContainers()) {
     for (Container cont : component.getContainers()) {
@@ -573,7 +576,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
         continue;
         continue;
       }
       }
       if (hosts.contains(contReport.getNodeHttpAddress())) {
       if (hosts.contains(contReport.getNodeHttpAddress())) {
-        Assert.fail("Container " + contReport.getContainerId()
+        fail("Container " + contReport.getContainerId()
             + " came up in the same host as another container.");
             + " came up in the same host as another container.");
       } else {
       } else {
         hosts.add(contReport.getNodeHttpAddress());
         hosts.add(contReport.getNodeHttpAddress());
@@ -590,19 +593,19 @@ public class TestYarnNativeServices extends ServiceTestUtils {
       // this test is that it has to wait that long. Setting a higher wait time
       // this test is that it has to wait that long. Setting a higher wait time
       // will add to the total time taken by tests to run.
       // will add to the total time taken by tests to run.
       waitForServiceToBeStable(client, exampleApp, 10000);
       waitForServiceToBeStable(client, exampleApp, 10000);
-      Assert.fail("Service should not be in a stable state. It should throw "
+      fail("Service should not be in a stable state. It should throw "
           + "a timeout exception.");
           + "a timeout exception.");
     } catch (Exception e) {
     } catch (Exception e) {
       // Check that service state is not STABLE and only 3 containers are
       // Check that service state is not STABLE and only 3 containers are
       // running and the fourth one should not get allocated.
       // running and the fourth one should not get allocated.
       service = client.getStatus(exampleApp.getName());
       service = client.getStatus(exampleApp.getName());
       component = service.getComponent("compa");
       component = service.getComponent("compa");
-      Assert.assertNotEquals("Service state should not be STABLE",
-          ServiceState.STABLE, service.getState());
-      Assert.assertEquals("Component state should be FLEXING",
-          ComponentState.FLEXING, component.getState());
-      Assert.assertEquals("3 containers are expected to be running", 3,
-          component.getContainers().size());
+      assertNotEquals(ServiceState.STABLE, service.getState(),
+          "Service state should not be STABLE");
+      assertEquals(ComponentState.FLEXING, component.getState(),
+          "Component state should be FLEXING");
+      assertEquals(3, component.getContainers().size(),
+          "3 containers are expected to be running");
     }
     }
 
 
     // Flex compa down to 4 now, which is still more containers than the no of
     // Flex compa down to 4 now, which is still more containers than the no of
@@ -619,19 +622,19 @@ public class TestYarnNativeServices extends ServiceTestUtils {
       // this test is that it has to wait that long. Setting a higher wait time
       // this test is that it has to wait that long. Setting a higher wait time
       // will add to the total time taken by tests to run.
       // will add to the total time taken by tests to run.
       waitForServiceToBeStable(client, exampleApp, 10000);
       waitForServiceToBeStable(client, exampleApp, 10000);
-      Assert.fail("Service should not be in a stable state. It should throw "
+      fail("Service should not be in a stable state. It should throw "
           + "a timeout exception.");
           + "a timeout exception.");
     } catch (Exception e) {
     } catch (Exception e) {
       // Check that service state is not STABLE and only 3 containers are
       // Check that service state is not STABLE and only 3 containers are
       // running and the fourth one should not get allocated.
       // running and the fourth one should not get allocated.
       service = client.getStatus(exampleApp.getName());
       service = client.getStatus(exampleApp.getName());
       component = service.getComponent("compa");
       component = service.getComponent("compa");
-      Assert.assertNotEquals("Service state should not be STABLE",
-          ServiceState.STABLE, service.getState());
-      Assert.assertEquals("Component state should be FLEXING",
-          ComponentState.FLEXING, component.getState());
-      Assert.assertEquals("3 containers are expected to be running", 3,
-          component.getContainers().size());
+      assertNotEquals(ServiceState.STABLE, service.getState(),
+          "Service state should not be STABLE");
+      assertEquals(ComponentState.FLEXING, component.getState(),
+          "Component state should be FLEXING");
+      assertEquals(3, component.getContainers().size(),
+          "3 containers are expected to be running");
     }
     }
 
 
     // Finally flex compa down to 3, which is exactly the number of containers
     // Finally flex compa down to 3, which is exactly the number of containers
@@ -648,12 +651,14 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     client.actionDestroy(exampleApp.getName());
     client.actionDestroy(exampleApp.getName());
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testAMSigtermDoesNotKillApplication() throws Exception {
   public void testAMSigtermDoesNotKillApplication() throws Exception {
     runAMSignalTest(SignalContainerCommand.GRACEFUL_SHUTDOWN);
     runAMSignalTest(SignalContainerCommand.GRACEFUL_SHUTDOWN);
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testAMSigkillDoesNotKillApplication() throws Exception {
   public void testAMSigkillDoesNotKillApplication() throws Exception {
     runAMSignalTest(SignalContainerCommand.FORCEFUL_SHUTDOWN);
     runAMSignalTest(SignalContainerCommand.FORCEFUL_SHUTDOWN);
   }
   }
@@ -685,7 +690,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
         ApplicationReport ar = client.getYarnClient()
         ApplicationReport ar = client.getYarnClient()
             .getApplicationReport(exampleAppId);
             .getApplicationReport(exampleAppId);
         YarnApplicationState state = ar.getYarnApplicationState();
         YarnApplicationState state = ar.getYarnApplicationState();
-        Assert.assertTrue(state == YarnApplicationState.RUNNING ||
+        assertTrue(state == YarnApplicationState.RUNNING ||
             state == YarnApplicationState.ACCEPTED);
             state == YarnApplicationState.ACCEPTED);
         if (state != YarnApplicationState.RUNNING) {
         if (state != YarnApplicationState.RUNNING) {
           return false;
           return false;
@@ -698,7 +703,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
         if (appStatus2.getState() != ServiceState.STABLE) {
         if (appStatus2.getState() != ServiceState.STABLE) {
           return false;
           return false;
         }
         }
-        Assert.assertEquals(getSortedContainerIds(appStatus1).toString(),
+        assertEquals(getSortedContainerIds(appStatus1).toString(),
             getSortedContainerIds(appStatus2).toString());
             getSortedContainerIds(appStatus2).toString());
         return true;
         return true;
       } catch (YarnException | IOException e) {
       } catch (YarnException | IOException e) {
@@ -729,7 +734,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
   //    threshold the service will continue to run beyond the window of 3 secs.
   //    threshold the service will continue to run beyond the window of 3 secs.
   // 4. Flex the component to 5 containers. This makes health = 60%, so based on
   // 4. Flex the component to 5 containers. This makes health = 60%, so based on
   //    threshold the service will be stopped after the window of 3 secs.
   //    threshold the service will be stopped after the window of 3 secs.
-  @Test (timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testComponentHealthThresholdMonitor() throws Exception {
   public void testComponentHealthThresholdMonitor() throws Exception {
     // We need to enable scheduler placement-constraint at the cluster level to
     // We need to enable scheduler placement-constraint at the cluster level to
     // let apps use placement policies.
     // let apps use placement policies.
@@ -772,10 +778,10 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     // Check service is stable and all 3 containers are running
     // Check service is stable and all 3 containers are running
     Service service = client.getStatus(exampleApp.getName());
     Service service = client.getStatus(exampleApp.getName());
     Component component = service.getComponent("compa");
     Component component = service.getComponent("compa");
-    Assert.assertEquals("Service state should be STABLE", ServiceState.STABLE,
-        service.getState());
-    Assert.assertEquals("3 containers are expected to be running", 3,
-        component.getContainers().size());
+    assertEquals(ServiceState.STABLE,
+        service.getState(), "Service state should be STABLE");
+    assertEquals(3, component.getContainers().size(),
+        "3 containers are expected to be running");
 
 
     // Flex compa up to 4 - will make health 75% (3 out of 4 running), but still
     // Flex compa up to 4 - will make health 75% (3 out of 4 running), but still
     // above threshold of 65%, so service will continue to run.
     // above threshold of 65%, so service will continue to run.
@@ -790,18 +796,18 @@ public class TestYarnNativeServices extends ServiceTestUtils {
       // the timeout the service should continue to run since health is 75%
       // the timeout the service should continue to run since health is 75%
       // which is above the threshold of 65%.
       // which is above the threshold of 65%.
       waitForServiceToBeStable(client, exampleApp, 6000);
       waitForServiceToBeStable(client, exampleApp, 6000);
-      Assert.fail("Service should not be in a stable state. It should throw "
+      fail("Service should not be in a stable state. It should throw "
           + "a timeout exception.");
           + "a timeout exception.");
     } catch (Exception e) {
     } catch (Exception e) {
       // Check that service state is STARTED and only 3 containers are running
       // Check that service state is STARTED and only 3 containers are running
       service = client.getStatus(exampleApp.getName());
       service = client.getStatus(exampleApp.getName());
       component = service.getComponent("compa");
       component = service.getComponent("compa");
-      Assert.assertEquals("Service state should be STARTED",
-          ServiceState.STARTED, service.getState());
-      Assert.assertEquals("Component state should be FLEXING",
-          ComponentState.FLEXING, component.getState());
-      Assert.assertEquals("3 containers are expected to be running", 3,
-          component.getContainers().size());
+      assertEquals(ServiceState.STARTED, service.getState(),
+          "Service state should be STARTED");
+      assertEquals(ComponentState.FLEXING, component.getState(),
+          "Component state should be FLEXING");
+      assertEquals(3, component.getContainers().size(),
+          "3 containers are expected to be running");
     }
     }
 
 
     // Flex compa up to 5 - will make health 60% (3 out of 5 running), so
     // Flex compa up to 5 - will make health 60% (3 out of 5 running), so
@@ -817,7 +823,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
       waitForServiceToBeInState(client, exampleApp, ServiceState.FAILED,
       waitForServiceToBeInState(client, exampleApp, ServiceState.FAILED,
           14000);
           14000);
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.fail("Should not have thrown exception");
+      fail("Should not have thrown exception");
     }
     }
 
 
     LOG.info("Destroy service {}", exampleApp);
     LOG.info("Destroy service {}", exampleApp);
@@ -848,7 +854,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
         String compInstanceName = containerList.get(index).getComponentInstanceName();
         String compInstanceName = containerList.get(index).getComponentInstanceName();
         String compName =
         String compName =
             compInstanceName.substring(0, compInstanceName.lastIndexOf('-'));
             compInstanceName.substring(0, compInstanceName.lastIndexOf('-'));
-        Assert.assertEquals(comp, compName);
+        assertEquals(comp, compName);
         index++;
         index++;
       }
       }
     }
     }
@@ -922,7 +928,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     }
     }
   }
   }
 
 
-  @Test (timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testRestartServiceForNonExistingInRM() throws Exception {
   public void testRestartServiceForNonExistingInRM() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 0);
     conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 0);
@@ -940,11 +947,12 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     client.actionStart(exampleApp.getName());
     client.actionStart(exampleApp.getName());
     waitForServiceToBeStable(client, exampleApp);
     waitForServiceToBeStable(client, exampleApp);
     Service service = client.getStatus(exampleApp.getName());
     Service service = client.getStatus(exampleApp.getName());
-    Assert.assertEquals("Restarted service state should be STABLE",
-        ServiceState.STABLE, service.getState());
+    assertEquals(ServiceState.STABLE, service.getState(),
+        "Restarted service state should be STABLE");
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testAMFailureValidity() throws Exception {
   public void testAMFailureValidity() throws Exception {
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     ServiceClient client = createClient(getConf());
     ServiceClient client = createClient(getConf());
@@ -972,7 +980,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     yarnClient.signalToContainer(attemptReport.getAMContainerId(),
     yarnClient.signalToContainer(attemptReport.getAMContainerId(),
         SignalContainerCommand.GRACEFUL_SHUTDOWN);
         SignalContainerCommand.GRACEFUL_SHUTDOWN);
     waitForServiceToBeStable(client, exampleApp);
     waitForServiceToBeStable(client, exampleApp);
-    Assert.assertEquals(ServiceState.STABLE, client.getStatus(
+    assertEquals(ServiceState.STABLE, client.getStatus(
         exampleApp.getName()).getState());
         exampleApp.getName()).getState());
 
 
     // kill AM2 after 'yarn.service.am-failure.validity-interval-ms'
     // kill AM2 after 'yarn.service.am-failure.validity-interval-ms'
@@ -983,7 +991,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     yarnClient.signalToContainer(attemptReport.getAMContainerId(),
     yarnClient.signalToContainer(attemptReport.getAMContainerId(),
         SignalContainerCommand.GRACEFUL_SHUTDOWN);
         SignalContainerCommand.GRACEFUL_SHUTDOWN);
     waitForServiceToBeStable(client, exampleApp);
     waitForServiceToBeStable(client, exampleApp);
-    Assert.assertEquals(ServiceState.STABLE, client.getStatus(
+    assertEquals(ServiceState.STABLE, client.getStatus(
         exampleApp.getName()).getState());
         exampleApp.getName()).getState());
   }
   }
 
 
@@ -1003,22 +1011,23 @@ public class TestYarnNativeServices extends ServiceTestUtils {
     return service;
     return service;
   }
   }
 
 
-  @Test(timeout = 200000)
+  @Test
+  @Timeout(value = 200)
   public void testServiceSameNameWithFailure() throws Exception{
   public void testServiceSameNameWithFailure() throws Exception{
     setupInternal(NUM_NMS);
     setupInternal(NUM_NMS);
     ServiceClient client = createClient(getConf());
     ServiceClient client = createClient(getConf());
     try {
     try {
       client.actionCreate(createServiceWithSingleComp(1024000));
       client.actionCreate(createServiceWithSingleComp(1024000));
-      Assert.fail("Service should throw YarnException as memory is " +
+      fail("Service should throw YarnException as memory is " +
           "configured as 1000GB, which is more than allowed");
           "configured as 1000GB, which is more than allowed");
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.assertTrue(true);
+      assertTrue(true);
     }
     }
     Service service = createServiceWithSingleComp(128);
     Service service = createServiceWithSingleComp(128);
     try {
     try {
       client.actionCreate(service);
       client.actionCreate(service);
     } catch (SliderException e){
     } catch (SliderException e){
-      Assert.fail("Not able to submit service as the files related to" +
+      fail("Not able to submit service as the files related to" +
           " failed service with same name are not cleared");
           " failed service with same name are not cleared");
     }
     }
     waitForServiceToBeStable(client,service);
     waitForServiceToBeStable(client,service);

+ 9 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/client/TestBuildExternalComponents.java

@@ -25,10 +25,9 @@ import org.apache.hadoop.yarn.service.api.records.Component;
 import org.apache.hadoop.yarn.service.conf.ExampleAppJson;
 import org.apache.hadoop.yarn.service.conf.ExampleAppJson;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -37,6 +36,8 @@ import java.util.List;
 import java.util.Set;
 import java.util.Set;
 
 
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.YARN_SERVICE_BASE_PATH;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.YARN_SERVICE_BASE_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test for building / resolving components of type SERVICE.
  * Test for building / resolving components of type SERVICE.
@@ -49,9 +50,9 @@ public class TestBuildExternalComponents {
   // Check component names match with expected
   // Check component names match with expected
   private static void checkComponentNames(List<Component> components,
   private static void checkComponentNames(List<Component> components,
       Set<String> expectedComponents) {
       Set<String> expectedComponents) {
-    Assert.assertEquals(expectedComponents.size(), components.size());
+    assertEquals(expectedComponents.size(), components.size());
     for (Component comp : components) {
     for (Component comp : components) {
-      Assert.assertTrue(expectedComponents.contains(comp.getName()));
+      assertTrue(expectedComponents.contains(comp.getName()));
     }
     }
   }
   }
 
 
@@ -70,7 +71,7 @@ public class TestBuildExternalComponents {
     checkComponentNames(components, names);
     checkComponentNames(components, names);
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     basedir = new File("target", "apps");
     basedir = new File("target", "apps");
     if (basedir.exists()) {
     if (basedir.exists()) {
@@ -81,7 +82,7 @@ public class TestBuildExternalComponents {
     conf.set(YARN_SERVICE_BASE_PATH, basedir.getAbsolutePath());
     conf.set(YARN_SERVICE_BASE_PATH, basedir.getAbsolutePath());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     if (basedir != null) {
     if (basedir != null) {
       FileUtils.deleteDirectory(basedir);
       FileUtils.deleteDirectory(basedir);

+ 45 - 40
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/client/TestServiceCLI.java

@@ -34,12 +34,11 @@ import org.apache.hadoop.yarn.service.conf.ExampleAppJson;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConstants;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConstants;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.io.TempDir;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -51,20 +50,21 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.spy;
 import static org.apache.hadoop.yarn.client.api.AppAdminClient.YARN_APP_ADMIN_CLIENT_PREFIX;
 import static org.apache.hadoop.yarn.client.api.AppAdminClient.YARN_APP_ADMIN_CLIENT_PREFIX;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.DEPENDENCY_TARBALL_PATH;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.DEPENDENCY_TARBALL_PATH;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.YARN_SERVICE_BASE_PATH;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.YARN_SERVICE_BASE_PATH;
 import static org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes.EXIT_SUCCESS;
 import static org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes.EXIT_SUCCESS;
 import static org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes.EXIT_UNAUTHORIZED;
 import static org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes.EXIT_UNAUTHORIZED;
-import static org.mockito.Mockito.spy;
 
 
 public class TestServiceCLI {
 public class TestServiceCLI {
   private static final Logger LOG = LoggerFactory.getLogger(TestServiceCLI
   private static final Logger LOG = LoggerFactory.getLogger(TestServiceCLI
       .class);
       .class);
 
 
-  @Rule
-  public TemporaryFolder tmpFolder = new TemporaryFolder();
-
   private Configuration conf = new YarnConfiguration();
   private Configuration conf = new YarnConfiguration();
   private SliderFileSystem fs;
   private SliderFileSystem fs;
   private ApplicationCLI cli;
   private ApplicationCLI cli;
@@ -97,7 +97,7 @@ public class TestServiceCLI {
         "-D", basedirProp, "-save", serviceName,
         "-D", basedirProp, "-save", serviceName,
         ExampleAppJson.resourceName(appDef),
         ExampleAppJson.resourceName(appDef),
         "-appTypes", DUMMY_APP_TYPE};
         "-appTypes", DUMMY_APP_TYPE};
-    Assert.assertEquals(EXIT_SUCCESS, runCLI(args));
+    assertEquals(EXIT_SUCCESS, runCLI(args));
   }
   }
 
 
   private void buildApp(String serviceName, String appDef,
   private void buildApp(String serviceName, String appDef,
@@ -108,7 +108,7 @@ public class TestServiceCLI {
         "-appTypes", DUMMY_APP_TYPE,
         "-appTypes", DUMMY_APP_TYPE,
         "-updateLifetime", lifetime,
         "-updateLifetime", lifetime,
         "-changeQueue", queue};
         "-changeQueue", queue};
-    Assert.assertEquals(EXIT_SUCCESS, runCLI(args));
+    assertEquals(EXIT_SUCCESS, runCLI(args));
   }
   }
 
 
   private static Path getDependencyTarGz(File dir) {
   private static Path getDependencyTarGz(File dir) {
@@ -117,13 +117,13 @@ public class TestServiceCLI {
         .DEPENDENCY_TAR_GZ_FILE_EXT).getAbsolutePath());
         .DEPENDENCY_TAR_GZ_FILE_EXT).getAbsolutePath());
   }
   }
 
 
-  @Before
-  public void setup() throws Throwable {
+  @BeforeEach
+  public void setup(@TempDir java.nio.file.Path tempDir) throws Throwable {
     basedir = new File("target", "apps");
     basedir = new File("target", "apps");
     basedirProp = YARN_SERVICE_BASE_PATH + "=" + basedir.getAbsolutePath();
     basedirProp = YARN_SERVICE_BASE_PATH + "=" + basedir.getAbsolutePath();
     conf.set(YARN_SERVICE_BASE_PATH, basedir.getAbsolutePath());
     conf.set(YARN_SERVICE_BASE_PATH, basedir.getAbsolutePath());
     fs = new SliderFileSystem(conf);
     fs = new SliderFileSystem(conf);
-    dependencyTarGzBaseDir = tmpFolder.getRoot();
+    dependencyTarGzBaseDir = tempDir.toFile();
     fs.getFileSystem()
     fs.getFileSystem()
         .setPermission(new Path(dependencyTarGzBaseDir.getAbsolutePath()),
         .setPermission(new Path(dependencyTarGzBaseDir.getAbsolutePath()),
             new FsPermission("755"));
             new FsPermission("755"));
@@ -145,7 +145,7 @@ public class TestServiceCLI {
     createCLI();
     createCLI();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     if (basedir != null) {
     if (basedir != null) {
       FileUtils.deleteDirectory(basedir);
       FileUtils.deleteDirectory(basedir);
@@ -153,7 +153,8 @@ public class TestServiceCLI {
     cli.stop();
     cli.stop();
   }
   }
 
 
-  @Test (timeout = 180000)
+  @Test
+  @Timeout(value = 180)
   public void testFlexComponents() throws Throwable {
   public void testFlexComponents() throws Throwable {
     // currently can only test building apps, since that is the only
     // currently can only test building apps, since that is the only
     // operation that doesn't require an RM
     // operation that doesn't require an RM
@@ -176,7 +177,8 @@ public class TestServiceCLI {
     assertThat(result).isEqualTo(0);
     assertThat(result).isEqualTo(0);
   }
   }
 
 
-  @Test (timeout = 180000)
+  @Test
+  @Timeout(value = 180)
   public void testInitiateAutoFinalizeServiceUpgrade() throws Exception {
   public void testInitiateAutoFinalizeServiceUpgrade() throws Exception {
     String[] args =  {"app", "-upgrade", "app-1",
     String[] args =  {"app", "-upgrade", "app-1",
         "-initiate", ExampleAppJson.resourceName(ExampleAppJson.APP_JSON),
         "-initiate", ExampleAppJson.resourceName(ExampleAppJson.APP_JSON),
@@ -233,40 +235,43 @@ public class TestServiceCLI {
     assertThat(result).isEqualTo(0);
     assertThat(result).isEqualTo(0);
   }
   }
 
 
-  @Test (timeout = 180000)
+  @Test
+  @Timeout(value = 180)
   public void testEnableFastLaunch() throws Exception {
   public void testEnableFastLaunch() throws Exception {
     fs.getFileSystem().create(new Path(basedir.getAbsolutePath(), "test.jar"))
     fs.getFileSystem().create(new Path(basedir.getAbsolutePath(), "test.jar"))
         .close();
         .close();
 
 
     Path defaultPath = new Path(dependencyTarGz.toString());
     Path defaultPath = new Path(dependencyTarGz.toString());
-    Assert.assertFalse("Dependency tarball should not exist before the test",
-        fs.isFile(defaultPath));
+    assertFalse(fs.isFile(defaultPath),
+        "Dependency tarball should not exist before the test");
     String[] args = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
     String[] args = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
         "-appTypes", DUMMY_APP_TYPE};
         "-appTypes", DUMMY_APP_TYPE};
-    Assert.assertEquals(EXIT_SUCCESS, runCLI(args));
-    Assert.assertTrue("Dependency tarball did not exist after the test",
-        fs.isFile(defaultPath));
+    assertEquals(EXIT_SUCCESS, runCLI(args));
+    assertTrue(fs.isFile(defaultPath),
+        "Dependency tarball did not exist after the test");
 
 
     File secondBaseDir = new File(dependencyTarGzBaseDir, "2");
     File secondBaseDir = new File(dependencyTarGzBaseDir, "2");
     Path secondTarGz = getDependencyTarGz(secondBaseDir);
     Path secondTarGz = getDependencyTarGz(secondBaseDir);
-    Assert.assertFalse("Dependency tarball should not exist before the test",
-        fs.isFile(secondTarGz));
+    assertFalse(fs.isFile(secondTarGz),
+        "Dependency tarball should not exist before the test");
     String[] args2 = {"app", "-D", yarnAdminNoneAclProp, "-D",
     String[] args2 = {"app", "-D", yarnAdminNoneAclProp, "-D",
         dfsAdminAclProp, "-D", dependencyTarGzProp, "-enableFastLaunch",
         dfsAdminAclProp, "-D", dependencyTarGzProp, "-enableFastLaunch",
         secondBaseDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
         secondBaseDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
-    Assert.assertEquals(EXIT_SUCCESS, runCLI(args2));
-    Assert.assertTrue("Dependency tarball did not exist after the test",
-        fs.isFile(secondTarGz));
+    assertEquals(EXIT_SUCCESS, runCLI(args2));
+    assertTrue(fs.isFile(secondTarGz),
+        "Dependency tarball did not exist after the test");
   }
   }
 
 
-  @Test (timeout = 180000)
+  @Test
+  @Timeout(value = 180)
   public void testEnableFastLaunchUserPermissions() throws Exception {
   public void testEnableFastLaunchUserPermissions() throws Exception {
     String[] args = {"app", "-D", yarnAdminNoneAclProp, "-D",
     String[] args = {"app", "-D", yarnAdminNoneAclProp, "-D",
         dependencyTarGzProp, "-enableFastLaunch", "-appTypes", DUMMY_APP_TYPE};
         dependencyTarGzProp, "-enableFastLaunch", "-appTypes", DUMMY_APP_TYPE};
-    Assert.assertEquals(EXIT_UNAUTHORIZED, runCLI(args));
+    assertEquals(EXIT_UNAUTHORIZED, runCLI(args));
   }
   }
 
 
-  @Test (timeout = 180000)
+  @Test
+  @Timeout(value = 180)
   public void testEnableFastLaunchFilePermissions() throws Exception {
   public void testEnableFastLaunchFilePermissions() throws Exception {
     File badDir = new File(dependencyTarGzBaseDir, "bad");
     File badDir = new File(dependencyTarGzBaseDir, "bad");
     badDir.mkdir();
     badDir.mkdir();
@@ -275,7 +280,7 @@ public class TestServiceCLI {
 
 
     String[] args = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
     String[] args = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
         badDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
         badDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
-    Assert.assertEquals(EXIT_UNAUTHORIZED, runCLI(args));
+    assertEquals(EXIT_UNAUTHORIZED, runCLI(args));
 
 
     badDir = new File(badDir, "child");
     badDir = new File(badDir, "child");
     badDir.mkdir();
     badDir.mkdir();
@@ -284,7 +289,7 @@ public class TestServiceCLI {
 
 
     String[] args2 = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
     String[] args2 = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
         badDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
         badDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
-    Assert.assertEquals(EXIT_UNAUTHORIZED, runCLI(args2));
+    assertEquals(EXIT_UNAUTHORIZED, runCLI(args2));
 
 
     badDir = new File(dependencyTarGzBaseDir, "badx");
     badDir = new File(dependencyTarGzBaseDir, "badx");
     badDir.mkdir();
     badDir.mkdir();
@@ -293,24 +298,24 @@ public class TestServiceCLI {
 
 
     String[] args3 = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
     String[] args3 = {"app", "-D", dependencyTarGzProp, "-enableFastLaunch",
         badDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
         badDir.getAbsolutePath(), "-appTypes", DUMMY_APP_TYPE};
-    Assert.assertEquals(EXIT_UNAUTHORIZED, runCLI(args3));
+    assertEquals(EXIT_UNAUTHORIZED, runCLI(args3));
   }
   }
 
 
   private void checkApp(String serviceName, String compName, long count, Long
   private void checkApp(String serviceName, String compName, long count, Long
       lifetime, String queue) throws IOException {
       lifetime, String queue) throws IOException {
     Service service = ServiceApiUtil.loadService(fs, serviceName);
     Service service = ServiceApiUtil.loadService(fs, serviceName);
-    Assert.assertEquals(serviceName, service.getName());
-    Assert.assertEquals(lifetime, service.getLifetime());
-    Assert.assertEquals(queue, service.getQueue());
+    assertEquals(serviceName, service.getName());
+    assertEquals(lifetime, service.getLifetime());
+    assertEquals(queue, service.getQueue());
     List<Component> components = service.getComponents();
     List<Component> components = service.getComponents();
     for (Component component : components) {
     for (Component component : components) {
       if (component.getName().equals(compName)) {
       if (component.getName().equals(compName)) {
-        Assert.assertEquals(count, component.getNumberOfContainers()
+        assertEquals(count, component.getNumberOfContainers()
             .longValue());
             .longValue());
         return;
         return;
       }
       }
     }
     }
-    Assert.fail();
+    fail();
   }
   }
 
 
   private static final String DUMMY_APP_TYPE = "dummy";
   private static final String DUMMY_APP_TYPE = "dummy";

+ 24 - 22
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/client/TestServiceClient.java

@@ -49,9 +49,8 @@ import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
 import org.apache.hadoop.yarn.service.exceptions.ErrorStrings;
 import org.apache.hadoop.yarn.service.exceptions.ErrorStrings;
 import org.apache.hadoop.yarn.service.utils.FilterUtils;
 import org.apache.hadoop.yarn.service.utils.FilterUtils;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
@@ -60,7 +59,10 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
-import static org.mockito.ArgumentMatchers.any;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -72,8 +74,8 @@ public class TestServiceClient {
   private static final Logger LOG = LoggerFactory.getLogger(
   private static final Logger LOG = LoggerFactory.getLogger(
       TestServiceClient.class);
       TestServiceClient.class);
 
 
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
   @Test
   @Test
@@ -89,12 +91,12 @@ public class TestServiceClient {
     client.getConfig().set("yarn.service.classpath", "{{VAR_1}},{{VAR_2}}");
     client.getConfig().set("yarn.service.classpath", "{{VAR_1}},{{VAR_2}}");
     String newPath = client.addAMEnv().get("CLASSPATH");
     String newPath = client.addAMEnv().get("CLASSPATH");
 
 
-    Assert.assertEquals(originalPath + "<CPS>{{VAR_1}}<CPS>{{VAR_2}}", newPath);
+    assertEquals(originalPath + "<CPS>{{VAR_1}}<CPS>{{VAR_2}}", newPath);
     //restoring the original value for service classpath
     //restoring the original value for service classpath
     client.getConfig().set("yarn.service.classpath", oldParam);
     client.getConfig().set("yarn.service.classpath", oldParam);
 
 
     newPath = client.addAMEnv().get("CLASSPATH");
     newPath = client.addAMEnv().get("CLASSPATH");
-    Assert.assertEquals(originalPath, newPath);
+    assertEquals(originalPath, newPath);
 
 
     client.stop();
     client.stop();
   }
   }
@@ -109,11 +111,11 @@ public class TestServiceClient {
     try {
     try {
       client.initiateUpgrade(service);
       client.initiateUpgrade(service);
     } catch (YarnException ex) {
     } catch (YarnException ex) {
-      Assert.assertEquals(ErrorStrings.SERVICE_UPGRADE_DISABLED,
+      assertEquals(ErrorStrings.SERVICE_UPGRADE_DISABLED,
           ex.getMessage());
           ex.getMessage());
       return;
       return;
     }
     }
-    Assert.fail();
+    fail();
   }
   }
 
 
   @Test
   @Test
@@ -127,8 +129,8 @@ public class TestServiceClient {
 
 
     Service fromFs = ServiceApiUtil.loadServiceUpgrade(rule.getFs(),
     Service fromFs = ServiceApiUtil.loadServiceUpgrade(rule.getFs(),
         service.getName(), service.getVersion());
         service.getName(), service.getVersion());
-    Assert.assertEquals(service.getName(), fromFs.getName());
-    Assert.assertEquals(service.getVersion(), fromFs.getVersion());
+    assertEquals(service.getName(), fromFs.getName());
+    assertEquals(service.getVersion(), fromFs.getVersion());
     client.stop();
     client.stop();
   }
   }
 
 
@@ -149,7 +151,7 @@ public class TestServiceClient {
     client.actionUpgrade(service, comp.getContainers());
     client.actionUpgrade(service, comp.getContainers());
     CompInstancesUpgradeResponseProto response = client.getLastProxyResponse(
     CompInstancesUpgradeResponseProto response = client.getLastProxyResponse(
         CompInstancesUpgradeResponseProto.class);
         CompInstancesUpgradeResponseProto.class);
-    Assert.assertNotNull("upgrade did not complete", response);
+    assertNotNull(response, "upgrade did not complete");
     client.stop();
     client.stop();
   }
   }
 
 
@@ -169,11 +171,11 @@ public class TestServiceClient {
 
 
     ComponentContainers[] compContainers = client.getContainers(
     ComponentContainers[] compContainers = client.getContainers(
         service.getName(), Lists.newArrayList("compa"), "v1", null);
         service.getName(), Lists.newArrayList("compa"), "v1", null);
-    Assert.assertEquals("num comp", 1, compContainers.length);
-    Assert.assertEquals("comp name", "compa",
-        compContainers[0].getComponentName());
-    Assert.assertEquals("num containers", 2,
-        compContainers[0].getContainers().size());
+    assertEquals(1, compContainers.length, "num comp");
+    assertEquals("compa",
+        compContainers[0].getComponentName(), "comp name");
+    assertEquals(2,
+        compContainers[0].getContainers().size(), "num containers");
     client.stop();
     client.stop();
   }
   }
 
 
@@ -191,13 +193,13 @@ public class TestServiceClient {
     try {
     try {
       client.initiateUpgrade(service);
       client.initiateUpgrade(service);
     } catch (YarnException ex) {
     } catch (YarnException ex) {
-      Assert.assertEquals("All the components of the service " +
+      assertEquals("All the components of the service " +
               service.getName() + " have " + Component.RestartPolicyEnum.NEVER
               service.getName() + " have " + Component.RestartPolicyEnum.NEVER
               + " restart policy, so it cannot be upgraded.",
               + " restart policy, so it cannot be upgraded.",
           ex.getMessage());
           ex.getMessage());
       return;
       return;
     }
     }
-    Assert.fail();
+    fail();
   }
   }
 
 
   private Service createService() throws IOException,
   private Service createService() throws IOException,
@@ -241,8 +243,8 @@ public class TestServiceClient {
 
 
       ApplicationAttemptReport attemptReport =
       ApplicationAttemptReport attemptReport =
           ApplicationAttemptReport.newInstance(client.attemptId, "localhost", 0,
           ApplicationAttemptReport.newInstance(client.attemptId, "localhost", 0,
-              null, null, null,
-              YarnApplicationAttemptState.RUNNING, null);
+          null, null, null,
+          YarnApplicationAttemptState.RUNNING, null);
       when(yarnClient.getApplicationAttemptReport(any()))
       when(yarnClient.getApplicationAttemptReport(any()))
           .thenReturn(attemptReport);
           .thenReturn(attemptReport);
       when(yarnClient.getApplicationReport(client.appId)).thenReturn(appReport);
       when(yarnClient.getApplicationReport(client.appId)).thenReturn(appReport);

+ 57 - 57
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/TestComponent.java

@@ -31,9 +31,8 @@ import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEvent;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEvent;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEventType;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceEventType;
 import org.apache.log4j.Logger;
 import org.apache.log4j.Logger;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 
 import java.util.Iterator;
 import java.util.Iterator;
 
 
@@ -43,6 +42,7 @@ import static org.apache.hadoop.yarn.service.component.instance.ComponentInstanc
 
 
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConstants
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConstants
     .CONTAINER_STATE_REPORT_AS_SERVICE_STATE;
     .CONTAINER_STATE_REPORT_AS_SERVICE_STATE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 /**
 /**
  * Tests for {@link Component}.
  * Tests for {@link Component}.
@@ -51,8 +51,8 @@ public class TestComponent {
 
 
   static final Logger LOG = Logger.getLogger(TestComponent.class);
   static final Logger LOG = Logger.getLogger(TestComponent.class);
 
 
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
   @Test
   @Test
@@ -64,8 +64,8 @@ public class TestComponent {
     ComponentEvent upgradeEvent = new ComponentEvent(comp.getName(),
     ComponentEvent upgradeEvent = new ComponentEvent(comp.getName(),
         ComponentEventType.UPGRADE);
         ComponentEventType.UPGRADE);
     comp.handle(upgradeEvent);
     comp.handle(upgradeEvent);
-    Assert.assertEquals("component not in need upgrade state",
-        ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState());
+    assertEquals(ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState(),
+        "component not in need upgrade state");
   }
   }
 
 
   @Test
   @Test
@@ -83,18 +83,18 @@ public class TestComponent {
     comp.getUpgradeStatus().decContainersThatNeedUpgrade();
     comp.getUpgradeStatus().decContainersThatNeedUpgrade();
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
-    Assert.assertEquals("component not in need upgrade state",
-        ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState());
+    assertEquals(ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState(),
+        "component not in need upgrade state");
 
 
     // second instance finished upgrading
     // second instance finished upgrading
     comp.getUpgradeStatus().decContainersThatNeedUpgrade();
     comp.getUpgradeStatus().decContainersThatNeedUpgrade();
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in stable state",
-        ComponentState.STABLE, comp.getComponentSpec().getState());
-    Assert.assertEquals("component did not upgrade successfully", "val1",
-        comp.getComponentSpec().getConfiguration().getEnv("key1"));
+    assertEquals(ComponentState.STABLE, comp.getComponentSpec().getState(),
+        "component not in stable state");
+    assertEquals("val1", comp.getComponentSpec().getConfiguration().getEnv("key1"),
+        "component did not upgrade successfully");
   }
   }
 
 
   @Test
   @Test
@@ -124,8 +124,8 @@ public class TestComponent {
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in needs upgrade state",
-        ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState());
+    assertEquals(ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState(),
+        "component not in needs upgrade state");
   }
   }
 
 
   @Test
   @Test
@@ -137,10 +137,10 @@ public class TestComponent {
     ComponentEvent upgradeEvent = new ComponentEvent(comp.getName(),
     ComponentEvent upgradeEvent = new ComponentEvent(comp.getName(),
         ComponentEventType.CANCEL_UPGRADE);
         ComponentEventType.CANCEL_UPGRADE);
     comp.handle(upgradeEvent);
     comp.handle(upgradeEvent);
-    Assert.assertEquals("component not in need upgrade state",
-        ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState());
+    assertEquals(ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState(),
+        "component not in need upgrade state");
 
 
-    Assert.assertEquals(
+    assertEquals(
         org.apache.hadoop.yarn.service.component.ComponentState
         org.apache.hadoop.yarn.service.component.ComponentState
             .CANCEL_UPGRADING, comp.getState());
             .CANCEL_UPGRADING, comp.getState());
   }
   }
@@ -190,16 +190,16 @@ public class TestComponent {
     comp.handle(stopEvent);
     comp.handle(stopEvent);
     instance1.handle(new ComponentInstanceEvent(
     instance1.handle(new ComponentInstanceEvent(
         instance1.getContainer().getId(), STOP));
         instance1.getContainer().getId(), STOP));
-    Assert.assertEquals(
+    assertEquals(
         org.apache.hadoop.yarn.service.component.ComponentState
         org.apache.hadoop.yarn.service.component.ComponentState
             .CANCEL_UPGRADING, comp.getState());
             .CANCEL_UPGRADING, comp.getState());
 
 
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in needs upgrade state",
-        ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState());
-    Assert.assertEquals(
+    assertEquals(ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState(),
+        "component not in needs upgrade state");
+    assertEquals(
         org.apache.hadoop.yarn.service.component.ComponentState
         org.apache.hadoop.yarn.service.component.ComponentState
             .CANCEL_UPGRADING, comp.getState());
             .CANCEL_UPGRADING, comp.getState());
 
 
@@ -214,18 +214,18 @@ public class TestComponent {
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in flexing state",
-        ComponentState.FLEXING, comp.getComponentSpec().getState());
+    assertEquals(ComponentState.FLEXING, comp.getComponentSpec().getState(),
+        "component not in flexing state");
     // new container get allocated
     // new container get allocated
     context.assignNewContainer(context.attemptId, 10, comp);
     context.assignNewContainer(context.attemptId, 10, comp);
 
 
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
             ComponentEventType.CHECK_STABLE));
             ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in stable state",
-        ComponentState.STABLE, comp.getComponentSpec().getState());
-    Assert.assertEquals("cancel upgrade failed", "val0",
-        comp.getComponentSpec().getConfiguration().getEnv("key1"));
+    assertEquals(ComponentState.STABLE, comp.getComponentSpec().getState(),
+        "component not in stable state");
+    assertEquals("val0", comp.getComponentSpec().getConfiguration().getEnv("key1"),
+        "cancel upgrade failed");
   }
   }
 
 
   @Test
   @Test
@@ -249,10 +249,10 @@ public class TestComponent {
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in stable state",
-        ComponentState.STABLE, comp.getComponentSpec().getState());
-    Assert.assertEquals("cancel upgrade failed", "val0",
-        comp.getComponentSpec().getConfiguration().getEnv("key1"));
+    assertEquals(ComponentState.STABLE, comp.getComponentSpec().getState(),
+        "component not in stable state");
+    assertEquals("val0", comp.getComponentSpec().getConfiguration().getEnv("key1"),
+        "cancel upgrade failed");
   }
   }
 
 
   @Test
   @Test
@@ -272,8 +272,8 @@ public class TestComponent {
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in flexing state",
-        ComponentState.FLEXING, comp.getComponentSpec().getState());
+    assertEquals(ComponentState.FLEXING, comp.getComponentSpec().getState(),
+        "component not in flexing state");
 
 
     for (ComponentInstance instance : comp.getAllComponentInstances()) {
     for (ComponentInstance instance : comp.getAllComponentInstances()) {
       // new container get allocated
       // new container get allocated
@@ -283,10 +283,10 @@ public class TestComponent {
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in stable state",
-        ComponentState.STABLE, comp.getComponentSpec().getState());
-    Assert.assertEquals("cancel upgrade failed", "val0",
-        comp.getComponentSpec().getConfiguration().getEnv("key1"));
+    assertEquals(ComponentState.STABLE, comp.getComponentSpec().getState(),
+        "component not in stable state");
+    assertEquals("val0", comp.getComponentSpec().getConfiguration().getEnv("key1"),
+        "cancel upgrade failed");
   }
   }
 
 
   private void cancelUpgradeWhileUpgrading(
   private void cancelUpgradeWhileUpgrading(
@@ -327,16 +327,16 @@ public class TestComponent {
         instance1.getContainer().getId(), STOP));
         instance1.getContainer().getId(), STOP));
 
 
     // component should be in cancel upgrade
     // component should be in cancel upgrade
-    Assert.assertEquals(
+    assertEquals(
         org.apache.hadoop.yarn.service.component.ComponentState
         org.apache.hadoop.yarn.service.component.ComponentState
             .CANCEL_UPGRADING, comp.getState());
             .CANCEL_UPGRADING, comp.getState());
 
 
     comp.handle(new ComponentEvent(comp.getName(),
     comp.handle(new ComponentEvent(comp.getName(),
         ComponentEventType.CHECK_STABLE));
         ComponentEventType.CHECK_STABLE));
 
 
-    Assert.assertEquals("component not in needs upgrade state",
-        ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState());
-    Assert.assertEquals(
+    assertEquals(ComponentState.NEEDS_UPGRADE, comp.getComponentSpec().getState(),
+        "component not in needs upgrade state");
+    assertEquals(
         org.apache.hadoop.yarn.service.component.ComponentState
         org.apache.hadoop.yarn.service.component.ComponentState
             .CANCEL_UPGRADING, comp.getState());
             .CANCEL_UPGRADING, comp.getState());
   }
   }
@@ -362,11 +362,11 @@ public class TestComponent {
       ComponentInstance componentInstance = instanceIter.next();
       ComponentInstance componentInstance = instanceIter.next();
       Container instanceContainer = componentInstance.getContainer();
       Container instanceContainer = componentInstance.getContainer();
 
 
-      Assert.assertEquals(0, comp.getNumSucceededInstances());
-      Assert.assertEquals(0, comp.getNumFailedInstances());
-      Assert.assertEquals(2, comp.getNumRunningInstances());
-      Assert.assertEquals(2, comp.getNumReadyInstances());
-      Assert.assertEquals(0, comp.getPendingInstances().size());
+      assertEquals(0, comp.getNumSucceededInstances());
+      assertEquals(0, comp.getNumFailedInstances());
+      assertEquals(2, comp.getNumRunningInstances());
+      assertEquals(2, comp.getNumReadyInstances());
+      assertEquals(0, comp.getPendingInstances().size());
 
 
       //stop 1 container
       //stop 1 container
       ContainerStatus containerStatus = ContainerStatus.newInstance(
       ContainerStatus containerStatus = ContainerStatus.newInstance(
@@ -380,15 +380,15 @@ public class TestComponent {
           new ComponentInstanceEvent(componentInstance.getContainer().getId(),
           new ComponentInstanceEvent(componentInstance.getContainer().getId(),
               ComponentInstanceEventType.STOP).setStatus(containerStatus));
               ComponentInstanceEventType.STOP).setStatus(containerStatus));
 
 
-      Assert.assertEquals(1, comp.getNumSucceededInstances());
-      Assert.assertEquals(0, comp.getNumFailedInstances());
-      Assert.assertEquals(1, comp.getNumRunningInstances());
-      Assert.assertEquals(1, comp.getNumReadyInstances());
-      Assert.assertEquals(0, comp.getPendingInstances().size());
+      assertEquals(1, comp.getNumSucceededInstances());
+      assertEquals(0, comp.getNumFailedInstances());
+      assertEquals(1, comp.getNumRunningInstances());
+      assertEquals(1, comp.getNumReadyInstances());
+      assertEquals(0, comp.getPendingInstances().size());
 
 
       org.apache.hadoop.yarn.service.component.ComponentState componentState =
       org.apache.hadoop.yarn.service.component.ComponentState componentState =
           Component.checkIfStable(comp);
           Component.checkIfStable(comp);
-      Assert.assertEquals(
+      assertEquals(
           org.apache.hadoop.yarn.service.component.ComponentState.STABLE,
           org.apache.hadoop.yarn.service.component.ComponentState.STABLE,
           componentState);
           componentState);
     }
     }
@@ -431,14 +431,14 @@ public class TestComponent {
 
 
       ComponentState componentState =
       ComponentState componentState =
           comp.getComponentSpec().getState();
           comp.getComponentSpec().getState();
-      Assert.assertEquals(
+      assertEquals(
           ComponentState.SUCCEEDED,
           ComponentState.SUCCEEDED,
           componentState);
           componentState);
     }
     }
 
 
     ServiceState serviceState =
     ServiceState serviceState =
         testService.getState();
         testService.getState();
-    Assert.assertEquals(
+    assertEquals(
         ServiceState.SUCCEEDED,
         ServiceState.SUCCEEDED,
         serviceState);
         serviceState);
   }
   }
@@ -484,7 +484,7 @@ public class TestComponent {
         }
         }
         ComponentState componentState =
         ComponentState componentState =
             comp.getComponentSpec().getState();
             comp.getComponentSpec().getState();
-        Assert.assertEquals(
+        assertEquals(
             ComponentState.SUCCEEDED,
             ComponentState.SUCCEEDED,
             componentState);
             componentState);
       }
       }
@@ -492,7 +492,7 @@ public class TestComponent {
 
 
     ServiceState serviceState =
     ServiceState serviceState =
         testService.getState();
         testService.getState();
-    Assert.assertEquals(
+    assertEquals(
         ServiceState.SUCCEEDED,
         ServiceState.SUCCEEDED,
         serviceState);
         serviceState);
   }
   }

+ 16 - 19
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/TestComponentDecommissionInstances.java

@@ -27,12 +27,9 @@ import org.apache.hadoop.yarn.service.api.records.Container;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
 import org.apache.hadoop.yarn.service.client.ServiceClient;
 import org.apache.hadoop.yarn.service.client.ServiceClient;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -45,6 +42,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.TimeoutException;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
 /**
  * Test decommissioning component instances.
  * Test decommissioning component instances.
  */
  */
@@ -55,16 +55,13 @@ public class TestComponentDecommissionInstances extends ServiceTestUtils {
   private static final String APP_NAME = "test-decommission";
   private static final String APP_NAME = "test-decommission";
   private static final String COMPA = "compa";
   private static final String COMPA = "compa";
 
 
-  @Rule
-  public TemporaryFolder tmpFolder = new TemporaryFolder();
-
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     File tmpYarnDir = new File("target", "tmp");
     File tmpYarnDir = new File("target", "tmp");
     FileUtils.deleteQuietly(tmpYarnDir);
     FileUtils.deleteQuietly(tmpYarnDir);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     shutdown();
     shutdown();
   }
   }
@@ -129,19 +126,19 @@ public class TestComponentDecommissionInstances extends ServiceTestUtils {
       throws IOException, YarnException {
       throws IOException, YarnException {
     Service service = client.getStatus(APP_NAME);
     Service service = client.getStatus(APP_NAME);
     Component component = service.getComponent(COMPA);
     Component component = service.getComponent(COMPA);
-    Assert.assertEquals("Service state should be STABLE", ServiceState.STABLE,
-        service.getState());
-    Assert.assertEquals(instances.length + " containers are expected to be " +
-        "running", instances.length, component.getContainers().size());
+    assertEquals(ServiceState.STABLE,
+        service.getState(), "Service state should be STABLE");
+    assertEquals(instances.length, component.getContainers().size(),
+        instances.length + " containers are expected to be running");
     Set<String> existingInstances = new HashSet<>();
     Set<String> existingInstances = new HashSet<>();
     for (Container cont : component.getContainers()) {
     for (Container cont : component.getContainers()) {
       existingInstances.add(cont.getComponentInstanceName());
       existingInstances.add(cont.getComponentInstanceName());
     }
     }
-    Assert.assertEquals(instances.length + " instances are expected to be " +
-        "running", instances.length, existingInstances.size());
+    assertEquals(instances.length, existingInstances.size(),
+        instances.length + " instances are expected to be running");
     for (String instance : instances) {
     for (String instance : instances) {
-      Assert.assertTrue("Expected instance did not exist " + instance,
-          existingInstances.contains(instance));
+      assertTrue(existingInstances.contains(instance),
+          "Expected instance did not exist " + instance);
     }
     }
   }
   }
 }
 }

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/TestComponentRestartPolicy.java

@@ -19,9 +19,9 @@ package org.apache.hadoop.yarn.service.component;
 
 
 import org.apache.hadoop.yarn.api.records.ContainerStatus;
 import org.apache.hadoop.yarn.api.records.ContainerStatus;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 

+ 46 - 53
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/component/instance/TestComponentInstance.java

@@ -42,9 +42,8 @@ import org.apache.hadoop.yarn.service.component.ComponentEvent;
 import org.apache.hadoop.yarn.service.component.ComponentEventType;
 import org.apache.hadoop.yarn.service.component.ComponentEventType;
 import org.apache.hadoop.yarn.service.component.TestComponent;
 import org.apache.hadoop.yarn.service.component.TestComponent;
 import org.apache.hadoop.yarn.service.utils.ServiceUtils;
 import org.apache.hadoop.yarn.service.utils.ServiceUtils;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
 import java.nio.file.Files;
 import java.nio.file.Files;
@@ -56,6 +55,8 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
@@ -71,8 +72,8 @@ import static org.mockito.Mockito.when;
  */
  */
 public class TestComponentInstance {
 public class TestComponentInstance {
 
 
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
   @Test
   @Test
@@ -90,8 +91,8 @@ public class TestComponentInstance {
     instance.handle(instanceEvent);
     instance.handle(instanceEvent);
     Container containerSpec = component.getComponentSpec().getContainer(
     Container containerSpec = component.getComponentSpec().getContainer(
         instance.getContainer().getId().toString());
         instance.getContainer().getId().toString());
-    Assert.assertEquals("instance not upgrading", ContainerState.UPGRADING,
-        containerSpec.getState());
+    assertEquals(ContainerState.UPGRADING,
+        containerSpec.getState(), "instance not upgrading");
   }
   }
 
 
   @Test
   @Test
@@ -110,15 +111,14 @@ public class TestComponentInstance {
     instance.handle(instanceEvent);
     instance.handle(instanceEvent);
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
         ComponentInstanceEventType.START));
         ComponentInstanceEventType.START));
-    Assert.assertEquals("instance not running",
-        ContainerState.RUNNING_BUT_UNREADY,
+    assertEquals(ContainerState.RUNNING_BUT_UNREADY,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance not running");
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
         ComponentInstanceEventType.BECOME_READY));
         ComponentInstanceEventType.BECOME_READY));
-    Assert.assertEquals("instance not ready", ContainerState.READY,
+    assertEquals(ContainerState.READY,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance not ready");
   }
   }
 
 
 
 
@@ -145,9 +145,9 @@ public class TestComponentInstance {
         .setStatus(containerStatus);
         .setStatus(containerStatus);
     // this is the call back from NM for the upgrade
     // this is the call back from NM for the upgrade
     instance.handle(stopEvent);
     instance.handle(stopEvent);
-    Assert.assertEquals("instance did not fail", ContainerState.FAILED_UPGRADE,
+    assertEquals(ContainerState.FAILED_UPGRADE,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance did not fail");
   }
   }
 
 
   @Test
   @Test
@@ -168,10 +168,9 @@ public class TestComponentInstance {
     // NM finished updgrae
     // NM finished updgrae
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
         ComponentInstanceEventType.START));
         ComponentInstanceEventType.START));
-    Assert.assertEquals("instance not running",
-        ContainerState.RUNNING_BUT_UNREADY,
+    assertEquals(ContainerState.RUNNING_BUT_UNREADY,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance not running");
 
 
     ContainerStatus containerStatus = mock(ContainerStatus.class);
     ContainerStatus containerStatus = mock(ContainerStatus.class);
     when(containerStatus.getExitStatus()).thenReturn(
     when(containerStatus.getExitStatus()).thenReturn(
@@ -181,9 +180,9 @@ public class TestComponentInstance {
         .setStatus(containerStatus);
         .setStatus(containerStatus);
     // this is the call back from NM for the upgrade
     // this is the call back from NM for the upgrade
     instance.handle(stopEvent);
     instance.handle(stopEvent);
-    Assert.assertEquals("instance did not fail", ContainerState.FAILED_UPGRADE,
+    assertEquals(ContainerState.FAILED_UPGRADE,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance did not fail");
   }
   }
 
 
   @Test
   @Test
@@ -202,9 +201,9 @@ public class TestComponentInstance {
         ComponentInstanceEventType.CANCEL_UPGRADE);
         ComponentInstanceEventType.CANCEL_UPGRADE);
     instance.handle(cancelEvent);
     instance.handle(cancelEvent);
 
 
-    Assert.assertEquals("instance not ready", ContainerState.READY,
+    assertEquals(ContainerState.READY,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance not ready");
   }
   }
 
 
   @Test
   @Test
@@ -225,8 +224,8 @@ public class TestComponentInstance {
 
 
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
     instance.handle(new ComponentInstanceEvent(instance.getContainer().getId(),
         ComponentInstanceEventType.STOP));
         ComponentInstanceEventType.STOP));
-    Assert.assertEquals("instance not init", ComponentInstanceState.INIT,
-        instance.getState());
+    assertEquals(ComponentInstanceState.INIT,
+        instance.getState(), "instance not init");
   }
   }
 
 
   @Test
   @Test
@@ -244,10 +243,9 @@ public class TestComponentInstance {
         instance.getContainer().getId(), ComponentInstanceEventType.UPGRADE);
         instance.getContainer().getId(), ComponentInstanceEventType.UPGRADE);
     instance.handle(upgradeEvent);
     instance.handle(upgradeEvent);
 
 
-    Assert.assertEquals("instance should start upgrading",
-        ContainerState.NEEDS_UPGRADE,
+    assertEquals(ContainerState.NEEDS_UPGRADE,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance should start upgrading");
   }
   }
 
 
   @Test
   @Test
@@ -296,30 +294,26 @@ public class TestComponentInstance {
         LocalizationState.PENDING);
         LocalizationState.PENDING);
 
 
     instance.updateLocalizationStatuses(Lists.newArrayList(status));
     instance.updateLocalizationStatuses(Lists.newArrayList(status));
-    Assert.assertTrue("retriever should still be active",
-        instance.isLclRetrieverActive());
+    assertTrue(instance.isLclRetrieverActive(),
+        "retriever should still be active");
 
 
     Container container = instance.getContainerSpec();
     Container container = instance.getContainerSpec();
-    Assert.assertTrue(container.getLocalizationStatuses() != null);
-    Assert.assertEquals("dest file",
-        container.getLocalizationStatuses().get(0).getDestFile(),
-        status.getResourceKey());
-    Assert.assertEquals("state",
-        container.getLocalizationStatuses().get(0).getState(),
-        status.getLocalizationState());
+    assertTrue(container.getLocalizationStatuses() != null);
+    assertEquals(container.getLocalizationStatuses().get(0).getDestFile(),
+        status.getResourceKey(), "dest file");
+    assertEquals(container.getLocalizationStatuses().get(0).getState(),
+        status.getLocalizationState(), "state");
 
 
     status = LocalizationStatus.newInstance("file1",
     status = LocalizationStatus.newInstance("file1",
         LocalizationState.COMPLETED);
         LocalizationState.COMPLETED);
     instance.updateLocalizationStatuses(Lists.newArrayList(status));
     instance.updateLocalizationStatuses(Lists.newArrayList(status));
-    Assert.assertTrue("retriever should not be active",
-        !instance.isLclRetrieverActive());
-    Assert.assertTrue(container.getLocalizationStatuses() != null);
-    Assert.assertEquals("dest file",
-        container.getLocalizationStatuses().get(0).getDestFile(),
-        status.getResourceKey());
-    Assert.assertEquals("state",
-        container.getLocalizationStatuses().get(0).getState(),
-        status.getLocalizationState());
+    assertTrue(!instance.isLclRetrieverActive(),
+        "retriever should not be active");
+    assertTrue(container.getLocalizationStatuses() != null);
+    assertEquals(container.getLocalizationStatuses().get(0).getDestFile(),
+        status.getResourceKey(), "dest file");
+    assertEquals(container.getLocalizationStatuses().get(0).getState(),
+        status.getLocalizationState(), "state");
   }
   }
 
 
   private void validateCancelWhileUpgrading(boolean upgradeSuccessful,
   private void validateCancelWhileUpgrading(boolean upgradeSuccessful,
@@ -337,10 +331,9 @@ public class TestComponentInstance {
         instance.getContainer().getId(), ComponentInstanceEventType.UPGRADE);
         instance.getContainer().getId(), ComponentInstanceEventType.UPGRADE);
     instance.handle(upgradeEvent);
     instance.handle(upgradeEvent);
 
 
-    Assert.assertEquals("instance should be upgrading",
-        ContainerState.UPGRADING,
+    assertEquals(ContainerState.UPGRADING,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance should be upgrading");
 
 
     cancelCompUpgrade(component);
     cancelCompUpgrade(component);
     ComponentInstanceEvent cancelEvent = new ComponentInstanceEvent(
     ComponentInstanceEvent cancelEvent = new ComponentInstanceEvent(
@@ -361,9 +354,9 @@ public class TestComponentInstance {
           ComponentInstanceEventType.STOP));
           ComponentInstanceEventType.STOP));
     }
     }
 
 
-    Assert.assertEquals("instance not upgrading", ContainerState.UPGRADING,
+    assertEquals(ContainerState.UPGRADING,
         component.getComponentSpec().getContainer(instance.getContainer()
         component.getComponentSpec().getContainer(instance.getContainer()
-            .getId().toString()).getState());
+        .getId().toString()).getState(), "instance not upgrading");
 
 
     // response for cancel received
     // response for cancel received
     if (cancelUpgradeSuccessful) {
     if (cancelUpgradeSuccessful) {
@@ -377,12 +370,12 @@ public class TestComponentInstance {
           instance.getContainer().getId(), ComponentInstanceEventType.STOP));
           instance.getContainer().getId(), ComponentInstanceEventType.STOP));
     }
     }
     if (cancelUpgradeSuccessful) {
     if (cancelUpgradeSuccessful) {
-      Assert.assertEquals("instance not ready", ContainerState.READY,
+      assertEquals(ContainerState.READY,
           component.getComponentSpec().getContainer(instance.getContainer()
           component.getComponentSpec().getContainer(instance.getContainer()
-              .getId().toString()).getState());
+          .getId().toString()).getState(), "instance not ready");
     } else {
     } else {
-      Assert.assertEquals("instance not init", ComponentInstanceState.INIT,
-          instance.getState());
+      assertEquals(ComponentInstanceState.INIT,
+          instance.getState(), "instance not init");
     }
     }
   }
   }
 
 

+ 21 - 18
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/conf/TestAppJsonResolve.java

@@ -28,8 +28,7 @@ import org.apache.hadoop.yarn.service.api.records.ConfigFile;
 import org.apache.hadoop.yarn.service.api.records.Configuration;
 import org.apache.hadoop.yarn.service.api.records.Configuration;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -41,11 +40,15 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 
 
 import static org.apache.hadoop.yarn.service.conf.ExampleAppJson.*;
 import static org.apache.hadoop.yarn.service.conf.ExampleAppJson.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test global configuration resolution.
  * Test global configuration resolution.
  */
  */
-public class TestAppJsonResolve extends Assert {
+public class TestAppJsonResolve  {
   protected static final Logger LOG =
   protected static final Logger LOG =
       LoggerFactory.getLogger(TestAppJsonResolve.class);
       LoggerFactory.getLogger(TestAppJsonResolve.class);
 
 
@@ -199,18 +202,18 @@ public class TestAppJsonResolve extends Assert {
 
 
     // Validate worker's resources
     // Validate worker's resources
     Resource workerResource = orig.getComponent("worker").getResource();
     Resource workerResource = orig.getComponent("worker").getResource();
-    Assert.assertEquals(1, workerResource.getCpus().intValue());
-    Assert.assertEquals(1024, workerResource.calcMemoryMB());
-    Assert.assertNotNull(workerResource.getAdditional());
-    Assert.assertEquals(2, workerResource.getAdditional().size());
-    Assert.assertEquals(3333, workerResource.getAdditional().get(
+    assertEquals(1, workerResource.getCpus().intValue());
+    assertEquals(1024, workerResource.calcMemoryMB());
+    assertNotNull(workerResource.getAdditional());
+    assertEquals(2, workerResource.getAdditional().size());
+    assertEquals(3333, workerResource.getAdditional().get(
         "resource-1").getValue().longValue());
         "resource-1").getValue().longValue());
-    Assert.assertEquals("Gi", workerResource.getAdditional().get(
+    assertEquals("Gi", workerResource.getAdditional().get(
         "resource-1").getUnit());
         "resource-1").getUnit());
 
 
-    Assert.assertEquals(5, workerResource.getAdditional().get(
+    assertEquals(5, workerResource.getAdditional().get(
         "yarn.io/gpu").getValue().longValue());
         "yarn.io/gpu").getValue().longValue());
-    Assert.assertEquals("", workerResource.getAdditional().get(
+    assertEquals("", workerResource.getAdditional().get(
         "yarn.io/gpu").getUnit());
         "yarn.io/gpu").getUnit());
 
 
     other = orig.getComponent("other").getConfiguration();
     other = orig.getComponent("other").getConfiguration();
@@ -221,16 +224,16 @@ public class TestAppJsonResolve extends Assert {
   public void testSetResourceAttributes() throws IOException {
   public void testSetResourceAttributes() throws IOException {
     Service orig = ExampleAppJson.loadResource(EXTERNAL_JSON_3);
     Service orig = ExampleAppJson.loadResource(EXTERNAL_JSON_3);
     Component component = orig.getComponent("volume-service");
     Component component = orig.getComponent("volume-service");
-    Assert.assertNotNull(component);
+    assertNotNull(component);
     Map<String, ResourceInformation> adResource = component
     Map<String, ResourceInformation> adResource = component
         .getResource().getAdditional();
         .getResource().getAdditional();
-    Assert.assertNotNull(adResource);
-    Assert.assertEquals(1, adResource.size());
+    assertNotNull(adResource);
+    assertEquals(1, adResource.size());
     Map.Entry<String, ResourceInformation> volume = adResource
     Map.Entry<String, ResourceInformation> volume = adResource
         .entrySet().iterator().next();
         .entrySet().iterator().next();
-    Assert.assertEquals("yarn.io/csi-volume", volume.getKey());
-    Assert.assertEquals(100L, volume.getValue().getValue().longValue());
-    Assert.assertEquals(2, volume.getValue().getAttributes().size());
-    Assert.assertEquals(1, volume.getValue().getTags().size());
+    assertEquals("yarn.io/csi-volume", volume.getKey());
+    assertEquals(100L, volume.getValue().getValue().longValue());
+    assertEquals(2, volume.getValue().getAttributes().size());
+    assertEquals(1, volume.getValue().getTags().size());
   }
   }
 }
 }

+ 11 - 14
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/conf/TestLoadExampleAppJson.java

@@ -23,28 +23,23 @@ import org.apache.hadoop.yarn.service.ServiceTestUtils;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
 
 
 import static org.apache.hadoop.yarn.service.ServiceTestUtils.JSON_SER_DESER;
 import static org.apache.hadoop.yarn.service.ServiceTestUtils.JSON_SER_DESER;
 
 
-/**
- * Test loading example resources.
- */
-@RunWith(value = Parameterized.class)
-public class TestLoadExampleAppJson extends Assert {
+
+public class TestLoadExampleAppJson extends Assertions {
   private String resource;
   private String resource;
 
 
-  public TestLoadExampleAppJson(String resource) {
-    this.resource = resource;
+  public void initTestLoadExampleAppJson(String pResource) {
+    this.resource = pResource;
   }
   }
 
 
-  @Parameterized.Parameters
   public static Collection<String[]> filenames() {
   public static Collection<String[]> filenames() {
     String[][] stringArray = new String[ExampleAppJson
     String[][] stringArray = new String[ExampleAppJson
         .ALL_EXAMPLE_RESOURCES.size()][1];
         .ALL_EXAMPLE_RESOURCES.size()][1];
@@ -55,8 +50,10 @@ public class TestLoadExampleAppJson extends Assert {
     return Arrays.asList(stringArray);
     return Arrays.asList(stringArray);
   }
   }
 
 
-  @Test
-  public void testLoadResource() throws Throwable {
+  @MethodSource("filenames")
+  @ParameterizedTest
+  public void testLoadResource(String pResource) throws Throwable {
+    initTestLoadExampleAppJson(pResource);
     try {
     try {
       Service service = JSON_SER_DESER.fromResource(resource);
       Service service = JSON_SER_DESER.fromResource(resource);
 
 

+ 4 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/conf/TestValidateServiceNames.java

@@ -20,12 +20,13 @@ package org.apache.hadoop.yarn.service.conf;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
 import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 
 
+import static org.junit.jupiter.api.Assertions.fail;
+
 /**
 /**
  * Test cluster name validation.
  * Test cluster name validation.
  */
  */
@@ -38,7 +39,7 @@ public class TestValidateServiceNames {
   void assertInvalidName(String name) {
   void assertInvalidName(String name) {
     try {
     try {
       ServiceApiUtil.validateNameFormat(name, new Configuration());
       ServiceApiUtil.validateNameFormat(name, new Configuration());
-      Assert.fail();
+      fail();
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       //
       //
     }
     }

+ 5 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/containerlaunch/TestAbstractLauncher.java

@@ -27,9 +27,8 @@ import org.apache.hadoop.yarn.service.component.OnFailureRestartPolicy;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.provider.defaultImpl
 import org.apache.hadoop.yarn.service.provider.defaultImpl
     .DefaultProviderService;
     .DefaultProviderService;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
@@ -41,6 +40,7 @@ import static org.apache.hadoop.yarn.service.conf.YarnServiceConf
     .DEFAULT_CONTAINER_RETRY_INTERVAL;
     .DEFAULT_CONTAINER_RETRY_INTERVAL;
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf
 import static org.apache.hadoop.yarn.service.conf.YarnServiceConf
     .DEFAULT_CONTAINER_RETRY_MAX;
     .DEFAULT_CONTAINER_RETRY_MAX;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verify;
@@ -53,7 +53,7 @@ public class TestAbstractLauncher {
 
 
   private AbstractLauncher launcher;
   private AbstractLauncher launcher;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     launcher = new AbstractLauncher(mock(ServiceContext.class));
     launcher = new AbstractLauncher(mock(ServiceContext.class));
   }
   }
@@ -68,7 +68,7 @@ public class TestAbstractLauncher {
     String dockerContainerMounts = launcher.containerLaunchContext
     String dockerContainerMounts = launcher.containerLaunchContext
         .getEnvironment().get(AbstractLauncher.ENV_DOCKER_CONTAINER_MOUNTS);
         .getEnvironment().get(AbstractLauncher.ENV_DOCKER_CONTAINER_MOUNTS);
 
 
-    Assert.assertEquals("s1:t1:ro,s2:t2:ro", dockerContainerMounts);
+    assertEquals("s1:t1:ro,s2:t2:ro", dockerContainerMounts);
   }
   }
 
 
   @Test
   @Test

+ 10 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/monitor/TestServiceMonitor.java

@@ -29,10 +29,9 @@ import org.apache.hadoop.yarn.service.ServiceTestUtils;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.Component;
 import org.apache.hadoop.yarn.service.api.records.Component;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -40,6 +39,8 @@ import java.util.Collections;
 
 
 import static org.apache.hadoop.registry.client.api.RegistryConstants
 import static org.apache.hadoop.registry.client.api.RegistryConstants
     .KEY_REGISTRY_ZK_QUORUM;
     .KEY_REGISTRY_ZK_QUORUM;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestServiceMonitor extends ServiceTestUtils {
 public class TestServiceMonitor extends ServiceTestUtils {
 
 
@@ -47,7 +48,7 @@ public class TestServiceMonitor extends ServiceTestUtils {
   YarnConfiguration conf = new YarnConfiguration();
   YarnConfiguration conf = new YarnConfiguration();
   TestingCluster zkCluster;
   TestingCluster zkCluster;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     basedir = new File("target", "apps");
     basedir = new File("target", "apps");
     if (basedir.exists()) {
     if (basedir.exists()) {
@@ -62,7 +63,7 @@ public class TestServiceMonitor extends ServiceTestUtils {
     System.out.println("ZK cluster: " +  zkCluster.getConnectString());
     System.out.println("ZK cluster: " +  zkCluster.getConnectString());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     if (basedir != null) {
     if (basedir != null) {
       FileUtils.deleteDirectory(basedir);
       FileUtils.deleteDirectory(basedir);
@@ -100,9 +101,9 @@ public class TestServiceMonitor extends ServiceTestUtils {
     am.start();
     am.start();
 
 
     // compa ready
     // compa ready
-    Assert.assertTrue(am.getComponent("compa").areDependenciesReady());
+    assertTrue(am.getComponent("compa").areDependenciesReady());
     //compb not ready
     //compb not ready
-    Assert.assertFalse(am.getComponent("compb").areDependenciesReady());
+    assertFalse(am.getComponent("compb").areDependenciesReady());
 
 
     // feed 1 container to compa,
     // feed 1 container to compa,
     am.feedContainerToComp(exampleApp, 1, "compa");
     am.feedContainerToComp(exampleApp, 1, "compa");
@@ -120,7 +121,7 @@ public class TestServiceMonitor extends ServiceTestUtils {
     am.waitForNumDesiredContainers("compa", 2);
     am.waitForNumDesiredContainers("compa", 2);
 
 
     // compb dependencies not satisfied again.
     // compb dependencies not satisfied again.
-    Assert.assertFalse(am.getComponent("compb").areDependenciesReady());
+    assertFalse(am.getComponent("compb").areDependenciesReady());
     am.stop();
     am.stop();
   }
   }
 }
 }

+ 29 - 31
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/monitor/probe/TestDefaultProbe.java

@@ -20,9 +20,8 @@ package org.apache.hadoop.yarn.service.monitor.probe;
 import org.apache.hadoop.yarn.api.records.ContainerStatus;
 import org.apache.hadoop.yarn.api.records.ContainerStatus;
 import org.apache.hadoop.yarn.service.api.records.ReadinessCheck;
 import org.apache.hadoop.yarn.service.api.records.ReadinessCheck;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
 
 
@@ -32,23 +31,21 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
 /**
 /**
  * Tests for default probe.
  * Tests for default probe.
  */
  */
-@RunWith(Parameterized.class)
 public class TestDefaultProbe {
 public class TestDefaultProbe {
-  private final DefaultProbe probe;
+  private DefaultProbe probe;
 
 
-  public TestDefaultProbe(Probe probe) {
-    this.probe = (DefaultProbe) probe;
+  public void initTestDefaultProbe(Probe paramProbe) {
+    this.probe = (DefaultProbe) paramProbe;
   }
   }
 
 
-  @Parameterized.Parameters
   public static Collection<Object[]> data() {
   public static Collection<Object[]> data() {
     // test run 1: Default probe checks that container has an IP
     // test run 1: Default probe checks that container has an IP
     Probe p1 = MonitorUtils.getProbe(null);
     Probe p1 = MonitorUtils.getProbe(null);
@@ -71,8 +68,10 @@ public class TestDefaultProbe {
     return Arrays.asList(new Object[][] {{p1}, {p2}, {p3}});
     return Arrays.asList(new Object[][] {{p1}, {p2}, {p3}});
   }
   }
 
 
-  @Test
-  public void testDefaultProbe() {
+  @MethodSource("data")
+  @ParameterizedTest
+  public void testDefaultProbe(Probe paramProbe) {
+    initTestDefaultProbe(paramProbe);
     // component instance has a good hostname, so probe will eventually succeed
     // component instance has a good hostname, so probe will eventually succeed
     // whether or not DNS checking is enabled
     // whether or not DNS checking is enabled
     ComponentInstance componentInstance =
     ComponentInstance componentInstance =
@@ -89,35 +88,34 @@ public class TestDefaultProbe {
       componentInstance, boolean expectDNSCheckFailure) {
       componentInstance, boolean expectDNSCheckFailure) {
     // on the first ping, null container status results in failure
     // on the first ping, null container status results in failure
     ProbeStatus probeStatus = probe.ping(componentInstance);
     ProbeStatus probeStatus = probe.ping(componentInstance);
-    assertFalse("Expected failure for " + probeStatus.toString(),
-        probeStatus.isSuccess());
-    assertTrue("Expected IP failure for " + probeStatus.toString(),
-        probeStatus.toString().contains(
-        componentInstance.getCompInstanceName() + ": IP is not available yet"));
+    assertFalse(probeStatus.isSuccess(),
+        "Expected failure for " + probeStatus.toString());
+    assertTrue(probeStatus.toString().contains(
+        componentInstance.getCompInstanceName() + ": IP is not available yet"),
+        "Expected IP failure for " + probeStatus.toString());
 
 
     // on the second ping, container status is retrieved but there are no
     // on the second ping, container status is retrieved but there are no
     // IPs, resulting in failure
     // IPs, resulting in failure
     probeStatus = probe.ping(componentInstance);
     probeStatus = probe.ping(componentInstance);
-    assertFalse("Expected failure for " + probeStatus.toString(),
-        probeStatus.isSuccess());
-    assertTrue("Expected IP failure for " + probeStatus.toString(),
-        probeStatus.toString().contains(componentInstance
-            .getCompInstanceName() + ": IP is not available yet"));
+    assertFalse(probeStatus.isSuccess(),
+        "Expected failure for " + probeStatus.toString());
+    assertTrue(probeStatus.toString().contains(componentInstance
+        .getCompInstanceName() + ": IP is not available yet"),
+        "Expected IP failure for " + probeStatus.toString());
 
 
     // on the third ping, IPs are retrieved and success depends on whether or
     // on the third ping, IPs are retrieved and success depends on whether or
     // not a DNS lookup can be performed for the component instance hostname
     // not a DNS lookup can be performed for the component instance hostname
     probeStatus = probe.ping(componentInstance);
     probeStatus = probe.ping(componentInstance);
     if (expectDNSCheckFailure) {
     if (expectDNSCheckFailure) {
-      assertFalse("Expected failure for " + probeStatus.toString(),
-          probeStatus.isSuccess());
-      assertTrue("Expected DNS failure for " + probeStatus.toString(),
-          probeStatus.toString().contains(componentInstance
-              .getCompInstanceName() + ": DNS checking is enabled, but lookup" +
-              " for " + componentInstance.getHostname() + " is not available " +
-              "yet"));
+      assertFalse(probeStatus.isSuccess(),
+          "Expected failure for " + probeStatus.toString());
+      assertTrue(probeStatus.toString().contains(componentInstance
+          .getCompInstanceName() + ": DNS checking is enabled, but lookup" +
+          " for " + componentInstance.getHostname() + " is not available " +
+          "yet"), "Expected DNS failure for " + probeStatus.toString());
     } else {
     } else {
-      assertTrue("Expected success for " + probeStatus.toString(),
-          probeStatus.isSuccess());
+      assertTrue(probeStatus.isSuccess(),
+          "Expected success for " + probeStatus.toString());
     }
     }
   }
   }
 
 

+ 15 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/provider/TestAbstractProviderService.java

@@ -36,16 +36,16 @@ import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.containerlaunch.AbstractLauncher;
 import org.apache.hadoop.yarn.service.containerlaunch.AbstractLauncher;
 import org.apache.hadoop.yarn.service.containerlaunch.ContainerLaunchService;
 import org.apache.hadoop.yarn.service.containerlaunch.ContainerLaunchService;
 import org.apache.hadoop.yarn.service.provider.docker.DockerProviderService;
 import org.apache.hadoop.yarn.service.provider.docker.DockerProviderService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 
 import java.io.File;
 import java.io.File;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -58,11 +58,11 @@ public class TestAbstractProviderService {
   private Service testService;
   private Service testService;
   private AbstractLauncher launcher;
   private AbstractLauncher launcher;
 
 
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     testService = TestServiceManager.createBaseDef("testService");
     testService = TestServiceManager.createBaseDef("testService");
     serviceContext = new MockRunningServiceContext(rule, testService);
     serviceContext = new MockRunningServiceContext(rule, testService);
@@ -70,7 +70,7 @@ public class TestAbstractProviderService {
     rule.getFs().setAppDir(new Path("target/testAbstractProviderService"));
     rule.getFs().setAppDir(new Path("target/testAbstractProviderService"));
   }
   }
 
 
-  @After
+  @AfterEach
   public void teardown() throws Exception {
   public void teardown() throws Exception {
     FileUtils.deleteQuietly(
     FileUtils.deleteQuietly(
         new File(rule.getFs().getAppDir().toUri().getPath()));
         new File(rule.getFs().getAppDir().toUri().getPath()));
@@ -91,8 +91,8 @@ public class TestAbstractProviderService {
         rule.getFs(), serviceContext.scheduler.getConfig(), container, clc,
         rule.getFs(), serviceContext.scheduler.getConfig(), container, clc,
         null);
         null);
 
 
-    Assert.assertEquals("commands", Lists.newArrayList(clc.getLaunchCommand()),
-        launcher.getCommands());
+    assertEquals(Lists.newArrayList(clc.getLaunchCommand()),
+        launcher.getCommands(), "commands");
   }
   }
 
 
   @Test
   @Test
@@ -110,8 +110,8 @@ public class TestAbstractProviderService {
         rule.getFs(), serviceContext.scheduler.getConfig(), container, clc,
         rule.getFs(), serviceContext.scheduler.getConfig(), container, clc,
         null);
         null);
 
 
-    Assert.assertEquals("commands don't match.",
-        Lists.newArrayList("ls,-l, space"), launcher.getCommands());
+    assertEquals(Lists.newArrayList("ls,-l, space"),
+        launcher.getCommands(), "commands don't match.");
   }
   }
 
 
   @Test
   @Test
@@ -132,8 +132,8 @@ public class TestAbstractProviderService {
     providerService.buildContainerLaunchContext(launcher, testService, instance,
     providerService.buildContainerLaunchContext(launcher, testService, instance,
         rule.getFs(), serviceContext.scheduler.getConfig(), container, clc);
         rule.getFs(), serviceContext.scheduler.getConfig(), container, clc);
 
 
-    Assert.assertEquals("artifact", clc.getArtifact().getId(),
-        launcher.getDockerImage());
+    assertEquals(clc.getArtifact().getId(),
+        launcher.getDockerImage(), "artifact");
   }
   }
 
 
   private static ContainerLaunchService.ComponentLaunchContext
   private static ContainerLaunchService.ComponentLaunchContext

+ 6 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/provider/TestProviderUtils.java

@@ -30,14 +30,14 @@ import org.apache.hadoop.yarn.service.api.records.Configuration;
 import org.apache.hadoop.yarn.service.containerlaunch.AbstractLauncher;
 import org.apache.hadoop.yarn.service.containerlaunch.AbstractLauncher;
 import org.apache.hadoop.yarn.service.containerlaunch.ContainerLaunchService;
 import org.apache.hadoop.yarn.service.containerlaunch.ContainerLaunchService;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -169,8 +169,8 @@ public class TestProviderUtils {
     Mockito.verify(launcher).addLocalResource(
     Mockito.verify(launcher).addLocalResource(
         Mockito.eq("sourceFile4"), any(LocalResource.class));
         Mockito.eq("sourceFile4"), any(LocalResource.class));
 
 
-    Assert.assertEquals(3, resolved.getResolvedRsrcPaths().size());
-    Assert.assertEquals(resolved.getResolvedRsrcPaths().get("destFile1"),
+    assertEquals(3, resolved.getResolvedRsrcPaths().size());
+    assertEquals(resolved.getResolvedRsrcPaths().get("destFile1"),
         "destFile1");
         "destFile1");
   }
   }
 
 
@@ -179,7 +179,7 @@ public class TestProviderUtils {
     String command = "ls  -l \" space\"";
     String command = "ls  -l \" space\"";
     String expected = "ls,-l, space";
     String expected = "ls,-l, space";
     String actual = ProviderUtils.replaceSpacesWithDelimiter(command, ",");
     String actual = ProviderUtils.replaceSpacesWithDelimiter(command, ",");
-    Assert.assertEquals("replaceSpaceWithDelimiter produces unexpected result.",
-        expected, actual);
+    assertEquals(expected, actual,
+        "replaceSpaceWithDelimiter produces unexpected result.");
   }
   }
 }
 }

+ 12 - 12
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/providers/TestAbstractClientProvider.java

@@ -23,13 +23,13 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.yarn.service.api.records.Artifact;
 import org.apache.hadoop.yarn.service.api.records.Artifact;
 import org.apache.hadoop.yarn.service.api.records.ConfigFile;
 import org.apache.hadoop.yarn.service.api.records.ConfigFile;
 import org.apache.hadoop.yarn.service.provider.AbstractClientProvider;
 import org.apache.hadoop.yarn.service.provider.AbstractClientProvider;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -69,21 +69,21 @@ public class TestAbstractClientProvider {
 
 
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "null file type");
+      fail(EXCEPTION_PREFIX + "null file type");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
 
 
     configFile.setType(ConfigFile.TypeEnum.TEMPLATE);
     configFile.setType(ConfigFile.TypeEnum.TEMPLATE);
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "empty src_file for type template");
+      fail(EXCEPTION_PREFIX + "empty src_file for type template");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
 
 
     configFile.setSrcFile("srcfile");
     configFile.setSrcFile("srcfile");
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "empty dest file");
+      fail(EXCEPTION_PREFIX + "empty dest file");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
 
 
@@ -91,7 +91,7 @@ public class TestAbstractClientProvider {
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     configFile = new ConfigFile();
     configFile = new ConfigFile();
@@ -101,7 +101,7 @@ public class TestAbstractClientProvider {
     configFiles.add(configFile);
     configFiles.add(configFile);
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "dest file with multiple path elements");
+      fail(EXCEPTION_PREFIX + "dest file with multiple path elements");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
 
 
@@ -109,13 +109,13 @@ public class TestAbstractClientProvider {
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     configFile.setDestFile("destfile");
     configFile.setDestFile("destfile");
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "duplicate dest file");
+      fail(EXCEPTION_PREFIX + "duplicate dest file");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
 
 
@@ -127,14 +127,14 @@ public class TestAbstractClientProvider {
     configFiles.add(configFile);
     configFiles.add(configFile);
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "dest file with multiple path elements");
+      fail(EXCEPTION_PREFIX + "dest file with multiple path elements");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
 
 
     configFile.setDestFile("/path/destfile3");
     configFile.setDestFile("/path/destfile3");
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "src file should be specified");
+      fail(EXCEPTION_PREFIX + "src file should be specified");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
 
 
@@ -156,7 +156,7 @@ public class TestAbstractClientProvider {
 
 
     try {
     try {
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
       clientProvider.validateConfigFiles(configFiles, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + "src file is a directory");
+      fail(EXCEPTION_PREFIX + "src file is a directory");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
   }
   }

+ 6 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/providers/TestDefaultClientProvider.java

@@ -17,6 +17,8 @@
  */
  */
 package org.apache.hadoop.yarn.service.providers;
 package org.apache.hadoop.yarn.service.providers;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -27,8 +29,7 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.yarn.service.api.records.ConfigFile;
 import org.apache.hadoop.yarn.service.api.records.ConfigFile;
 import org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages;
 import org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages;
 import org.apache.hadoop.yarn.service.provider.defaultImpl.DefaultClientProvider;
 import org.apache.hadoop.yarn.service.provider.defaultImpl.DefaultClientProvider;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestDefaultClientProvider {
 public class TestDefaultClientProvider {
   private static final String EXCEPTION_PREFIX = "Should have thrown "
   private static final String EXCEPTION_PREFIX = "Should have thrown "
@@ -48,19 +49,19 @@ public class TestDefaultClientProvider {
 
 
     try {
     try {
       defaultClientProvider.validateConfigFile(configFile, compName, mockFs);
       defaultClientProvider.validateConfigFile(configFile, compName, mockFs);
-      Assert.fail(EXCEPTION_PREFIX + " dest_file must be relative");
+      fail(EXCEPTION_PREFIX + " dest_file must be relative");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       String actualMsg = String.format(
       String actualMsg = String.format(
           RestApiErrorMessages.ERROR_CONFIGFILE_DEST_FILE_FOR_COMP_NOT_ABSOLUTE,
           RestApiErrorMessages.ERROR_CONFIGFILE_DEST_FILE_FOR_COMP_NOT_ABSOLUTE,
           compName, "no", configFile.getDestFile());
           compName, "no", configFile.getDestFile());
-      Assert.assertEquals(actualMsg, e.getLocalizedMessage());
+      assertEquals(actualMsg, e.getLocalizedMessage());
     }
     }
 
 
     configFile.setDestFile("../a.txt");
     configFile.setDestFile("../a.txt");
     try {
     try {
       defaultClientProvider.validateConfigFile(configFile, compName, mockFs);
       defaultClientProvider.validateConfigFile(configFile, compName, mockFs);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getLocalizedMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getLocalizedMessage());
     }
     }
   }
   }
 }
 }

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/providers/TestProviderFactory.java

@@ -31,9 +31,9 @@ import org.apache.hadoop.yarn.service.provider.tarball.TarballClientProvider;
 import org.apache.hadoop.yarn.service.provider.tarball.TarballProviderFactory;
 import org.apache.hadoop.yarn.service.provider.tarball.TarballProviderFactory;
 import org.apache.hadoop.yarn.service.provider.tarball.TarballProviderService;
 import org.apache.hadoop.yarn.service.provider.tarball.TarballProviderService;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test provider factories.
  * Test provider factories.

+ 6 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/timelineservice/TestServiceTimelinePublisher.java

@@ -41,9 +41,9 @@ import org.apache.hadoop.yarn.service.api.records.PlacementType;
 import org.apache.hadoop.yarn.service.api.records.Resource;
 import org.apache.hadoop.yarn.service.api.records.Resource;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstance;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceId;
 import org.apache.hadoop.yarn.service.component.instance.ComponentInstanceId;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -54,7 +54,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -78,7 +78,7 @@ public class TestServiceTimelinePublisher {
   private static String CONTAINER_BAREHOST =
   private static String CONTAINER_BAREHOST =
       "localhost.com";
       "localhost.com";
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     config = new Configuration();
     config = new Configuration();
     config.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     config.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
@@ -90,7 +90,7 @@ public class TestServiceTimelinePublisher {
     serviceTimelinePublisher.start();
     serviceTimelinePublisher.start();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (serviceTimelinePublisher != null) {
     if (serviceTimelinePublisher != null) {
       serviceTimelinePublisher.stop();
       serviceTimelinePublisher.stop();

+ 8 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/utils/TestCoreFileSystem.java

@@ -21,17 +21,18 @@ package org.apache.hadoop.yarn.service.utils;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.yarn.service.ServiceTestUtils;
 import org.apache.hadoop.yarn.service.ServiceTestUtils;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConstants;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConstants;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 /**
 /**
  * Tests for {@link CoreFileSystem}.
  * Tests for {@link CoreFileSystem}.
  */
  */
 public class TestCoreFileSystem {
 public class TestCoreFileSystem {
 
 
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
   @Test
   @Test
@@ -40,7 +41,7 @@ public class TestCoreFileSystem {
     String version = "v1";
     String version = "v1";
     Path expectedPath = new Path(rule.getFs().buildClusterDirPath(serviceName),
     Path expectedPath = new Path(rule.getFs().buildClusterDirPath(serviceName),
         YarnServiceConstants.UPGRADE_DIR + "/" + version);
         YarnServiceConstants.UPGRADE_DIR + "/" + version);
-    Assert.assertEquals("incorrect upgrade path", expectedPath,
-        rule.getFs().buildClusterUpgradeDirPath(serviceName, version));
+    assertEquals(expectedPath, rule.getFs().buildClusterUpgradeDirPath(serviceName, version),
+        "incorrect upgrade path");
   }
   }
 }
 }

+ 19 - 22
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/utils/TestFilterUtils.java

@@ -26,16 +26,17 @@ import org.apache.hadoop.yarn.service.ServiceTestUtils;
 import org.apache.hadoop.yarn.service.TestServiceManager;
 import org.apache.hadoop.yarn.service.TestServiceManager;
 import org.apache.hadoop.yarn.service.api.records.ComponentContainers;
 import org.apache.hadoop.yarn.service.api.records.ComponentContainers;
 import org.apache.hadoop.yarn.service.api.records.ContainerState;
 import org.apache.hadoop.yarn.service.api.records.ContainerState;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 
 import java.util.List;
 import java.util.List;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 public class TestFilterUtils {
 public class TestFilterUtils {
 
 
-  @Rule
-  public ServiceTestUtils.ServiceFSWatcher rule =
+  @RegisterExtension
+  private ServiceTestUtils.ServiceFSWatcher rule =
       new ServiceTestUtils.ServiceFSWatcher();
       new ServiceTestUtils.ServiceFSWatcher();
 
 
   @Test
   @Test
@@ -45,9 +46,9 @@ public class TestFilterUtils {
     List<ComponentContainers> compContainers = FilterUtils.filterInstances(
     List<ComponentContainers> compContainers = FilterUtils.filterInstances(
         new MockRunningServiceContext(rule,
         new MockRunningServiceContext(rule,
             TestServiceManager.createBaseDef("service")), req);
             TestServiceManager.createBaseDef("service")), req);
-    Assert.assertEquals("num comps", 2, compContainers.size());
+    assertEquals(2, compContainers.size(), "num comps");
     compContainers.forEach(item -> {
     compContainers.forEach(item -> {
-      Assert.assertEquals("num containers", 2, item.getContainers().size());
+      assertEquals(2, item.getContainers().size(), "num containers");
     });
     });
   }
   }
 
 
@@ -58,12 +59,9 @@ public class TestFilterUtils {
     List<ComponentContainers> compContainers = FilterUtils.filterInstances(
     List<ComponentContainers> compContainers = FilterUtils.filterInstances(
         new MockRunningServiceContext(rule,
         new MockRunningServiceContext(rule,
             TestServiceManager.createBaseDef("service")), req);
             TestServiceManager.createBaseDef("service")), req);
-    Assert.assertEquals("num comps", 1, compContainers.size());
-    Assert.assertEquals("comp name", "compa",
-        compContainers.get(0).getComponentName());
-
-    Assert.assertEquals("num containers", 2,
-        compContainers.get(0).getContainers().size());
+    assertEquals(1, compContainers.size(), "num comps");
+    assertEquals("compa", compContainers.get(0).getComponentName(), "comp name");
+    assertEquals(2, compContainers.get(0).getContainers().size(), "num containers");
   }
   }
 
 
   @Test
   @Test
@@ -74,15 +72,14 @@ public class TestFilterUtils {
         GetCompInstancesRequestProto.newBuilder();
         GetCompInstancesRequestProto.newBuilder();
 
 
     reqBuilder.setVersion("v2");
     reqBuilder.setVersion("v2");
-    Assert.assertEquals("num comps", 0,
-        FilterUtils.filterInstances(sc, reqBuilder.build()).size());
+    assertEquals(0, FilterUtils.filterInstances(sc, reqBuilder.build()).size(),
+        "num comps");
 
 
     reqBuilder.addAllComponentNames(Lists.newArrayList("compa"))
     reqBuilder.addAllComponentNames(Lists.newArrayList("compa"))
         .setVersion("v1").build();
         .setVersion("v1").build();
 
 
-    Assert.assertEquals("num containers", 2,
-        FilterUtils.filterInstances(sc, reqBuilder.build()).get(0)
-            .getContainers().size());
+    assertEquals(2, FilterUtils.filterInstances(sc, reqBuilder.build()).get(0)
+        .getContainers().size(), "num containers");
   }
   }
 
 
   @Test
   @Test
@@ -96,16 +93,16 @@ public class TestFilterUtils {
         ContainerState.READY.toString()));
         ContainerState.READY.toString()));
     List<ComponentContainers> compContainers = FilterUtils.filterInstances(sc,
     List<ComponentContainers> compContainers = FilterUtils.filterInstances(sc,
         reqBuilder.build());
         reqBuilder.build());
-    Assert.assertEquals("num comps", 2, compContainers.size());
+    assertEquals(2, compContainers.size(), "num comps");
     compContainers.forEach(item -> {
     compContainers.forEach(item -> {
-      Assert.assertEquals("num containers", 2, item.getContainers().size());
+      assertEquals(2, item.getContainers().size(), "num containers");
     });
     });
 
 
     reqBuilder.clearContainerStates();
     reqBuilder.clearContainerStates();
     reqBuilder.addAllContainerStates(Lists.newArrayList(
     reqBuilder.addAllContainerStates(Lists.newArrayList(
         ContainerState.STOPPED.toString()));
         ContainerState.STOPPED.toString()));
-    Assert.assertEquals("num comps", 0,
-        FilterUtils.filterInstances(sc, reqBuilder.build()).size());
+    assertEquals(0, FilterUtils.filterInstances(sc, reqBuilder.build()).size(),
+        "num comps");
   }
   }
 
 
 }
 }

+ 59 - 56
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/utils/TestServiceApiUtil.java

@@ -32,9 +32,9 @@ import org.apache.hadoop.yarn.service.api.records.Resource;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
 import org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages;
 import org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -45,13 +45,14 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
 
 
-import static org.assertj.core.api.Assertions.assertThat;
 import static org.apache.hadoop.test.LambdaTestUtils.intercept;
 import static org.apache.hadoop.test.LambdaTestUtils.intercept;
 import static org.apache.hadoop.yarn.service.conf.RestApiConstants.DEFAULT_UNLIMITED_LIFETIME;
 import static org.apache.hadoop.yarn.service.conf.RestApiConstants.DEFAULT_UNLIMITED_LIFETIME;
 import static org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages.*;
 import static org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Test for ServiceApiUtil helper methods.
  * Test for ServiceApiUtil helper methods.
@@ -72,12 +73,13 @@ public class TestServiceApiUtil extends ServiceTestUtils {
   private static final YarnConfiguration CONF_DNS_ENABLED = new
   private static final YarnConfiguration CONF_DNS_ENABLED = new
       YarnConfiguration();
       YarnConfiguration();
 
 
-  @BeforeClass
+  @BeforeAll
   public static void init() {
   public static void init() {
     CONF_DNS_ENABLED.setBoolean(RegistryConstants.KEY_DNS_ENABLED, true);
     CONF_DNS_ENABLED.setBoolean(RegistryConstants.KEY_DNS_ENABLED, true);
   }
   }
 
 
-  @Test(timeout = 90000)
+  @Test
+  @Timeout(value = 90)
   public void testResourceValidation() throws Exception {
   public void testResourceValidation() throws Exception {
     assertEquals(RegistryConstants.MAX_FQDN_LABEL_LENGTH + 1, LEN_64_STR
     assertEquals(RegistryConstants.MAX_FQDN_LABEL_LENGTH + 1, LEN_64_STR
         .length());
         .length());
@@ -89,7 +91,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     // no name
     // no name
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with no name");
+      fail(EXCEPTION_PREFIX + "service with no name");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(ERROR_APPLICATION_NAME_INVALID, e.getMessage());
       assertEquals(ERROR_APPLICATION_NAME_INVALID, e.getMessage());
     }
     }
@@ -98,7 +100,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     // no version
     // no version
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + " service with no version");
+      fail(EXCEPTION_PREFIX + " service with no version");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(ERROR_APPLICATION_VERSION_INVALID,
       assertEquals(String.format(ERROR_APPLICATION_VERSION_INVALID,
           app.getName()), e.getMessage());
           app.getName()), e.getMessage());
@@ -111,7 +113,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
       app.setName(badName);
       app.setName(badName);
       try {
       try {
         ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
         ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-        Assert.fail(EXCEPTION_PREFIX + "service with bad name " + badName);
+        fail(EXCEPTION_PREFIX + "service with bad name " + badName);
       } catch (IllegalArgumentException e) {
       } catch (IllegalArgumentException e) {
 
 
       }
       }
@@ -123,7 +125,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     app.addComponent(comp);
     app.addComponent(comp);
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DEFAULT_DNS);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DEFAULT_DNS);
-      Assert.fail(EXCEPTION_PREFIX + "service with no launch command");
+      fail(EXCEPTION_PREFIX + "service with no launch command");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(RestApiErrorMessages.ERROR_ABSENT_LAUNCH_COMMAND,
       assertEquals(RestApiErrorMessages.ERROR_ABSENT_LAUNCH_COMMAND,
           e.getMessage());
           e.getMessage());
@@ -134,7 +136,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
         .MAX_FQDN_LABEL_LENGTH));
         .MAX_FQDN_LABEL_LENGTH));
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with no launch command");
+      fail(EXCEPTION_PREFIX + "service with no launch command");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(RestApiErrorMessages.ERROR_ABSENT_LAUNCH_COMMAND,
       assertEquals(RestApiErrorMessages.ERROR_ABSENT_LAUNCH_COMMAND,
           e.getMessage());
           e.getMessage());
@@ -146,7 +148,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     app.setResource(res);
     app.setResource(res);
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with no memory");
+      fail(EXCEPTION_PREFIX + "service with no memory");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(
       assertEquals(String.format(
           RestApiErrorMessages.ERROR_RESOURCE_MEMORY_FOR_COMP_INVALID,
           RestApiErrorMessages.ERROR_RESOURCE_MEMORY_FOR_COMP_INVALID,
@@ -158,7 +160,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     res.setCpus(-2);
     res.setCpus(-2);
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(
+      fail(
           EXCEPTION_PREFIX + "service with invalid no of cpus");
           EXCEPTION_PREFIX + "service with invalid no of cpus");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(
       assertEquals(String.format(
@@ -170,9 +172,9 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     res.setCpus(2);
     res.setCpus(2);
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with no container count");
+      fail(EXCEPTION_PREFIX + "service with no container count");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.assertTrue(e.getMessage()
+      assertTrue(e.getMessage()
           .contains(ERROR_CONTAINERS_COUNT_INVALID));
           .contains(ERROR_CONTAINERS_COUNT_INVALID));
     }
     }
 
 
@@ -180,7 +182,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     res.setProfile("hbase_finance_large");
     res.setProfile("hbase_finance_large");
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX
+      fail(EXCEPTION_PREFIX
           + "service with resource profile along with cpus/memory");
           + "service with resource profile along with cpus/memory");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(RestApiErrorMessages
       assertEquals(String.format(RestApiErrorMessages
@@ -195,7 +197,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     res.setMemory(null);
     res.setMemory(null);
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with resource profile only");
+      fail(EXCEPTION_PREFIX + "service with resource profile only");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(ERROR_RESOURCE_PROFILE_NOT_SUPPORTED_YET,
       assertEquals(ERROR_RESOURCE_PROFILE_NOT_SUPPORTED_YET,
           e.getMessage());
           e.getMessage());
@@ -209,9 +211,9 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     // null number of containers
     // null number of containers
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "null number of containers");
+      fail(EXCEPTION_PREFIX + "null number of containers");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.assertTrue(e.getMessage()
+      assertTrue(e.getMessage()
           .startsWith(ERROR_CONTAINERS_COUNT_INVALID));
           .startsWith(ERROR_CONTAINERS_COUNT_INVALID));
     }
     }
   }
   }
@@ -236,7 +238,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     app.setComponents(Collections.singletonList(comp));
     app.setComponents(Collections.singletonList(comp));
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with no artifact id");
+      fail(EXCEPTION_PREFIX + "service with no artifact id");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(ERROR_ARTIFACT_ID_FOR_COMP_INVALID, compName),
       assertEquals(String.format(ERROR_ARTIFACT_ID_FOR_COMP_INVALID, compName),
           e.getMessage());
           e.getMessage());
@@ -246,7 +248,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     artifact.setType(Artifact.TypeEnum.SERVICE);
     artifact.setType(Artifact.TypeEnum.SERVICE);
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with no artifact id");
+      fail(EXCEPTION_PREFIX + "service with no artifact id");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(ERROR_ARTIFACT_ID_INVALID, e.getMessage());
       assertEquals(ERROR_ARTIFACT_ID_INVALID, e.getMessage());
     }
     }
@@ -255,7 +257,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     artifact.setType(Artifact.TypeEnum.TARBALL);
     artifact.setType(Artifact.TypeEnum.TARBALL);
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with no artifact id");
+      fail(EXCEPTION_PREFIX + "service with no artifact id");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(ERROR_ARTIFACT_ID_FOR_COMP_INVALID, compName),
       assertEquals(String.format(ERROR_ARTIFACT_ID_FOR_COMP_INVALID, compName),
           e.getMessage());
           e.getMessage());
@@ -268,7 +270,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       LOG.error("service attributes specified should be valid here", e);
       LOG.error("service attributes specified should be valid here", e);
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     assertThat(app.getLifetime()).isEqualTo(DEFAULT_UNLIMITED_LIFETIME);
     assertThat(app.getLifetime()).isEqualTo(DEFAULT_UNLIMITED_LIFETIME);
@@ -315,7 +317,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     assertEquals(1, app.getComponents().size());
     assertEquals(1, app.getComponents().size());
@@ -333,7 +335,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     // duplicate component name fails
     // duplicate component name fails
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with component collision");
+      fail(EXCEPTION_PREFIX + "service with component collision");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals("Component name collision: " + compName, e.getMessage());
       assertEquals("Component name collision: " + compName, e.getMessage());
     }
     }
@@ -350,7 +352,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     //component name same as service name
     //component name same as service name
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "component name matches service name");
+      fail(EXCEPTION_PREFIX + "component name matches service name");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals("Component name test must not be same as service name test",
       assertEquals("Component name test must not be same as service name test",
           e.getMessage());
           e.getMessage());
@@ -372,7 +374,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
   }
   }
 
 
@@ -390,7 +392,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     assertEquals(1, app.getComponents().size());
     assertEquals(1, app.getComponents().size());
@@ -403,7 +405,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     assertEquals(1, app.getComponents().size());
     assertEquals(1, app.getComponents().size());
@@ -440,7 +442,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     c.setDependencies(Arrays.asList("e"));
     c.setDependencies(Arrays.asList("e"));
     try {
     try {
       verifyDependencySorting(Arrays.asList(a, b, c, d, e));
       verifyDependencySorting(Arrays.asList(a, b, c, d, e));
-      Assert.fail(EXCEPTION_PREFIX + "components with dependency cycle");
+      fail(EXCEPTION_PREFIX + "components with dependency cycle");
     } catch (IllegalArgumentException ex) {
     } catch (IllegalArgumentException ex) {
       assertEquals(String.format(
       assertEquals(String.format(
           RestApiErrorMessages.ERROR_DEPENDENCY_CYCLE, Arrays.asList(c, d,
           RestApiErrorMessages.ERROR_DEPENDENCY_CYCLE, Arrays.asList(c, d,
@@ -453,7 +455,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(service, sfs,
       ServiceApiUtil.validateAndResolveService(service, sfs,
           CONF_DEFAULT_DNS);
           CONF_DEFAULT_DNS);
-      Assert.fail(EXCEPTION_PREFIX + "components with bad dependencies");
+      fail(EXCEPTION_PREFIX + "components with bad dependencies");
     } catch (IllegalArgumentException ex) {
     } catch (IllegalArgumentException ex) {
       assertEquals(String.format(
       assertEquals(String.format(
           RestApiErrorMessages.ERROR_DEPENDENCY_INVALID, "b", "e"), ex
           RestApiErrorMessages.ERROR_DEPENDENCY_INVALID, "b", "e"), ex
@@ -476,7 +478,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     for (String name : invalidNames) {
     for (String name : invalidNames) {
       try {
       try {
         ServiceApiUtil.validateNameFormat(name, new Configuration());
         ServiceApiUtil.validateNameFormat(name, new Configuration());
-        Assert.fail();
+        fail();
       } catch (IllegalArgumentException ex) {
       } catch (IllegalArgumentException ex) {
         ex.printStackTrace();
         ex.printStackTrace();
       }
       }
@@ -496,7 +498,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     // invalid component name fails if dns is enabled
     // invalid component name fails if dns is enabled
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "service with invalid component name");
+      fail(EXCEPTION_PREFIX + "service with invalid component name");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(RestApiErrorMessages
       assertEquals(String.format(RestApiErrorMessages
           .ERROR_COMPONENT_NAME_INVALID, maxLen, compName), e.getMessage());
           .ERROR_COMPONENT_NAME_INVALID, maxLen, compName), e.getMessage());
@@ -506,7 +508,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DEFAULT_DNS);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DEFAULT_DNS);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     compName = LEN_64_STR.substring(0, maxLen);
     compName = LEN_64_STR.substring(0, maxLen);
@@ -517,7 +519,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
   }
   }
 
 
@@ -534,7 +536,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
 
 
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "constraint with no type");
+      fail(EXCEPTION_PREFIX + "constraint with no type");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(
       assertEquals(String.format(
           RestApiErrorMessages.ERROR_PLACEMENT_POLICY_CONSTRAINT_TYPE_NULL,
           RestApiErrorMessages.ERROR_PLACEMENT_POLICY_CONSTRAINT_TYPE_NULL,
@@ -546,7 +548,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
 
 
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
-      Assert.fail(EXCEPTION_PREFIX + "constraint with no scope");
+      fail(EXCEPTION_PREFIX + "constraint with no scope");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(String.format(
       assertEquals(String.format(
           RestApiErrorMessages.ERROR_PLACEMENT_POLICY_CONSTRAINT_SCOPE_NULL,
           RestApiErrorMessages.ERROR_PLACEMENT_POLICY_CONSTRAINT_SCOPE_NULL,
@@ -564,7 +566,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
       ServiceApiUtil.validateAndResolveService(app, sfs, CONF_DNS_ENABLED);
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
   }
   }
 
 
@@ -581,7 +583,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     // Keytab with no URI scheme should succeed too
     // Keytab with no URI scheme should succeed too
@@ -589,7 +591,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
   }
   }
 
 
@@ -602,7 +604,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
 
 
     try {
     try {
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
-      Assert.fail(EXCEPTION_PREFIX + "service with invalid principal name " +
+      fail(EXCEPTION_PREFIX + "service with invalid principal name " +
           "format.");
           "format.");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       assertEquals(
       assertEquals(
@@ -616,7 +618,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
 
 
     kp.setPrincipalName(null);
     kp.setPrincipalName(null);
@@ -624,7 +626,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     try {
     try {
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
       ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
     } catch (NullPointerException e) {
     } catch (NullPointerException e) {
-        Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
+      fail(NO_EXCEPTION_PREFIX + e.getMessage());
     }
     }
   }
   }
 
 
@@ -643,8 +645,8 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     expected.add("compb");
     expected.add("compb");
     expected.add("compa");
     expected.add("compa");
     for (int i = 0; i < expected.size(); i++) {
     for (int i = 0; i < expected.size(); i++) {
-      Assert.assertEquals("Components are not equal.", expected.get(i),
-          order.get(i));
+      assertEquals(expected.get(i),
+          order.get(i), "Components are not equal.");
     }
     }
   }
   }
 
 
@@ -663,8 +665,8 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     expected.add("compa");
     expected.add("compa");
     expected.add("compb");
     expected.add("compb");
     for (int i = 0; i < expected.size(); i++) {
     for (int i = 0; i < expected.size(); i++) {
-      Assert.assertEquals("Components are not equal.", expected.get(i),
-          order.get(i));
+      assertEquals(expected.get(i),
+          order.get(i), "Components are not equal.");
     }
     }
   }
   }
 
 
@@ -686,8 +688,8 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     expected.add("compa");
     expected.add("compa");
     expected.add("compb");
     expected.add("compb");
     for (int i = 0; i < expected.size(); i++) {
     for (int i = 0; i < expected.size(); i++) {
-      Assert.assertEquals("Components are not equal.", expected.get(i),
-          order.get(i));
+      assertEquals(expected.get(i),
+          order.get(i), "Components are not equal.");
     }
     }
   }
   }
 
 
@@ -703,12 +705,13 @@ public class TestServiceApiUtil extends ServiceTestUtils {
     expected.add("compa");
     expected.add("compa");
     expected.add("compb");
     expected.add("compb");
     for (int i = 0; i < expected.size(); i++) {
     for (int i = 0; i < expected.size(); i++) {
-      Assert.assertEquals("Components are not equal.", expected.get(i),
-          order.get(i));
+      assertEquals(expected.get(i),
+          order.get(i), "Components are not equal.");
     }
     }
   }
   }
 
 
-  @Test(timeout = 1500)
+  @Test
+  @Timeout(value = 1)
   public void testNoServiceDependencies() {
   public void testNoServiceDependencies() {
     Service service = createExampleApplication();
     Service service = createExampleApplication();
     Component compa = createComponent("compa");
     Component compa = createComponent("compa");
@@ -743,7 +746,7 @@ public class TestServiceApiUtil extends ServiceTestUtils {
       Thread.sleep(1000);
       Thread.sleep(1000);
     } catch (InterruptedException e) {
     } catch (InterruptedException e) {
     }
     }
-    Assert.assertTrue(thread.isAlive());
+    assertTrue(thread.isAlive());
   }
   }
 
 
   @Test
   @Test