diff --git a/.codespellrc b/.codespellrc
new file mode 100644
index 0000000000..fee7e92ef2
--- /dev/null
+++ b/.codespellrc
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+[codespell]
+ignore-words-list = thirdparty,afterall,AfterAll
diff --git a/hadoop-shim/pom.xml b/hadoop-shim/pom.xml
index e1a82a60ee..1e9f67895b 100644
--- a/hadoop-shim/pom.xml
+++ b/hadoop-shim/pom.xml
@@ -34,8 +34,8 @@
slf4j-api
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
org.apache.hadoop
diff --git a/hadoop-shim/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShimsLoader.java b/hadoop-shim/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShimsLoader.java
index 8c65135a82..db1bcdc17e 100644
--- a/hadoop-shim/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShimsLoader.java
+++ b/hadoop-shim/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShimsLoader.java
@@ -18,11 +18,15 @@
*/
package org.apache.tez.hadoop.shim;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.hadoop.shim.DummyShimProvider.DummyShim;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
public class TestHadoopShimsLoader {
@@ -30,8 +34,8 @@ public class TestHadoopShimsLoader {
public void testBasicLoader() {
HadoopShimsLoader loader = new HadoopShimsLoader(new Configuration(false));
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(DefaultHadoopShim.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(DefaultHadoopShim.class, shim.getClass());
}
@Test
@@ -40,16 +44,19 @@ public void testLoaderOverride() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_PROVIDER_CLASS, DummyShimProvider.class.getName());
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(DummyShim.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(DummyShim.class, shim.getClass());
}
- @Test(expected = RuntimeException.class)
+ @Test
public void testInvalidOverride() {
Configuration conf = new Configuration(false);
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_PROVIDER_CLASS, "org.apache.tez.foo");
- HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
- HadoopShim shim = loader.getHadoopShim();
+ assertThrows(
+ RuntimeException.class,
+ () -> {
+ HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
+ HadoopShim shim = loader.getHadoopShim();
+ });
}
-
}
diff --git a/pom.xml b/pom.xml
index ccdc48d2d1..12c8388362 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,8 +85,7 @@
2.18.6
2.46
1.5.4
- 4.13.2
- 5.9.3
+ 6.1.0
org.fusesource.leveldbjni
0.12
1.8
@@ -629,8 +628,8 @@
${hadoop.version}
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
com.google.inject
@@ -890,22 +889,10 @@
commons-cli
${commons-cli.version}
-
- junit
- junit
- ${junit.version}
- test
-
org.junit.jupiter
- junit-jupiter-api
- ${junit.jupiter.version}
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- ${junit.jupiter.version}
+ junit-jupiter
+ ${junit.version}
test
diff --git a/tez-api/pom.xml b/tez-api/pom.xml
index 5131258dcd..e54e15226c 100644
--- a/tez-api/pom.xml
+++ b/tez-api/pom.xml
@@ -90,8 +90,8 @@
protobuf-java
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
org.glassfish.jersey.core
diff --git a/tez-api/src/test/java/org/apache/tez/client/TestTezClient.java b/tez-api/src/test/java/org/apache/tez/client/TestTezClient.java
index 07121cf1ee..42c24ce4ea 100644
--- a/tez-api/src/test/java/org/apache/tez/client/TestTezClient.java
+++ b/tez-api/src/test/java/org/apache/tez/client/TestTezClient.java
@@ -18,12 +18,14 @@
*/
package org.apache.tez.client;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeast;
@@ -99,9 +101,8 @@
import com.google.protobuf.RpcController;
import com.google.protobuf.ServiceException;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.ArgumentCaptor;
public class TestTezClient {
@@ -211,27 +212,36 @@ TezClientForTest configureAndCreateTezClient(Map lrs, boo
return client;
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientApp() throws Exception {
testTezClient(false, true, "testTezClientApp");
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientSession() throws Exception {
testTezClient(true, true, "testTezClientSession");
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientReconnect() throws Exception {
testTezClientReconnect(true);
}
- @Test (timeout = 5000, expected = IllegalStateException.class)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientReconnectNoSession() throws Exception {
- testTezClientReconnect(false);
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ testTezClientReconnect(false);
+ });
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientSessionLargeDAGPlan() throws Exception {
// request size is within threshold of being serialized
_testTezClientSessionLargeDAGPlan(10*1024*1024, 10, 10, false);
@@ -294,7 +304,8 @@ private void _testTezClientSessionLargeDAGPlan(int maxIPCMsgSize, int payloadSiz
}
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetClient() throws Exception {
/* BEGIN first TezClient usage without calling stop() */
TezClientForTest client = testTezClient(true, false, "testGetClient");
@@ -354,7 +365,7 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
if (isSession) {
verify(client.mockYarnClient, times(1)).submitApplication(captor.capture());
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -387,7 +398,7 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
} else {
verify(client.mockYarnClient, times(1)).submitApplication(captor.capture());
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(4, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(4, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -424,8 +435,8 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
ArgumentCaptor captor1 = ArgumentCaptor.forClass(SubmitDAGRequestProto.class);
verify(client.sessionAmProxy, times(2)).submitDAG(any(), captor1.capture());
SubmitDAGRequestProto proto = captor1.getValue();
- Assert.assertEquals(1, proto.getAdditionalAmResources().getLocalResourcesCount());
- Assert.assertEquals(lrName2, proto.getAdditionalAmResources().getLocalResources(0).getName());
+ assertEquals(1, proto.getAdditionalAmResources().getLocalResourcesCount());
+ assertEquals(lrName2, proto.getAdditionalAmResources().getLocalResources(0).getName());
} else {
// new app master
assertTrue(dagClient.getExecutionContext().contains(appId2.toString()));
@@ -433,7 +444,7 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
verify(client.mockYarnClient, times(2)).submitApplication(captor.capture());
// additional resource is added
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(5, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(5, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -482,7 +493,7 @@ public void testTezClientReconnect(boolean isSession) throws Exception {
if (isSession) {
verify(client.mockYarnClient, times(1)).submitApplication(captor.capture());
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -550,7 +561,8 @@ public void testTezClientReconnect(boolean isSession) throws Exception {
client2.stop();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPreWarm() throws Exception {
TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -575,7 +587,8 @@ public void testPreWarm() throws Exception {
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPreWarmCloseStuck() throws Exception {
TezClientForTest client = configureAndCreateTezClient();
client.setPrewarmTimeoutMs(10L); // Don't wait too long.
@@ -604,7 +617,8 @@ private void setClientToReportStoppedDags(TezClientForTest client) throws Except
.setSucceededTaskCount(1).setTotalTaskCount(1).build()).build()).build());
}
- @Test (timeout=30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testPreWarmWithTimeout() throws Exception {
long startTime = 0 , endTime = 0;
TezClientForTest client = configureAndCreateTezClient();
@@ -632,12 +646,11 @@ public void testPreWarmWithTimeout() throws Exception {
fail("PreWarm should have encountered an Exception!");
} catch (SessionNotReady te) {
endTime = Time.monotonicNow();
- assertTrue("Time taken is not as expected",
- (endTime - startTime) > timeout);
+ assertTrue((endTime - startTime) > timeout, "Time taken is not as expected");
verify(spyClient, times(0)).submitDAG(any());
- Assert.assertTrue("Unexpected Exception message: " + te.getMessage(),
- te.getMessage().contains("Tez AM not ready"));
-
+ assertTrue(
+ te.getMessage().contains("Tez AM not ready"),
+ "Unexpected Exception message: " + te.getMessage());
}
when(
@@ -650,8 +663,7 @@ public void testPreWarmWithTimeout() throws Exception {
startTime = Time.monotonicNow();
spyClient.preWarm(vertex, timeout, TimeUnit.MILLISECONDS);
endTime = Time.monotonicNow();
- assertTrue("Time taken is not as expected",
- (endTime - startTime) <= timeout);
+ assertTrue((endTime - startTime) <= timeout, "Time taken is not as expected");
verify(spyClient, times(1)).submitDAG(any());
} catch (TezException te) {
fail("PreWarm should have succeeded!");
@@ -685,15 +697,15 @@ public void run() {
startTime = Time.monotonicNow();
spyClient.preWarm(vertex, timeout, TimeUnit.MILLISECONDS);
endTime = Time.monotonicNow();
- assertTrue("Time taken is not as expected",
- (endTime - startTime) <= timeout);
+ assertTrue((endTime - startTime) <= timeout, "Time taken is not as expected");
verify(spyClient, times(2)).submitDAG(any());
setClientToReportStoppedDags(client);
spyClient.stop();
client.stop();
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testMultipleSubmissions() throws Exception {
testMultipleSubmissionsJob(false);
testMultipleSubmissionsJob(true);
@@ -735,7 +747,8 @@ public void testMultipleSubmissionsJob(boolean isSession) throws Exception {
client2.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitTillReady_Interrupt() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -757,11 +770,12 @@ public void run() {
thread.join(250);
thread.interrupt();
thread.join();
- Assert.assertThat(exceptionReference.get(), CoreMatchers.instanceOf(InterruptedException.class));
+ assertInstanceOf(InterruptedException.class, exceptionReference.get());
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitTillReadyAppFailed() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -779,7 +793,8 @@ public void testWaitTillReadyAppFailed() throws Exception {
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitTillReadyAppFailedNoDiagnostics() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -794,7 +809,8 @@ public void testWaitTillReadyAppFailedNoDiagnostics() throws Exception {
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSubmitDAGAppFailed() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -819,7 +835,8 @@ public void testSubmitDAGAppFailed() throws Exception {
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientCounterLimits() throws YarnException, IOException, ServiceException {
Limits.reset();
int defaultCounterLimit = TezConfiguration.TEZ_COUNTERS_MAX_DEFAULT;
@@ -843,7 +860,8 @@ public void testTezClientCounterLimits() throws YarnException, IOException, Serv
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testClientBuilder() {
TezConfiguration tezConfWitSession = new TezConfiguration();
tezConfWitSession.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
@@ -914,7 +932,8 @@ public static class InvalidChecker {
// No-op class
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidJavaOptsChecker1() throws YarnException, IOException, ServiceException,
TezException {
TezConfiguration conf = new TezConfiguration();
@@ -923,7 +942,8 @@ public void testInvalidJavaOptsChecker1() throws YarnException, IOException, Ser
client.start();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidJavaOptsChecker2() throws YarnException, IOException, ServiceException,
TezException {
TezConfiguration conf = new TezConfiguration();
@@ -932,7 +952,8 @@ public void testInvalidJavaOptsChecker2() throws YarnException, IOException, Ser
client.start();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testStopRetriesUntilTerminalState() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.setBoolean(TezConfiguration.TEZ_CLIENT_ASYNCHRONOUS_STOP, false);
@@ -944,12 +965,13 @@ public void testStopRetriesUntilTerminalState() throws Exception {
try {
client.stop();
} catch (Exception e) {
- Assert.fail("Expected ApplicationNotFoundException");
+ fail("Expected ApplicationNotFoundException");
}
verify(client.mockYarnClient, atLeast(2)).getApplicationReport(client.mockAppId);
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testStopRetriesUntilTimeout() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.setBoolean(TezConfiguration.TEZ_CLIENT_ASYNCHRONOUS_STOP, false);
@@ -962,28 +984,30 @@ public void testStopRetriesUntilTimeout() throws Exception {
try {
client.stop();
} catch (Exception e) {
- Assert.fail("Stop should complete without exception: " + e);
+ fail("Stop should complete without exception: " + e);
}
long end = System.currentTimeMillis();
verify(client.mockYarnClient, atLeast(2)).getApplicationReport(client.mockAppId);
- Assert.assertTrue("Stop ended before timeout", end - start > HARD_KILL_TIMEOUT);
+ assertTrue(end - start > HARD_KILL_TIMEOUT, "Stop ended before timeout");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSubmitHostPopulated() throws YarnException, IOException, ServiceException, TezException {
TezConfiguration conf = new TezConfiguration();
configureAndCreateTezClient(conf);
InetAddress ip = InetAddress.getLocalHost();
if (ip != null) {
- Assert.assertEquals(ip.getCanonicalHostName(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST));
- Assert.assertEquals(ip.getHostAddress(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST_ADDRESS));
+ assertEquals(ip.getCanonicalHostName(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST));
+ assertEquals(ip.getHostAddress(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST_ADDRESS));
} else {
- Assert.fail("Failed to retrieve local host information");
+ fail("Failed to retrieve local host information");
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testClientResubmit() throws Exception {
TezClientForTest client = configureAndCreateTezClient(null, true, null);
client.start();
@@ -1002,15 +1026,16 @@ public void testClientResubmit() throws Exception {
for (int i = 0; i < 3; ++i) {
try {
client.submitDAG(dag);
- Assert.fail("Expected TezUncheckedException here.");
+ fail("Expected TezUncheckedException here.");
} catch(TezUncheckedException ex) {
- Assert.assertTrue(ex.getMessage().contains("Invalid/conflicting GC options found"));
+ assertTrue(ex.getMessage().contains("Invalid/conflicting GC options found"));
}
}
client.stop();
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testMissingYarnAppStatus() throws Exception {
// verify an app not found exception is thrown when YARN reports a null app status
ApplicationId appId1 = ApplicationId.newInstance(0, 1);
@@ -1029,7 +1054,8 @@ public void testMissingYarnAppStatus() throws Exception {
}
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testAMClientHeartbeat() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS, 10);
@@ -1059,7 +1085,8 @@ public void testAMClientHeartbeat() throws Exception {
verify(client2.sessionAmProxy, times(0)).getAMStatus(any(), any());
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testAMHeartbeatFailOnGetAMProxy_AppNotStarted() throws Exception {
int amHeartBeatTimeoutSecs = 3;
TezConfiguration conf = new TezConfiguration();
@@ -1075,7 +1102,8 @@ public void testAMHeartbeatFailOnGetAMProxy_AppNotStarted() throws Exception {
assertFalse(client.getAMKeepAliveService().isTerminated());
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testAMHeartbeatFailOnGetAMProxy_AppFailed() throws Exception {
int amHeartBeatTimeoutSecs = 3;
TezConfiguration conf = new TezConfiguration();
@@ -1091,7 +1119,8 @@ public void testAMHeartbeatFailOnGetAMProxy_AppFailed() throws Exception {
assertTrue(client.getAMKeepAliveService().isTerminated());
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testAMHeartbeatFailOnGetAMStatus() throws Exception {
int amHeartBeatTimeoutSecs = 3;
TezConfiguration conf = new TezConfiguration();
@@ -1109,7 +1138,8 @@ public void testAMHeartbeatFailOnGetAMStatus() throws Exception {
}
//See TEZ-3874
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testYarnZkDeprecatedConf() {
Configuration conf = new Configuration(false);
String val = "hostname:2181";
diff --git a/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java b/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java
index 2d18bc5d3e..28de3aaf4f 100644
--- a/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java
+++ b/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java
@@ -18,11 +18,14 @@
*/
package org.apache.tez.client;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.FileNotFoundException;
@@ -32,7 +35,6 @@
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -40,6 +42,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
@@ -78,8 +81,8 @@
import org.apache.tez.dag.api.records.DAGProtos.PlanKeyValuePair;
import org.apache.tez.serviceplugins.api.ServicePluginsDescriptor;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
/**
*
*/
@@ -91,7 +94,8 @@ public class TestTezClientUtils {
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesNotDefined() throws Exception {
TezConfiguration conf = new TezConfiguration(false);
@@ -99,40 +103,41 @@ public void validateSetTezJarLocalResourcesNotDefined() throws Exception {
try {
Map resources = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
- Assert.fail("Expected TezUncheckedException");
+ fail("Expected TezUncheckedException");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Invalid configuration of tez jars"));
+ assertTrue(e.getMessage().contains("Invalid configuration of tez jars"));
}
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedButEmpty() throws Exception {
File emptyDir = new File(TEST_ROOT_DIR, "emptyDir");
emptyDir.deleteOnExit();
- Assert.assertTrue(emptyDir.mkdirs());
+ assertTrue(emptyDir.mkdirs());
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_LIB_URIS, emptyDir.toURI().toURL().toString());
Credentials credentials = new Credentials();
try {
Map resources = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
- Assert.fail("Expected TezUncheckedException");
+ fail("Expected TezUncheckedException");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("No files found in locations"));
+ assertTrue(e.getMessage().contains("No files found in locations"));
}
}
- /**
- *
- */
- @Test(expected=FileNotFoundException.class, timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedNonExistingDirectory() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_LIB_URIS, "file:///foo");
Credentials credentials = new Credentials();
Map resources = new HashMap();
- TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
+ assertThrows(FileNotFoundException.class, () -> {
+ TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
+ });
}
private static List getDirAndFileURL() throws MalformedURLException {
@@ -155,7 +160,8 @@ private static List getDirAndFileURL() throws MalformedURLException {
return urls;
}
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectory() throws Exception {
List cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -169,7 +175,7 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectory() throws Exc
Map localizedMap = new HashMap();
boolean usingArchive = TezClientUtils.setupTezJarsLocalResources(conf, credentials,
localizedMap);
- Assert.assertFalse(usingArchive);
+ assertFalse(usingArchive);
Set resourceNames = localizedMap.keySet();
boolean assertedDir = false;
boolean assertedFile = false;
@@ -198,7 +204,8 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectory() throws Exc
*
* @throws Exception
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnored() throws Exception {
List cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -211,7 +218,7 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnored() thr
conf.setBoolean(TezConfiguration.TEZ_IGNORE_LIB_URIS, true);
Credentials credentials = new Credentials();
Map localizedMap = new HashMap();
- Assert.assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
+ assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
assertTrue(localizedMap.isEmpty());
}
@@ -219,7 +226,8 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnored() thr
*
* @throws Exception
*/
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnoredSetToFalse() throws Exception {
List cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -232,7 +240,7 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnoredSetToF
conf.setBoolean(TezConfiguration.TEZ_IGNORE_LIB_URIS, false);
Credentials credentials = new Credentials();
Map localizedMap = new HashMap();
- Assert.assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
+ assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
assertFalse(localizedMap.isEmpty());
}
@@ -240,7 +248,8 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnoredSetToF
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezDefaultFS() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
StringBuilder tezLibUris = new StringBuilder();
@@ -253,7 +262,7 @@ public void testTezDefaultFS() throws Exception {
Path file = new Path(topDir, "file.jar");
- Assert.assertTrue(localFs.createNewFile(file));
+ assertTrue(localFs.createNewFile(file));
tezLibUris.append(localFs.makeQualified(file).toString());
TezConfiguration conf = new TezConfiguration();
@@ -263,14 +272,15 @@ public void testTezDefaultFS() throws Exception {
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
- Assert.assertTrue(localFs.delete(file, true));
- Assert.assertTrue(localFs.delete(topDir, true));
+ assertTrue(localFs.delete(file, true));
+ assertTrue(localFs.delete(topDir, true));
}
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesMultipleTarballs() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
StringBuilder tezLibUris = new StringBuilder();
@@ -285,8 +295,8 @@ public void validateSetTezJarLocalResourcesMultipleTarballs() throws Exception {
Path tarFile1 = new Path(topDir, "f1.tar.gz");
Path tarFile2 = new Path(topDir, "f2.tar.gz");
- Assert.assertTrue(localFs.createNewFile(tarFile1));
- Assert.assertTrue(localFs.createNewFile(tarFile2));
+ assertTrue(localFs.createNewFile(tarFile1));
+ assertTrue(localFs.createNewFile(tarFile2));
tezLibUris.append(localFs.makeQualified(tarFile1).toString()).append("#tar1").append(",");
tezLibUris.append(localFs.makeQualified(tarFile2).toString()).append("#tar2").append(",");
@@ -296,22 +306,23 @@ public void validateSetTezJarLocalResourcesMultipleTarballs() throws Exception {
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set resourceNames = localizedMap.keySet();
- Assert.assertEquals(2, resourceNames.size());
- Assert.assertTrue(resourceNames.contains("tar1"));
- Assert.assertTrue(resourceNames.contains("tar2"));
- Assert.assertFalse(resourceNames.contains("f1.tar.gz"));
- Assert.assertFalse(resourceNames.contains("f2.tar.gz"));
+ assertEquals(2, resourceNames.size());
+ assertTrue(resourceNames.contains("tar1"));
+ assertTrue(resourceNames.contains("tar2"));
+ assertFalse(resourceNames.contains("f1.tar.gz"));
+ assertFalse(resourceNames.contains("f2.tar.gz"));
- Assert.assertTrue(localFs.delete(tarFile1, true));
- Assert.assertTrue(localFs.delete(tarFile2, true));
- Assert.assertTrue(localFs.delete(topDir, true));
+ assertTrue(localFs.delete(tarFile1, true));
+ assertTrue(localFs.delete(tarFile2, true));
+ assertTrue(localFs.delete(topDir, true));
}
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesMixTarballAndJar() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
StringBuilder tezLibUris = new StringBuilder();
@@ -327,9 +338,9 @@ public void validateSetTezJarLocalResourcesMixTarballAndJar() throws Exception {
Path jarFile2 = new Path(topDir, "f2.jar");
Path jarFile3 = new Path(topDir, "f3.jar");
- Assert.assertTrue(localFs.createNewFile(tarFile1));
- Assert.assertTrue(localFs.createNewFile(jarFile2));
- Assert.assertTrue(localFs.createNewFile(jarFile3));
+ assertTrue(localFs.createNewFile(tarFile1));
+ assertTrue(localFs.createNewFile(jarFile2));
+ assertTrue(localFs.createNewFile(jarFile3));
tezLibUris.append(localFs.makeQualified(topDir).toString()).append(",");
tezLibUris.append(localFs.makeQualified(tarFile1).toString()).append("#tar1").append(",");
@@ -340,19 +351,20 @@ public void validateSetTezJarLocalResourcesMixTarballAndJar() throws Exception {
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set resourceNames = localizedMap.keySet();
- Assert.assertEquals(4, resourceNames.size());
- Assert.assertTrue(resourceNames.contains("tar1"));
- Assert.assertTrue(resourceNames.contains("f1.tar.gz"));
- Assert.assertTrue(resourceNames.contains("f2.jar"));
- Assert.assertTrue(resourceNames.contains("f3.jar"));
-
- Assert.assertTrue(localFs.delete(tarFile1, true));
- Assert.assertTrue(localFs.delete(jarFile2, true));
- Assert.assertTrue(localFs.delete(jarFile3, true));
- Assert.assertTrue(localFs.delete(topDir, true));
+ assertEquals(4, resourceNames.size());
+ assertTrue(resourceNames.contains("tar1"));
+ assertTrue(resourceNames.contains("f1.tar.gz"));
+ assertTrue(resourceNames.contains("f2.jar"));
+ assertTrue(resourceNames.contains("f3.jar"));
+
+ assertTrue(localFs.delete(tarFile1, true));
+ assertTrue(localFs.delete(jarFile2, true));
+ assertTrue(localFs.delete(jarFile3, true));
+ assertTrue(localFs.delete(topDir, true));
}
- @Test(timeout = 2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
// this test checks if the priority field is set properly in the
// ApplicationSubmissionContext
public void testAppSubmissionContextForPriority() throws Exception {
@@ -377,7 +389,8 @@ public void testAppSubmissionContextForPriority() throws Exception {
assertEquals(testpriority, appcontext.getPriority().getPriority());
}
- @Test(timeout=1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
// when tez config property for app priority not set,
// tez should not set app priority and let YARN deal with it.
public void testSetApplicationPriority() {
@@ -389,7 +402,8 @@ public void testSetApplicationPriority() {
assertNull(appContext.getPriority());
}
- @Test(timeout=1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
public void testSetApplicationTags() {
TezConfiguration conf = new TezConfiguration(false);
conf.set(TezConfiguration.TEZ_APPLICATION_TAGS, "foo,bar");
@@ -404,7 +418,8 @@ public void testSetApplicationTags() {
assertTrue(appContext.getApplicationTags().contains("bar"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSessionTokenInAmClc() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
@@ -438,10 +453,11 @@ public void testSessionTokenInAmClc() throws IOException, YarnException {
Token jtSent = new Token();
jtSent.readFields(dibb);
- assertTrue(Arrays.equals(jobToken.getIdentifier(), jtSent.getIdentifier()));
+ assertArrayEquals(jobToken.getIdentifier(), jtSent.getIdentifier());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMLoggingOptsSimple() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
@@ -481,7 +497,8 @@ public void testAMLoggingOptsSimple() throws IOException, YarnException {
assertNull(logEnv);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMLoggingOptsPerLogger() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
@@ -523,7 +540,8 @@ public void testAMLoggingOptsPerLogger() throws IOException, YarnException {
assertEquals("org.apache.hadoop.ipc=DEBUG;org.apache.hadoop.security=DEBUG", logEnv);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMCommandOpts() {
Path tmpDir = new Path(Environment.PWD.$(),
YarnConfiguration.DEFAULT_CONTAINER_TEMP_DIR);
@@ -573,7 +591,8 @@ public void testAMCommandOpts() {
+ TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_ADD_OPENS_DEFAULT, amOptsConstructed);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskCommandOpts() throws TezException {
TezConfiguration tezConf = new TezConfiguration();
String taskCommandOpts = "-Xmx 200m -Dtest.property";
@@ -585,8 +604,8 @@ public void testTaskCommandOpts() throws TezException {
expected =
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT + " " + taskCommandOpts;
assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test2: Setup cluster-default command opts explicitly
String taskClusterDefaultCommandOpts =
@@ -596,8 +615,8 @@ public void testTaskCommandOpts() throws TezException {
taskOptsConstructed = TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
expected = taskClusterDefaultCommandOpts + " " + taskCommandOpts;
assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test3: Don't setup Xmx explicitly
taskCommandOpts = "-Dtest.property";
@@ -606,8 +625,8 @@ public void testTaskCommandOpts() throws TezException {
TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
expected = taskClusterDefaultCommandOpts + " " + taskCommandOpts;
assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test4: Pass in a dag-configured value.
String programmaticTaskOpts = "-Dset.programatically=true -Djava.net.preferIPv4Stack=false";
@@ -616,72 +635,74 @@ public void testTaskCommandOpts() throws TezException {
// Container logging is always added at the end, if it's required.
expected = taskClusterDefaultCommandOpts + " " + taskCommandOpts + " " + programmaticTaskOpts;
assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultMemoryJavaOpts() {
final double factor = 0.8;
String origJavaOpts = "-Xmx";
String javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1000, 1), factor);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1000, 1), factor);
- Assert.assertTrue(javaOpts.contains("-Xmx800m"));
+ assertTrue(javaOpts.contains("-Xmx800m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1, 1), factor);
- Assert.assertTrue(javaOpts.contains("-Xmx1m"));
+ assertTrue(javaOpts.contains("-Xmx1m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(-1, 1), factor);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), factor);
- Assert.assertTrue(javaOpts.contains("-Xmx284m"));
+ assertTrue(javaOpts.contains("-Xmx284m"));
origJavaOpts = " -Xms100m ";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), factor);
- Assert.assertFalse(javaOpts.contains("-Xmx284m"));
- Assert.assertTrue(javaOpts.contains("-Xms100m"));
+ assertFalse(javaOpts.contains("-Xmx284m"));
+ assertTrue(javaOpts.contains("-Xms100m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), 0);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), 100);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1000, 1), -1);
- Assert.assertTrue(javaOpts.contains("-Xmx700m"));
+ assertTrue(javaOpts.contains("-Xmx700m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(5000, 1), -1);
- Assert.assertTrue(javaOpts.contains("-Xmx4000m"));
+ assertTrue(javaOpts.contains("-Xmx4000m"));
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultLoggingJavaOpts() {
String origJavaOpts = null;
String javaOpts = TezClientUtils.maybeAddDefaultLoggingJavaOpts("FOOBAR", origJavaOpts);
- Assert.assertNotNull(javaOpts);
- Assert.assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR")
+ assertNotNull(javaOpts);
+ assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR")
&& javaOpts.contains(TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE)
&&
javaOpts.contains("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator"));
@@ -691,14 +712,15 @@ public void testDefaultLoggingJavaOpts() {
public void testDefaultLoggingJavaOptsWithRootLogger() {
String origJavaOpts = "-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=INFO -DtestProperty=value";
String javaOpts = TezClientUtils.maybeAddDefaultLoggingJavaOpts("FOOBAR", origJavaOpts);
- Assert.assertNotNull(javaOpts);
- Assert.assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR"));
- Assert.assertTrue(javaOpts.contains(TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE)
+ assertNotNull(javaOpts);
+ assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR"));
+ assertTrue(javaOpts.contains(TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE)
&& javaOpts.contains("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator"));
- Assert.assertTrue(javaOpts.contains("-DtestProperty=value"));
+ assertTrue(javaOpts.contains("-DtestProperty=value"));
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfYarnZkWorkaround() {
Configuration conf = new Configuration(false);
String val = "localhost:2181";
@@ -714,13 +736,14 @@ public void testConfYarnZkWorkaround() {
String v = expected.remove(kvPair.getKey());
// this way the test still validates that the original
// key/value pairs can be found in the proto's conf
- assertEquals("Unexpected value for key: " + kvPair.getKey(), v, kvPair.getValue());
+ assertEquals(v, kvPair.getValue(), "Unexpected value for key: " + kvPair.getKey());
}
}
- assertTrue("Expected keys not found in conf: " + expected.keySet(), expected.isEmpty());
+ assertTrue(expected.isEmpty(), "Expected keys not found in conf: " + expected.keySet());
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfSerializationForAm() {
Configuration conf =new Configuration(false);
String val1 = "fixedProperty";
@@ -758,24 +781,24 @@ public static void testLocalResourceVisibility(DistributedFileSystem remoteFs, C
String fsURI = remoteFs.getUri().toString();
topLevelDir = new Path(fsURI, "/testLRVisibility");
- Assert.assertTrue(remoteFs.mkdirs(topLevelDir, publicDirPerms));
+ assertTrue(remoteFs.mkdirs(topLevelDir, publicDirPerms));
Path publicSubDir = new Path(topLevelDir, "public_sub_dir");
- Assert.assertTrue(remoteFs.mkdirs(publicSubDir, publicDirPerms));
+ assertTrue(remoteFs.mkdirs(publicSubDir, publicDirPerms));
Path privateSubDir = new Path(topLevelDir, "private_sub_dir");
- Assert.assertTrue(remoteFs.mkdirs(privateSubDir, privateDirPerms));
+ assertTrue(remoteFs.mkdirs(privateSubDir, privateDirPerms));
Path publicFile = new Path(publicSubDir, "public_file");
- Assert.assertTrue(remoteFs.createNewFile(publicFile));
+ assertTrue(remoteFs.createNewFile(publicFile));
remoteFs.setPermission(publicFile, publicFilePerms);
Path privateFile = new Path(publicSubDir, "private_file");
- Assert.assertTrue(remoteFs.createNewFile(privateFile));
+ assertTrue(remoteFs.createNewFile(privateFile));
remoteFs.setPermission(privateFile, privateFilePerms);
Path publicFileInPrivateSubdir = new Path(privateSubDir, "public_file_in_private_subdir");
- Assert.assertTrue(remoteFs.createNewFile(publicFileInPrivateSubdir));
+ assertTrue(remoteFs.createNewFile(publicFileInPrivateSubdir));
remoteFs.setPermission(publicFileInPrivateSubdir, publicFilePerms);
TezConfiguration tezConf = new TezConfiguration(conf);
@@ -786,35 +809,41 @@ public static void testLocalResourceVisibility(DistributedFileSystem remoteFs, C
Map lrMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(tezConf, new Credentials(), lrMap);
- Assert.assertEquals(publicFile.getName(), LocalResourceVisibility.PUBLIC,
- lrMap.get(publicFile.getName()).getVisibility());
+ assertEquals(
+ LocalResourceVisibility.PUBLIC,
+ lrMap.get(publicFile.getName()).getVisibility(),
+ publicFile.getName());
- Assert.assertEquals(privateFile.getName(), LocalResourceVisibility.PRIVATE,
- lrMap.get(privateFile.getName()).getVisibility());
+ assertEquals(
+ LocalResourceVisibility.PRIVATE,
+ lrMap.get(privateFile.getName()).getVisibility(),
+ privateFile.getName());
- Assert.assertEquals(publicFileInPrivateSubdir.getName(), LocalResourceVisibility.PRIVATE,
- lrMap.get(publicFileInPrivateSubdir.getName()).getVisibility());
+ assertEquals(
+ LocalResourceVisibility.PRIVATE,
+ lrMap.get(publicFileInPrivateSubdir.getName()).getVisibility(),
+ publicFileInPrivateSubdir.getName());
// test tar.gz
tezConf = new TezConfiguration(conf);
Path tarFile = new Path(topLevelDir, "foo.tar.gz");
- Assert.assertTrue(remoteFs.createNewFile(tarFile));
+ assertTrue(remoteFs.createNewFile(tarFile));
//public
remoteFs.setPermission(tarFile, publicFilePerms);
tezConf.set(TezConfiguration.TEZ_LIB_URIS, tarFile.toString());
lrMap.clear();
- Assert.assertTrue(
+ assertTrue(
TezClientUtils.setupTezJarsLocalResources(tezConf, new Credentials(), lrMap));
- Assert.assertEquals(LocalResourceVisibility.PUBLIC,
+ assertEquals(LocalResourceVisibility.PUBLIC,
lrMap.get(TezConstants.TEZ_TAR_LR_NAME).getVisibility());
//private
remoteFs.setPermission(tarFile, privateFilePerms);
lrMap.clear();
TezClientUtils.setupTezJarsLocalResources(tezConf, new Credentials(), lrMap);
- Assert.assertEquals(LocalResourceVisibility.PRIVATE,
+ assertEquals(LocalResourceVisibility.PRIVATE,
lrMap.get(TezConstants.TEZ_TAR_LR_NAME).getVisibility());
} finally {
@@ -824,7 +853,8 @@ public static void testLocalResourceVisibility(DistributedFileSystem remoteFs, C
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfigurationAllowAll() {
Configuration srcConf = new Configuration(false);
@@ -855,7 +885,8 @@ private Path createFile(FileSystem fs, Path dir, String fileName) throws IOExcep
return fs.makeQualified(f1);
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezAuxLocalResourcesWithFilesAndFolders() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
List resources = new ArrayList();
@@ -889,12 +920,13 @@ public void validateSetTezAuxLocalResourcesWithFilesAndFolders() throws Exceptio
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set resourceNames = localizedMap.keySet();
- Assert.assertEquals(2, resourceNames.size());
- Assert.assertTrue(resourceNames.contains("f1.txt"));
- Assert.assertTrue(resourceNames.contains("dir2-f.txt"));
+ assertEquals(2, resourceNames.size());
+ assertTrue(resourceNames.contains("f1.txt"));
+ assertTrue(resourceNames.contains("dir2-f.txt"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testServiceDescriptorSerializationForAM() {
Configuration conf = new Configuration(false);
ServicePluginsDescriptor servicePluginsDescriptor = ServicePluginsDescriptor.create(true);
@@ -906,33 +938,35 @@ public void testServiceDescriptorSerializationForAM() {
assertTrue(confProto.getAmPluginDescriptor().getUberEnabled());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskLaunchCmdOptsSetup() throws TezException {
Configuration conf = new Configuration(false);
String vOpts = "";
String opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
+ assertEquals(opts,
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT + " "
+ TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS_DEFAULT + " " + vOpts);
vOpts = "foo";
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
+ assertEquals(opts,
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT + " " + vOpts);
String taskOpts = "taskOpts";
conf.set(TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS, taskOpts);
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
+ assertEquals(opts,
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT
+ " " + taskOpts + " " + vOpts);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testClusterTaskLaunchCmdOptsSetup() throws TezException {
Configuration conf = new Configuration(false);
String adminOpts = "adminOpts";
@@ -941,20 +975,20 @@ public void testClusterTaskLaunchCmdOptsSetup() throws TezException {
String vOpts = "";
String opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
- adminOpts + " "
- + TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS_DEFAULT + " " + vOpts);
+ assertEquals(adminOpts + " "
+ + TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS_DEFAULT + " " + vOpts,
+ opts);
vOpts = "foo";
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts, adminOpts + " " + vOpts);
+ assertEquals(adminOpts + " " + vOpts, opts);
String taskOpts = "taskOpts";
conf.set(TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS, taskOpts);
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts, adminOpts + " " + taskOpts + " " + vOpts);
+ assertEquals(adminOpts + " " + taskOpts + " " + vOpts, opts);
}
@@ -981,6 +1015,6 @@ public void testSessionCredentialsMergedBeforeAmConfigCredentials() throws Excep
// if there is another token in am conf creds of the same token type,
// session token should be applied while creating ContainerLaunchContext
- Assert.assertEquals(sessionToken, amLaunchCredentials.getToken(tokenType));
+ assertEquals(sessionToken, amLaunchCredentials.getToken(tokenType));
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/client/registry/TestAMRecord.java b/tez-api/src/test/java/org/apache/tez/client/registry/TestAMRecord.java
index fc9c05dd7d..895f3f70c9 100644
--- a/tez-api/src/test/java/org/apache/tez/client/registry/TestAMRecord.java
+++ b/tez-api/src/test/java/org/apache/tez/client/registry/TestAMRecord.java
@@ -18,7 +18,11 @@
*/
package org.apache.tez.client.registry;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.ConcurrentHashMap;
@@ -26,7 +30,8 @@
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.tez.client.registry.zookeeper.ZkConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
public class TestAMRecord {
@@ -228,12 +233,12 @@ public void testToString() {
assertNotNull(str);
// Validate actual JSON-like snippets from the string
- assertTrue("Should contain appId=value snippet", str.contains("appId=" + appId.toString()));
- assertTrue("Should contain hostName=value snippet", str.contains("hostName=" + hostName));
- assertTrue("Should contain hostIp=value snippet", str.contains("hostIp=" + hostIp));
- assertTrue("Should contain port=value snippet", str.contains("port=" + port));
- assertTrue("Should contain externalId=value snippet", str.contains("externalId=" + externalId));
- assertTrue("Should contain computeName=value snippet", str.contains("computeName=" + computeName));
+ assertTrue(str.contains("appId=" + appId.toString()), "Should contain appId=value snippet");
+ assertTrue(str.contains("hostName=" + hostName), "Should contain hostName=value snippet");
+ assertTrue(str.contains("hostIp=" + hostIp), "Should contain hostIp=value snippet");
+ assertTrue(str.contains("port=" + port), "Should contain port=value snippet");
+ assertTrue(str.contains("externalId=" + externalId), "Should contain externalId=value snippet");
+ assertTrue(str.contains("computeName=" + computeName), "Should contain computeName=value snippet");
}
@Test
diff --git a/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkConfig.java b/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkConfig.java
index 9f943feba0..5c903c8333 100644
--- a/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkConfig.java
+++ b/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkConfig.java
@@ -18,8 +18,9 @@
*/
package org.apache.tez.client.registry.zookeeper;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.concurrent.TimeUnit;
@@ -28,7 +29,8 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.TezConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
public class TestZkConfig {
@@ -189,34 +191,36 @@ public void testCreateCuratorFramework() {
assertEquals(zkConfig.getZkQuorum(), curator.getZookeeperClient().getCurrentConnectionString());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullZkQuorum() {
TezConfiguration conf = new TezConfiguration();
// Don't set zkQuorum
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> new ZkConfig(conf));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testEmptyZkQuorum() {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "");
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> new ZkConfig(conf));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullNamespace() {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "localhost:2181");
- conf.set(TezConfiguration.TEZ_AM_REGISTRY_NAMESPACE, null);
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> {
+ conf.set(TezConfiguration.TEZ_AM_REGISTRY_NAMESPACE, null);
+ new ZkConfig(conf);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testEmptyNamespace() {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "localhost:2181");
conf.set(TezConfiguration.TEZ_AM_REGISTRY_NAMESPACE, "");
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> new ZkConfig(conf));
}
@Test
diff --git a/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkFrameworkClient.java b/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkFrameworkClient.java
index 70cc75c669..e96cbd4416 100644
--- a/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkFrameworkClient.java
+++ b/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkFrameworkClient.java
@@ -18,7 +18,10 @@
*/
package org.apache.tez.client.registry.zookeeper;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -37,9 +40,10 @@
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.zookeeper.CreateMode;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,22 +59,26 @@ public class TestZkFrameworkClient {
private static final File TEST_DIR = new File(System.getProperty("test.build.data", "target"),
TestZkFrameworkClient.class.getName()).getAbsoluteFile();
- private TestingServer zkServer;
+ private static TestingServer zkServer;
private ZkFrameworkClient zkFrameworkClient;
private CuratorFramework curatorClient;
- @Before
- public void setup() throws Exception {
+ @BeforeAll
+ public static void setup() throws Exception {
zkServer = new TestingServer(true);
LOG.info("Started ZooKeeper test server on port: {}", zkServer.getPort());
}
- @After
- public void teardown() throws Exception {
+ @AfterEach
+ public void teardownEach() throws Exception {
if (zkFrameworkClient != null) {
zkFrameworkClient.close();
}
IOUtils.closeQuietly(curatorClient);
+ }
+
+ @AfterAll
+ public static void teardown() throws Exception {
IOUtils.closeQuietly(zkServer);
}
@@ -84,13 +92,13 @@ public void testInitAndLifecycle() throws Exception {
zkFrameworkClient = new ZkFrameworkClient();
zkFrameworkClient.init(tezConf);
- assertFalse("Client should not be running after init", zkFrameworkClient.isRunning());
+ assertFalse(zkFrameworkClient.isRunning(), "Client should not be running after init");
zkFrameworkClient.start();
- assertTrue("Client should be running after start", zkFrameworkClient.isRunning());
+ assertTrue(zkFrameworkClient.isRunning(), "Client should be running after start");
zkFrameworkClient.stop();
- assertFalse("Client should not be running after stop", zkFrameworkClient.isRunning());
+ assertFalse(zkFrameworkClient.isRunning(), "Client should not be running after stop");
}
/**
@@ -114,12 +122,12 @@ public void testGetApplicationReportWithRegisteredAM() throws Exception {
ApplicationReport report = zkFrameworkClient.getApplicationReport(appId);
- assertNotNull("Application report should not be null", report);
- assertEquals("Application ID should match", appId, report.getApplicationId());
- assertEquals("Host should match", testHostName, report.getHost());
- assertEquals("Port should match", testPort, report.getRpcPort());
- assertEquals("AM host should be cached", testHostName, zkFrameworkClient.getAmHost());
- assertEquals("AM port should be cached", testPort, zkFrameworkClient.getAmPort());
+ assertNotNull(report, "Application report should not be null");
+ assertEquals(appId, report.getApplicationId(), "Application ID should match");
+ assertEquals(testHostName, report.getHost(), "Host should match");
+ assertEquals(testPort, report.getRpcPort(), "Port should match");
+ assertEquals(testHostName, zkFrameworkClient.getAmHost(), "AM host should be cached");
+ assertEquals(testPort, zkFrameworkClient.getAmPort(), "AM port should be cached");
}
/**
@@ -139,12 +147,10 @@ public void testGetApplicationReportWithMissingAM() throws Exception {
ApplicationReport report = zkFrameworkClient.getApplicationReport(appId);
- assertNotNull("Application report should not be null", report);
- assertEquals("Application ID should match", appId, report.getApplicationId());
- assertEquals("Final status should be FAILED", FinalApplicationStatus.FAILED,
- report.getFinalApplicationStatus());
- assertTrue("Diagnostics should mention missing AM",
- report.getDiagnostics().contains("AM record not found"));
+ assertNotNull(report, "Application report should not be null");
+ assertEquals(appId, report.getApplicationId(), "Application ID should match");
+ assertEquals(FinalApplicationStatus.FAILED, report.getFinalApplicationStatus(), "Final status should be FAILED");
+ assertTrue(report.getDiagnostics().contains("AM record not found"), "Diagnostics should mention missing AM");
}
/**
@@ -169,12 +175,20 @@ public void testCreateApplication() throws Exception {
YarnClientApplication clientApp = zkFrameworkClient.createApplication();
- assertNotNull("YarnClientApplication should not be null", clientApp);
- assertNotNull("ApplicationSubmissionContext should not be null", clientApp.getApplicationSubmissionContext());
- assertEquals("Application ID should match", appId, clientApp.getApplicationSubmissionContext().getApplicationId());
- assertNotNull("GetNewApplicationResponse should not be null", clientApp.getNewApplicationResponse());
- assertEquals("Response application ID should match",
- appId, clientApp.getNewApplicationResponse().getApplicationId());
+ assertNotNull(clientApp, "YarnClientApplication should not be null");
+ assertNotNull(
+ clientApp.getApplicationSubmissionContext(),
+ "ApplicationSubmissionContext should not be null");
+ assertEquals(
+ appId,
+ clientApp.getApplicationSubmissionContext().getApplicationId(),
+ "Application ID should match");
+ assertNotNull(
+ clientApp.getNewApplicationResponse(), "GetNewApplicationResponse should not be null");
+ assertEquals(
+ appId,
+ clientApp.getNewApplicationResponse().getApplicationId(),
+ "Response application ID should match");
}
/**
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestJavaOptsChecker.java b/tez-api/src/test/java/org/apache/tez/common/TestJavaOptsChecker.java
index 1fc510662a..bc162f1475 100644
--- a/tez-api/src/test/java/org/apache/tez/common/TestJavaOptsChecker.java
+++ b/tez-api/src/test/java/org/apache/tez/common/TestJavaOptsChecker.java
@@ -18,64 +18,69 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.util.concurrent.TimeUnit;
+
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestJavaOptsChecker {
private final JavaOptsChecker javaOptsChecker = new JavaOptsChecker();
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicChecker() throws TezException {
javaOptsChecker.checkOpts(TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS_DEFAULT);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleGC() {
// Clashing GC values
String opts = "-XX:+UseSerialGC -XX:+UseG1GC -XX:+UseParallelGC ";
try {
javaOptsChecker.checkOpts(opts);
- Assert.fail("Expected check to fail with opts=" + opts);
+ fail("Expected check to fail with opts=" + opts);
} catch (TezException e) {
- Assert.assertTrue(e.getMessage(),
- e.getMessage().contains("Invalid/conflicting GC options found"));
+ assertTrue(e.getMessage().contains("Invalid/conflicting GC options found"),
+ e.getMessage());
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPositiveNegativeOpts() throws TezException {
// Multiple positive GC values
String opts = "-XX:+UseSerialGC -XX:+UseG1GC -XX:+UseParallelGC -XX:-UseG1GC ";
try {
javaOptsChecker.checkOpts(opts);
- Assert.fail("Expected check to fail with opts=" + opts);
+ fail("Expected check to fail with opts=" + opts);
} catch (TezException e) {
- Assert.assertTrue(e.getMessage(),
- e.getMessage().contains("Invalid/conflicting GC options found"));
+ assertTrue(e.getMessage().contains("Invalid/conflicting GC options found"), e.getMessage());
}
// Positive following a negative is still a positive
opts = " -XX:-UseG1GC -XX:+UseParallelGC -XX:-UseG1GC -XX:+UseG1GC";
try {
javaOptsChecker.checkOpts(opts);
- Assert.fail("Expected check to fail with opts=" + opts);
+ fail("Expected check to fail with opts=" + opts);
} catch (TezException e) {
- Assert.assertTrue(e.getMessage(),
- e.getMessage().contains("Invalid/conflicting GC options found"));
+ assertTrue(e.getMessage().contains("Invalid/conflicting GC options found"), e.getMessage());
}
// Order of positive and negative matters
opts = " -XX:+UseG1GC -XX:-UseG1GC -XX:+UseParallelGC -XX:-UseG1GC -XX:+UseG1GC";
try {
javaOptsChecker.checkOpts(opts);
- Assert.fail("Expected check to fail with opts=" + opts);
+ fail("Expected check to fail with opts=" + opts);
} catch (TezException e) {
- Assert.assertTrue(e.getMessage(),
- e.getMessage().contains("Invalid/conflicting GC options found"));
+ assertTrue(e.getMessage().contains("Invalid/conflicting GC options found"), e.getMessage());
}
// Sanity check for good condition
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestRPCUtil.java b/tez-api/src/test/java/org/apache/tez/common/TestRPCUtil.java
index b8facb5d1d..c1a737ceb9 100644
--- a/tez-api/src/test/java/org/apache/tez/common/TestRPCUtil.java
+++ b/tez-api/src/test/java/org/apache/tez/common/TestRPCUtil.java
@@ -18,8 +18,11 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.ipc.RemoteException;
import org.apache.tez.dag.api.SessionNotRunning;
@@ -27,12 +30,13 @@
import com.google.protobuf.ServiceException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestRPCUtil {
- @Test (timeout=1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
public void testUnknownExceptionUnwrapping() {
Class extends Throwable> exception = TezException.class;
String className = "UnknownException.class";
@@ -97,8 +101,8 @@ public void testRPCServiceExceptionUnwrapping() {
t = thrown;
}
- Assert.assertTrue(IOException.class.isInstance(t));
- Assert.assertTrue(t.getMessage().contains(message));
+ assertTrue(IOException.class.isInstance(t));
+ assertTrue(t.getMessage().contains(message));
}
@Test
@@ -113,8 +117,8 @@ public void testRPCIOExceptionUnwrapping() {
} catch (Throwable thrown) {
t = thrown;
}
- Assert.assertTrue(FileNotFoundException.class.isInstance(t));
- Assert.assertTrue(t.getMessage().contains(message));
+ assertTrue(FileNotFoundException.class.isInstance(t));
+ assertTrue(t.getMessage().contains(message));
}
@Test
@@ -130,8 +134,8 @@ public void testRPCRuntimeExceptionUnwrapping() {
t = thrown;
}
- Assert.assertTrue(NullPointerException.class.isInstance(t));
- Assert.assertTrue(t.getMessage().contains(message));
+ assertTrue(NullPointerException.class.isInstance(t));
+ assertTrue(t.getMessage().contains(message));
}
private void verifyRemoteExceptionUnwrapping(
@@ -158,15 +162,16 @@ private void verifyRemoteExceptionUnwrapping(
t = thrown;
}
- Assert.assertTrue("Expected exception [" + expectedLocalException
- + "] but found " + t, expectedLocalException.isInstance(t));
- Assert.assertTrue(
- "Expected message [" + message + "] but found " + t.getMessage(), t
- .getMessage().contains(message));
+ assertTrue(
+ expectedLocalException.isInstance(t),
+ "Expected exception [" + expectedLocalException + "] but found " + t);
+ assertTrue(
+ t.getMessage().contains(message),
+ "Expected message [" + message + "] but found " + t.getMessage());
}
-
- @Test (timeout=1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
public void testRemoteNonIOExceptionUnwrapping() {
Class extends Throwable> exception = TezException.class;
verifyRemoteExceptionUnwrapping(exception, IOException.class.getName(), false);
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestReflectionUtils.java b/tez-api/src/test/java/org/apache/tez/common/TestReflectionUtils.java
index f7696175cd..602cc1d75a 100644
--- a/tez-api/src/test/java/org/apache/tez/common/TestReflectionUtils.java
+++ b/tez-api/src/test/java/org/apache/tez/common/TestReflectionUtils.java
@@ -18,15 +18,16 @@
*/
package org.apache.tez.common;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+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;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Collections;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -34,7 +35,8 @@
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.api.TezReflectionException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestReflectionUtils {
@@ -47,18 +49,20 @@ public ParameterizedConstructorClass(String first, int second) {
}
}
- @Test(timeout = 5000)
- public void testConstructorWithParameters() throws TezReflectionException
- {
- Class>[] parameterTypes = new Class[] { String.class, Integer.TYPE };
- Object[] parameters = new Object[] { new String("test"), 1 };
- ParameterizedConstructorClass instance = ReflectionUtils.createClazzInstance(
- ParameterizedConstructorClass.class.getName(), parameterTypes, parameters);
- assertEquals("Class not constructed with first parameter correctly", instance.first, "test");
- assertEquals("Class not constructed with second parameter correctly", instance.second, 1);
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testConstructorWithParameters() throws TezReflectionException {
+ Class>[] parameterTypes = new Class[] {String.class, Integer.TYPE};
+ Object[] parameters = new Object[] {new String("test"), 1};
+ ParameterizedConstructorClass instance =
+ ReflectionUtils.createClazzInstance(
+ ParameterizedConstructorClass.class.getName(), parameterTypes, parameters);
+ assertEquals(instance.first, "test", "Class not constructed with first parameter correctly");
+ assertEquals(instance.second, 1, "Class not constructed with second parameter correctly");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAddResourceToClasspath() throws IOException, TezException {
TezClassLoader.setupTezClassLoader();
String rsrcName = "dummyfile.xml";
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestTezCommonUtils.java b/tez-api/src/test/java/org/apache/tez/common/TestTezCommonUtils.java
index 30c3ed6759..ef7f7049d6 100644
--- a/tez-api/src/test/java/org/apache/tez/common/TestTezCommonUtils.java
+++ b/tez-api/src/test/java/org/apache/tez/common/TestTezCommonUtils.java
@@ -18,9 +18,17 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.File;
import java.io.IOException;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -38,10 +46,10 @@
import com.google.common.collect.Maps;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+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.LoggerFactory;
@@ -58,7 +66,7 @@ public class TestTezCommonUtils {
private static FileSystem remoteFs = null;
private static final Logger LOG = LoggerFactory.getLogger(TestTezCommonUtils.class);
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
conf.set(TezConfiguration.TEZ_AM_STAGING_DIR, STAGE_DIR);
LOG.info("Starting mini clusters");
@@ -74,7 +82,7 @@ public static void setup() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (dfsCluster != null) {
try {
@@ -87,23 +95,25 @@ public static void afterClass() throws InterruptedException {
}
// Testing base staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezBaseStagingPath() throws Exception {
Configuration localConf = new Configuration();
// Check if default works with localFS
localConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, LOCAL_STAGING_DIR.getAbsolutePath());
localConf.set("fs.defaultFS", "file:///");
Path stageDir = TezCommonUtils.getTezBaseStagingPath(localConf);
- Assert.assertEquals("file:" + LOCAL_STAGING_DIR, stageDir.toString());
+ assertEquals("file:" + LOCAL_STAGING_DIR, stageDir.toString());
// check if user set something, indeed works
conf.set(TezConfiguration.TEZ_AM_STAGING_DIR, STAGE_DIR);
stageDir = TezCommonUtils.getTezBaseStagingPath(conf);
- Assert.assertEquals(stageDir.toString(), RESOLVED_STAGE_DIR);
+ assertEquals(stageDir.toString(), RESOLVED_STAGE_DIR);
}
// Testing System staging dir if createed
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCreateTezSysStagingPath() throws Exception {
String strAppId = "testAppId";
String expectedStageDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
@@ -116,24 +126,26 @@ public void testCreateTezSysStagingPath() throws Exception {
if (fs.exists(stagePath)) {
fs.delete(stagePath, true);
}
- Assert.assertFalse(fs.exists(stagePath));
+ assertFalse(fs.exists(stagePath));
Path stageDir = TezCommonUtils.createTezSystemStagingPath(conf, strAppId);
- Assert.assertEquals(stageDir.toString(), expectedStageDir);
- Assert.assertTrue(fs.exists(stagePath));
+ assertEquals(stageDir.toString(), expectedStageDir);
+ assertTrue(fs.exists(stagePath));
}
// Testing System staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezSysStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
String expectedStageDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId;
- Assert.assertEquals(stageDir.toString(), expectedStageDir);
+ assertEquals(stageDir.toString(), expectedStageDir);
}
// Testing conf staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezConfStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -141,11 +153,12 @@ public void testTezConfStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.TEZ_PB_BINARY_CONF_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing session jars staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezSessionJarStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -153,11 +166,12 @@ public void testTezSessionJarStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing bin plan staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezBinPlanStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -165,11 +179,12 @@ public void testTezBinPlanStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.TEZ_PB_PLAN_BINARY_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing text plan staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezTextPlanStagingPath() throws Exception {
String strAppId = "testAppId";
String dagPBName = "testDagPBName";
@@ -179,11 +194,12 @@ public void testTezTextPlanStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ strAppId + "-" + dagPBName + "-" + TezConstants.TEZ_PB_PLAN_TEXT_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -191,11 +207,12 @@ public void testTezRecoveryStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing app attempt specific recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezAttemptRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -205,11 +222,12 @@ public void testTezAttemptRecoveryStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME + Path.SEPARATOR + "2";
- Assert.assertEquals(recoveryStageDir.toString(), expectedDir);
+ assertEquals(recoveryStageDir.toString(), expectedDir);
}
// Testing DAG specific recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezDAGRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -222,11 +240,12 @@ public void testTezDAGRecoveryStagingPath() throws Exception {
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME + Path.SEPARATOR + "2" + Path.SEPARATOR
+ "dag_123" + TezConstants.DAG_RECOVERY_RECOVER_FILE_SUFFIX;
- Assert.assertEquals(expectedDir, dagRecoveryPathj.toString());
+ assertEquals(expectedDir, dagRecoveryPathj.toString());
}
// Testing Summary recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezSummaryRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -238,26 +257,29 @@ public void testTezSummaryRecoveryStagingPath() throws Exception {
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME + Path.SEPARATOR + "2" + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_SUMMARY_FILE_SUFFIX;
- Assert.assertEquals(expectedDir, summaryRecoveryPathj.toString());
+ assertEquals(expectedDir, summaryRecoveryPathj.toString());
}
// This test is running here to leverage existing mini cluster
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLocalResourceVisibility() throws Exception {
TestTezClientUtils.testLocalResourceVisibility(dfsCluster.getFileSystem(), conf);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testStringTokenize() {
String s = "foo:bar:xyz::too";
String[] expectedTokens = { "foo", "bar" , "xyz" , "too"};
String[] tokens = new String[4];
TezCommonUtils.tokenizeString(s, ":").toArray(tokens);
- Assert.assertArrayEquals(expectedTokens, tokens);
+ assertArrayEquals(expectedTokens, tokens);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAddAdditionalLocalResources() {
String lrName = "LR";
Map originalLrs;
@@ -289,9 +311,9 @@ public void testAddAdditionalLocalResources() {
LocalResourceType.FILE, LocalResourceVisibility.PUBLIC, 100, 1));
try {
TezCommonUtils.addAdditionalLocalResources(additionalLrs, originalLrs, "");
- Assert.fail("Duplicate LRs with different sizes expected to fail");
+ fail("Duplicate LRs with different sizes expected to fail");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
// Different path, same size, diff timestamp
@@ -314,56 +336,57 @@ public void testAddAdditionalLocalResources() {
LocalResourceType.FILE, LocalResourceVisibility.PUBLIC, 100, 1));
try {
TezCommonUtils.addAdditionalLocalResources(additionalLrs, originalLrs, "");
- Assert.fail("Duplicate LRs with different sizes expected to fail");
+ fail("Duplicate LRs with different sizes expected to fail");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMClientHeartBeatTimeout() {
TezConfiguration conf = new TezConfiguration(false);
// -1 for any negative value
- Assert.assertEquals(-1,
+ assertEquals(-1,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS, -2);
- Assert.assertEquals(-1,
+ assertEquals(-1,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
// For any value > 0 but less than min, revert to min
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS,
TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM - 1);
- Assert.assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 1000,
+ assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 1000,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
// For val > min, should remain val as configured
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS,
TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 2);
- Assert.assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 2000,
+ assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 2000,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
conf = new TezConfiguration(false);
- Assert.assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -1, 10));
- Assert.assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -123, 10));
- Assert.assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 0, 10));
+ assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -1, 10));
+ assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -123, 10));
+ assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 0, 10));
// min poll interval is 1000
- Assert.assertEquals(1000, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 600, 10));
+ assertEquals(1000, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 600, 10));
// Poll interval is heartbeat interval/10
- Assert.assertEquals(2000,
+ assertEquals(2000,
TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 20000, 10));
// Configured poll interval ignored
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_POLL_INTERVAL_MILLIS, -1);
- Assert.assertEquals(4000,
+ assertEquals(4000,
TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 20000, 5));
// Positive poll interval is allowed
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_POLL_INTERVAL_MILLIS, 2000);
- Assert.assertEquals(2000,
+ assertEquals(2000,
TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 20000, 5));
@@ -376,7 +399,7 @@ public void testLogSystemProperties() throws Exception {
conf.set(TezConfiguration.TEZ_JVM_SYSTEM_PROPERTIES_TO_LOG, " ");
String value = TezCommonUtils.getSystemPropertiesToLog(conf);
for(String key: TezConfiguration.TEZ_JVM_SYSTEM_PROPERTIES_TO_LOG_DEFAULT) {
- Assert.assertTrue(value.contains(key));
+ assertTrue(value.contains(key));
}
// test logging of selected keys
@@ -385,32 +408,33 @@ public void testLogSystemProperties() throws Exception {
String version = "java.version";
conf.set(TezConfiguration.TEZ_JVM_SYSTEM_PROPERTIES_TO_LOG, classpath + ", " + os);
value = TezCommonUtils.getSystemPropertiesToLog(conf);
- Assert.assertNotNull(value);
- Assert.assertTrue(value.contains(classpath));
- Assert.assertTrue(value.contains(os));
- Assert.assertFalse(value.contains(version));
+ assertNotNull(value);
+ assertTrue(value.contains(classpath));
+ assertTrue(value.contains(os));
+ assertFalse(value.contains(version));
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetDAGSessionTimeout() {
Configuration conf = new Configuration(false);
- Assert.assertEquals(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS_DEFAULT*1000,
+ assertEquals(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS_DEFAULT*1000,
TezCommonUtils.getDAGSessionTimeout(conf));
// set to 1 month - * 1000 guaranteed to cross positive integer boundary
conf.setInt(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS,
24 * 60 * 60 * 30);
- Assert.assertEquals(86400l*1000*30,
+ assertEquals(86400l*1000*30,
TezCommonUtils.getDAGSessionTimeout(conf));
// set to negative val
conf.setInt(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS,
-24 * 60 * 60 * 30);
- Assert.assertEquals(-1,
+ assertEquals(-1,
TezCommonUtils.getDAGSessionTimeout(conf));
conf.setInt(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS, 0);
- Assert.assertEquals(1000,
+ assertEquals(1000,
TezCommonUtils.getDAGSessionTimeout(conf));
}
@@ -426,7 +450,7 @@ public void testMkDirForAM() throws IOException {
FileSystem remoteFileSystem = miniDFS.getFileSystem();
Path path = new Path(TEST_ROOT_DIR + "/testMkDirForAM");
TezCommonUtils.mkDirForAM(remoteFileSystem, path);
- Assert.assertEquals(TezCommonUtils.TEZ_AM_DIR_PERMISSION, remoteFileSystem.getFileStatus(path).getPermission());
+ assertEquals(TezCommonUtils.TEZ_AM_DIR_PERMISSION, remoteFileSystem.getFileStatus(path).getPermission());
miniDFS.shutdown();
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestTezYARNUtils.java b/tez-api/src/test/java/org/apache/tez/common/TestTezYARNUtils.java
index 84d9d47b16..384b6c7171 100644
--- a/tez-api/src/test/java/org/apache/tez/common/TestTezYARNUtils.java
+++ b/tez-api/src/test/java/org/apache/tez/common/TestTezYARNUtils.java
@@ -19,12 +19,15 @@
package org.apache.tez.common;
import static org.apache.tez.common.TezYARNUtils.appendToEnvFromInputString;
-import static org.junit.Assert.assertEquals;
+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 java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.Shell;
@@ -32,97 +35,114 @@
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezConstants;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestTezYARNUtils {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAuxClasspath() {
Configuration conf = new Configuration(false);
conf.set(TezConfiguration.TEZ_CLUSTER_ADDITIONAL_CLASSPATH_PREFIX, "foobar");
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains("foobar"));
- Assert.assertTrue(classpath.indexOf("foobar") <
+ assertTrue(classpath.contains("foobar"));
+ assertTrue(classpath.indexOf("foobar") <
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
- Assert.assertTrue(classpath.indexOf("foobar") <
+ assertTrue(classpath.indexOf("foobar") <
classpath.indexOf(Environment.PWD.$()));
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testUserClasspathFirstFalse() {
Configuration conf = new Configuration(false);
conf.setBoolean(TezConfiguration.TEZ_USER_CLASSPATH_FIRST, false);
conf.set(TezConfiguration.TEZ_CLUSTER_ADDITIONAL_CLASSPATH_PREFIX, "foobar");
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains("foobar"));
- Assert.assertTrue(classpath.indexOf("foobar") >
+ assertTrue(classpath.contains("foobar"));
+ assertTrue(classpath.indexOf("foobar") >
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
- Assert.assertTrue(classpath.indexOf("foobar") >
+ assertTrue(classpath.indexOf("foobar") >
classpath.indexOf(Environment.PWD.$()));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicArchiveClasspath() {
Configuration conf = new Configuration(false);
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains(Environment.PWD.$()));
- Assert.assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ assertTrue(classpath.contains(Environment.PWD.$()));
+ assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ "lib" + File.separator + "*"));
- Assert.assertTrue(!classpath.contains(Environment.HADOOP_CONF_DIR.$()));
- Assert.assertTrue(classpath.indexOf(Environment.PWD.$()) <
+ assertFalse(classpath.contains(Environment.HADOOP_CONF_DIR.$()));
+ assertTrue(classpath.indexOf(Environment.PWD.$()) <
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNoHadoopConfInClasspath() {
Configuration conf = new Configuration(false);
conf.setBoolean(TezConfiguration.TEZ_CLASSPATH_ADD_HADOOP_CONF, true);
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains(Environment.PWD.$()));
- Assert.assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ assertTrue(classpath.contains(Environment.PWD.$()));
+ assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ "lib" + File.separator + "*"));
- Assert.assertTrue(classpath.contains(Environment.HADOOP_CONF_DIR.$()));
- Assert.assertTrue(classpath.indexOf(Environment.PWD.$()) <
+ assertTrue(classpath.contains(Environment.HADOOP_CONF_DIR.$()));
+ assertTrue(classpath.indexOf(Environment.PWD.$()) <
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
- Assert.assertTrue(classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME) <
+ assertTrue(classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME) <
classpath.indexOf(Environment.HADOOP_CONF_DIR.$()));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetupDefaultEnvironment() {
Configuration conf = new Configuration(false);
conf.set(TezConfiguration.TEZ_AM_LAUNCH_ENV, "LD_LIBRARY_PATH=USER_PATH,USER_KEY=USER_VALUE");
- conf.set(TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV, "LD_LIBRARY_PATH=DEFAULT_PATH,DEFAULT_KEY=DEFAULT_VALUE");
+ conf.set(
+ TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV,
+ "LD_LIBRARY_PATH=DEFAULT_PATH,DEFAULT_KEY=DEFAULT_VALUE");
Map environment = new TreeMap();
- TezYARNUtils.setupDefaultEnv(environment, conf,
+ TezYARNUtils.setupDefaultEnv(
+ environment,
+ conf,
TezConfiguration.TEZ_AM_LAUNCH_ENV,
TezConfiguration.TEZ_AM_LAUNCH_ENV_DEFAULT,
TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV,
- TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV_DEFAULT, false);
+ TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV_DEFAULT,
+ false);
String value1 = environment.get("USER_KEY");
- Assert.assertEquals("User env should merge with default env", "USER_VALUE", value1);
+ assertEquals("USER_VALUE", value1, "User env should merge with default env");
String value2 = environment.get("DEFAULT_KEY");
- Assert.assertEquals("User env should merge with default env", "DEFAULT_VALUE", value2);
+ assertEquals("DEFAULT_VALUE", value2, "User env should merge with default env");
String value3 = environment.get("LD_LIBRARY_PATH");
- Assert.assertEquals("User env should append default env",
- Environment.PWD.$() + File.pathSeparator + "USER_PATH" + File.pathSeparator + "DEFAULT_PATH", value3);
- }
+ assertEquals(
+ Environment.PWD.$()
+ + File.pathSeparator
+ + "USER_PATH"
+ + File.pathSeparator
+ + "DEFAULT_PATH",
+ value3,
+ "User env should append default env");
+ }
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezLibUrisClasspath() {
Configuration conf = new Configuration(false);
conf.set(TezConfiguration.TEZ_LIB_URIS_CLASSPATH, "foobar");
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains("foobar"));
- Assert.assertTrue(classpath.contains(Environment.PWD.$()));
- Assert.assertTrue(classpath.indexOf("foobar") >
+ assertTrue(classpath.contains("foobar"));
+ assertTrue(classpath.contains(Environment.PWD.$()));
+ assertTrue(classpath.indexOf("foobar") >
classpath.indexOf(Environment.PWD.$()));
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java b/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java
index 7050d3aff3..4b0a29120e 100644
--- a/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java
+++ b/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java
@@ -18,8 +18,12 @@
*/
package org.apache.tez.common;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestVersionInfo {
@@ -28,34 +32,38 @@ public class TestVersionInfo {
private static final String BUILD_TIME = "20141024-1052";
private static final String SCM_URL = "scm:git:https://gitbox.apache.org/repos/asf/tez.git";
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTest1File() {
VersionInfo versionInfo = new VersionInfo("test1");
- Assert.assertEquals(VERSION, versionInfo.getVersion());
- Assert.assertEquals(REVISION, versionInfo.getRevision());
- Assert.assertEquals(BUILD_TIME, versionInfo.getBuildTime());
- Assert.assertEquals(SCM_URL, versionInfo.getSCMURL());
+ assertEquals(VERSION, versionInfo.getVersion());
+ assertEquals(REVISION, versionInfo.getRevision());
+ assertEquals(BUILD_TIME, versionInfo.getBuildTime());
+ assertEquals(SCM_URL, versionInfo.getSCMURL());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTest2File() {
VersionInfo versionInfo = new VersionInfo("test2");
- Assert.assertEquals(VERSION, versionInfo.getVersion());
- Assert.assertEquals(REVISION, versionInfo.getRevision());
- Assert.assertEquals(BUILD_TIME, versionInfo.getBuildTime());
- Assert.assertEquals(VersionInfo.UNKNOWN, versionInfo.getSCMURL());
+ assertEquals(VERSION, versionInfo.getVersion());
+ assertEquals(REVISION, versionInfo.getRevision());
+ assertEquals(BUILD_TIME, versionInfo.getBuildTime());
+ assertEquals(VersionInfo.UNKNOWN, versionInfo.getSCMURL());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTest3File() {
VersionInfo versionInfo = new VersionInfo("test3");
- Assert.assertEquals(VERSION, versionInfo.getVersion());
- Assert.assertEquals(REVISION, versionInfo.getRevision());
- Assert.assertEquals("", versionInfo.getBuildTime());
- Assert.assertEquals(SCM_URL, versionInfo.getSCMURL());
+ assertEquals(VERSION, versionInfo.getVersion());
+ assertEquals(REVISION, versionInfo.getRevision());
+ assertEquals("", versionInfo.getBuildTime());
+ assertEquals(SCM_URL, versionInfo.getSCMURL());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNonExistentFile() {
VersionInfo versionInfo = new VersionInfo("test4");
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestACLConfigurationParser.java b/tez-api/src/test/java/org/apache/tez/common/security/TestACLConfigurationParser.java
index de2c6ade33..ed197f433f 100644
--- a/tez-api/src/test/java/org/apache/tez/common/security/TestACLConfigurationParser.java
+++ b/tez-api/src/test/java/org/apache/tez/common/security/TestACLConfigurationParser.java
@@ -18,17 +18,24 @@
*/
package org.apache.tez.common.security;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezConstants;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestACLConfigurationParser {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testACLConfigParser() {
Configuration conf = new Configuration(false);
@@ -39,43 +46,44 @@ public void testACLConfigParser() {
conf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewACLs);
ACLConfigurationParser parser = new ACLConfigurationParser(conf);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
- Assert.assertFalse(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
+ assertFalse(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
conf.set(TezConfiguration.TEZ_AM_MODIFY_ACLS, modifyACLs);
parser = new ACLConfigurationParser(conf);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user3"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user3"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGroupsOnly() {
Configuration conf = new Configuration(false);
String adminACLs = "admin1,admin4, admgrp3,admgrp4,admgrp5 ";
@@ -84,20 +92,21 @@ public void testGroupsOnly() {
conf.set(YarnConfiguration.YARN_ADMIN_ACL, adminACLs);
ACLConfigurationParser parser = new ACLConfigurationParser(conf);
- Assert.assertFalse(parser.getAllowedUsers().isEmpty());
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertFalse(parser.getAllowedUsers().isEmpty());
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGACLConfigParser() {
Configuration conf = new Configuration(false);
@@ -108,44 +117,44 @@ public void testDAGACLConfigParser() {
conf.set(YarnConfiguration.YARN_ADMIN_ACL, adminACLs);
ACLConfigurationParser parser = new ACLConfigurationParser(conf, true);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
- Assert.assertFalse(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
+ assertFalse(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
conf.set(TezConstants.TEZ_DAG_MODIFY_ACLS, modifyACLs);
parser = new ACLConfigurationParser(conf, true);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
- Assert.assertNotNull(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
+ assertNotNull(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL));
+ assertFalse(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestACLManager.java b/tez-api/src/test/java/org/apache/tez/common/security/TestACLManager.java
index eeaf50091c..78d2a5022b 100644
--- a/tez-api/src/test/java/org/apache/tez/common/security/TestACLManager.java
+++ b/tez-api/src/test/java/org/apache/tez/common/security/TestACLManager.java
@@ -18,8 +18,13 @@
*/
package org.apache.tez.common.security;
+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 java.io.IOException;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
@@ -28,15 +33,16 @@
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.records.DAGProtos.ACLInfo;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestACLManager {
private static final String[] noGroups = new String[0];
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCurrentUserACLChecks() {
UserGroupInformation currentUser = UserGroupInformation.createUserForTesting("currentUser", noGroups);
UserGroupInformation dagUser = UserGroupInformation.createUserForTesting("dagUser", noGroups);
@@ -46,36 +52,37 @@ public void testCurrentUserACLChecks() {
UserGroupInformation user = user1;
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
user = currentUser;
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
aclManager = new ACLManager(currentUser.getShortUserName(), new Configuration(false));
user = user1;
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
user = currentUser;
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
ACLManager dagAclManager = new ACLManager(aclManager, dagUser.getShortUserName(),
ACLInfo.getDefaultInstance());
user = dagUser;
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
- Assert.assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
+ assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
user = user1;
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOtherUserACLChecks() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -100,24 +107,25 @@ public void testOtherUserACLChecks() throws IOException {
ACLManager aclManager = new ACLManager(currentUser.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
-
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
+
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNoGroupsACLChecks() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -140,24 +148,25 @@ public void testNoGroupsACLChecks() throws IOException {
conf.set(TezConfiguration.TEZ_AM_MODIFY_ACLS, modifyACLs);
ACLManager aclManager = new ACLManager(currentUser.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
-
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
+
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void checkAMACLs() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -187,48 +196,49 @@ public void checkAMACLs() throws IOException {
ACLManager aclManager = new ACLManager(currentUser.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(currentUser));
- Assert.assertTrue(aclManager.checkAMViewAccess(user1));
- Assert.assertTrue(aclManager.checkAMViewAccess(user2));
- Assert.assertFalse(aclManager.checkAMViewAccess(user3));
- Assert.assertTrue(aclManager.checkAMViewAccess(user4));
- Assert.assertFalse(aclManager.checkAMViewAccess(user5));
- Assert.assertFalse(aclManager.checkAMViewAccess(user6));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkAMModifyAccess(currentUser));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user1));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user2));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user3));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user4));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user5));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user6));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGViewAccess(currentUser));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user2));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user3));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user4));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user5));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user6));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGModifyAccess(currentUser));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user1));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user2));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user3));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user4));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user5));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user6));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser2));
+ assertTrue(aclManager.checkAMViewAccess(currentUser));
+ assertTrue(aclManager.checkAMViewAccess(user1));
+ assertTrue(aclManager.checkAMViewAccess(user2));
+ assertFalse(aclManager.checkAMViewAccess(user3));
+ assertTrue(aclManager.checkAMViewAccess(user4));
+ assertFalse(aclManager.checkAMViewAccess(user5));
+ assertFalse(aclManager.checkAMViewAccess(user6));
+ assertTrue(aclManager.checkAMViewAccess(admuser1));
+ assertTrue(aclManager.checkAMViewAccess(admuser2));
+
+ assertTrue(aclManager.checkAMModifyAccess(currentUser));
+ assertFalse(aclManager.checkAMModifyAccess(user1));
+ assertFalse(aclManager.checkAMModifyAccess(user2));
+ assertTrue(aclManager.checkAMModifyAccess(user3));
+ assertFalse(aclManager.checkAMModifyAccess(user4));
+ assertTrue(aclManager.checkAMModifyAccess(user5));
+ assertFalse(aclManager.checkAMModifyAccess(user6));
+ assertTrue(aclManager.checkAMModifyAccess(admuser1));
+ assertTrue(aclManager.checkAMModifyAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGViewAccess(currentUser));
+ assertTrue(aclManager.checkDAGViewAccess(user1));
+ assertTrue(aclManager.checkDAGViewAccess(user2));
+ assertFalse(aclManager.checkDAGViewAccess(user3));
+ assertTrue(aclManager.checkDAGViewAccess(user4));
+ assertFalse(aclManager.checkDAGViewAccess(user5));
+ assertFalse(aclManager.checkDAGViewAccess(user6));
+ assertTrue(aclManager.checkDAGViewAccess(admuser1));
+ assertTrue(aclManager.checkDAGViewAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGModifyAccess(currentUser));
+ assertFalse(aclManager.checkDAGModifyAccess(user1));
+ assertFalse(aclManager.checkDAGModifyAccess(user2));
+ assertTrue(aclManager.checkDAGModifyAccess(user3));
+ assertFalse(aclManager.checkDAGModifyAccess(user4));
+ assertTrue(aclManager.checkDAGModifyAccess(user5));
+ assertFalse(aclManager.checkDAGModifyAccess(user6));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser1));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser2));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void checkDAGACLs() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -271,53 +281,54 @@ public void checkDAGACLs() throws IOException {
ACLManager aclManager = new ACLManager(amAclManager, dagUser.getShortUserName(),
builder.build());
- Assert.assertTrue(aclManager.checkAMViewAccess(currentUser));
- Assert.assertFalse(aclManager.checkAMViewAccess(dagUser));
- Assert.assertTrue(aclManager.checkAMViewAccess(user1));
- Assert.assertTrue(aclManager.checkAMViewAccess(user2));
- Assert.assertFalse(aclManager.checkAMViewAccess(user3));
- Assert.assertTrue(aclManager.checkAMViewAccess(user4));
- Assert.assertFalse(aclManager.checkAMViewAccess(user5));
- Assert.assertFalse(aclManager.checkAMViewAccess(user6));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkAMModifyAccess(currentUser));
- Assert.assertFalse(aclManager.checkAMModifyAccess(dagUser));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user1));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user2));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user3));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user4));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user5));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user6));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGViewAccess(currentUser));
- Assert.assertTrue(aclManager.checkDAGViewAccess(dagUser));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user2));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user3));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user4));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user5));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user6));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGModifyAccess(currentUser));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(dagUser));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user1));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user2));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user3));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user4));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user5));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user6));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser2));
+ assertTrue(aclManager.checkAMViewAccess(currentUser));
+ assertFalse(aclManager.checkAMViewAccess(dagUser));
+ assertTrue(aclManager.checkAMViewAccess(user1));
+ assertTrue(aclManager.checkAMViewAccess(user2));
+ assertFalse(aclManager.checkAMViewAccess(user3));
+ assertTrue(aclManager.checkAMViewAccess(user4));
+ assertFalse(aclManager.checkAMViewAccess(user5));
+ assertFalse(aclManager.checkAMViewAccess(user6));
+ assertTrue(aclManager.checkAMViewAccess(admuser1));
+ assertTrue(aclManager.checkAMViewAccess(admuser2));
+
+ assertTrue(aclManager.checkAMModifyAccess(currentUser));
+ assertFalse(aclManager.checkAMModifyAccess(dagUser));
+ assertFalse(aclManager.checkAMModifyAccess(user1));
+ assertFalse(aclManager.checkAMModifyAccess(user2));
+ assertTrue(aclManager.checkAMModifyAccess(user3));
+ assertFalse(aclManager.checkAMModifyAccess(user4));
+ assertTrue(aclManager.checkAMModifyAccess(user5));
+ assertFalse(aclManager.checkAMModifyAccess(user6));
+ assertTrue(aclManager.checkAMModifyAccess(admuser1));
+ assertTrue(aclManager.checkAMModifyAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGViewAccess(currentUser));
+ assertTrue(aclManager.checkDAGViewAccess(dagUser));
+ assertTrue(aclManager.checkDAGViewAccess(user1));
+ assertTrue(aclManager.checkDAGViewAccess(user2));
+ assertFalse(aclManager.checkDAGViewAccess(user3));
+ assertTrue(aclManager.checkDAGViewAccess(user4));
+ assertTrue(aclManager.checkDAGViewAccess(user5));
+ assertTrue(aclManager.checkDAGViewAccess(user6));
+ assertTrue(aclManager.checkDAGViewAccess(admuser1));
+ assertTrue(aclManager.checkDAGViewAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGModifyAccess(currentUser));
+ assertTrue(aclManager.checkDAGModifyAccess(dagUser));
+ assertFalse(aclManager.checkDAGModifyAccess(user1));
+ assertFalse(aclManager.checkDAGModifyAccess(user2));
+ assertTrue(aclManager.checkDAGModifyAccess(user3));
+ assertFalse(aclManager.checkDAGModifyAccess(user4));
+ assertTrue(aclManager.checkDAGModifyAccess(user5));
+ assertTrue(aclManager.checkDAGModifyAccess(user6));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser1));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser2));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWildCardCheck() {
Configuration conf = new Configuration(false);
String viewACLs = " * ";
@@ -329,17 +340,18 @@ public void testWildCardCheck() {
UserGroupInformation u1 = UserGroupInformation.createUserForTesting("u1", noGroups);
ACLManager aclManager = new ACLManager(a1.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(a1));
- Assert.assertTrue(aclManager.checkAMViewAccess(u1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(u1));
+ assertTrue(aclManager.checkAMViewAccess(a1));
+ assertTrue(aclManager.checkAMViewAccess(u1));
+ assertTrue(aclManager.checkAMModifyAccess(a1));
+ assertTrue(aclManager.checkAMModifyAccess(u1));
+ assertTrue(aclManager.checkDAGViewAccess(a1));
+ assertTrue(aclManager.checkDAGViewAccess(u1));
+ assertTrue(aclManager.checkDAGModifyAccess(a1));
+ assertTrue(aclManager.checkDAGModifyAccess(u1));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAdminWildCardCheck() {
Configuration conf = new Configuration(false);
String yarnAdminACLs = " * ";
@@ -349,17 +361,18 @@ public void testAdminWildCardCheck() {
UserGroupInformation u1 = UserGroupInformation.createUserForTesting("u1", noGroups);
ACLManager aclManager = new ACLManager(a1.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(a1));
- Assert.assertTrue(aclManager.checkAMViewAccess(u1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(u1));
+ assertTrue(aclManager.checkAMViewAccess(a1));
+ assertTrue(aclManager.checkAMViewAccess(u1));
+ assertTrue(aclManager.checkAMModifyAccess(a1));
+ assertTrue(aclManager.checkAMModifyAccess(u1));
+ assertTrue(aclManager.checkDAGViewAccess(a1));
+ assertTrue(aclManager.checkDAGViewAccess(u1));
+ assertTrue(aclManager.checkDAGModifyAccess(a1));
+ assertTrue(aclManager.checkDAGModifyAccess(u1));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testACLsDisabled() {
Configuration conf = new Configuration(false);
conf.setBoolean(TezConfiguration.TEZ_AM_ACLS_ENABLED, false);
@@ -372,27 +385,28 @@ public void testACLsDisabled() {
UserGroupInformation u1 = UserGroupInformation.createUserForTesting("u1", noGroups);
ACLManager aclManager = new ACLManager(a1.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(a1));
- Assert.assertTrue(aclManager.checkAMViewAccess(u1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(u1));
+ assertTrue(aclManager.checkAMViewAccess(a1));
+ assertTrue(aclManager.checkAMViewAccess(u1));
+ assertTrue(aclManager.checkAMModifyAccess(a1));
+ assertTrue(aclManager.checkAMModifyAccess(u1));
+ assertTrue(aclManager.checkDAGViewAccess(a1));
+ assertTrue(aclManager.checkDAGViewAccess(u1));
+ assertTrue(aclManager.checkDAGModifyAccess(a1));
+ assertTrue(aclManager.checkDAGModifyAccess(u1));
ACLManager dagAclManager = new ACLManager(aclManager, "dagUser", null);
- Assert.assertTrue(dagAclManager.checkAMViewAccess(a1));
- Assert.assertTrue(dagAclManager.checkAMViewAccess(u1));
- Assert.assertTrue(dagAclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(dagAclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(dagAclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(dagAclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(dagAclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(dagAclManager.checkDAGModifyAccess(u1));
+ assertTrue(dagAclManager.checkAMViewAccess(a1));
+ assertTrue(dagAclManager.checkAMViewAccess(u1));
+ assertTrue(dagAclManager.checkAMModifyAccess(a1));
+ assertTrue(dagAclManager.checkAMModifyAccess(u1));
+ assertTrue(dagAclManager.checkDAGViewAccess(a1));
+ assertTrue(dagAclManager.checkDAGViewAccess(u1));
+ assertTrue(dagAclManager.checkDAGModifyAccess(a1));
+ assertTrue(dagAclManager.checkDAGModifyAccess(u1));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertToYARNACLs() {
String currentUser = "c1";
Configuration conf = new Configuration(false);
@@ -402,18 +416,18 @@ public void testConvertToYARNACLs() {
ACLManager aclManager = new ACLManager(currentUser, conf);
Map yarnAcls = aclManager.toYARNACls();
- Assert.assertTrue(yarnAcls.containsKey(ApplicationAccessType.VIEW_APP));
- Assert.assertEquals("c1,user1,user4 grp3,grp4",
+ assertTrue(yarnAcls.containsKey(ApplicationAccessType.VIEW_APP));
+ assertEquals("c1,user1,user4 grp3,grp4",
yarnAcls.get(ApplicationAccessType.VIEW_APP));
- Assert.assertTrue(yarnAcls.containsKey(ApplicationAccessType.MODIFY_APP));
- Assert.assertEquals("*",
+ assertTrue(yarnAcls.containsKey(ApplicationAccessType.MODIFY_APP));
+ assertEquals("*",
yarnAcls.get(ApplicationAccessType.MODIFY_APP));
viewACLs = " grp3,grp4 ";
conf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewACLs);
ACLManager aclManager1 = new ACLManager(currentUser, conf);
yarnAcls = aclManager1.toYARNACls();
- Assert.assertEquals("c1 grp3,grp4",
+ assertEquals("c1 grp3,grp4",
yarnAcls.get(ApplicationAccessType.VIEW_APP));
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestDAGAccessControls.java b/tez-api/src/test/java/org/apache/tez/common/security/TestDAGAccessControls.java
index e9c89a32ce..f291c4423e 100644
--- a/tez-api/src/test/java/org/apache/tez/common/security/TestDAGAccessControls.java
+++ b/tez-api/src/test/java/org/apache/tez/common/security/TestDAGAccessControls.java
@@ -18,33 +18,40 @@
*/
package org.apache.tez.common.security;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.TezConfiguration;
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestDAGAccessControls {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testStringBasedConstructor() {
DAGAccessControls dagAccessControls = new DAGAccessControls("u1 g1", "u2 g2");
- Assert.assertEquals(1, dagAccessControls.getUsersWithViewACLs().size());
- Assert.assertEquals(1, dagAccessControls.getUsersWithModifyACLs().size());
- Assert.assertEquals(1, dagAccessControls.getGroupsWithViewACLs().size());
- Assert.assertEquals(1, dagAccessControls.getGroupsWithModifyACLs().size());
+ assertEquals(1, dagAccessControls.getUsersWithViewACLs().size());
+ assertEquals(1, dagAccessControls.getUsersWithModifyACLs().size());
+ assertEquals(1, dagAccessControls.getGroupsWithViewACLs().size());
+ assertEquals(1, dagAccessControls.getGroupsWithModifyACLs().size());
- Assert.assertTrue(dagAccessControls.getUsersWithViewACLs().contains("u1"));
- Assert.assertTrue(dagAccessControls.getUsersWithModifyACLs().contains("u2"));
- Assert.assertTrue(dagAccessControls.getGroupsWithViewACLs().contains("g1"));
- Assert.assertTrue(dagAccessControls.getGroupsWithModifyACLs().contains("g2"));
+ assertTrue(dagAccessControls.getUsersWithViewACLs().contains("u1"));
+ assertTrue(dagAccessControls.getUsersWithModifyACLs().contains("u2"));
+ assertTrue(dagAccessControls.getGroupsWithViewACLs().contains("g1"));
+ assertTrue(dagAccessControls.getGroupsWithModifyACLs().contains("g2"));
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMergeIntoAmAcls() {
DAGAccessControls dagAccessControls = new DAGAccessControls("u1 g1", "u2 g2");
Configuration conf = new Configuration(false);
@@ -133,15 +140,15 @@ public void assertACLS(String expected, String obtained) {
String [] parts1 = expected.split(" ");
String [] parts2 = obtained.split(" ");
- Assert.assertEquals(parts1.length, parts2.length);
+ assertEquals(parts1.length, parts2.length);
- Assert.assertEquals(
+ assertEquals(
Sets.newHashSet(parts1[0].split(",")), Sets.newHashSet(parts2[0].split(",")));
if (parts1.length < 2) {
return;
}
- Assert.assertEquals(
+ assertEquals(
Sets.newHashSet(parts1[1].split(",")), Sets.newHashSet(parts2[1].split(",")));
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestTokenCache.java b/tez-api/src/test/java/org/apache/tez/common/security/TestTokenCache.java
index 867eb26398..6f56ad63e0 100644
--- a/tez-api/src/test/java/org/apache/tez/common/security/TestTokenCache.java
+++ b/tez-api/src/test/java/org/apache/tez/common/security/TestTokenCache.java
@@ -18,6 +18,9 @@
*/
package org.apache.tez.common.security;
+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.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -28,6 +31,7 @@
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -40,9 +44,9 @@
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
-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.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -52,7 +56,7 @@ public class TestTokenCache {
private static String renewer;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
conf = new Configuration();
conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/host@REALM");
@@ -61,7 +65,8 @@ public static void setup() throws Exception {
renewer = Master.getMasterPrincipal(conf);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
@SuppressWarnings("deprecation")
public void testBinaryCredentials() throws Exception {
String binaryTokenFile = null;
@@ -85,7 +90,7 @@ public void testBinaryCredentials() throws Exception {
Credentials newCreds = new Credentials();
TokenCache.mergeBinaryTokens(newCreds, conf, binaryTokenFile);
- Assert.assertTrue(newCreds.getAllTokens().size() > 0);
+ assertTrue(newCreds.getAllTokens().size() > 0);
checkTokens(creds, newCreds);
} finally {
if (binaryTokenFile != null) {
@@ -98,7 +103,8 @@ public void testBinaryCredentials() throws Exception {
}
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testObtainTokensForFileSystems() throws Exception {
Path[] paths = makePaths(100, "test://dir/file");
Credentials creds = new Credentials();
@@ -171,12 +177,12 @@ public Token> answer(InvocationOnMock invocation) throws Throwable {
}
private void checkTokens(Credentials creds, Credentials newCreds) {
- Assert.assertEquals(creds.getAllTokens().size(),
+ assertEquals(creds.getAllTokens().size(),
newCreds.getAllTokens().size());
for (Token> token : newCreds.getAllTokens()) {
Token> credsToken = creds.getToken(token.getService());
- Assert.assertTrue(credsToken != null);
- Assert.assertEquals(token, credsToken);
+ assertNotNull(credsToken);
+ assertEquals(token, credsToken);
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAG.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAG.java
index 6fcd25bc12..11187c7f7c 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAG.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAG.java
@@ -18,8 +18,15 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.Collections;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.yarn.api.records.LocalResource;
import org.apache.hadoop.yarn.api.records.LocalResourceType;
@@ -34,15 +41,16 @@
import org.apache.tez.dag.api.records.DAGProtos.DAGPlan;
import org.apache.tez.dag.api.records.DAGProtos.DAGPlan.Builder;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestDAG {
private final int dummyTaskCount = 2;
private final Resource dummyTaskResource = Resource.newInstance(1, 1);
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedVertices() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("Processor"),
dummyTaskCount, dummyTaskResource);
@@ -52,14 +60,15 @@ public void testDuplicatedVertices() {
dag.addVertex(v1);
try {
dag.addVertex(v2);
- Assert.fail("should fail it due to duplicated vertices");
+ fail("should fail it due to duplicated vertices");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertEquals("Vertex v1 already defined!", e.getMessage());
+ assertEquals("Vertex v1 already defined!", e.getMessage());
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedEdges() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("Processor"),
dummyTaskCount, dummyTaskResource);
@@ -81,14 +90,15 @@ public void testDuplicatedEdges() {
dag.addEdge(edge1);
try {
dag.addEdge(edge2);
- Assert.fail("should fail it due to duplicated edges");
+ fail("should fail it due to duplicated edges");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertTrue(e.getMessage().contains("already defined!"));
+ assertTrue(e.getMessage().contains("already defined!"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedVertexGroup() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("Processor"),
dummyTaskCount, dummyTaskResource);
@@ -102,17 +112,18 @@ public void testDuplicatedVertexGroup() {
try {
dag.createVertexGroup("group_1", v2, v3);
- Assert.fail("should fail it due to duplicated VertexGroups");
+ fail("should fail it due to duplicated VertexGroups");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertEquals("VertexGroup group_1 already defined!", e.getMessage());
+ assertEquals("VertexGroup group_1 already defined!", e.getMessage());
}
// it is possible to create vertex group with same member but different group name
dag.createVertexGroup("group_2", v1, v2);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedGroupInputEdge() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -148,14 +159,15 @@ public void testDuplicatedGroupInputEdge() {
dag.addEdge(e1);
try {
dag.addEdge(e2);
- Assert.fail("should fail it due to duplicated GroupInputEdge");
+ fail("should fail it due to duplicated GroupInputEdge");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertTrue(e.getMessage().contains("already defined"));
+ assertTrue(e.getMessage().contains("already defined"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGConf() {
DAG dag = DAG.create("DAG-testDAGConf");
// it's OK to set custom configuration
@@ -164,9 +176,9 @@ public void testDAGConf() {
// set invalid AM level configuration
try {
dag.setConf(TezConfiguration.TEZ_AM_SESSION_MODE, true+"");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertEquals("tez.am.mode.session is set at the scope of DAG,"
+ assertEquals("tez.am.mode.session is set at the scope of DAG,"
+ " but it is only valid in the scope of AM",
e.getMessage());
}
@@ -176,7 +188,8 @@ public void testDAGConf() {
dag.setConf(TezConfiguration.TEZ_AM_TASK_MAX_FAILED_ATTEMPTS, 3 + "");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexConf() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
// it's OK to set custom property
@@ -185,9 +198,9 @@ public void testVertexConf() {
// set invalid AM level configuration
try {
v1.setConf(TezConfiguration.TEZ_AM_SESSION_MODE, true+"");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertEquals("tez.am.mode.session is set at the scope of VERTEX,"
+ assertEquals("tez.am.mode.session is set at the scope of VERTEX,"
+ " but it is only valid in the scope of AM",
e.getMessage());
}
@@ -195,9 +208,9 @@ public void testVertexConf() {
// set invalid DAG level configuration
try {
v1.setConf(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, false + "");
- Assert.fail("should fail due to invalid configuration set");
+ fail("should fail due to invalid configuration set");
} catch (IllegalStateException e) {
- Assert.assertEquals("tez.am.commit-all-outputs-on-dag-success is set at the scope of VERTEX,"
+ assertEquals("tez.am.commit-all-outputs-on-dag-success is set at the scope of VERTEX,"
+ " but it is only valid in the scope of DAG",
e.getMessage());
}
@@ -205,30 +218,31 @@ public void testVertexConf() {
v1.setConf(TezConfiguration.TEZ_AM_TASK_MAX_FAILED_ATTEMPTS, 3 + "");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedInput() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
DataSourceDescriptor dataSource =
DataSourceDescriptor.create(InputDescriptor.create("dummyInput"), null, null);
try {
v1.addDataSource(null, dataSource);
- Assert.fail("Should fail due to invalid inputName");
+ fail("Should fail due to invalid inputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("InputName should not be null, empty or white space only,"));
}
try {
v1.addDataSource("", dataSource);
- Assert.fail("Should fail due to invalid inputName");
+ fail("Should fail due to invalid inputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("InputName should not be null, empty or white space only,"));
}
try {
v1.addDataSource(" ", dataSource);
- Assert.fail("Should fail due to invalid inputName");
+ fail("Should fail due to invalid inputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("InputName should not be null, empty or white space only,"));
}
@@ -236,36 +250,37 @@ public void testDuplicatedInput() {
try {
v1.addDataSource("input_1",
DataSourceDescriptor.create(InputDescriptor.create("dummyInput"), null, null));
- Assert.fail("Should fail due to duplicated input");
+ fail("Should fail due to duplicated input");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Duplicated input:input_1, vertexName=v1", e.getMessage());
+ assertEquals("Duplicated input:input_1, vertexName=v1", e.getMessage());
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedOutput_1() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
DataSinkDescriptor dataSink =
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null);
try {
v1.addDataSink(null, dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink("", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink(" ", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
@@ -274,13 +289,14 @@ public void testDuplicatedOutput_1() {
try {
v1.addDataSink("output_1",
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null));
- Assert.fail("Should fail due to duplicated output");
+ fail("Should fail due to duplicated output");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
+ assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedOutput_2() {
DAG dag = DAG.create("DAG-testDuplicatedOutput_2");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
@@ -288,23 +304,23 @@ public void testDuplicatedOutput_2() {
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null);
try {
v1.addDataSink(null, dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink("", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink(" ", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
@@ -314,9 +330,9 @@ public void testDuplicatedOutput_2() {
try {
vGroup.addDataSink("output_1",
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null));
- Assert.fail("Should fail due to duplicated output");
+ fail("Should fail due to duplicated output");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
+ assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
}
}
@@ -324,13 +340,13 @@ public void testDuplicatedOutput_2() {
public void testCallerContext() {
try {
CallerContext.create("ctxt", "", "", "desc");
- Assert.fail("Expected failure for invalid args");
+ fail("Expected failure for invalid args");
} catch (Exception e) {
// Expected
}
try {
CallerContext.create("", "desc");
- Assert.fail("Expected failure for invalid args");
+ fail("Expected failure for invalid args");
} catch (Exception e) {
// Expected
}
@@ -339,8 +355,8 @@ public void testCallerContext() {
CallerContext.create("ctxt", null);
CallerContext callerContext = CallerContext.create("ctxt", "desc");
- Assert.assertTrue(callerContext.toString().contains("desc"));
- Assert.assertFalse(callerContext.contextAsSimpleString().contains("desc"));
+ assertTrue(callerContext.toString().contains("desc"));
+ assertFalse(callerContext.contextAsSimpleString().contains("desc"));
}
@@ -361,7 +377,7 @@ public void testRecreateDAG() {
DAGPlan firstPlan = dag.createDag(tezConf, null, null, null, false);
for (int i = 0; i < 3; ++i) {
DAGPlan dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals(dagPlan, firstPlan);
+ assertEquals(dagPlan, firstPlan);
}
}
@@ -383,43 +399,43 @@ public void testCreateDAGForHistoryLogLevel() {
// Expect null when history log level is not set in both dag and tezConf
DAGPlan dagPlan = dag.createDag(tezConf, null, null, null, false);
Builder builder = DAGPlan.newBuilder(dagPlan);
- Assert.assertNull(findKVP(builder.getDagConf(), TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
+ assertNull(findKVP(builder.getDagConf(), TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set tezConf but not dag, expect value in tezConf.
tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, "TASK");
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals("TASK", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
+ assertEquals("TASK", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set invalid value in tezConf, expect exception.
tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, "invalid");
try {
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.fail("Expected illegal argument exception");
+ fail("Expected illegal argument exception");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
+ assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
" is set to invalid value: invalid", e.getMessage());
}
// Set value in dag, should override tez conf value.
dag.setHistoryLogLevel(HistoryLogLevel.VERTEX);
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals("VERTEX", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
+ assertEquals("VERTEX", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set value directly into dagConf.
dag.setConf(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, HistoryLogLevel.DAG.name());
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals("DAG", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
+ assertEquals("DAG", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set value invalid directly into dagConf and expect exception.
dag.setConf(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, "invalid");
try {
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.fail("Expected illegal argument exception");
+ fail("Expected illegal argument exception");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
+ assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
" is set to invalid value: invalid", e.getMessage());
}
}
@@ -431,7 +447,7 @@ private String findKVP(ConfigurationProto conf, String key) {
if (foundValue == null) {
foundValue = conf.getConfKeyValues(i).getValue();
} else {
- Assert.fail("Multiple values found: " + foundValue + ", " +
+ fail("Multiple values found: " + foundValue + ", " +
conf.getConfKeyValues(i).getValue());
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGPlan.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGPlan.java
index 0a348c4c55..71d1ffa717 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGPlan.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGPlan.java
@@ -18,15 +18,21 @@
*/
package org.apache.tez.dag.api;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.Arrays;
+import java.nio.file.Path;
import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.security.Credentials;
@@ -51,17 +57,18 @@
import org.apache.tez.serviceplugins.api.TaskCommunicatorDescriptor;
import org.apache.tez.serviceplugins.api.TaskSchedulerDescriptor;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.io.*;
// based on TestDAGLocationHint
public class TestDAGPlan {
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder(); //TODO: doesn't seem to be deleting this folder automatically as expected.
- @Test(timeout = 5000)
+ @TempDir
+ public Path tempFolder;
+
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicJobPlanSerde() throws IOException {
DAGPlan job = DAGPlan.newBuilder()
@@ -81,7 +88,7 @@ public void testBasicJobPlanSerde() throws IOException {
.build())
.build())
.build();
- File file = tempFolder.newFile("jobPlan");
+ File file = tempFolder.resolve("jobPlan").toFile();
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(file);
@@ -103,10 +110,11 @@ public void testBasicJobPlanSerde() throws IOException {
outStream.close();
}
- Assert.assertEquals(job, inJob);
+ assertEquals(job, inJob);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEdgeManagerSerde() {
DAG dag = DAG.create("DAG-testEdgeManagerSerde");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -137,13 +145,13 @@ public void testEdgeManagerSerde() {
.getEdgeList().get(0));
EdgeManagerPluginDescriptor emDesc = edgeProperty.getEdgeManagerDescriptor();
- Assert.assertNotNull(emDesc);
- Assert.assertEquals("emClass", emDesc.getClassName());
- Assert.assertTrue(
- Arrays.equals("emPayload".getBytes(), emDesc.getUserPayload().deepCopyAsArray()));
+ assertNotNull(emDesc);
+ assertEquals("emClass", emDesc.getClassName());
+ assertArrayEquals("emPayload".getBytes(), emDesc.getUserPayload().deepCopyAsArray());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testUserPayloadSerde() {
DAG dag = DAG.create("DAG-testUserPayloadSerde");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -204,7 +212,8 @@ public void testUserPayloadSerde() {
assertEquals("output", edgeProperty.getEdgeSource().getClassName());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void userVertexOrderingIsMaintained() {
DAG dag = DAG.create("DAG-userVertexOrderingIsMaintained");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -277,7 +286,8 @@ public void userVertexOrderingIsMaintained() {
assertEquals("output", edgeProperty.getEdgeSource().getClassName());
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCredentialsSerde() {
DAG dag = DAG.create("DAG-testCredentialsSerde");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -321,7 +331,8 @@ public void testCredentialsSerde() {
assertNotNull(fetchedCredentials.getToken(new Text("Token2")));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidExecContext_1() {
DAG dag = DAG.create("DAG-testInvalidExecContext_1");
dag.setExecutionContext(VertexExecutionContext.createExecuteInAm(true));
@@ -346,7 +357,8 @@ public void testInvalidExecContext_1() {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidExecContext_2() {
ServicePluginsDescriptor servicePluginsDescriptor = ServicePluginsDescriptor
@@ -428,7 +440,8 @@ public void testInvalidExecContext_2() {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testServiceDescriptorPropagation() {
DAG dag = DAG.create("DAG-testServiceDescriptorPropagation");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -491,7 +504,8 @@ public void testServiceDescriptorPropagation() {
assertFalse(v2Proto.hasExecutionContext());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidJavaOpts() {
DAG dag = DAG.create("DAG-testInvalidJavaOpts");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -507,7 +521,7 @@ public void testInvalidJavaOpts() {
dag.createDag(conf, null, null, null, true, null, new JavaOptsChecker());
fail("Expected dag creation to fail for invalid java opts");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Invalid/conflicting GC options"));
+ assertTrue(e.getMessage().contains("Invalid/conflicting GC options"));
}
// Should not fail as java opts valid
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
index 4c4390a451..9383e9b26b 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
@@ -18,6 +18,14 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
@@ -25,6 +33,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.LocalResource;
@@ -45,8 +54,8 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestDAGVerify {
@@ -61,7 +70,8 @@ public class TestDAGVerify {
// v1
// |
// v2
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyScatterGather() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -81,7 +91,8 @@ public void testVerifyScatterGather() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyCustomEdge() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -102,7 +113,8 @@ public void testVerifyCustomEdge() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyOneToOne() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -122,7 +134,8 @@ public void testVerifyOneToOne() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (known) -> v2 (-1) -> v3 (-1)
public void testVerifyOneToOneInferParallelism() {
Vertex v1 = Vertex.create("v1",
@@ -151,11 +164,12 @@ public void testVerifyOneToOneInferParallelism() {
dag.addEdge(e1);
dag.addEdge(e2);
dag.verify();
- Assert.assertEquals(dummyTaskCount, v2.getParallelism());
- Assert.assertEquals(dummyTaskCount, v3.getParallelism());
+ assertEquals(dummyTaskCount, v2.getParallelism());
+ assertEquals(dummyTaskCount, v3.getParallelism());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (known) -> v2 (-1) -> v3 (-1)
// The test checks resiliency to ordering of the vertices/edges
public void testVerifyOneToOneInferParallelismReverseOrder() {
@@ -185,11 +199,12 @@ public void testVerifyOneToOneInferParallelismReverseOrder() {
dag.addEdge(e2);
dag.addEdge(e1);
dag.verify();
- Assert.assertEquals(dummyTaskCount, v2.getParallelism());
- Assert.assertEquals(dummyTaskCount, v3.getParallelism());
+ assertEquals(dummyTaskCount, v2.getParallelism());
+ assertEquals(dummyTaskCount, v3.getParallelism());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyOneToOneNoInferParallelism() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -210,10 +225,11 @@ public void testVerifyOneToOneNoInferParallelism() {
dag.addVertex(v2);
dag.addEdge(e1);
dag.verify();
- Assert.assertEquals(-1, v2.getParallelism());
+ assertEquals(-1, v2.getParallelism());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (-1) -> v2 (known) -> v3 (-1)
public void testVerifyOneToOneIncorrectParallelism1() {
Vertex v1 = Vertex.create("v1",
@@ -243,14 +259,15 @@ public void testVerifyOneToOneIncorrectParallelism1() {
dag.addEdge(e2);
try {
dag.verify();
- Assert.assertTrue(false);
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"1-1 Edge. Destination vertex parallelism must match source vertex"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (-1) -> v3 (-1), v2 (known) -> v3 (-1)
// order of edges should not matter
public void testVerifyOneToOneIncorrectParallelism2() {
@@ -291,14 +308,15 @@ public void testVerifyOneToOneIncorrectParallelism2() {
dag.addEdge(e3);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"1-1 Edge. Destination vertex parallelism must match source vertex"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyBroadcast() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -318,7 +336,8 @@ public void testVerifyBroadcast() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerify3() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -338,7 +357,8 @@ public void testVerify3() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerify4() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -363,7 +383,8 @@ public void testVerify4() {
// v2 ^
// | | ^
// v3 v4
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCycle1() {
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -413,9 +434,9 @@ public void testCycle1() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
+ assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
}
// v1
@@ -423,7 +444,8 @@ public void testCycle1() {
// -> v2
// ^ | |
// v3 v4
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCycle2() {
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -473,13 +495,14 @@ public void testCycle2() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
+ assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
}
// v1 -> v1
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSelfCycle(){
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -499,12 +522,13 @@ public void testSelfCycle(){
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("DAG contains a self-cycle"));
+ assertTrue(ex.getMessage().startsWith("DAG contains a self-cycle"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void repeatedVertexName() {
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -522,12 +546,13 @@ public void repeatedVertexName() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("Vertex v1 already defined"));
+ assertTrue(ex.getMessage().startsWith("Vertex v1 already defined"));
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAndInputVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -548,10 +573,11 @@ public void testInputAndInputVertexNameCollision() {
dag.addVertex(v1);
dag.addVertex(v2);
dag.addEdge(e1);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOutputAndOutputVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -572,10 +598,11 @@ public void testOutputAndOutputVertexNameCollision() {
dag.addVertex(v1);
dag.addVertex(v2);
dag.addEdge(e1);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOutputAndVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -589,10 +616,11 @@ public void testOutputAndVertexNameCollision() {
DAG dag = DAG.create("DAG-testOutputAndVertexNameCollision");
dag.addVertex(v1);
dag.addVertex(v2);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAndVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -606,13 +634,14 @@ public void testInputAndVertexNameCollision() {
DAG dag = DAG.create("DAG-testInputAndVertexNameCollision");
dag.addVertex(v1);
dag.addVertex(v2);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
// v1 v2
// | |
// v3
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void BinaryInputAllowed() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -642,7 +671,8 @@ public void BinaryInputAllowed() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexGroupWithMultipleOutputEdges() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -687,15 +717,16 @@ public void testVertexGroupWithMultipleOutputEdges() {
dag.verify(); // should be OK when called multiple times
}
- Assert.assertEquals(2, v1.getOutputVertices().size());
- Assert.assertEquals(2, v2.getOutputVertices().size());
- Assert.assertTrue(v1.getOutputVertices().contains(v3));
- Assert.assertTrue(v1.getOutputVertices().contains(v4));
- Assert.assertTrue(v2.getOutputVertices().contains(v3));
- Assert.assertTrue(v2.getOutputVertices().contains(v4));
+ assertEquals(2, v1.getOutputVertices().size());
+ assertEquals(2, v2.getOutputVertices().size());
+ assertTrue(v1.getOutputVertices().contains(v3));
+ assertTrue(v1.getOutputVertices().contains(v4));
+ assertTrue(v2.getOutputVertices().contains(v3));
+ assertTrue(v2.getOutputVertices().contains(v4));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexGroup() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -749,35 +780,36 @@ public void testVertexGroup() {
// for the first Group v1 and v2 should get connected to v4 and also have 1 output
// for the second Group v2 and v3 should get connected to v5
// the Group place holders should disappear
- Assert.assertNull(dag.getVertex(uv12.getGroupName()));
- Assert.assertNull(dag.getVertex(uv23.getGroupName()));
- Assert.assertFalse(dag.edges.contains(e1));
- Assert.assertFalse(dag.edges.contains(e2));
- Assert.assertEquals(1, v1.getOutputs().size());
- Assert.assertEquals(1, v2.getOutputs().size());
- Assert.assertEquals(outDesc, v1.getOutputs().get(0).getIODescriptor());
- Assert.assertEquals(outDesc, v2.getOutputs().get(0).getIODescriptor());
- Assert.assertEquals(1, v1.getOutputVertices().size());
- Assert.assertEquals(1, v3.getOutputVertices().size());
- Assert.assertEquals(2, v2.getOutputVertices().size());
- Assert.assertTrue(v1.getOutputVertices().contains(v4));
- Assert.assertTrue(v3.getOutputVertices().contains(v5));
- Assert.assertTrue(v2.getOutputVertices().contains(v4));
- Assert.assertTrue(v2.getOutputVertices().contains(v5));
- Assert.assertEquals(2, v4.getInputVertices().size());
- Assert.assertTrue(v4.getInputVertices().contains(v1));
- Assert.assertTrue(v4.getInputVertices().contains(v2));
- Assert.assertEquals(2, v5.getInputVertices().size());
- Assert.assertTrue(v5.getInputVertices().contains(v2));
- Assert.assertTrue(v5.getInputVertices().contains(v3));
- Assert.assertEquals(1, v4.getGroupInputs().size());
- Assert.assertTrue(v4.getGroupInputs().containsKey(groupName1));
- Assert.assertEquals(1, v5.getGroupInputs().size());
- Assert.assertTrue(v5.getGroupInputs().containsKey(groupName2));
- Assert.assertEquals(2, dag.vertexGroups.size());
+ assertNull(dag.getVertex(uv12.getGroupName()));
+ assertNull(dag.getVertex(uv23.getGroupName()));
+ assertFalse(dag.edges.contains(e1));
+ assertFalse(dag.edges.contains(e2));
+ assertEquals(1, v1.getOutputs().size());
+ assertEquals(1, v2.getOutputs().size());
+ assertEquals(outDesc, v1.getOutputs().get(0).getIODescriptor());
+ assertEquals(outDesc, v2.getOutputs().get(0).getIODescriptor());
+ assertEquals(1, v1.getOutputVertices().size());
+ assertEquals(1, v3.getOutputVertices().size());
+ assertEquals(2, v2.getOutputVertices().size());
+ assertTrue(v1.getOutputVertices().contains(v4));
+ assertTrue(v3.getOutputVertices().contains(v5));
+ assertTrue(v2.getOutputVertices().contains(v4));
+ assertTrue(v2.getOutputVertices().contains(v5));
+ assertEquals(2, v4.getInputVertices().size());
+ assertTrue(v4.getInputVertices().contains(v1));
+ assertTrue(v4.getInputVertices().contains(v2));
+ assertEquals(2, v5.getInputVertices().size());
+ assertTrue(v5.getInputVertices().contains(v2));
+ assertTrue(v5.getInputVertices().contains(v3));
+ assertEquals(1, v4.getGroupInputs().size());
+ assertTrue(v4.getGroupInputs().containsKey(groupName1));
+ assertEquals(1, v5.getGroupInputs().size());
+ assertTrue(v5.getGroupInputs().containsKey(groupName2));
+ assertEquals(2, dag.vertexGroups.size());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexGroupOneToOne() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -828,13 +860,14 @@ public void testVertexGroupOneToOne() {
dag.verify(); // should be OK when called multiple times
}
- Assert.assertEquals(dummyTaskCount, v5.getParallelism());
+ assertEquals(dummyTaskCount, v5.getParallelism());
}
// v1
// | |
// v2 v3
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void BinaryOutput() {
IllegalStateException ex = null;
try {
@@ -868,10 +901,11 @@ public void BinaryOutput() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNull(ex);
+ assertNull(ex);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDagWithNoVertices() {
IllegalStateException ex=null;
try {
@@ -881,14 +915,15 @@ public void testDagWithNoVertices() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage()
+ assertTrue(ex.getMessage()
.startsWith("Invalid dag containing 0 vertices"));
}
@SuppressWarnings("unused")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidVertexConstruction() {
{
Vertex v1 = Vertex.create("v1",
@@ -902,11 +937,10 @@ public void testInvalidVertexConstruction() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
-2, dummyTaskResource);
- Assert.fail("Expected exception for 0 parallelism");
+ fail("Expected exception for 0 parallelism");
} catch (IllegalArgumentException e) {
- Assert
- .assertTrue(e
- .getMessage()
+ assertTrue(
+ e.getMessage()
.startsWith(
"Parallelism should be -1 if determined by the AM, otherwise should be >= 0"));
}
@@ -914,13 +948,14 @@ public void testInvalidVertexConstruction() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
1, null);
- Assert.fail("Expected exception for 0 parallelism");
+ fail("Expected exception for 0 parallelism");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().startsWith("Resource cannot be null"));
+ assertTrue(e.getMessage().startsWith("Resource cannot be null"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleRootInputsAllowed() {
DAG dag = DAG.create("DAG-testMultipleRootInputsAllowed");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -944,7 +979,8 @@ public void testMultipleRootInputsAllowed() {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGCreateDataInference() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
Map lrs1 = Maps.newHashMap();
@@ -971,16 +1007,17 @@ public void testDAGCreateDataInference() {
dag.addVertex(v1);
dag.addTaskLocalFiles(lrs1);
DAGPlan dagPlan = dag.createDag(new TezConfiguration(), null, null, null, true);
- Assert.assertEquals(lrName1, dagPlan.getLocalResource(0).getName());
+ assertEquals(lrName1, dagPlan.getLocalResource(0).getName());
VertexPlan vPlan = dagPlan.getVertex(0);
PlanTaskConfiguration taskPlan = vPlan.getTaskConfig();
- Assert.assertEquals(dummyTaskCount, taskPlan.getNumTasks());
- Assert.assertEquals(TezConfiguration.TEZ_TASK_RESOURCE_MEMORY_MB_DEFAULT, taskPlan.getMemoryMb());
- Assert.assertEquals(lrName2, taskPlan.getLocalResource(0).getName());
- Assert.assertEquals(dummyTaskCount, vPlan.getTaskLocationHintCount());
+ assertEquals(dummyTaskCount, taskPlan.getNumTasks());
+ assertEquals(TezConfiguration.TEZ_TASK_RESOURCE_MEMORY_MB_DEFAULT, taskPlan.getMemoryMb());
+ assertEquals(lrName2, taskPlan.getLocalResource(0).getName());
+ assertEquals(dummyTaskCount, vPlan.getTaskLocationHintCount());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInferredFilesFail() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -999,9 +1036,9 @@ public void testInferredFilesFail() {
// Allowed since the LR is the same.
try {
v1.addTaskLocalFiles(lrs2);
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
DataSourceDescriptor ds = DataSourceDescriptor.create(InputDescriptor.create("I.class"),
@@ -1013,20 +1050,21 @@ public void testInferredFilesFail() {
dag.addTaskLocalFiles(lrs);
try {
dag.addTaskLocalFiles(lrs2);
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
try {
// data source will add duplicate common files to vertex
dag.createDag(new TezConfiguration(), null, null, null, true);
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGAccessControls() {
DAG dag = DAG.create("DAG-testDAGAccessControls");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -1043,27 +1081,28 @@ public void testDAGAccessControls() {
Configuration conf = new Configuration(false);
DAGPlan dagPlan = dag.createDag(conf, null, null, null, true);
- Assert.assertNull(conf.get(TezConstants.TEZ_DAG_VIEW_ACLS));
- Assert.assertNull(conf.get(TezConstants.TEZ_DAG_MODIFY_ACLS));
+ assertNull(conf.get(TezConstants.TEZ_DAG_VIEW_ACLS));
+ assertNull(conf.get(TezConstants.TEZ_DAG_MODIFY_ACLS));
ACLInfo aclInfo = dagPlan.getAclInfo();
- Assert.assertEquals(Collections.singletonList("u1"), aclInfo.getUsersWithViewAccessList());
- Assert.assertEquals(Collections.singletonList("g1"), aclInfo.getGroupsWithViewAccessList());
- Assert.assertEquals(Collections.singletonList("*"), aclInfo.getUsersWithModifyAccessList());
- Assert.assertEquals(Collections.singletonList("g2"), aclInfo.getGroupsWithModifyAccessList());
+ assertEquals(Collections.singletonList("u1"), aclInfo.getUsersWithViewAccessList());
+ assertEquals(Collections.singletonList("g1"), aclInfo.getGroupsWithViewAccessList());
+ assertEquals(Collections.singletonList("*"), aclInfo.getUsersWithModifyAccessList());
+ assertEquals(Collections.singletonList("g2"), aclInfo.getGroupsWithModifyAccessList());
}
// v1 has input initializer
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGInvalidParallelism1() {
DAG dag = DAG.create("DAG-testDAGInvalidParallelism1");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1075,16 +1114,17 @@ public void testDAGInvalidParallelism1() {
}
// v1 has custom vertex manager
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGInvalidParallelism2() {
DAG dag = DAG.create("DAG-testDAGInvalidParallelism2");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1094,16 +1134,17 @@ public void testDAGInvalidParallelism2() {
}
// v1 has 1-1 united source vertex v0 which has input initializer
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGInvalidParallelism3() {
DAG dag = DAG.create("DAG-testDAGInvalidParallelism3");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1128,9 +1169,9 @@ public void testDAGInvalidParallelism4() {
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1169,7 +1210,8 @@ public void testDAGWithSplitsOnClient() {
}
// Verifies failure in case of a file size difference. Does not verify sha differences.
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGWithConflictingResource() {
DAG dag = DAG.create("DAG-testDAGWithConflictingResource");
Map localResourceMap = new HashMap<>();
@@ -1188,9 +1230,9 @@ public void testDAGWithConflictingResource() {
try {
dag.verifyLocalResources(new TezConfiguration());
- Assert.fail("should report failure on conflict resources");
+ fail("should report failure on conflict resources");
} catch (Exception e) {
- Assert.assertTrue(e.getMessage().contains("There is conflicting local resource"));
+ assertTrue(e.getMessage().contains("There is conflicting local resource"));
}
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDagTypeConverters.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDagTypeConverters.java
index a9cc1e2dd1..6a73d22c5c 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestDagTypeConverters.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestDagTypeConverters.java
@@ -18,14 +18,19 @@
*/
package org.apache.tez.dag.api;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.yarn.api.records.URL;
@@ -47,12 +52,13 @@
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestDagTypeConverters {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezEntityDescriptorSerialization() throws IOException {
UserPayload payload = UserPayload.create(ByteBuffer.wrap(new String("Foobar").getBytes()), 100);
String historytext = "Bar123";
@@ -61,24 +67,25 @@ public void testTezEntityDescriptorSerialization() throws IOException {
.setHistoryText(historytext);
TezEntityDescriptorProto proto =
DagTypeConverters.convertToDAGPlan(entityDescriptor);
- Assert.assertEquals(payload.getVersion(), proto.getTezUserPayload().getVersion());
- Assert.assertArrayEquals(payload.deepCopyAsArray(), proto.getTezUserPayload().getUserPayload().toByteArray());
+ assertEquals(payload.getVersion(), proto.getTezUserPayload().getVersion());
+ assertArrayEquals(payload.deepCopyAsArray(), proto.getTezUserPayload().getUserPayload().toByteArray());
assertTrue(proto.hasHistoryText());
- Assert.assertNotEquals(historytext, proto.getHistoryText());
- Assert.assertEquals(historytext, new String(
+ assertNotEquals(historytext, proto.getHistoryText());
+ assertEquals(historytext, new String(
TezCommonUtils.decompressByteStringToByteArray(proto.getHistoryText())));
// Ensure that the history text is not deserialized
InputDescriptor inputDescriptor =
DagTypeConverters.convertInputDescriptorFromDAGPlan(proto);
- Assert.assertNull(inputDescriptor.getHistoryText());
+ assertNull(inputDescriptor.getHistoryText());
// Check history text value
String actualHistoryText = DagTypeConverters.getHistoryTextFromProto(proto, TezCommonUtils.newInflater());
- Assert.assertEquals(historytext, actualHistoryText);
+ assertEquals(historytext, actualHistoryText);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testYarnPathTranslation() {
// Without port
String p1String = "hdfs://mycluster/file";
@@ -89,9 +96,9 @@ public void testYarnPathTranslation() {
String p1StringSerialized = DagTypeConverters.convertToDAGPlan(lr1Url);
// Deserialize
URL lr1UrlDeserialized = DagTypeConverters.convertToYarnURL(p1StringSerialized);
- Assert.assertEquals("mycluster", lr1UrlDeserialized.getHost());
- Assert.assertEquals("/file", lr1UrlDeserialized.getFile());
- Assert.assertEquals("hdfs", lr1UrlDeserialized.getScheme());
+ assertEquals("mycluster", lr1UrlDeserialized.getHost());
+ assertEquals("/file", lr1UrlDeserialized.getFile());
+ assertEquals("hdfs", lr1UrlDeserialized.getScheme());
// With port
@@ -103,14 +110,15 @@ public void testYarnPathTranslation() {
String p2StringSerialized = DagTypeConverters.convertToDAGPlan(lr2Url);
// Deserialize
URL lr2UrlDeserialized = DagTypeConverters.convertToYarnURL(p2StringSerialized);
- Assert.assertEquals("mycluster", lr2UrlDeserialized.getHost());
- Assert.assertEquals("/file", lr2UrlDeserialized.getFile());
- Assert.assertEquals("hdfs", lr2UrlDeserialized.getScheme());
- Assert.assertEquals(2311, lr2UrlDeserialized.getPort());
+ assertEquals("mycluster", lr2UrlDeserialized.getHost());
+ assertEquals("/file", lr2UrlDeserialized.getFile());
+ assertEquals("hdfs", lr2UrlDeserialized.getScheme());
+ assertEquals(2311, lr2UrlDeserialized.getPort());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexExecutionContextTranslation() {
VertexExecutionContext originalContext;
VertexExecutionContextProto contextProto;
@@ -142,7 +150,8 @@ public void testVertexExecutionContextTranslation() {
static final String testComm = "testComm";
static final String classSuffix = "_class";
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testServiceDescriptorTranslation() {
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestEntityDescriptor.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestEntityDescriptor.java
index 366edde5a5..76bb5c1383 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestEntityDescriptor.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestEntityDescriptor.java
@@ -18,6 +18,9 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.spy;
@@ -28,25 +31,26 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.tez.common.TezUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestEntityDescriptor {
public void verifyResults(InputDescriptor entityDescriptor, InputDescriptor deserialized, UserPayload payload,
String confVal) throws IOException {
- Assert.assertEquals(entityDescriptor.getClassName(), deserialized.getClassName());
+ assertEquals(entityDescriptor.getClassName(), deserialized.getClassName());
// History text is not serialized when sending to tasks
- Assert.assertNull(deserialized.getHistoryText());
- Assert.assertArrayEquals(payload.deepCopyAsArray(), deserialized.getUserPayload().deepCopyAsArray());
+ assertNull(deserialized.getHistoryText());
+ assertArrayEquals(payload.deepCopyAsArray(), deserialized.getUserPayload().deepCopyAsArray());
Configuration deserializedConf = TezUtils.createConfFromUserPayload(deserialized.getUserPayload());
- Assert.assertEquals(confVal, deserializedConf.get("testKey"));
+ assertEquals(confVal, deserializedConf.get("testKey"));
}
public void testSingularWrite(InputDescriptor entityDescriptor, InputDescriptor deserialized, UserPayload payload,
@@ -74,7 +78,8 @@ public void testSegmentedWrite(InputDescriptor entityDescriptor, InputDescriptor
verifyResults(entityDescriptor, deserialized, payload, confVal);
}
- @Test (timeout=3000)
+ @Test
+ @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
public void testEntityDescriptorHadoopSerialization() throws IOException {
/* This tests the alternate serialization code path
* if the DataOutput is not DataOutputBuffer
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestHistoryLogLevel.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestHistoryLogLevel.java
index e73ca9079c..165d0bbcf2 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestHistoryLogLevel.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestHistoryLogLevel.java
@@ -18,15 +18,16 @@
*/
package org.apache.tez.dag.api;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
public class TestHistoryLogLevel {
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestTaskLocationHint.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestTaskLocationHint.java
index e2330beefb..a6ae02f1b1 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestTaskLocationHint.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestTaskLocationHint.java
@@ -18,14 +18,20 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import java.util.concurrent.TimeUnit;
+
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestTaskLocationHint {
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEquality() {
TaskLocationHint t1 = TaskLocationHint.createTaskLocationHint("v1", 0);
TaskLocationHint t2 = TaskLocationHint.createTaskLocationHint("v1", 0);
@@ -42,21 +48,21 @@ public void testEquality() {
TaskLocationHint t10 = TaskLocationHint.createTaskLocationHint(
Sets.newHashSet(new String[] {"n1"}), Sets.newHashSet(new String[] {"r1", "r2"}));
- Assert.assertEquals(t1, t2);
- Assert.assertEquals(t5, t6);
- Assert.assertEquals(t7, t8);
- Assert.assertEquals(t2, t1);
- Assert.assertEquals(t6, t5);
- Assert.assertEquals(t8, t7);
- Assert.assertNotEquals(t1, t3);
- Assert.assertNotEquals(t3, t1);
- Assert.assertNotEquals(t1, t4);
- Assert.assertNotEquals(t4, t1);
- Assert.assertNotEquals(t1, t5);
- Assert.assertNotEquals(t5, t1);
- Assert.assertNotEquals(t8, t9);
- Assert.assertNotEquals(t9, t8);
- Assert.assertNotEquals(t9, t10);
- Assert.assertNotEquals(t10, t9);
+ assertEquals(t1, t2);
+ assertEquals(t5, t6);
+ assertEquals(t7, t8);
+ assertEquals(t2, t1);
+ assertEquals(t6, t5);
+ assertEquals(t8, t7);
+ assertNotEquals(t1, t3);
+ assertNotEquals(t3, t1);
+ assertNotEquals(t1, t4);
+ assertNotEquals(t4, t1);
+ assertNotEquals(t1, t5);
+ assertNotEquals(t5, t1);
+ assertNotEquals(t8, t9);
+ assertNotEquals(t9, t8);
+ assertNotEquals(t9, t10);
+ assertNotEquals(t10, t9);
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestTezConfiguration.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestTezConfiguration.java
index a49fa3c86c..e5097ab57d 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/TestTezConfiguration.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/TestTezConfiguration.java
@@ -18,53 +18,60 @@
*/
package org.apache.tez.dag.api;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+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.fail;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestTezConfiguration {
private static final String expectedValue = "tez.tar.gz";
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConstruction() {
TezConfiguration tezConf1 = new TezConfiguration();
- Assert.assertEquals(expectedValue, tezConf1.get(TezConfiguration.TEZ_LIB_URIS));
+ assertEquals(expectedValue, tezConf1.get(TezConfiguration.TEZ_LIB_URIS));
Configuration tezConf2 = new Configuration(true);
- Assert.assertNull(tezConf2.get(TezConfiguration.TEZ_LIB_URIS));
+ assertNull(tezConf2.get(TezConfiguration.TEZ_LIB_URIS));
TezConfiguration tezConf3 = new TezConfiguration(new Configuration());
- Assert.assertEquals(expectedValue, tezConf3.get(TezConfiguration.TEZ_LIB_URIS));
+ assertEquals(expectedValue, tezConf3.get(TezConfiguration.TEZ_LIB_URIS));
TezConfiguration tezConf4 = new TezConfiguration(false);
- Assert.assertNull(tezConf4.get(TezConfiguration.TEZ_LIB_URIS));
+ assertNull(tezConf4.get(TezConfiguration.TEZ_LIB_URIS));
Configuration tezConf5 = new Configuration(true);
- Assert.assertNull(tezConf5.get(TezConfiguration.TEZ_LIB_URIS));
+ assertNull(tezConf5.get(TezConfiguration.TEZ_LIB_URIS));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testKeySet() throws IllegalAccessException {
Class> c = TezConfiguration.class;
Set expectedKeys = new HashSet();
for (Field f : c.getFields()) {
- if (!f.getName().endsWith("DEFAULT") && f.getType() == String.class
+ if (!f.getName().endsWith("DEFAULT")
+ && f.getType() == String.class
&& !f.getName().equals("TEZ_SITE_XML")) {
- String value = (String)f.get(null);
+ String value = (String) f.get(null);
// not prefix
if (!value.endsWith(".")) {
expectedKeys.add((String) f.get(null));
- Assert.assertNotNull("field " + f.getName() + " do not have annotation of ConfigurationScope.",
- f.getAnnotation(ConfigurationScope.class));
+ assertNotNull(
+ f.getAnnotation(ConfigurationScope.class),
+ "field " + f.getName() + " do not have annotation of ConfigurationScope.");
}
}
}
@@ -75,6 +82,6 @@ public void testKeySet() throws IllegalAccessException {
fail("Found unexpected key: " + key + " in key set");
}
}
- assertTrue("Missing keys in key set: " + expectedKeys, expectedKeys.size() == 0);
+ assertEquals(0, expectedKeys.size(), "Missing keys in key set: " + expectedKeys);
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestATSHttpClient.java b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestATSHttpClient.java
index 175c136a14..da47f17293 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestATSHttpClient.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestATSHttpClient.java
@@ -18,7 +18,10 @@
*/
package org.apache.tez.dag.api.client;
-import static junit.framework.TestCase.fail;
+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.junit.jupiter.api.Assumptions.assumeFalse;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -28,32 +31,34 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.tez.common.counters.TezCounters;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezException;
+import org.apache.tez.dag.api.client.DAGStatus.State;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestATSHttpClient {
- @Before
- public void setup() {
+ @BeforeAll
+ public static void setup() {
// Disable tests if hadoop version is less than 2.4.0
// as Timeline is not supported in 2.2.x or 2.3.x
// If enabled with the lower versions, tests fail due to incompatible use of an API
// YarnConfiguration::useHttps which only exists in versions 2.4 and higher
String hadoopVersion = System.getProperty("tez.hadoop.version");
- Assume.assumeFalse(hadoopVersion.startsWith("2.2.") || hadoopVersion.startsWith("2.3."));
+ assumeFalse(hadoopVersion.startsWith("2.2.") || hadoopVersion.startsWith("2.3."));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetDagStatusThrowsExceptionOnEmptyJson() throws TezException {
ApplicationId mockAppId = mock(ApplicationId.class);
DAGClientTimelineImpl httpClient = new DAGClientTimelineImpl(mockAppId, "EXAMPLE_DAG_ID",
@@ -73,11 +78,12 @@ public void testGetDagStatusThrowsExceptionOnEmptyJson() throws TezException {
fail("should not come here");
}
- Assert.assertTrue("Expected TezException but did not happen", exceptionHappened);
+ assertTrue(exceptionHappened, "Expected TezException but did not happen");
verify(spyClient).getJsonRootEntity(expectedDagUrl);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetDagStatusSimple() throws TezException, JSONException, IOException {
DAGClientTimelineImpl
httpClient = new DAGClientTimelineImpl(mock(ApplicationId.class),"EXAMPLE_DAG_ID",
@@ -119,25 +125,24 @@ public void testGetDagStatusSimple() throws TezException, JSONException, IOExcep
DAGStatus dagStatus = spyClient.getDAGStatus(statusOptions);
- Assert.assertEquals("DAG State", DAGStatus.State.SUCCEEDED, dagStatus.getState());
- Assert.assertEquals("DAG Diagnostics size", 1, dagStatus.getDiagnostics().size());
- Assert.assertEquals("DAG diagnostics detail", "SAMPLE_DIAGNOSTICS",
- dagStatus.getDiagnostics().get(0));
- Assert.assertEquals("Counters Size", 2, dagStatus.getDAGCounters().countCounters());
- Assert.assertEquals("Counter Value", 1,
- dagStatus.getDAGCounters().getGroup("CG1").findCounter("C1").getValue());
- Assert.assertEquals("total tasks", 15, dagStatus.getDAGProgress().getTotalTaskCount());
- Assert.assertEquals("failed tasks", 2, dagStatus.getDAGProgress().getFailedTaskCount());
- Assert.assertEquals("killed tasks", 6, dagStatus.getDAGProgress().getKilledTaskCount());
- Assert.assertEquals("succeeded tasks", 7, dagStatus.getDAGProgress().getSucceededTaskCount());
- Assert.assertEquals("running tasks", 8, dagStatus.getDAGProgress().getRunningTaskCount());
+ assertEquals(State.SUCCEEDED, dagStatus.getState(), "DAG State");
+ assertEquals(1, dagStatus.getDiagnostics().size(), "DAG Diagnostics size");
+ assertEquals("SAMPLE_DIAGNOSTICS", dagStatus.getDiagnostics().get(0), "DAG diagnostics detail");
+ assertEquals(2, dagStatus.getDAGCounters().countCounters(), "Counters Size");
+ assertEquals(1, dagStatus.getDAGCounters().getGroup("CG1").findCounter("C1").getValue(), "Counter Value");
+ assertEquals(15, dagStatus.getDAGProgress().getTotalTaskCount(), "total tasks");
+ assertEquals(2, dagStatus.getDAGProgress().getFailedTaskCount(), "failed tasks");
+ assertEquals(6, dagStatus.getDAGProgress().getKilledTaskCount(), "killed tasks");
+ assertEquals(7, dagStatus.getDAGProgress().getSucceededTaskCount(), "succeeded tasks");
+ assertEquals(8, dagStatus.getDAGProgress().getRunningTaskCount(), "running tasks");
final Map vertexProgress = dagStatus.getVertexProgress();
- Assert.assertEquals("vertex progress count", 2, vertexProgress.size());
- Assert.assertTrue("vertex name1", vertexProgress.containsKey("v1"));
- Assert.assertTrue("vertex name2", vertexProgress.containsKey("v2"));
+ assertEquals(2, vertexProgress.size(), "vertex progress count");
+ assertTrue(vertexProgress.containsKey("v1"), "vertex name1");
+ assertTrue(vertexProgress.containsKey("v2"), "vertex name2");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetVertexStatusSimple() throws JSONException, TezException, IOException {
DAGClientTimelineImpl
httpClient = new DAGClientTimelineImpl(mock(ApplicationId.class), "EXAMPLE_DAG_ID",
@@ -165,16 +170,15 @@ public void testGetVertexStatusSimple() throws JSONException, TezException, IOEx
doReturn(new JSONObject(jsonData)).when(spyClient).getJsonRootEntity(expectedVertexUrl);
VertexStatus vertexStatus = spyClient.getVertexStatus("vertex1name", statusOptions);
- Assert.assertEquals("status check", VertexStatus.State.SUCCEEDED, vertexStatus.getState());
- Assert.assertEquals("diagnostics", "diagnostics1", vertexStatus.getDiagnostics().get(0));
+ assertEquals(VertexStatus.State.SUCCEEDED, vertexStatus.getState(), "status check");
+ assertEquals("diagnostics1", vertexStatus.getDiagnostics().get(0), "diagnostics");
final Progress progress = vertexStatus.getProgress();
final TezCounters vertexCounters = vertexStatus.getVertexCounters();
- Assert.assertEquals("failed task count", 1, progress.getFailedTaskCount());
- Assert.assertEquals("suceeded task count", 2, progress.getSucceededTaskCount());
- Assert.assertEquals("killed task count", 3, progress.getKilledTaskCount());
- Assert.assertEquals("total task count", 4, progress.getTotalTaskCount());
- Assert.assertEquals("Counters Size", 2, vertexCounters.countCounters());
- Assert.assertEquals("Counter Value", 1,
- vertexCounters.getGroup("CG1").findCounter("C1").getValue());
+ assertEquals(1, progress.getFailedTaskCount(), "failed task count");
+ assertEquals(2, progress.getSucceededTaskCount(), "suceeded task count");
+ assertEquals(3, progress.getKilledTaskCount(), "killed task count");
+ assertEquals(4, progress.getTotalTaskCount(), "total task count");
+ assertEquals(2, vertexCounters.countCounters(), "Counters Size");
+ assertEquals(1, vertexCounters.getGroup("CG1").findCounter("C1").getValue(), "Counter Value");
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java
index 806eb2a2fe..5bb987300e 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java
@@ -17,11 +17,12 @@
* under the License.
*/
package org.apache.tez.dag.api.client;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import java.net.HttpURLConnection;
import java.net.URI;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
@@ -29,25 +30,28 @@
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.api.client.TimelineReaderFactory.TimelineReaderPseudoAuthenticatedStrategy;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestTimelineReaderFactory {
- // ensure TimelineReaderTokenAuthenticatedStrategy is used.
- @Test(timeout = 5000)
+ // ensure on hadoop 2.6+ TimelineReaderTokenAuthenticatedStrategy is used.
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testShouldUseTokenDelegationAuthStrategy() throws TezException {
String returnedClassName =
TimelineReaderFactory.getTimelineReaderStrategy(mock(Configuration.class), false, 0)
.getClass()
.getCanonicalName();
- Assert.assertEquals("should use token delegation auth",
+ assertEquals(
"org.apache.tez.dag.api.client.TimelineReaderFactory.TimelineReaderTokenAuthenticatedStrategy",
- returnedClassName);
+ returnedClassName,
+ "should use token delegation auth");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPseudoAuthenticatorConnectionUrlShouldHaveUserName() throws Exception {
ConnectionConfigurator connConf = mock(ConnectionConfigurator.class);
TimelineReaderPseudoAuthenticatedStrategy.PseudoAuthenticatedURLConnectionFactory
@@ -56,7 +60,7 @@ public void testPseudoAuthenticatorConnectionUrlShouldHaveUserName() throws Exce
String inputUrl = "http://host:8080/path";
String expectedUrl = inputUrl + "?user.name=" + UserGroupInformation.getCurrentUser().getShortUserName();
HttpURLConnection httpURLConnection = connectionFactory.getConnection(URI.create(inputUrl).toURL());
- Assert.assertEquals(expectedUrl, httpURLConnection.getURL().toString());
+ assertEquals(expectedUrl, httpURLConnection.getURL().toString());
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClient.java b/tez-api/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClient.java
index 168fdc0939..20af2f984b 100644
--- a/tez-api/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClient.java
+++ b/tez-api/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClient.java
@@ -18,8 +18,14 @@
*/
package org.apache.tez.dag.api.client.rpc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.doAnswer;
@@ -34,6 +40,7 @@
import java.lang.reflect.Field;
import java.util.EnumSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;
@@ -77,9 +84,9 @@
import com.google.protobuf.RpcController;
import com.google.protobuf.ServiceException;
-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 org.junit.jupiter.api.Timeout;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.internal.util.collections.Sets;
@@ -187,7 +194,7 @@ public boolean matches(GetVertexStatusRequestProto requestProto) {
}
}
- @Before
+ @BeforeEach
public void setUp() throws YarnException, IOException, TezException, ServiceException{
setUpData();
@@ -216,7 +223,8 @@ public void setUp() throws YarnException, IOException, TezException, ServiceExce
realClient.proxy = mockProxy;
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testApp() throws IOException, TezException, ServiceException{
assertTrue(dagClient.getExecutionContext().contains(mockAppId.toString()));
assertEquals(mockAppId.toString(), dagClient.getSessionIdentifierString());
@@ -225,7 +233,8 @@ public void testApp() throws IOException, TezException, ServiceException{
assertEquals(mockAppReport, realClient.getApplicationReportInternal());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGStatus() throws Exception{
DAGStatus resultDagStatus = dagClient.getDAGStatus(null);
verify(mockProxy, times(1)).getDAGStatus(null, GetDAGStatusRequestProto.newBuilder()
@@ -240,7 +249,8 @@ public void testDAGStatus() throws Exception{
System.out.println("DAGStatusWithCounter:" + resultDagStatus);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexStatus() throws Exception{
VertexStatus resultVertexStatus = dagClient.getVertexStatus("v1", null);
verify(mockProxy).getVertexStatus(null, GetVertexStatusRequestProto.newBuilder()
@@ -256,14 +266,16 @@ public void testVertexStatus() throws Exception{
System.out.println("VertexWithCounter:" + resultVertexStatus);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTryKillDAG() throws Exception{
dagClient.tryKillDAG();
verify(mockProxy, times(1)).tryKillDAG(null, TryKillDAGRequestProto.newBuilder()
.setDagId(dagIdStr).build());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitForCompletion() throws Exception{
// first time return DAG_RUNNING, second time return DAG_SUCCEEDED
when(mockProxy.getDAGStatus(isNull(), any()))
@@ -283,7 +295,8 @@ public void testWaitForCompletion() throws Exception{
.getDAGStatus(rpcControllerArgumentCaptor.capture(), argumentCaptor.capture());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitForCompletionWithStatusUpdates() throws Exception{
// first time and second time return DAG_RUNNING, third time return DAG_SUCCEEDED
@@ -338,7 +351,8 @@ public void testWaitForCompletionWithStatusUpdates() throws Exception{
.getDAGStatus(rpcControllerArgumentCaptor.capture(), argumentCaptor.capture());
}
- @Test(timeout = 50000)
+ @Test
+ @Timeout(value = 50000, unit = TimeUnit.MILLISECONDS)
public void testGetDagStatusWithTimeout() throws Exception {
long startTime;
long endTime;
@@ -412,7 +426,8 @@ public void testGetDagStatusWithTimeout() throws Exception {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDagClientTimelineEnabledCondition() throws IOException {
String historyLoggingClass = "org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService";
@@ -591,7 +606,7 @@ public void testTimelineClientCleanup() throws Exception {
reloaderThread = thread;
}
}
- Assert.assertTrue("Reloader is not alive", reloaderThread.isAlive());
+ assertTrue(reloaderThread.isAlive(), "Reloader is not alive");
dagClient.close();
boolean reloaderStillAlive = true;
@@ -602,10 +617,11 @@ public void testTimelineClientCleanup() throws Exception {
}
Thread.sleep(1000);
}
- Assert.assertFalse("Reloader is still alive", reloaderStillAlive);
+ assertFalse(reloaderStillAlive, "Reloader is still alive");
}
- @Test(timeout = 50000)
+ @Test
+ @Timeout(value = 50000, unit = TimeUnit.MILLISECONDS)
public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
long startTime;
long endTime;
@@ -625,8 +641,8 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
// Fetch from AM. RUNNING
rmDagStatus =
- new DAGStatus(constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING),
- DagStatusSource.RM);
+ new DAGStatus(
+ constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING), DagStatusSource.RM);
dagClientImpl.setRmDagStatus(rmDagStatus);
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_RUNNING, -1));
@@ -639,14 +655,14 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
assertEquals(0, dagClientImpl.numGetStatusViaRmInvocations);
// Directly from AM - one refresh. One with timeout.
assertEquals(2, dagClientRpc.numGetStatusViaAmInvocations);
- assertEquals(DAGStatus.State.RUNNING, dagStatus.getState());
+ assertEquals(State.RUNNING, dagStatus.getState());
// Fetch from AM. Success.
dagClientImpl.resetCounters();
dagClientRpc.resetCounters();
rmDagStatus =
- new DAGStatus(constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING),
- DagStatusSource.RM);
+ new DAGStatus(
+ constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING), DagStatusSource.RM);
dagClientImpl.setRmDagStatus(rmDagStatus);
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_SUCCEEDED, 1000L));
@@ -654,17 +670,17 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
dagStatus = dagClientImpl.getDAGStatus(EnumSet.noneOf(StatusGetOpts.class), 2000L);
endTime = System.currentTimeMillis();
diff = endTime - startTime;
- assertTrue("diff is " + diff, diff > 500L && diff < 1500L);
+ assertTrue(diff > 500L && diff < 1500L, "diff is " + diff);
// Directly from AM
assertEquals(0, dagClientImpl.numGetStatusViaRmInvocations);
// Directly from AM - previous request cached, so single invocation only.
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
- assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
+ assertEquals(State.SUCCEEDED, dagStatus.getState());
// verify that the cachedDAGStatus is correct
DAGStatus cachedDagStatus = dagClientImpl.getCachedDAGStatus();
- Assert.assertNotNull(cachedDagStatus);
- Assert.assertSame(dagStatus, cachedDagStatus);
+ assertNotNull(cachedDagStatus);
+ assertSame(dagStatus, cachedDagStatus);
// When AM proxy throws an exception, the cachedDAGStatus should be returned
dagClientImpl.resetCounters();
@@ -675,8 +691,8 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
assertEquals(0, dagClientImpl.numGetStatusViaRmInvocations);
// Directly from AM - previous request cached, so single invocation only.
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
- assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
- Assert.assertSame(dagStatus, cachedDagStatus);
+ assertEquals(State.SUCCEEDED, dagStatus.getState());
+ assertSame(dagStatus, cachedDagStatus);
// test that RM is invoked when the cacheExpires and the AM fails.
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_SUCCEEDED, 1000L));
@@ -689,13 +705,13 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
assertEquals(1, dagClientImpl.numGetStatusViaRmInvocations);
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
assertEquals(State.RUNNING, dagStatus.getState());
- Assert.assertNotSame(dagStatus, cachedDagStatus);
+ assertNotSame(dagStatus, cachedDagStatus);
// verify that the cachedDAGStatus is null because AM threw exception before setting the
// cache.
cachedDagStatus = dagClientImpl.getCachedDAGStatus();
- Assert.assertNull(cachedDagStatus);
- Assert.assertNotNull(dagStatus);
+ assertNull(cachedDagStatus);
+ assertNotNull(dagStatus);
// inject fault in RM too. getDAGStatus should return null;
dagClientImpl.resetCounters();
@@ -704,9 +720,9 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
dagClientImpl.injectFault();
try {
dagClientImpl.getDAGStatus(EnumSet.noneOf(StatusGetOpts.class));
- Assert.fail("The RM should throw IOException");
+ fail("The RM should throw IOException");
} catch (IOException ioException) {
- Assert.assertEquals(ioException.getMessage(), "Fault Injected for RM");
+ assertEquals(ioException.getMessage(), "Fault Injected for RM");
assertEquals(1, dagClientImpl.numGetStatusViaRmInvocations);
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
}
diff --git a/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestCompositeDataMovementEvent.java b/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestCompositeDataMovementEvent.java
index 23f94c956f..b8efafaeff 100644
--- a/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestCompositeDataMovementEvent.java
+++ b/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestCompositeDataMovementEvent.java
@@ -18,25 +18,30 @@
*/
package org.apache.tez.runtime.api.events;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.nio.ByteBuffer;
+import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestCompositeDataMovementEvent {
ByteBuffer userPayload = ByteBuffer.wrap("Dummy userPayLoad".getBytes());
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetCount(){
int numPartitions = 2;
int startIndex = 2;
CompositeDataMovementEvent cdme1 =
CompositeDataMovementEvent.create(startIndex, numPartitions, userPayload);
- Assert.assertEquals(numPartitions, cdme1.getCount());
- Assert.assertEquals(startIndex, cdme1.getSourceIndexStart());
+ assertEquals(numPartitions, cdme1.getCount());
+ assertEquals(startIndex, cdme1.getSourceIndexStart());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetEvents(){
int numOutputs = 0;
int startIndex = 1;
@@ -45,7 +50,7 @@ public void testGetEvents(){
for(DataMovementEvent dme: cdme2.getEvents()){
numOutputs++;
}
- Assert.assertEquals(numOutputs, cdme2.getCount());
+ assertEquals(numOutputs, cdme2.getCount());
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestInputDataInformationEvent.java b/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestInputDataInformationEvent.java
index 63f9e11796..b71e362977 100644
--- a/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestInputDataInformationEvent.java
+++ b/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestInputDataInformationEvent.java
@@ -18,11 +18,13 @@
*/
package org.apache.tez.runtime.api.events;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestInputDataInformationEvent {
@@ -32,24 +34,24 @@ public void testApiPayloadOrPath() {
InputDataInformationEvent.createWithSerializedPayload(0, ByteBuffer.wrap("payload1".getBytes()));
// event created by createWithSerializedPayload should contain serialized payload
// but not a path or a deserialized payload
- Assert.assertEquals(
+ assertEquals(
"payload1",
StandardCharsets.UTF_8.decode(eventWithSerializedPayload.getUserPayload()).toString());
- Assert.assertNull(eventWithSerializedPayload.getSerializedPath());
- Assert.assertNull(eventWithSerializedPayload.getDeserializedUserPayload());
+ assertNull(eventWithSerializedPayload.getSerializedPath());
+ assertNull(eventWithSerializedPayload.getDeserializedUserPayload());
InputDataInformationEvent eventWithObjectPayload = InputDataInformationEvent.createWithObjectPayload(0, "payload2");
// event created by eventWithObjectPayload should contain a deserialized payload
// but not a path or serialized payload
- Assert.assertEquals("payload2", eventWithObjectPayload.getDeserializedUserPayload());
- Assert.assertNull(eventWithObjectPayload.getSerializedPath());
- Assert.assertNull(eventWithObjectPayload.getUserPayload());
+ assertEquals("payload2", eventWithObjectPayload.getDeserializedUserPayload());
+ assertNull(eventWithObjectPayload.getSerializedPath());
+ assertNull(eventWithObjectPayload.getUserPayload());
InputDataInformationEvent eventWithPath = InputDataInformationEvent.createWithSerializedPath(0, "file://hello");
// event created by createWithSerializedPath should contain a path
// but neither serialized nor deserialized payload
- Assert.assertEquals("file://hello", eventWithPath.getSerializedPath());
- Assert.assertNull(eventWithPath.getUserPayload());
- Assert.assertNull(eventWithPath.getDeserializedUserPayload());
+ assertEquals("file://hello", eventWithPath.getSerializedPath());
+ assertNull(eventWithPath.getUserPayload());
+ assertNull(eventWithPath.getDeserializedUserPayload());
}
}
diff --git a/tez-common/pom.xml b/tez-common/pom.xml
index 700100df70..bce5be4cf3 100644
--- a/tez-common/pom.xml
+++ b/tez-common/pom.xml
@@ -71,9 +71,8 @@
test
- junit
- junit
- test
+ org.junit.jupiter
+ junit-jupiter
diff --git a/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java b/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java
index 2068490358..4cae6bb934 100644
--- a/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java
+++ b/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java
@@ -30,6 +30,7 @@
import org.apache.hadoop.net.DNSToSwitchMapping;
import org.apache.hadoop.yarn.util.RackResolver;
+
/**
* Mock RackResolver
* Overrides CachedDNSToSwitchMapping to ensure that it does not try to resolve hostnames
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcher.java b/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcher.java
index f9cbd7a2f1..e95646866b 100644
--- a/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcher.java
+++ b/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcher.java
@@ -18,14 +18,18 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.event.AbstractEvent;
import org.apache.hadoop.yarn.event.EventHandler;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestAsyncDispatcher {
@@ -79,7 +83,8 @@ public void handle(TestEvent3 event) {
}
@SuppressWarnings("unchecked")
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasic() throws Exception {
CountDownLatch latch = new CountDownLatch(4);
CountDownEventHandler.latch = latch;
@@ -99,15 +104,16 @@ public void testBasic() throws Exception {
central.close();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleRegisterFail() throws Exception {
AsyncDispatcher central = new AsyncDispatcher("Type1");
try {
central.register(TestEventType1.class, new TestEventHandler1());
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
+ assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
} finally {
central.close();
}
@@ -116,9 +122,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
central.register(TestEventType1.class, new TestEventHandler1());
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
+ assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
} finally {
central.close();
}
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcherConcurrent.java b/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcherConcurrent.java
index 89f346bdca..fc8b3ac7f2 100644
--- a/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcherConcurrent.java
+++ b/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcherConcurrent.java
@@ -18,13 +18,17 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.event.EventHandler;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
@SuppressWarnings("unchecked")
public class TestAsyncDispatcherConcurrent {
@@ -94,7 +98,8 @@ public void handle(TestEvent3 event) {
}
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasic() throws Exception {
CountDownLatch latch = new CountDownLatch(4);
CountDownEventHandler.init(latch);
@@ -115,7 +120,8 @@ public void testBasic() throws Exception {
central.close();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultiThreads() throws Exception {
CountDownLatch latch = new CountDownLatch(4);
CountDownEventHandler.init(latch);
@@ -134,15 +140,16 @@ public void testMultiThreads() throws Exception {
central.close();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleRegisterFail() throws Exception {
AsyncDispatcher central = new AsyncDispatcher("Type1");
try {
central.register(TestEventType1.class, new TestEventHandler1());
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
+ assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
} finally {
central.close();
}
@@ -151,9 +158,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
central.register(TestEventType1.class, new TestEventHandler1());
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
+ assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
} finally {
central.close();
}
@@ -162,9 +169,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
+ assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
} finally {
central.close();
}
@@ -173,9 +180,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
+ assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
} finally {
central.close();
}
@@ -186,9 +193,9 @@ public void testMultipleRegisterFail() throws Exception {
TestEventType1.class, new TestEventHandler2(), "Type2", 1);
central.registerWithExistingDispatcher(TestEventType1.class, new TestEventHandler1(),
concDispatcher);
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
+ assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
} finally {
central.close();
}
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestTezSharedExecutor.java b/tez-common/src/test/java/org/apache/tez/common/TestTezSharedExecutor.java
index 35b814d93d..4475254762 100644
--- a/tez-common/src/test/java/org/apache/tez/common/TestTezSharedExecutor.java
+++ b/tez-common/src/test/java/org/apache/tez/common/TestTezSharedExecutor.java
@@ -18,6 +18,11 @@
*/
package org.apache.tez.common;
+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 java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -34,10 +39,10 @@
import org.apache.hadoop.conf.Configuration;
-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 org.junit.jupiter.api.Timeout;
public class TestTezSharedExecutor {
@@ -113,18 +118,19 @@ public void run() {
private TezSharedExecutor sharedExecutor;
- @Before
+ @BeforeEach
public void setup() {
sharedExecutor = new TezSharedExecutor(new Configuration());
}
- @After
+ @AfterEach
public void cleanup() {
sharedExecutor.shutdownNow();
sharedExecutor = null;
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSimpleExecution() throws Exception {
ConcurrentHashMap map = new ConcurrentHashMap<>();
@@ -132,13 +138,13 @@ public void testSimpleExecution() throws Exception {
// Test runnable
service.submit(new Counter(map, "test")).get();
- Assert.assertEquals(1, map.get("test").get());
+ assertEquals(1, map.get("test").get());
// Test runnable with a result
final Object expected = new Object();
Object val = service.submit(new Counter(map, "test"), expected).get();
- Assert.assertEquals(expected, val);
- Assert.assertEquals(2, map.get("test").get());
+ assertEquals(expected, val);
+ assertEquals(2, map.get("test").get());
// Test callable.
val = service.submit(new Callable