You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by ab...@apache.org on 2026/07/02 07:21:38 UTC
(tez) branch master updated: TEZ-4719: Move to Junit6 (#502) (Raghav Aggarwal reviewed by Laszlo Bodor)
This is an automated email from the ASF dual-hosted git repository.
abstractdog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tez.git
The following commit(s) were added to refs/heads/master by this push:
new d53e67d73 TEZ-4719: Move to Junit6 (#502) (Raghav Aggarwal reviewed by Laszlo Bodor)
d53e67d73 is described below
commit d53e67d73bbffa52d9c18bf016426b0d59365692
Author: Raghav Aggarwal <ra...@gmail.com>
AuthorDate: Thu Jul 2 12:51:32 2026 +0530
TEZ-4719: Move to Junit6 (#502) (Raghav Aggarwal reviewed by Laszlo Bodor)
---
.codespellrc | 21 +
hadoop-shim/pom.xml | 4 +-
.../tez/hadoop/shim/TestHadoopShimsLoader.java | 24 +-
pom.xml | 33 +-
tez-api/pom.xml | 4 +-
.../java/org/apache/tez/client/TestTezClient.java | 150 +-
.../org/apache/tez/client/TestTezClientUtils.java | 290 ++--
.../apache/tez/client/registry/TestAMRecord.java | 20 +-
.../client/registry/zookeeper/TestZkConfig.java | 27 +-
.../registry/zookeeper/TestZkFrameworkClient.java | 66 +-
.../org/apache/tez/common/TestJavaOptsChecker.java | 38 +-
.../java/org/apache/tez/common/TestRPCUtil.java | 34 +-
.../org/apache/tez/common/TestReflectionUtils.java | 33 +-
.../org/apache/tez/common/TestTezCommonUtils.java | 161 ++-
.../org/apache/tez/common/TestTezYARNUtils.java | 95 +-
.../org/apache/tez/common/TestVersionInfo.java | 44 +-
.../security/TestACLConfigurationParser.java | 173 +--
.../apache/tez/common/security/TestACLManager.java | 363 ++---
.../tez/common/security/TestDAGAccessControls.java | 37 +-
.../apache/tez/common/security/TestTokenCache.java | 26 +-
.../test/java/org/apache/tez/dag/api/TestDAG.java | 142 +-
.../java/org/apache/tez/dag/api/TestDAGPlan.java | 62 +-
.../java/org/apache/tez/dag/api/TestDAGVerify.java | 310 ++--
.../apache/tez/dag/api/TestDagTypeConverters.java | 55 +-
.../apache/tez/dag/api/TestEntityDescriptor.java | 19 +-
.../apache/tez/dag/api/TestHistoryLogLevel.java | 13 +-
.../apache/tez/dag/api/TestTaskLocationHint.java | 44 +-
.../apache/tez/dag/api/TestTezConfiguration.java | 38 +-
.../tez/dag/api/client/TestATSHttpClient.java | 76 +-
.../dag/api/client/TestTimelineReaderFactory.java | 22 +-
.../tez/dag/api/client/rpc/TestDAGClient.java | 82 +-
.../api/events/TestCompositeDataMovementEvent.java | 19 +-
.../api/events/TestInputDataInformationEvent.java | 24 +-
tez-common/pom.xml | 5 +-
.../org/apache/tez/common/TestAsyncDispatcher.java | 22 +-
.../tez/common/TestAsyncDispatcherConcurrent.java | 37 +-
.../apache/tez/common/TestTezSharedExecutor.java | 63 +-
.../java/org/apache/tez/common/TestTezUtils.java | 173 ++-
.../org/apache/tez/dag/records/TestTezIds.java | 66 +-
.../java/org/apache/tez/util/TestNumberFormat.java | 14 +-
.../java/org/apache/tez/util/TestStopWatch.java | 22 +-
.../tez/util/TestTezMxBeanResourceCalculator.java | 33 +-
tez-dag/pom.xml | 7 +-
.../registry/zookeeper/TestZkAMRegistryClient.java | 63 +-
.../tez/dag/api/client/TestDAGClientHandler.java | 19 +-
.../tez/dag/api/client/TestDAGClientServer.java | 11 +-
.../dag/api/client/TestVertexStatusBuilder.java | 13 +-
.../registry/zookeeper/TestZkAMRegistry.java | 41 +-
...estDAGClientAMProtocolBlockingPBServerImpl.java | 26 +-
.../tez/dag/app/PluginWrapperTestHelpers.java | 10 +-
.../org/apache/tez/dag/app/TestDAGAppMaster.java | 109 +-
.../apache/tez/dag/app/TestMemoryWithEvents.java | 30 +-
.../apache/tez/dag/app/TestMockDAGAppMaster.java | 325 +++--
.../org/apache/tez/dag/app/TestPreemption.java | 23 +-
.../org/apache/tez/dag/app/TestRecoveryParser.java | 80 +-
.../org/apache/tez/dag/app/TestSpeculation.java | 459 +++---
.../dag/app/TestTaskCommunicatorContextImpl.java | 23 +-
.../tez/dag/app/TestTaskCommunicatorManager.java | 49 +-
.../tez/dag/app/TestTaskCommunicatorManager1.java | 83 +-
.../tez/dag/app/TestTaskCommunicatorManager2.java | 30 +-
.../tez/dag/app/TestTaskCommunicatorWrapper.java | 8 +-
.../app/dag/TestRootInputInitializerManager.java | 15 +-
.../tez/dag/app/dag/TestStateChangeNotifier.java | 26 +-
.../dag/app/TestTezTaskCommunicatorManager.java | 9 +-
.../apache/tez/dag/app/dag/impl/TestCommit.java | 809 ++++++-----
.../apache/tez/dag/app/dag/impl/TestDAGImpl.java | 549 +++----
.../tez/dag/app/dag/impl/TestDAGRecovery.java | 91 +-
.../tez/dag/app/dag/impl/TestDAGScheduler.java | 75 +-
.../TestDAGSchedulerNaturalOrderControlled.java | 18 +-
.../org/apache/tez/dag/app/dag/impl/TestEdge.java | 74 +-
.../dag/impl/TestImmediateStartVertexManager.java | 13 +-
.../app/dag/impl/TestRootInputVertexManager.java | 225 +--
.../tez/dag/app/dag/impl/TestTaskAttempt.java | 311 ++--
.../apache/tez/dag/app/dag/impl/TestTaskImpl.java | 234 +--
.../tez/dag/app/dag/impl/TestVertexImpl.java | 1528 +++++++++++---------
.../tez/dag/app/dag/impl/TestVertexImpl2.java | 41 +-
.../tez/dag/app/dag/impl/TestVertexManager.java | 31 +-
.../tez/dag/app/dag/impl/TestVertexStats.java | 204 +--
.../dag/speculation/legacy/TestDataStatistics.java | 62 +-
.../app/launcher/TestContainerLauncherManager.java | 50 +-
.../app/launcher/TestContainerLauncherWrapper.java | 8 +-
.../tez/dag/app/launcher/TestDeletionTracker.java | 21 +-
.../dag/app/launcher/TestTezLocalCacheManager.java | 45 +-
.../apache/tez/dag/app/rm/TestContainerReuse.java | 49 +-
.../dag/app/rm/TestDagAwareYarnTaskScheduler.java | 55 +-
.../tez/dag/app/rm/TestLocalTaskScheduler.java | 30 +-
.../dag/app/rm/TestLocalTaskSchedulerService.java | 58 +-
.../apache/tez/dag/app/rm/TestTaskScheduler.java | 255 ++--
.../tez/dag/app/rm/TestTaskSchedulerHelpers.java | 3 +-
.../tez/dag/app/rm/TestTaskSchedulerManager.java | 118 +-
.../tez/dag/app/rm/TestTaskSchedulerWrapper.java | 8 +-
.../apache/tez/dag/app/rm/TestTezAMRMClient.java | 33 +-
.../tez/dag/app/rm/container/TestAMContainer.java | 127 +-
.../dag/app/rm/container/TestAMContainerMap.java | 12 +-
.../tez/dag/app/rm/node/TestAMNodeTracker.java | 72 +-
.../tez/dag/app/web/TestAMWebController.java | 221 +--
.../tez/dag/history/TestHistoryEventHandler.java | 14 +-
.../tez/dag/history/TestHistoryEventType.java | 10 +-
.../events/TestHistoryEventsProtoConversion.java | 392 ++---
.../impl/TestHistoryEventJsonConversion.java | 59 +-
.../dag/history/recovery/TestRecoveryService.java | 37 +-
.../apache/tez/dag/history/utils/TestDAGUtils.java | 108 +-
.../utils/TestSimple2LevelVersionComparator.java | 67 +-
.../dag/utils/TestTaskSpecificLaunchCmdOption.java | 36 +-
tez-examples/pom.xml | 5 -
tez-ext-service-tests/pom.xml | 7 +-
.../tez/dag/app/TezTestServiceCommunicator.java | 1 -
...zTestServiceTaskSchedulerServiceWithErrors.java | 1 +
.../tez/examples/JoinValidateConfigured.java | 1 -
.../org/apache/tez/service/ContainerRunner.java | 1 -
.../impl/TezTestServiceProtocolClientImpl.java | 1 -
.../tez/tests/ExternalTezServiceTestHelper.java | 2 +-
.../tez/tests/TestExtServicesWithLocalMode.java | 17 +-
.../apache/tez/tests/TestExternalTezServices.java | 47 +-
.../tez/tests/TestExternalTezServicesErrors.java | 37 +-
tez-mapreduce/pom.xml | 5 +-
.../hadoop/mapred/split/TestGroupedSplits.java | 87 +-
.../tez/mapreduce/combine/TestMRCombiner.java | 4 +-
.../common/TestMRInputAMSplitGenerator.java | 36 +-
.../common/TestMRInputSplitDistributor.java | 38 +-
.../hadoop/TestConfigTranslationMRToTez.java | 15 +-
.../tez/mapreduce/hadoop/TestDeprecatedKeys.java | 56 +-
.../apache/tez/mapreduce/hadoop/TestMRHelpers.java | 135 +-
.../tez/mapreduce/hadoop/TestMRInputHelpers.java | 96 +-
.../apache/tez/mapreduce/input/TestMRInput.java | 24 +-
.../tez/mapreduce/input/TestMultiMRInput.java | 36 +-
.../tez/mapreduce/lib/TestKVReadersWithMR.java | 23 +-
.../apache/tez/mapreduce/output/TestMROutput.java | 61 +-
.../output/TestMROutputConfigBuilder.java | 21 +-
.../tez/mapreduce/output/TestMROutputLegacy.java | 32 +-
.../tez/mapreduce/output/TestMultiMROutput.java | 41 +-
.../mapreduce/processor/map/TestMapProcessor.java | 20 +-
.../processor/reduce/TestReduceProcessor.java | 30 +-
tez-plugins/tez-aux-services/pom.xml | 7 +-
.../org/apache/tez/auxservices/TestIndexCache.java | 12 +-
.../apache/tez/auxservices/TestShuffleHandler.java | 244 ++--
.../tez/auxservices/TestShuffleHandlerJobs.java | 28 +-
tez-plugins/tez-history-parser/pom.xml | 15 +-
.../org/apache/tez/history/TestHistoryParser.java | 255 ++--
tez-plugins/tez-protobuf-history-plugin/pom.xml | 5 +-
.../logging/proto/TestDagManifestFileScanner.java | 46 +-
.../proto/TestHistoryEventProtoConverter.java | 140 +-
.../proto/TestProtoHistoryLoggingService.java | 104 +-
tez-plugins/tez-yarn-timeline-cache-plugin/pom.xml | 5 +-
.../logging/ats/TestTimelineCachePluginImpl.java | 127 +-
.../tez-yarn-timeline-history-with-acls/pom.xml | 15 +-
.../history/ats/acls/TestATSHistoryWithACLs.java | 42 +-
.../tez-yarn-timeline-history-with-fs/pom.xml | 10 +-
.../dag/history/ats/acls/TestATSHistoryV15.java | 36 +-
.../ats/TestATSV15HistoryLoggingService.java | 23 +-
tez-plugins/tez-yarn-timeline-history/pom.xml | 10 +-
.../logging/ats/TestATSHistoryLoggingService.java | 70 +-
.../logging/ats/TestATSHistoryWithMiniCluster.java | 28 +-
.../ats/TestHistoryEventTimelineConversion.java | 1052 ++++++--------
tez-runtime-internals/pom.xml | 6 +-
.../apache/tez/runtime/TestInputReadyTracker.java | 21 +-
.../runtime/TestLogicalIOProcessorRuntimeTask.java | 32 +-
.../tez/runtime/api/impl/TestProcessorContext.java | 14 +-
.../apache/tez/runtime/api/impl/TestTaskSpec.java | 33 +-
.../apache/tez/runtime/api/impl/TestTezEvent.java | 35 +-
.../common/objectregistry/TestObjectRegistry.java | 49 +-
.../common/resources/TestMemoryDistributor.java | 28 +-
.../metrics/TestFileSystemStatisticUpdater.java | 22 +-
.../runtime/metrics/TestTaskCounterUpdater.java | 13 +-
.../tez/runtime/task/TaskExecutionTestHelpers.java | 8 +-
.../tez/runtime/task/TestContainerExecution.java | 9 +-
.../tez/runtime/task/TestTaskExecution2.java | 68 +-
.../apache/tez/runtime/task/TestTaskReporter.java | 53 +-
.../tez/runtime/task/TestTezTaskRunner2.java | 15 +-
tez-runtime-library/pom.xml | 4 +-
.../TestFairShuffleVertexManager.java | 125 +-
.../vertexmanager/TestInputReadyVertexManager.java | 83 +-
.../vertexmanager/TestShuffleVertexManager.java | 131 +-
.../TestShuffleVertexManagerBase.java | 669 ++++-----
.../TestShuffleVertexManagerUtils.java | 1 -
.../TestVertexManagerWithConcurrentInput.java | 15 +-
.../org/apache/tez/http/TestHttpConnection.java | 45 +-
.../TestWeightedScalingMemoryDistributor.java | 24 +-
.../library/api/TestTezRuntimeConfiguration.java | 15 +-
.../TestCartesianProductCombination.java | 35 +-
.../TestCartesianProductConfig.java | 25 +-
.../TestCartesianProductEdgeManager.java | 15 +-
...TestCartesianProductEdgeManagerPartitioned.java | 25 +-
.../TestCartesianProductVertexManager.java | 52 +-
...stCartesianProductVertexManagerPartitioned.java | 24 +-
.../TestFairCartesianProductEdgeManager.java | 32 +-
.../TestFairCartesianProductVertexManager.java | 56 +-
.../library/cartesianproduct/TestGrouper.java | 23 +-
.../runtime/library/common/TestConfigUtils.java | 5 +-
.../library/common/TestInputIdentifiers.java | 40 +-
.../runtime/library/common/TestValuesIterator.java | 114 +-
.../common/comparator/TestProxyComparator.java | 23 +-
.../common/readers/TestUnorderedKVReader.java | 28 +-
.../library/common/shuffle/TestFetcher.java | 64 +-
.../library/common/shuffle/TestShuffleUtils.java | 133 +-
.../impl/TestShuffleInputEventHandlerImpl.java | 36 +-
.../common/shuffle/impl/TestShuffleManager.java | 71 +-
.../impl/TestSimpleFetchedInputAllocator.java | 14 +-
.../common/shuffle/orderedgrouped/TestFetcher.java | 47 +-
.../shuffle/orderedgrouped/TestMergeManager.java | 98 +-
.../common/shuffle/orderedgrouped/TestShuffle.java | 26 +-
...TestShuffleInputEventHandlerOrderedGrouped.java | 74 +-
.../orderedgrouped/TestShuffleScheduler.java | 78 +-
.../library/common/sort/impl/TestIFile.java | 147 +-
.../common/sort/impl/TestPipelinedSorter.java | 190 ++-
.../library/common/sort/impl/TestTezMerger.java | 72 +-
.../common/sort/impl/dflt/TestDefaultSorter.java | 126 +-
.../writers/TestUnorderedPartitionedKVWriter.java | 454 ++++--
.../TestOrderedGroupedMergedKVInputConfig.java | 33 +-
.../conf/TestOrderedPartitionedKVEdgeConfig.java | 107 +-
.../conf/TestOrderedPartitionedKVOutputConfig.java | 34 +-
.../library/conf/TestUnorderedKVEdgeConfig.java | 38 +-
.../library/conf/TestUnorderedKVInputConfig.java | 28 +-
.../library/conf/TestUnorderedKVOutputConfig.java | 28 +-
.../conf/TestUnorderedPartitionedKVEdgeConfig.java | 38 +-
.../TestUnorderedPartitionedKVOutputConfig.java | 61 +-
.../library/input/TestOrderedGroupedKVInput.java | 22 +-
.../input/TestSortedGroupedMergedInput.java | 42 +-
.../library/output/TestOnFileSortedOutput.java | 162 ++-
.../output/TestOnFileUnorderedKVOutput.java | 31 +-
.../output/TestOrderedPartitionedKVOutput2.java | 30 +-
.../library/output/TestUnorderedKVOutput2.java | 32 +-
.../output/TestUnorderedPartitionedKVOutput2.java | 14 +-
.../tez/runtime/library/utils/TestCodecUtils.java | 33 +-
tez-tests/pom.xml | 8 +-
.../java/org/apache/tez/mapreduce/TestMRRJobs.java | 90 +-
.../apache/tez/mapreduce/TestMRRJobsDAGApi.java | 138 +-
.../src/test/java/org/apache/tez/test/TestAM.java | 29 +-
.../java/org/apache/tez/test/TestAMRecovery.java | 51 +-
.../test/TestAMRecoveryAggregationBroadcast.java | 38 +-
.../java/org/apache/tez/test/TestDAGRecovery.java | 31 +-
.../java/org/apache/tez/test/TestDAGRecovery2.java | 31 +-
.../apache/tez/test/TestExceptionPropagation.java | 13 +-
.../org/apache/tez/test/TestFaultTolerance.java | 108 +-
.../java/org/apache/tez/test/TestLocalMode.java | 133 +-
.../org/apache/tez/test/TestMiniTezCluster.java | 13 +-
.../org/apache/tez/test/TestPipelinedShuffle.java | 24 +-
.../java/org/apache/tez/test/TestRecovery.java | 47 +-
.../org/apache/tez/test/TestSecureShuffle.java | 86 +-
.../tez/test/TestTaskErrorsUsingLocalMode.java | 15 +-
.../test/java/org/apache/tez/test/TestTezJobs.java | 206 +--
tez-tools/analyzers/job-analyzer/pom.xml | 15 +-
.../java/org/apache/tez/analyzer/TestAnalyzer.java | 51 +-
.../org/apache/tez/analyzer/TestCSVResult.java | 44 +-
244 files changed, 10329 insertions(+), 8970 deletions(-)
diff --git a/.codespellrc b/.codespellrc
new file mode 100644
index 000000000..fee7e92ef
--- /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 e1a82a60e..1e9f67895 100644
--- a/hadoop-shim/pom.xml
+++ b/hadoop-shim/pom.xml
@@ -34,8 +34,8 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
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 8c65135a8..f634b17de 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,14 @@
*/
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 +33,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 +43,17 @@ public class TestHadoopShimsLoader {
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 ccdc48d2d..fec11d4d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,8 +85,7 @@
<jackson.version>2.18.6</jackson.version>
<jersey.version>2.46</jersey.version>
<jettison.version>1.5.4</jettison.version>
- <junit.version>4.13.2</junit.version>
- <junit.jupiter.version>5.9.3</junit.jupiter.version>
+ <junit.version>6.1.0</junit.version>
<leveldbjni.group>org.fusesource.leveldbjni</leveldbjni.group>
<leveldb.version>0.12</leveldb.version>
<leveldbjni-all.version>1.8</leveldbjni-all.version>
@@ -269,6 +268,10 @@
<artifactId>pig</artifactId>
<version>${pig.version}</version>
<exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>*</artifactId>
@@ -628,10 +631,6 @@
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>${hadoop.version}</version>
<exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
<exclusion>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
@@ -890,22 +889,10 @@
<artifactId>commons-cli</artifactId>
<version>${commons-cli.version}</version>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
+ <artifactId>junit-jupiter</artifactId>
+ <version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -1286,6 +1273,12 @@
<bannedImport>org.codehaus.jackson.**</bannedImport>
</bannedImports>
</RestrictImports>
+ <bannedDependencies>
+ <excludes>
+ <exclude>junit:junit</exclude>
+ </excludes>
+ <message>JUnit 4 is not allowed. Use JUnit 6 (junit-jupiter) instead.</message>
+ </bannedDependencies>
</rules>
</configuration>
</execution>
diff --git a/tez-api/pom.xml b/tez-api/pom.xml
index 5131258dc..e54e15226 100644
--- a/tez-api/pom.xml
+++ b/tez-api/pom.xml
@@ -90,8 +90,8 @@
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
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 07121cf1e..19d066817 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.common.collect.Maps;
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,32 @@ public class TestTezClient {
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)
- public void testTezClientReconnectNoSession() throws Exception {
- testTezClientReconnect(false);
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testTezClientReconnectNoSession() {
+ 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 +300,8 @@ public class TestTezClient {
}
}
- @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 +361,7 @@ public class TestTezClient {
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 +394,7 @@ public class TestTezClient {
} 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 +431,8 @@ public class TestTezClient {
ArgumentCaptor<SubmitDAGRequestProto> 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 +440,7 @@ public class TestTezClient {
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 +489,7 @@ public class TestTezClient {
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 +557,8 @@ public class TestTezClient {
client2.stop();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPreWarm() throws Exception {
TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -575,7 +583,8 @@ public class TestTezClient {
}
- @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 +613,8 @@ public class TestTezClient {
.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 +642,9 @@ public class TestTezClient {
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 +657,7 @@ public class TestTezClient {
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 +691,15 @@ public class TestTezClient {
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 +741,8 @@ public class TestTezClient {
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 +764,12 @@ public class TestTezClient {
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 +787,8 @@ public class TestTezClient {
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 +803,8 @@ public class TestTezClient {
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 +829,8 @@ public class TestTezClient {
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 +854,8 @@ public class TestTezClient {
}
}
- @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 +926,8 @@ public class TestTezClient {
// 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 +936,8 @@ public class TestTezClient {
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 +946,8 @@ public class TestTezClient {
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 +959,13 @@ public class TestTezClient {
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 +978,30 @@ public class TestTezClient {
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 +1020,16 @@ public class TestTezClient {
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 +1048,8 @@ public class TestTezClient {
}
}
- @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 +1079,8 @@ public class TestTezClient {
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 +1096,8 @@ public class TestTezClient {
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 +1113,8 @@ public class TestTezClient {
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 +1132,8 @@ public class TestTezClient {
}
//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 2d18bc5d3..d635259a6 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.URI;
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.LinkedList;
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.ConfigurationProto;
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,39 @@ public class TestTezClientUtils {
try {
Map<String,LocalResource> resources = new HashMap<String, LocalResource>();
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<String,LocalResource> resources = new HashMap<String, LocalResource>();
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)
- public void validateSetTezJarLocalResourcesDefinedNonExistingDirectory() throws Exception {
-
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void validateSetTezJarLocalResourcesDefinedNonExistingDirectory() {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_LIB_URIS, "file:///foo");
Credentials credentials = new Credentials();
- Map<String,LocalResource> resources = new HashMap<String, LocalResource>();
- TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
+ Map<String, LocalResource> resources = new HashMap<>();
+ assertThrows(FileNotFoundException.class,
+ () -> TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources));
}
private static List<URL> getDirAndFileURL() throws MalformedURLException {
@@ -155,7 +158,8 @@ public class TestTezClientUtils {
return urls;
}
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectory() throws Exception {
List<URL> cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -169,7 +173,7 @@ public class TestTezClientUtils {
Map<String, LocalResource> localizedMap = new HashMap<String, LocalResource>();
boolean usingArchive = TezClientUtils.setupTezJarsLocalResources(conf, credentials,
localizedMap);
- Assert.assertFalse(usingArchive);
+ assertFalse(usingArchive);
Set<String> resourceNames = localizedMap.keySet();
boolean assertedDir = false;
boolean assertedFile = false;
@@ -198,7 +202,8 @@ public class TestTezClientUtils {
*
* @throws Exception
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnored() throws Exception {
List<URL> cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -211,7 +216,7 @@ public class TestTezClientUtils {
conf.setBoolean(TezConfiguration.TEZ_IGNORE_LIB_URIS, true);
Credentials credentials = new Credentials();
Map<String, LocalResource> localizedMap = new HashMap<String, LocalResource>();
- Assert.assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
+ assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
assertTrue(localizedMap.isEmpty());
}
@@ -219,7 +224,8 @@ public class TestTezClientUtils {
*
* @throws Exception
*/
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnoredSetToFalse() throws Exception {
List<URL> cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -232,7 +238,7 @@ public class TestTezClientUtils {
conf.setBoolean(TezConfiguration.TEZ_IGNORE_LIB_URIS, false);
Credentials credentials = new Credentials();
Map<String, LocalResource> localizedMap = new HashMap<String, LocalResource>();
- Assert.assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
+ assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
assertFalse(localizedMap.isEmpty());
}
@@ -240,7 +246,8 @@ public class TestTezClientUtils {
/**
*
*/
- @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 +260,7 @@ public class TestTezClientUtils {
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 +270,15 @@ public class TestTezClientUtils {
Map<String, LocalResource> localizedMap = new HashMap<String, LocalResource>();
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 +293,8 @@ public class TestTezClientUtils {
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 +304,23 @@ public class TestTezClientUtils {
Map<String, LocalResource> localizedMap = new HashMap<String, LocalResource>();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set<String> 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 +336,9 @@ public class TestTezClientUtils {
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 +349,20 @@ public class TestTezClientUtils {
Map<String, LocalResource> localizedMap = new HashMap<String, LocalResource>();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set<String> 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 +387,8 @@ public class TestTezClientUtils {
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 +400,8 @@ public class TestTezClientUtils {
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 +416,8 @@ public class TestTezClientUtils {
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 +451,11 @@ public class TestTezClientUtils {
Token<JobTokenIdentifier> jtSent = new Token<JobTokenIdentifier>();
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 +495,8 @@ public class TestTezClientUtils {
assertNull(logEnv);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMLoggingOptsPerLogger() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
@@ -523,7 +538,8 @@ public class TestTezClientUtils {
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 +589,8 @@ public class TestTezClientUtils {
+ 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";
@@ -584,9 +601,8 @@ public class TestTezClientUtils {
String taskOptsConstructed = TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
expected =
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT + " " + taskCommandOpts;
- assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ assertTrue(taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test2: Setup cluster-default command opts explicitly
String taskClusterDefaultCommandOpts =
@@ -595,9 +611,8 @@ public class TestTezClientUtils {
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS, taskClusterDefaultCommandOpts);
taskOptsConstructed = TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
expected = taskClusterDefaultCommandOpts + " " + taskCommandOpts;
- assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ assertTrue(taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test3: Don't setup Xmx explicitly
taskCommandOpts = "-Dtest.property";
@@ -605,9 +620,8 @@ public class TestTezClientUtils {
taskOptsConstructed =
TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
expected = taskClusterDefaultCommandOpts + " " + taskCommandOpts;
- assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ assertTrue(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";
@@ -615,73 +629,74 @@ public class TestTezClientUtils {
TezClientUtils.addDefaultsToTaskLaunchCmdOpts(programmaticTaskOpts, tezConf);
// 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));
+ assertTrue(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 +706,15 @@ public class TestTezClientUtils {
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 +730,14 @@ public class TestTezClientUtils {
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 +775,24 @@ public class TestTezClientUtils {
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 +803,35 @@ public class TestTezClientUtils {
Map<String, LocalResource> lrMap = new HashMap<String, LocalResource>();
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 +841,8 @@ public class TestTezClientUtils {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfigurationAllowAll() {
Configuration srcConf = new Configuration(false);
@@ -855,7 +873,8 @@ public class TestTezClientUtils {
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<String> resources = new ArrayList<String>();
@@ -889,12 +908,13 @@ public class TestTezClientUtils {
Map<String, LocalResource> localizedMap = new HashMap<String, LocalResource>();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set<String> 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 +926,35 @@ public class TestTezClientUtils {
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 +963,18 @@ public class TestTezClientUtils {
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 +1001,6 @@ public class TestTezClientUtils {
// 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 fc9c05dd7..0776b14f6 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,7 @@ import org.apache.hadoop.registry.client.types.ServiceRecord;
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 +232,12 @@ public class TestAMRecord {
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 9f943feba..3927e6771 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,7 @@ import org.apache.curator.framework.CuratorFramework;
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 +190,36 @@ public class TestZkConfig {
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 70cc75c66..1ea934967 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.client.registry.AMRecord;
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 class TestZkFrameworkClient {
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 class TestZkFrameworkClient {
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 class TestZkFrameworkClient {
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,12 @@ public class TestZkFrameworkClient {
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 1fc510662..59bb76db7 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,68 @@
*/
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 b8facb5d1..f5766bd0d 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 org.apache.tez.dag.api.TezException;
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 class TestRPCUtil {
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 class TestRPCUtil {
} 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 class TestRPCUtil {
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,13 @@ public class TestRPCUtil {
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 f7696175c..2c1c4c3f8 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.hadoop.fs.Path;
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,19 @@ public class TestReflectionUtils {
}
}
- @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[] {"test", 1};
+ ParameterizedConstructorClass instance =
+ ReflectionUtils.createClazzInstance(ParameterizedConstructorClass.class.getName(), parameterTypes, parameters);
+ assertEquals("test", instance.first, "Class not constructed with first parameter correctly");
+ assertEquals(1, instance.second, "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 30c3ed675..8f74bcdc1 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 org.apache.tez.dag.api.TezUncheckedException;
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 class TestTezCommonUtils {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (dfsCluster != null) {
try {
@@ -87,23 +95,25 @@ public class TestTezCommonUtils {
}
// 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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
+ 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 class TestTezCommonUtils {
+ 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<String, LocalResource> originalLrs;
@@ -289,9 +311,9 @@ public class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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 class TestTezCommonUtils {
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));
}
@@ -418,15 +442,12 @@ public class TestTezCommonUtils {
@Test
public void testMkDirForAM() throws IOException {
- Configuration remoteConf = new Configuration();
- remoteConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR);
+ Configuration remoteConf = new Configuration(conf);
remoteConf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "777");
- MiniDFSCluster miniDFS = new MiniDFSCluster.Builder(remoteConf).numDataNodes(3).format(true).racks(null)
- .build();
- 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());
- miniDFS.shutdown();
+ try (FileSystem remoteFileSystem = FileSystem.newInstance(remoteFs.getUri(), remoteConf)) {
+ Path path = new Path(TEST_ROOT_DIR + "/testMkDirForAM");
+ TezCommonUtils.mkDirForAM(remoteFileSystem, path);
+ assertEquals(TezCommonUtils.TEZ_AM_DIR_PERMISSION, remoteFileSystem.getFileStatus(path).getPermission());
+ }
}
}
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 84d9d47b1..87ea7176f 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,98 +35,102 @@ import org.apache.hadoop.yarn.api.ApplicationConstants.Environment;
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<String, String> environment = new TreeMap<String, String>();
- TezYARNUtils.setupDefaultEnv(environment, conf,
- TezConfiguration.TEZ_AM_LAUNCH_ENV,
- TezConfiguration.TEZ_AM_LAUNCH_ENV_DEFAULT,
- TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV,
+ Map<String, String> environment = new TreeMap<>();
+ 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);
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") >
- classpath.indexOf(Environment.PWD.$()));
+ assertTrue(classpath.contains("foobar"));
+ assertTrue(classpath.contains(Environment.PWD.$()));
+ assertTrue(classpath.indexOf("foobar") > classpath.indexOf(Environment.PWD.$()));
}
@Test
@@ -148,7 +155,7 @@ public class TestTezYARNUtils {
String badEnv = "0=,1,,2=a=b,3=a=,4==,5==a,==,c-3=3,=";
environment.clear();
appendToEnvFromInputString(environment, badEnv, File.pathSeparator);
- assertEquals(environment.size(), 0);
+ assertEquals(0, environment.size());
// Test "=" in the value part
environment.clear();
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 7050d3aff..4b0a29120 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 de2c6ade3..ed197f433 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 class TestACLConfigurationParser {
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 class TestACLConfigurationParser {
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 class TestACLConfigurationParser {
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 eeaf50091..ab40898fb 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,15 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
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 +51,37 @@ public class TestACLManager {
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 +106,25 @@ public class TestACLManager {
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 +147,25 @@ public class TestACLManager {
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 +195,49 @@ public class TestACLManager {
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 +280,54 @@ public class TestACLManager {
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 +339,18 @@ public class TestACLManager {
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 +360,18 @@ public class TestACLManager {
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 +384,28 @@ public class TestACLManager {
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 +415,18 @@ public class TestACLManager {
ACLManager aclManager = new ACLManager(currentUser, conf);
Map<ApplicationAccessType, String> 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 e9c89a32c..f291c4423 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 class TestDAGAccessControls {
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 867eb2639..6f56ad63e 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.io.IOException;
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.Token;
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 class TestTokenCache {
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 class TestTokenCache {
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 class TestTokenCache {
}
}
- @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 class TestTokenCache {
}
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 6fcd25bc1..11187c7f7 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.ConfigurationProto;
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
// 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 class TestDAG {
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 class TestDAG {
// 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 class TestDAG {
// 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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
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 class TestDAG {
// 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 @@ public class TestDAG {
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 0a348c4c5..26225644a 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.ServicePluginsDescriptor;
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.TempDir;
// 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 class TestDAGPlan {
.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 class TestDAGPlan {
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 class TestDAGPlan {
.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 class TestDAGPlan {
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 class TestDAGPlan {
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 class TestDAGPlan {
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 class TestDAGPlan {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidExecContext_2() {
ServicePluginsDescriptor servicePluginsDescriptor = ServicePluginsDescriptor
@@ -428,7 +440,8 @@ public class TestDAGPlan {
}
- @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 class TestDAGPlan {
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 class TestDAGPlan {
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 4c4390a45..e84a54c25 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.HashMap;
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.Lists;
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
// 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 class TestDAGVerify {
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 class TestDAGVerify {
// -> 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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
// 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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
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 class TestDAGVerify {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGCreateDataInference() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
Map<String, LocalResource> lrs1 = Maps.newHashMap();
@@ -971,16 +1007,17 @@ public class TestDAGVerify {
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 class TestDAGVerify {
// 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 class TestDAGVerify {
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,29 +1081,30 @@ public class TestDAGVerify {
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(
- "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());
+ 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());
}
DataSourceDescriptor dsDesc = DataSourceDescriptor.create(InputDescriptor.create(dummyInputClassName),
@@ -1075,18 +1114,19 @@ public class TestDAGVerify {
}
// 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(
- "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());
+ 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());
}
v1.setVertexManagerPlugin(VertexManagerPluginDescriptor.create(dummyVMPluginClassName));
@@ -1094,18 +1134,19 @@ public class TestDAGVerify {
}
// 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(
- "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());
+ 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());
}
Vertex v0 = Vertex.create("v0", ProcessorDescriptor.create(dummyProcessorClassName));
@@ -1128,11 +1169,11 @@ public class TestDAGVerify {
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.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());
+ 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());
}
Vertex v0 = Vertex.create("v2", ProcessorDescriptor.create(dummyProcessorClassName));
@@ -1169,7 +1210,8 @@ public class TestDAGVerify {
}
// 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<String, LocalResource> localResourceMap = new HashMap<>();
@@ -1188,9 +1230,9 @@ public class TestDAGVerify {
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 a9cc1e2dd..6a73d22c5 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 org.apache.tez.serviceplugins.api.TaskSchedulerDescriptor;
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 class TestDagTypeConverters {
.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 class TestDagTypeConverters {
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 class TestDagTypeConverters {
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 class TestDagTypeConverters {
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 366edde5a..76bb5c138 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.ByteArrayOutputStream;
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 class TestEntityDescriptor {
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 e73ca9079..165d0bbcf 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 e2330beef..a6ae02f1b 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 class TestTaskLocationHint {
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 a49fa3c86..e4ed629ce 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,59 @@
*/
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<String> expectedKeys = new HashSet<String>();
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 +81,6 @@ public class TestTezConfiguration {
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 175c136a1..da47f1729 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.io.IOException;
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 class TestATSHttpClient {
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 class TestATSHttpClient {
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<String, Progress> 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 class TestATSHttpClient {
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 806eb2a2f..89391a050 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,26 @@ import org.apache.hadoop.security.authentication.client.ConnectionConfigurator;
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",
- "org.apache.tez.dag.api.client.TimelineReaderFactory.TimelineReaderTokenAuthenticatedStrategy",
- returnedClassName);
+ assertEquals("org.apache.tez.dag.api.client.TimelineReaderFactory.TimelineReaderTokenAuthenticatedStrategy",
+ 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 +58,7 @@ public class TestTimelineReaderFactory {
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 168fdc093..69c679947 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.io.IOException;
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 org.apache.tez.dag.api.records.DAGProtos.VertexStatusStateProto;
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 class TestDAGClient {
}
}
- @Before
+ @BeforeEach
public void setUp() throws YarnException, IOException, TezException, ServiceException{
setUpData();
@@ -216,7 +223,8 @@ public class TestDAGClient {
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 class TestDAGClient {
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 class TestDAGClient {
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 class TestDAGClient {
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 class TestDAGClient {
.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 class TestDAGClient {
.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 class TestDAGClient {
}
- @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 class TestDAGClient {
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 class TestDAGClient {
}
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;
@@ -624,9 +640,7 @@ public class TestDAGClient {
DAGStatus rmDagStatus;
// Fetch from AM. RUNNING
- rmDagStatus =
- new DAGStatus(constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING),
- DagStatusSource.RM);
+ rmDagStatus = new DAGStatus(constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING), DagStatusSource.RM);
dagClientImpl.setRmDagStatus(rmDagStatus);
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_RUNNING, -1));
@@ -639,14 +653,12 @@ public class TestDAGClient {
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);
+ rmDagStatus = new DAGStatus(constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING), DagStatusSource.RM);
dagClientImpl.setRmDagStatus(rmDagStatus);
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_SUCCEEDED, 1000L));
@@ -654,17 +666,17 @@ public class TestDAGClient {
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 +687,8 @@ public class TestDAGClient {
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 +701,13 @@ public class TestDAGClient {
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 +716,9 @@ public class TestDAGClient {
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 23f94c956..b8efafaef 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 class TestCompositeDataMovementEvent {
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 63f9e1179..b71e36297 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 class TestInputDataInformationEvent {
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 700100df7..bce5be4cf 100644
--- a/tez-common/pom.xml
+++ b/tez-common/pom.xml
@@ -71,9 +71,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
</dependency>
</dependencies>
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 f9cbd7a2f..e95646866 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 class TestAsyncDispatcher {
}
@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 class TestAsyncDispatcher {
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 class TestAsyncDispatcher {
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 89f346bdc..fc8b3ac7f 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 class TestAsyncDispatcherConcurrent {
}
}
- @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 class TestAsyncDispatcherConcurrent {
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 class TestAsyncDispatcherConcurrent {
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 class TestAsyncDispatcherConcurrent {
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 class TestAsyncDispatcherConcurrent {
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 class TestAsyncDispatcherConcurrent {
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 class TestAsyncDispatcherConcurrent {
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 35b814d93..447525476 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 java.util.concurrent.atomic.AtomicInteger;
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 class TestTezSharedExecutor {
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<String, AtomicInteger> map = new ConcurrentHashMap<>();
@@ -132,13 +138,13 @@ public class TestTezSharedExecutor {
// 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<Object>() {
@@ -147,19 +153,20 @@ public class TestTezSharedExecutor {
return expected;
}
}).get();
- Assert.assertEquals(expected, val);
+ assertEquals(expected, val);
// Tasks should be rejected after a shutdown.
service.shutdown();
try {
service.submit(new Counter(map, "test"));
- Assert.fail("Expected rejected execution exception.");
+ fail("Expected rejected execution exception.");
} catch (RejectedExecutionException e) {
}
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testAwaitTermination() throws Exception {
ExecutorService service = sharedExecutor.createExecutorService(1, "await-termination");
CountDownLatch latch = new CountDownLatch(1);
@@ -169,18 +176,19 @@ public class TestTezSharedExecutor {
service.shutdown();
// Task stuck on latch hence it should fail to terminate.
- Assert.assertFalse(service.awaitTermination(100, TimeUnit.MILLISECONDS));
- Assert.assertFalse(service.isTerminated());
- Assert.assertTrue(service.isShutdown());
+ assertFalse(service.awaitTermination(100, TimeUnit.MILLISECONDS));
+ assertFalse(service.isTerminated());
+ assertTrue(service.isShutdown());
latch.countDown();
- Assert.assertTrue(service.awaitTermination(5, TimeUnit.SECONDS));
- Assert.assertTrue(service.isTerminated());
- Assert.assertTrue(service.isShutdown());
+ assertTrue(service.awaitTermination(5, TimeUnit.SECONDS));
+ assertTrue(service.isTerminated());
+ assertTrue(service.isShutdown());
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSerialExecution() throws Exception {
ExecutorService service = sharedExecutor.createExecutorService(1, "serial-test");
CountDownLatch latch = new CountDownLatch(1);
@@ -197,7 +205,7 @@ public class TestTezSharedExecutor {
service.shutdown();
// Until we release the task from the latch nothing moves forward.
- Assert.assertEquals(0, list.size());
+ assertEquals(0, list.size());
latch.countDown();
f1.get();
@@ -205,11 +213,12 @@ public class TestTezSharedExecutor {
for (Future<?> f : futures) {
f.get();
}
- Assert.assertEquals(10, list.size());
- Assert.assertEquals(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), list);
+ assertEquals(10, list.size());
+ assertEquals(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), list);
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testParallelExecution() throws Exception {
ConcurrentHashMap<String, AtomicInteger> map = new ConcurrentHashMap<>();
@@ -229,13 +238,13 @@ public class TestTezSharedExecutor {
for (Future<?> future : futures) {
future.get();
}
- Assert.assertEquals(expectedCounts[0], map.get("test0").get());
- Assert.assertEquals(expectedCounts[1], map.get("test1").get());
+ assertEquals(expectedCounts[0], map.get("test0").get());
+ assertEquals(expectedCounts[1], map.get("test1").get());
// Even if one service is shutdown the other should work.
services[0].shutdown();
services[1].submit(new Counter(map, "test1")).get();
- Assert.assertEquals(expectedCounts[1] + 1, map.get("test1").get());
+ assertEquals(expectedCounts[1] + 1, map.get("test1").get());
}
}
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
index f72255c16..de982840b 100644
--- a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
+++ b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
@@ -18,10 +18,11 @@
*/
package org.apache.tez.common;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import java.io.IOException;
import java.io.InputStream;
@@ -29,6 +30,7 @@ import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.client.TezClientUtils;
@@ -45,20 +47,21 @@ import com.google.protobuf.ByteString;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestTezUtils {
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testByteStringToAndFromConf() throws IOException {
Configuration conf = getConf();
- Assert.assertEquals(conf.size(), 6);
+ assertEquals(conf.size(), 6);
ByteString bsConf = TezUtils.createByteStringFromConf(conf);
conf.clear();
- Assert.assertEquals(conf.size(), 0);
+ assertEquals(conf.size(), 0);
conf = TezUtils.createConfFromByteString(bsConf);
- Assert.assertEquals(conf.size(), 6);
+ assertEquals(conf.size(), 6);
checkConf(conf);
}
@@ -75,104 +78,111 @@ public class TestTezUtils {
}
String largeValue = sb.toString();
- Assert.assertEquals(largeSize, largeValue.length());
+ assertEquals(largeSize, largeValue.length());
return largeValue;
}
private ByteString createByteString(Configuration conf, String largeValue) throws IOException {
conf.set("testLargeValue", largeValue);
- Assert.assertEquals(conf.size(), 7);
+ assertEquals(conf.size(), 7);
return TezUtils.createByteStringFromConf(conf);
}
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testByteStringToAndFromLargeConf() throws IOException {
Configuration conf = getConf();
String largeValue = constructLargeValue();
ByteString bsConf = createByteString(conf, largeValue);
conf.clear();
- Assert.assertEquals(conf.size(), 0);
+ assertEquals(conf.size(), 0);
conf = TezUtils.createConfFromByteString(bsConf);
- Assert.assertEquals(conf.size(), 7);
+ assertEquals(conf.size(), 7);
checkConf(conf);
- Assert.assertEquals(conf.get("testLargeValue"), largeValue);
+ assertEquals(conf.get("testLargeValue"), largeValue);
}
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testByteStringAddToLargeConf() throws IOException {
Configuration conf = getConf();
String largeValue = constructLargeValue();
ByteString bsConf = createByteString(conf, largeValue);
conf.clear();
- Assert.assertEquals(conf.size(), 0);
+ assertEquals(conf.size(), 0);
TezUtils.addToConfFromByteString(conf, bsConf);
- Assert.assertEquals(conf.size(), 7);
+ assertEquals(conf.size(), 7);
checkConf(conf);
- Assert.assertEquals(conf.get("testLargeValue"), largeValue);
+ assertEquals(conf.get("testLargeValue"), largeValue);
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testPayloadToAndFromConf() throws IOException {
Configuration conf = getConf();
- Assert.assertEquals(conf.size(), 6);
+ assertEquals(conf.size(), 6);
UserPayload bConf = TezUtils.createUserPayloadFromConf(conf);
conf.clear();
- Assert.assertEquals(conf.size(), 0);
+ assertEquals(conf.size(), 0);
conf = TezUtils.createConfFromUserPayload(bConf);
- Assert.assertEquals(conf.size(), 6);
+ assertEquals(conf.size(), 6);
checkConf(conf);
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testCleanVertexName() {
String testString = "special characters & spaces and longer than "
+ TezUtilsInternal.MAX_VERTEX_NAME_LENGTH + " characters";
- Assert.assertTrue(testString.length() > TezUtilsInternal.MAX_VERTEX_NAME_LENGTH);
+ assertTrue(testString.length() > TezUtilsInternal.MAX_VERTEX_NAME_LENGTH);
String cleaned = TezUtilsInternal.cleanVertexName(testString);
- Assert.assertTrue(cleaned.length() <= TezUtilsInternal.MAX_VERTEX_NAME_LENGTH);
- Assert.assertFalse(cleaned.contains("\\s+"));
- Assert.assertTrue(cleaned.matches("\\w+"));
+ assertTrue(cleaned.length() <= TezUtilsInternal.MAX_VERTEX_NAME_LENGTH);
+ assertFalse(cleaned.contains("\\s+"));
+ assertTrue(cleaned.matches("\\w+"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testBitSetToByteArray() {
BitSet bitSet = createBitSet(0);
byte[] bytes = TezUtilsInternal.toByteArray(bitSet);
- Assert.assertEquals(bytes.length, (bitSet.length() + 7) / 8);
+ assertEquals(bytes.length, (bitSet.length() + 7) / 8);
bitSet = createBitSet(1000);
bytes = TezUtilsInternal.toByteArray(bitSet);
- Assert.assertEquals(bytes.length, (bitSet.length() + 7) / 8);
+ assertEquals(bytes.length, (bitSet.length() + 7) / 8);
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testBitSetFromByteArray() {
BitSet bitSet = createBitSet(0);
byte[] bytes = TezUtilsInternal.toByteArray(bitSet);
- Assert.assertEquals(TezUtilsInternal.fromByteArray(bytes).cardinality(), bitSet.cardinality());
- Assert.assertTrue(TezUtilsInternal.fromByteArray(bytes).equals(bitSet));
+ assertEquals(TezUtilsInternal.fromByteArray(bytes).cardinality(), bitSet.cardinality());
+ assertEquals(TezUtilsInternal.fromByteArray(bytes), bitSet);
bitSet = createBitSet(1);
bytes = TezUtilsInternal.toByteArray(bitSet);
- Assert.assertEquals(TezUtilsInternal.fromByteArray(bytes).cardinality(), bitSet.cardinality());
- Assert.assertTrue(TezUtilsInternal.fromByteArray(bytes).equals(bitSet));
+ assertEquals(TezUtilsInternal.fromByteArray(bytes).cardinality(), bitSet.cardinality());
+ assertEquals(TezUtilsInternal.fromByteArray(bytes), bitSet);
bitSet = createBitSet(1000);
bytes = TezUtilsInternal.toByteArray(bitSet);
- Assert.assertEquals(TezUtilsInternal.fromByteArray(bytes).cardinality(), bitSet.cardinality());
- Assert.assertTrue(TezUtilsInternal.fromByteArray(bytes).equals(bitSet));
+ assertEquals(TezUtilsInternal.fromByteArray(bytes).cardinality(), bitSet.cardinality());
+ assertEquals(TezUtilsInternal.fromByteArray(bytes), bitSet);
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testBitSetConversion() {
for (int i = 0 ; i < 16 ; i++) {
BitSet bitSet = createBitSetWithSingleEntry(i);
byte[] bytes = TezUtilsInternal.toByteArray(bitSet);
BitSet deseraialized = TezUtilsInternal.fromByteArray(bytes);
- Assert.assertEquals(bitSet, deseraialized);
- Assert.assertEquals(bitSet.cardinality(), deseraialized.cardinality());
- Assert.assertEquals(1, deseraialized.cardinality());
+ assertEquals(bitSet, deseraialized);
+ assertEquals(bitSet.cardinality(), deseraialized.cardinality());
+ assertEquals(1, deseraialized.cardinality());
}
}
@@ -204,30 +214,31 @@ public class TestTezUtils {
}
private void checkConf(Configuration conf) {
- Assert.assertEquals(conf.get("test1"), "value1");
- Assert.assertTrue(conf.getBoolean("test2", false));
- Assert.assertEquals(conf.getDouble("test3", 0), 1.2345, 1e-15);
- Assert.assertEquals(conf.getInt("test4", 0), 34567);
- Assert.assertEquals(conf.getLong("test5", 0), 1234567890L);
+ assertEquals(conf.get("test1"), "value1");
+ assertTrue(conf.getBoolean("test2", false));
+ assertEquals(conf.getDouble("test3", 0), 1.2345, 1e-15);
+ assertEquals(conf.getInt("test4", 0), 34567);
+ assertEquals(conf.getLong("test5", 0), 1234567890L);
String tmp[] = conf.getStrings("test6");
- Assert.assertEquals(tmp.length, 3);
- Assert.assertEquals(tmp[0], "S1");
- Assert.assertEquals(tmp[1], "S2");
- Assert.assertEquals(tmp[2], "S3");
+ assertEquals(tmp.length, 3);
+ assertEquals(tmp[0], "S1");
+ assertEquals(tmp[1], "S2");
+ assertEquals(tmp[2], "S3");
}
private void checkJSONConfigObj(JSONObject confObject) throws JSONException {
- Assert.assertNotNull(confObject);
- Assert.assertEquals("value1", confObject.getString("test1"));
- Assert.assertEquals("true", confObject.getString("test2"));
- Assert.assertEquals("1.2345", confObject.getString("test3"));
- Assert.assertEquals("34567", confObject.getString("test4"));
- Assert.assertEquals("1234567890", confObject.getString("test5"));
- Assert.assertEquals("S1,S2,S3", confObject.getString("test6"));
+ assertNotNull(confObject);
+ assertEquals("value1", confObject.getString("test1"));
+ assertEquals("true", confObject.getString("test2"));
+ assertEquals("1.2345", confObject.getString("test3"));
+ assertEquals("34567", confObject.getString("test4"));
+ assertEquals("1234567890", confObject.getString("test5"));
+ assertEquals("S1,S2,S3", confObject.getString("test6"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testConvertToHistoryText() throws JSONException {
Configuration conf = getConf();
@@ -235,8 +246,8 @@ public class TestTezUtils {
JSONObject jsonObject = new JSONObject(confToJson);
- Assert.assertFalse(jsonObject.has(ATSConstants.DESC));
- Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
+ assertFalse(jsonObject.has(ATSConstants.DESC));
+ assertTrue(jsonObject.has(ATSConstants.CONFIG));
JSONObject confObject = jsonObject.getJSONObject(ATSConstants.CONFIG);
checkJSONConfigObj(confObject);
@@ -245,54 +256,56 @@ public class TestTezUtils {
confToJson = TezUtils.convertToHistoryText(desc, conf);
jsonObject = new JSONObject(confToJson);
- Assert.assertTrue(jsonObject.has(ATSConstants.DESC));
+ assertTrue(jsonObject.has(ATSConstants.DESC));
String descFromJson = jsonObject.getString(ATSConstants.DESC);
- Assert.assertEquals(desc, descFromJson);
+ assertEquals(desc, descFromJson);
- Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
+ assertTrue(jsonObject.has(ATSConstants.CONFIG));
confObject = jsonObject.getJSONObject("config");
checkJSONConfigObj(confObject);
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testConvertToHistoryTextWithReplaceVars() throws JSONException {
Configuration conf = getConf();
conf.set("user", "user1");
conf.set("location", "/tmp/${user}/");
String location = "/tmp/user1/";
- Assert.assertEquals(location, conf.get("location"));
+ assertEquals(location, conf.get("location"));
String confToJson = TezUtils.convertToHistoryText(conf);
JSONObject jsonObject = new JSONObject(confToJson);
- Assert.assertFalse(jsonObject.has(ATSConstants.DESC));
- Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
+ assertFalse(jsonObject.has(ATSConstants.DESC));
+ assertTrue(jsonObject.has(ATSConstants.CONFIG));
JSONObject confObject = jsonObject.getJSONObject(ATSConstants.CONFIG);
checkJSONConfigObj(confObject);
- Assert.assertEquals("user1", confObject.getString("user"));
- Assert.assertEquals(location, confObject.getString("location"));
+ assertEquals("user1", confObject.getString("user"));
+ assertEquals(location, confObject.getString("location"));
String desc = "desc123";
confToJson = TezUtils.convertToHistoryText(desc, conf);
jsonObject = new JSONObject(confToJson);
- Assert.assertTrue(jsonObject.has(ATSConstants.DESC));
+ assertTrue(jsonObject.has(ATSConstants.DESC));
String descFromJson = jsonObject.getString(ATSConstants.DESC);
- Assert.assertEquals(desc, descFromJson);
+ assertEquals(desc, descFromJson);
- Assert.assertTrue(jsonObject.has(ATSConstants.CONFIG));
+ assertTrue(jsonObject.has(ATSConstants.CONFIG));
confObject = jsonObject.getJSONObject("config");
checkJSONConfigObj(confObject);
- Assert.assertEquals("user1", confObject.getString("user"));
- Assert.assertEquals(location, confObject.getString("location"));
+ assertEquals("user1", confObject.getString("user"));
+ assertEquals(location, confObject.getString("location"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPopulateConfProtoFromEntries() {
Map<String, String> map = new HashMap<>();
map.put("nonNullKey", "value");
@@ -302,14 +315,16 @@ public class TestTezUtils {
assertEquals(confBuilder.getConfKeyValuesList().size(), 1);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testReadTezConfigurationXmlFromClasspath() throws IOException {
InputStream is = ClassLoader.getSystemResourceAsStream(TezConfiguration.TEZ_SITE_XML);
Configuration conf = TezUtilsInternal.readTezConfigurationXml(is);
assertEquals("tez.tar.gz", conf.get("tez.lib.uris"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPluginsDescriptorFromJSON() throws IOException {
InputStream is = ClassLoader.getSystemResourceAsStream(TezConstants.SERVICE_PLUGINS_DESCRIPTOR_JSON);
ServicePluginsDescriptor spd = TezClientUtils.createPluginsDescriptorFromJSON(is);
diff --git a/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java b/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java
index 4071da1c1..e145db9f7 100644
--- a/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java
+++ b/tez-common/src/test/java/org/apache/tez/dag/records/TestTezIds.java
@@ -18,11 +18,17 @@
*/
package org.apache.tez.dag.records;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,57 +37,58 @@ public class TestTezIds {
private static final Logger LOG = LoggerFactory.getLogger(TestTezIds.class);
private void verifyDagInfo(String[] splits, TezDAGID dagId) {
- Assert.assertEquals(dagId.getApplicationId().getClusterTimestamp(),
+ assertEquals(dagId.getApplicationId().getClusterTimestamp(),
Long.valueOf(splits[1]).longValue());
- Assert.assertEquals(dagId.getApplicationId().getId(),
+ assertEquals(dagId.getApplicationId().getId(),
Integer.valueOf(splits[2]).intValue());
- Assert.assertEquals(dagId.getId(),
+ assertEquals(dagId.getId(),
Integer.valueOf(splits[3]).intValue());
}
private void verifyVertexInfo(String[] splits, TezVertexID vId) {
verifyDagInfo(splits, vId.getDAGID());
- Assert.assertEquals(vId.getId(),
+ assertEquals(vId.getId(),
Integer.valueOf(splits[4]).intValue());
}
private void verifyTaskInfo(String[] splits, TezTaskID tId) {
verifyVertexInfo(splits, tId.getVertexID());
- Assert.assertEquals(tId.getId(),
+ assertEquals(tId.getId(),
Integer.valueOf(splits[5]).intValue());
}
private void verifyAttemptInfo(String[] splits, TezTaskAttemptID taId) {
verifyTaskInfo(splits, taId.getTaskID());
- Assert.assertEquals(taId.getId(),
+ assertEquals(taId.getId(),
Integer.valueOf(splits[6]).intValue());
}
private void verifyDagId(String dagIdStr, TezDAGID dagId) {
String[] splits = dagIdStr.split("_");
- Assert.assertEquals(4, splits.length);
+ assertEquals(4, splits.length);
verifyDagInfo(splits, dagId);
}
private void verifyVertexId(String vIdStr, TezVertexID vId) {
String[] splits = vIdStr.split("_");
- Assert.assertEquals(5, splits.length);
+ assertEquals(5, splits.length);
verifyVertexInfo(splits, vId);
}
private void verifyTaskId(String tIdStr, TezTaskID tId) {
String[] splits = tIdStr.split("_");
- Assert.assertEquals(6, splits.length);
+ assertEquals(6, splits.length);
verifyTaskInfo(splits, tId);
}
private void verifyAttemptId(String taIdStr, TezTaskAttemptID taId) {
String[] splits = taIdStr.split("_");
- Assert.assertEquals(7, splits.length);
+ assertEquals(7, splits.length);
verifyAttemptInfo(splits, taId);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testIdStringify() {
ApplicationId appId = ApplicationId.newInstance(9999, 72);
TezDAGID dagId = TezDAGID.getInstance(appId, 1);
@@ -99,10 +106,10 @@ public class TestTezIds {
LOG.info("Task ID:" + tIdStr);
LOG.info("Attempt ID:" + taIdStr);
- Assert.assertTrue(dagIdStr.startsWith("dag"));
- Assert.assertTrue(vIdStr.startsWith("vertex"));
- Assert.assertTrue(tIdStr.startsWith("task"));
- Assert.assertTrue(taIdStr.startsWith("attempt"));
+ assertTrue(dagIdStr.startsWith("dag"));
+ assertTrue(vIdStr.startsWith("vertex"));
+ assertTrue(tIdStr.startsWith("task"));
+ assertTrue(taIdStr.startsWith("attempt"));
verifyDagId(dagIdStr, dagId);
verifyVertexId(vIdStr, vId);
@@ -110,39 +117,40 @@ public class TestTezIds {
verifyAttemptId(taIdStr, taId);
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidDagIds() {
String dagIdStr = "aaa_111_1_1";
TezDAGID dagId;
try {
dagId = TezDAGID.fromString(dagIdStr);
- Assert.fail("Expected failure for invalid dagId=" + dagIdStr);
+ fail("Expected failure for invalid dagId=" + dagIdStr);
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains("Invalid DAG Id format"));
+ assertTrue(e.getMessage().contains("Invalid DAG Id format"));
}
dagIdStr = "dag_111_11";
try {
dagId = TezDAGID.fromString(dagIdStr);
- Assert.fail("Expected failure for invalid dagId=" + dagIdStr);
+ fail("Expected failure for invalid dagId=" + dagIdStr);
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains("Invalid DAG Id format"));
+ assertTrue(e.getMessage().contains("Invalid DAG Id format"));
}
dagIdStr = "dag_111_11_aa";
try {
dagId = TezDAGID.fromString(dagIdStr);
- Assert.fail("Expected failure for invalid dagId=" + dagIdStr);
+ fail("Expected failure for invalid dagId=" + dagIdStr);
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains("Error while parsing"));
+ assertTrue(e.getMessage().contains("Error while parsing"));
}
dagIdStr = "dag_111_aa_1";
try {
dagId = TezDAGID.fromString(dagIdStr);
- Assert.fail("Expected failure for invalid dagId=" + dagIdStr);
+ fail("Expected failure for invalid dagId=" + dagIdStr);
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains("Error while parsing"));
+ assertTrue(e.getMessage().contains("Error while parsing"));
}
}
@@ -156,18 +164,18 @@ public class TestTezIds {
// All dags within one group should have same id.
String groupId1 = dagId.getGroupId(numDagsPerGroup);
for (int i = 0; i < numDagsPerGroup; ++i) {
- Assert.assertEquals(TezDAGID.getInstance(appId, i + 1).getGroupId(numDagsPerGroup), groupId1);
+ assertEquals(TezDAGID.getInstance(appId, i + 1).getGroupId(numDagsPerGroup), groupId1);
}
// Assert different id across groups.
- Assert.assertNotEquals(
+ assertNotEquals(
TezDAGID.getInstance(appId, numDagsPerGroup + 1).getGroupId(numDagsPerGroup), groupId1);
// Invalid values -1, 0, 1 should throw IllegalArgumentException.
for (int i = -1; i < 2; ++i) {
try {
dagId.getGroupId(i);
- Assert.fail("Expected IllegalArgumentException for numDagsPerGroup: " + i);
+ fail("Expected IllegalArgumentException for numDagsPerGroup: " + i);
} catch (IllegalArgumentException e) {
}
}
diff --git a/tez-common/src/test/java/org/apache/tez/util/TestNumberFormat.java b/tez-common/src/test/java/org/apache/tez/util/TestNumberFormat.java
index bb30dbf26..701ce10ad 100644
--- a/tez-common/src/test/java/org/apache/tez/util/TestNumberFormat.java
+++ b/tez-common/src/test/java/org/apache/tez/util/TestNumberFormat.java
@@ -18,14 +18,18 @@
*/
package org.apache.tez.util;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.text.NumberFormat;
+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 TestNumberFormat {
- @Test(timeout = 1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
public void testLongWithPadding() throws Exception {
FastNumberFormat fastNumberFormat = FastNumberFormat.getInstance();
fastNumberFormat.setMinimumIntegerDigits(6);
@@ -33,8 +37,8 @@ public class TestNumberFormat {
numberFormat.setGroupingUsed(false);
numberFormat.setMinimumIntegerDigits(6);
long[] testLongs = {1, 23, 456, 7890, 12345, 678901, 2345689, 0, -0, -1, -23, -456, -7890, -12345, -678901, -2345689};
- for (long l: testLongs) {
- Assert.assertEquals("Number formats should be equal", numberFormat.format(l), fastNumberFormat.format(l));
+ for (long l : testLongs) {
+ assertEquals(numberFormat.format(l), fastNumberFormat.format(l), "Number formats should be equal");
}
}
}
diff --git a/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java b/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java
index a48938fee..b429a5978 100644
--- a/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java
+++ b/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java
@@ -18,8 +18,12 @@
*/
package org.apache.tez.util;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import org.junit.jupiter.api.Test;
public class TestStopWatch {
@@ -27,13 +31,13 @@ public class TestStopWatch {
public void testStartAndStop() throws Exception {
try {
StopWatch sw = new StopWatch();
- Assert.assertFalse(sw.isRunning());
+ assertFalse(sw.isRunning());
sw.start();
- Assert.assertTrue(sw.isRunning());
+ assertTrue(sw.isRunning());
sw.stop();
- Assert.assertFalse(sw.isRunning());
+ assertFalse(sw.isRunning());
} catch (Exception e) {
- Assert.fail("StopWatch should not fail with normal usage");
+ fail("StopWatch should not fail with normal usage");
}
}
@@ -43,16 +47,14 @@ public class TestStopWatch {
try {
sw.stop();
} catch (Exception e) {
- Assert.assertTrue("IllegalStateException is expected",
- e instanceof IllegalStateException);
+ assertInstanceOf(IllegalStateException.class, e, "IllegalStateException is expected");
}
sw.reset();
sw.start();
try {
sw.start();
} catch (Exception e) {
- Assert.assertTrue("IllegalStateException is expected",
- e instanceof IllegalStateException);
+ assertInstanceOf(IllegalStateException.class, e, "IllegalStateException is expected");
}
}
diff --git a/tez-common/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java b/tez-common/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java
index add3cb3df..ebc2d94fa 100644
--- a/tez-common/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java
+++ b/tez-common/src/test/java/org/apache/tez/util/TestTezMxBeanResourceCalculator.java
@@ -18,20 +18,26 @@
*/
package org.apache.tez.util;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.concurrent.TimeUnit;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree;
import org.apache.tez.dag.api.TezConfiguration;
-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 TestTezMxBeanResourceCalculator {
private ResourceCalculatorProcessTree resourceCalculator;
- @Before
+ @BeforeEach
public void setup() throws Exception {
Configuration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_TASK_RESOURCE_CALCULATOR_PROCESS_TREE_CLASS,
@@ -44,19 +50,20 @@ public class TestTezMxBeanResourceCalculator {
"", clazz, conf);
}
- @After
+ @AfterEach
public void teardown() {
resourceCalculator = null;
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testResourceCalculator() {
- Assert.assertTrue(resourceCalculator instanceof TezMxBeanResourceCalculator);
- Assert.assertTrue(resourceCalculator.getCumulativeCpuTime() > 0);
- Assert.assertTrue(resourceCalculator.getVirtualMemorySize() > 0);
- Assert.assertTrue(resourceCalculator.getRssMemorySize() > 0);
- Assert.assertTrue(resourceCalculator.getProcessTreeDump().equals(""));
- Assert.assertTrue(resourceCalculator.checkPidPgrpidForMatch());
+ assertInstanceOf(TezMxBeanResourceCalculator.class, resourceCalculator);
+ assertTrue(resourceCalculator.getCumulativeCpuTime() > 0);
+ assertTrue(resourceCalculator.getVirtualMemorySize() > 0);
+ assertTrue(resourceCalculator.getRssMemorySize() > 0);
+ assertEquals("", resourceCalculator.getProcessTreeDump());
+ assertTrue(resourceCalculator.checkPidPgrpidForMatch());
}
}
diff --git a/tez-dag/pom.xml b/tez-dag/pom.xml
index 6f05d1b7e..f4c9ed886 100644
--- a/tez-dag/pom.xml
+++ b/tez-dag/pom.xml
@@ -133,10 +133,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@@ -163,8 +159,7 @@
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
+ <artifactId>junit-jupiter</artifactId>
</dependency>
</dependencies>
diff --git a/tez-dag/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkAMRegistryClient.java b/tez-dag/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkAMRegistryClient.java
index 49287ccfc..95903f45c 100644
--- a/tez-dag/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkAMRegistryClient.java
+++ b/tez-dag/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkAMRegistryClient.java
@@ -18,12 +18,11 @@
*/
package org.apache.tez.client.registry.zookeeper;
-
import static org.apache.tez.frameworkplugins.FrameworkMode.STANDALONE_ZOOKEEPER;
-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.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.util.List;
@@ -46,9 +45,11 @@ import org.apache.tez.dag.app.DAGAppMaster;
import org.apache.tez.dag.app.LocalNodeContext;
import org.apache.tez.dag.app.MockDAGAppMaster;
-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.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,7 +74,7 @@ public class TestZkAMRegistryClient {
* Embedded ZooKeeper server for testing. Uses Apache Curator's {@link TestingServer}
* to provide an in-memory ZooKeeper instance.
*/
- private TestingServer zkServer;
+ private static TestingServer zkServer;
/**
* ZooKeeper-based AM registry client used to discover and retrieve AM records.
@@ -85,19 +86,23 @@ public class TestZkAMRegistryClient {
*/
private DAGAppMaster dagAppMaster;
- @Before
- public void setup() throws Exception {
+ @BeforeAll
+ public static void setup() throws Exception {
zkServer = new TestingServer();
zkServer.start();
LOG.info("Started ZooKeeper test server on port: {}", zkServer.getPort());
}
- @After
- public void teardown() throws Exception {
+ @AfterEach
+ public void teardownEach() throws Exception {
if (dagAppMaster != null) {
dagAppMaster.stop();
}
IOUtils.closeQuietly(registryClient);
+ }
+
+ @AfterAll
+ public static void teardown() throws Exception {
IOUtils.closeQuietly(zkServer);
}
@@ -122,7 +127,8 @@ public class TestZkAMRegistryClient {
*
* @throws Exception if any part of the test fails
*/
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testZkAmRegistryDiscovery() throws Exception {
TezConfiguration tezConf = getTezConfForZkDiscovery();
@@ -153,33 +159,34 @@ public class TestZkAMRegistryClient {
registryClient.start();
String workingDir = TEST_DIR.toString();
- String[] localDirs = new String[]{TEST_DIR.toString()};
- String[] logDirs = new String[]{TEST_DIR + "/logs"};
+ String[] localDirs = new String[] {TEST_DIR.toString()};
+ String[] logDirs = new String[] {TEST_DIR + "/logs"};
String jobUserName = UserGroupInformation.getCurrentUser().getShortUserName();
- dagAppMaster = new MockDAGAppMaster(attemptId, containerId, SystemClock.getInstance(),
- System.currentTimeMillis(), true, workingDir, localDirs, logDirs, new AtomicBoolean(true), false, false,
- new Credentials(), jobUserName, 1, 1, new LocalNodeContext("localhost", 0, 0));
+ dagAppMaster =
+ new MockDAGAppMaster(attemptId, containerId, SystemClock.getInstance(), System.currentTimeMillis(), true,
+ workingDir, localDirs, logDirs, new AtomicBoolean(true), false, false, new Credentials(), jobUserName, 1, 1,
+ new LocalNodeContext("localhost", 0, 0));
dagAppMaster.init(tezConf);
dagAppMaster.start();
// Wait for AM to be registered in ZooKeeper
boolean registered = amRegisteredLatch.await(30, TimeUnit.SECONDS);
- assertTrue("AM was not registered in ZooKeeper within timeout", registered);
- assertTrue("AM was not discovered by registry client", amDiscovered.get());
+ assertTrue(registered, "AM was not registered in ZooKeeper within timeout");
+ assertTrue(amDiscovered.get(), "AM was not discovered by registry client");
// Verify the AM record is available through the registry client
AMRecord amRecord = registryClient.getRecord(appId);
- assertNotNull("AM record should be retrievable from registry", amRecord);
- assertEquals("Application ID should match", appId, amRecord.getApplicationId());
- assertNotNull("Host should be set", amRecord.getHostName());
- assertTrue("Port should be positive", amRecord.getPort() > 0);
+ assertNotNull(amRecord, "AM record should be retrievable from registry");
+ assertEquals(appId, amRecord.getApplicationId(), "Application ID should match");
+ assertNotNull(amRecord.getHostName(), "Host should be set");
+ assertTrue(amRecord.getPort() > 0, "Port should be positive");
// Verify getAllRecords also returns the AM
List<AMRecord> allRecords = registryClient.getAllRecords();
- assertNotNull("getAllRecords should not return null", allRecords);
- assertFalse("getAllRecords should contain at least one record", allRecords.isEmpty());
+ assertNotNull(allRecords, "getAllRecords should not return null");
+ assertFalse(allRecords.isEmpty(), "getAllRecords should contain at least one record");
boolean found = false;
for (AMRecord record : allRecords) {
@@ -188,7 +195,7 @@ public class TestZkAMRegistryClient {
break;
}
}
- assertTrue("AM record should be in getAllRecords", found);
+ assertTrue(found, "AM record should be in getAllRecords");
}
private TezConfiguration getTezConfForZkDiscovery() {
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientHandler.java b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientHandler.java
index cf14b28a9..a1364d919 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientHandler.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientHandler.java
@@ -18,11 +18,16 @@
*/
package org.apache.tez.dag.api.client;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+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.*;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.yarn.api.records.LocalResource;
import org.apache.hadoop.yarn.util.SystemClock;
@@ -36,14 +41,16 @@ import org.apache.tez.dag.app.DAGAppMasterState;
import org.apache.tez.dag.app.dag.DAG;
import org.apache.tez.dag.records.TezDAGID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.ArgumentCaptor;
import org.mockito.internal.util.collections.Sets;
public class TestDAGClientHandler {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGClientHandler() throws TezException {
TezDAGID mockTezDAGId = mock(TezDAGID.class);
@@ -116,7 +123,7 @@ public class TestDAGClientHandler {
verify(mockDagAM, times(1)).tryKillDAG(eventCaptor.capture(),
contains("Sending client kill from"));
assertEquals(1, eventCaptor.getAllValues().size());
- assertTrue(eventCaptor.getAllValues().get(0) instanceof DAG);
+ assertInstanceOf(DAG.class, eventCaptor.getAllValues().get(0));
assertEquals("dag_9999_0001_1", ((DAG)eventCaptor.getAllValues().get(0)).getID().toString());
// submitDAG
@@ -148,7 +155,7 @@ public class TestDAGClientHandler {
assertEquals("dag_9999_0001_1", dagClientHandler.getDAG("dag_9999_0001_1").getID().toString());
}
- @Test(expected = NoCurrentDAGException.class)
+ @Test
public void testNoCurrentDAGException() throws TezException {
DAGAppMaster mockDagAM = getMockAm();
@@ -156,7 +163,7 @@ public class TestDAGClientHandler {
when(mockDagAM.getContext().getCurrentDAG()).thenReturn(null);
// so this should throw NoCurrentDAGException
- new DAGClientHandler(mockDagAM).getDAG("dag_0000_0000_0");
+ assertThrows(NoCurrentDAGException.class, () -> new DAGClientHandler(mockDagAM).getDAG("dag_0000_0000_0"));
}
private DAGAppMaster getMockAm() {
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientServer.java b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientServer.java
index 064b779fb..10b566b96 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientServer.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestDAGClientServer.java
@@ -18,11 +18,14 @@
*/
package org.apache.tez.dag.api.client;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.*;
import java.io.IOException;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -30,12 +33,14 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezUncheckedException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestDAGClientServer {
// try 10 times to allocate random port, fail it if no one is succeed.
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPortRange() {
boolean succeedToAllocate = false;
Random rand = new Random();
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java
index eeb5c36e6..03c9bd224 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/api/client/TestVertexStatusBuilder.java
@@ -18,22 +18,27 @@
*/
package org.apache.tez.dag.api.client;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.concurrent.TimeUnit;
+
import org.apache.tez.dag.api.records.DAGProtos;
import org.apache.tez.dag.app.dag.VertexState;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestVertexStatusBuilder {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexStateConversion() {
for (VertexState state : VertexState.values()) {
DAGProtos.VertexStatusStateProto stateProto =
VertexStatusBuilder.getProtoState(state);
VertexStatus.State clientState =
VertexStatus.getState(stateProto);
- Assert.assertEquals(state.name(), clientState.name());
+ assertEquals(state.name(), clientState.name());
}
}
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/api/client/registry/zookeeper/TestZkAMRegistry.java b/tez-dag/src/test/java/org/apache/tez/dag/api/client/registry/zookeeper/TestZkAMRegistry.java
index 3aa59d65a..f1d762387 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/api/client/registry/zookeeper/TestZkAMRegistry.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/api/client/registry/zookeeper/TestZkAMRegistry.java
@@ -18,9 +18,9 @@
*/
package org.apache.tez.dag.api.client.registry.zookeeper;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+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 java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -34,6 +34,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.test.TestingServer;
@@ -43,9 +44,10 @@ import org.apache.tez.client.registry.AMRegistryUtils;
import org.apache.tez.client.registry.zookeeper.ZkConfig;
import org.apache.tez.dag.api.TezConfiguration;
-import org.junit.After;
-import org.junit.Before;
-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;
/**
* Unit tests for {@link ZkAMRegistry}.
@@ -59,16 +61,16 @@ import org.junit.Test;
*/
public class TestZkAMRegistry {
- private TestingServer zkServer;
+ private static TestingServer zkServer;
- @Before
- public void setup() throws Exception {
+ @BeforeAll
+ public static void setup() throws Exception {
zkServer = new TestingServer();
zkServer.start();
}
- @After
- public void teardown() throws Exception {
+ @AfterAll
+ public static void teardown() throws Exception {
if (zkServer != null) {
zkServer.close();
}
@@ -86,12 +88,13 @@ public class TestZkAMRegistry {
assertNotNull(first);
assertNotNull(second);
- assertEquals("Cluster timestamps should match", first.getClusterTimestamp(), second.getClusterTimestamp());
- assertEquals("Second id should be first id + 1", first.getId() + 1, second.getId());
+ assertEquals(first.getClusterTimestamp(), second.getClusterTimestamp(), "Cluster timestamps should match");
+ assertEquals(first.getId() + 1, second.getId(), "Second id should be first id + 1");
}
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testGenerateNewIdFromParallelThreads() throws Exception {
final int threadCount = 50;
@@ -138,12 +141,12 @@ public class TestZkAMRegistry {
} finally {
executor.shutdown();
}
- assertEquals(String.format("All generated ids should be unique, ids found: %s", ids), threadCount, ids.size());
+ assertEquals(threadCount, ids.size(), String.format("All generated ids should be unique, ids found: %s", ids));
// additionally ensure cluster timestamp is the same for all IDs
long clusterTs = ids.iterator().next().getClusterTimestamp();
for (ApplicationId id : ids) {
- assertEquals("Cluster timestamps should match for all generated ids", clusterTs, id.getClusterTimestamp());
+ assertEquals(clusterTs, id.getClusterTimestamp(), "Cluster timestamps should match for all generated ids");
}
}
}
@@ -172,14 +175,14 @@ public class TestZkAMRegistry {
String path = zkConfig.getZkNamespace() + "/" + appId.toString();
byte[] data = checkClient.getData().forPath(path);
- assertNotNull("Data should be written to ZooKeeper for AMRecord", data);
+ assertNotNull(data, "Data should be written to ZooKeeper for AMRecord");
String json = new String(data, StandardCharsets.UTF_8);
String expectedJson = AMRegistryUtils.recordToJsonString(record);
- assertEquals("Stored AMRecord JSON should match expected", expectedJson, json);
+ assertEquals(expectedJson, json, "Stored AMRecord JSON should match expected");
// Remove record and ensure node is deleted
registry.remove(record);
- assertNull("Node should be removed from ZooKeeper after remove()", checkClient.checkExists().forPath(path));
+ assertNull(checkClient.checkExists().forPath(path), "Node should be removed from ZooKeeper after remove()");
}
}
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClientAMProtocolBlockingPBServerImpl.java b/tez-dag/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClientAMProtocolBlockingPBServerImpl.java
index c8a08a834..360d5ac13 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClientAMProtocolBlockingPBServerImpl.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClientAMProtocolBlockingPBServerImpl.java
@@ -18,9 +18,9 @@
*/
package org.apache.tez.dag.api.client.rpc;
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertArrayEquals;
-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.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -33,6 +33,7 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.FileSystem;
@@ -52,32 +53,33 @@ import org.apache.tez.dag.api.client.DAGClientHandler;
import org.apache.tez.dag.api.client.rpc.DAGClientAMProtocolRPC.SubmitDAGRequestProto;
import org.apache.tez.dag.api.records.DAGProtos.DAGPlan;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
public class TestDAGClientAMProtocolBlockingPBServerImpl {
- @Rule
- public TemporaryFolder tmpFolder = new TemporaryFolder(new File("target"));
+ @TempDir
+ public java.nio.file.Path tmpFolder;
@Captor
private ArgumentCaptor<Map<String, LocalResource>> localResourcesCaptor;
- @Before
+ @BeforeEach
public void init() {
MockitoAnnotations.initMocks(this);
}
- @Test(timeout = 100000)
+ @Test
+ @Timeout(value = 100000, unit = TimeUnit.MILLISECONDS)
@SuppressWarnings("unchecked")
public void testSubmitDagInSessionWithLargeDagPlan() throws Exception {
int maxIPCMsgSize = 1024;
String dagPlanName = "DAG-testSubmitDagInSessionWithLargeDagPlan";
- File requestFile = tmpFolder.newFile("request-file");
+ File requestFile = java.nio.file.Files.createFile(tmpFolder.resolve("request-file")).toFile();
TezConfiguration conf = new TezConfiguration();
conf.setInt(CommonConfigurationKeys.IPC_MAXIMUM_DATA_LENGTH, maxIPCMsgSize);
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/PluginWrapperTestHelpers.java b/tez-dag/src/test/java/org/apache/tez/dag/app/PluginWrapperTestHelpers.java
index 933063b57..f8859c9a2 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/PluginWrapperTestHelpers.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/PluginWrapperTestHelpers.java
@@ -18,7 +18,9 @@
*/
package org.apache.tez.dag.app;
-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.assertSame;
import static org.mockito.Mockito.mock;
import java.lang.reflect.Constructor;
@@ -31,7 +33,6 @@ import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public final class PluginWrapperTestHelpers {
private static final Logger LOG = LoggerFactory.getLogger(PluginWrapperTestHelpers.class);
@@ -69,8 +70,9 @@ public final class PluginWrapperTestHelpers {
if (answer.compareAsPrimitive) {
assertEquals(answer.lastRetValue, result);
} else {
- assertSame("Expected: " + System.identityHashCode(answer.lastRetValue) + ", actual=" +
- System.identityHashCode(result), answer.lastRetValue, result);
+ assertSame(answer.lastRetValue, result,
+ "Expected: " + System.identityHashCode(answer.lastRetValue) + ", actual=" +
+ System.identityHashCode(result));
}
}
}
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestDAGAppMaster.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestDAGAppMaster.java
index c9da5cd6d..e98d68f64 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestDAGAppMaster.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestDAGAppMaster.java
@@ -18,10 +18,12 @@
*/
package org.apache.tez.dag.app;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -44,6 +46,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -56,7 +59,6 @@ import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.SecretManager;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
-import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
@@ -93,10 +95,10 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-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.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -111,18 +113,19 @@ public class TestDAGAppMaster {
private static final File TEST_DIR = new File(System.getProperty("test.build.data"),
TestDAGAppMaster.class.getName()).getAbsoluteFile();
- @Before
- public void setup() {
+ @BeforeAll
+ public static void setup() {
FileUtil.fullyDelete(TEST_DIR);
TEST_DIR.mkdirs();
}
- @After
- public void teardown() {
+ @AfterAll
+ public static void teardown() {
FileUtil.fullyDelete(TEST_DIR);
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testInvalidSession() throws Exception {
// AM should fail if not the first attempt and in session mode and
// DAG recovery is disabled, otherwise the app can succeed without
@@ -144,11 +147,12 @@ public class TestDAGAppMaster {
break;
}
}
- Assert.assertTrue("Missing invalid session diagnostics", found);
+ assertTrue(found, "Missing invalid session diagnostics");
dam.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPluginParsing() throws IOException {
BiMap<String, Integer> pluginMap = HashBiMap.create();
Configuration conf = new Configuration(false);
@@ -165,7 +169,7 @@ public class TestDAGAppMaster {
assertEquals(1, pluginMap.size());
assertEquals(1, entities.size());
assertTrue(pluginMap.containsKey(TezConstants.getTezYarnServicePluginName()));
- assertTrue(0 == pluginMap.get(TezConstants.getTezYarnServicePluginName()));
+ assertEquals(0, (int) pluginMap.get(TezConstants.getTezYarnServicePluginName()));
assertEquals("testval",
TezUtils.createConfFromUserPayload(entities.get(0).getUserPayload()).get("testkey"));
@@ -176,7 +180,7 @@ public class TestDAGAppMaster {
assertEquals(1, pluginMap.size());
assertEquals(1, entities.size());
assertTrue(pluginMap.containsKey(TezConstants.getTezUberServicePluginName()));
- assertTrue(0 == pluginMap.get(TezConstants.getTezUberServicePluginName()));
+ assertEquals(0, (int) pluginMap.get(TezConstants.getTezUberServicePluginName()));
assertEquals("testval",
TezUtils.createConfFromUserPayload(entities.get(0).getUserPayload()).get("testkey"));
@@ -187,9 +191,9 @@ public class TestDAGAppMaster {
assertEquals(2, pluginMap.size());
assertEquals(2, entities.size());
assertTrue(pluginMap.containsKey(TezConstants.getTezYarnServicePluginName()));
- assertTrue(0 == pluginMap.get(TezConstants.getTezYarnServicePluginName()));
+ assertEquals(0, (int) pluginMap.get(TezConstants.getTezYarnServicePluginName()));
assertTrue(pluginMap.containsKey(TezConstants.getTezUberServicePluginName()));
- assertTrue(1 == pluginMap.get(TezConstants.getTezUberServicePluginName()));
+ assertEquals(1, (int) pluginMap.get(TezConstants.getTezUberServicePluginName()));
String pluginName = "d1";
@@ -210,7 +214,7 @@ public class TestDAGAppMaster {
assertEquals(1, pluginMap.size());
assertEquals(1, entities.size());
assertTrue(pluginMap.containsKey(pluginName));
- assertTrue(0 == pluginMap.get(pluginName));
+ assertEquals(0, (int) pluginMap.get(pluginName));
// Test descriptor, yarn and uber
pluginMap.clear();
@@ -219,16 +223,17 @@ public class TestDAGAppMaster {
assertEquals(3, pluginMap.size());
assertEquals(3, entities.size());
assertTrue(pluginMap.containsKey(TezConstants.getTezYarnServicePluginName()));
- assertTrue(0 == pluginMap.get(TezConstants.getTezYarnServicePluginName()));
+ assertEquals(0, (int) pluginMap.get(TezConstants.getTezYarnServicePluginName()));
assertTrue(pluginMap.containsKey(TezConstants.getTezUberServicePluginName()));
- assertTrue(1 == pluginMap.get(TezConstants.getTezUberServicePluginName()));
+ assertEquals(1, (int) pluginMap.get(TezConstants.getTezUberServicePluginName()));
assertTrue(pluginMap.containsKey(pluginName));
- assertTrue(2 == pluginMap.get(pluginName));
+ assertEquals(2, (int) pluginMap.get(pluginName));
entityDescriptors.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testParseAllPluginsNoneSpecified() throws IOException {
PluginManager pluginManager = new PluginManager();
Configuration conf = new Configuration(false);
@@ -263,7 +268,8 @@ public class TestDAGAppMaster {
TezConstants.getTezUberServicePluginName());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testParseAllPluginsCustomAndYarnSpecified() throws IOException {
Configuration conf = new Configuration(false);
conf.set(TEST_KEY, TEST_VAL);
@@ -293,7 +299,8 @@ public class TestDAGAppMaster {
assertEquals(TC_NAME + CLASS_SUFFIX, pluginDescriptors.getTaskCommunicatorDescriptors().get(1).getClassName());
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testShutdownTezAMWithMissingRecoveryAndFailureOnMissingData() throws Exception {
TezConfiguration conf = new TezConfiguration();
@@ -327,8 +334,8 @@ public class TestDAGAppMaster {
// This ensures that recovery data file system was called for getting summary files, and it will return false
verify(mockFs, times(2)).exists(captor.capture());
- Assert.assertTrue(captor.getAllValues().get(1).toString().contains("/recovery/1/summary"));
- Assert.assertTrue(captor.getAllValues().get(0).toString().contains("/recovery/1/RecoveryFatalErrorOccurred"));
+ assertTrue(captor.getAllValues().get(1).toString().contains("/recovery/1/summary"));
+ assertTrue(captor.getAllValues().get(0).toString().contains("/recovery/1/RecoveryFatalErrorOccurred"));
verify(dam.mockScheduler).setShouldUnregisterFlag();
verify(dam.mockShutdown).shutdown();
@@ -371,8 +378,8 @@ public class TestDAGAppMaster {
// This ensures that recovery data file system was called for getting summary files, and it will return false
verify(mockFs, times(2)).exists(captor.capture());
- Assert.assertTrue(captor.getAllValues().get(1).toString().contains("/recovery/1/summary"));
- Assert.assertTrue(captor.getAllValues().get(0).toString().contains("/recovery/1/RecoveryFatalErrorOccurred"));
+ assertTrue(captor.getAllValues().get(1).toString().contains("/recovery/1/summary"));
+ assertTrue(captor.getAllValues().get(0).toString().contains("/recovery/1/RecoveryFatalErrorOccurred"));
verify(dam.mockScheduler).setShouldUnregisterFlag();
verify(dam.mockShutdown).shutdown();
@@ -397,8 +404,8 @@ public class TestDAGAppMaster {
assertEquals(TEST_VAL,
TezUtils.createConfFromUserPayload(descriptors.get(0).getUserPayload()).get(TEST_KEY));
}
- assertTrue(map.get(expectedNames[i]) == i);
- assertTrue(map.inverse().get(i) == expectedNames[i]);
+ assertEquals((int) map.get(expectedNames[i]), i);
+ assertSame(map.inverse().get(i), expectedNames[i]);
}
}
@@ -453,16 +460,15 @@ public class TestDAGAppMaster {
TezConfiguration conf = new TezConfiguration(false);
conf.setBoolean(TezConfiguration.DAG_RECOVERY_ENABLED, false);
dam.init(conf);
- LambdaTestUtils.intercept(TezUncheckedException.class,
- "Cannot get ApplicationACLs before all services have started, The current service state is INITED",
- () -> dam.getContext().getApplicationACLs());
+ TezUncheckedException e1 = assertThrows(TezUncheckedException.class, () -> dam.getContext().getApplicationACLs());
+ assertTrue(e1.getMessage()
+ .contains("Cannot get ApplicationACLs before all services have started, The current service state is INITED"));
dam.start();
dam.stop();
Mockito.when(dam.mockShutdown.getShutdownTime()).thenReturn(Date.from(Instant.ofEpochMilli(Time.now())));
- LambdaTestUtils.intercept(TezUncheckedException.class,
- " Cannot get ApplicationACLs before all services have started, "
- + "The current service state is STOPPED. The shutdown hook started at "
- + dam.mockShutdown.getShutdownTime(), () -> dam.getContext().getApplicationACLs());
+ TezUncheckedException e2 = assertThrows(TezUncheckedException.class, () -> dam.getContext().getApplicationACLs());
+ assertTrue(e2.getMessage()
+ .contains("Cannot get ApplicationACLs before all services have started, The current service state is STOPPED"));
}
@Test
@@ -530,20 +536,14 @@ public class TestDAGAppMaster {
map.put(mockVertexID, mockVertex);
when(dag.getVertices()).thenReturn(map);
when(dag.getTotalVertices()).thenReturn(1);
- Assert.assertEquals("Progress was NaN and should be reported as 0",
- 0, am.getProgress(), 0);
+ assertEquals(0, am.getProgress(), 0, "Progress was NaN and should be reported as 0");
when(mockVertex.getProgress()).thenReturn(-10f);
- Assert.assertEquals("Progress was negative and should be reported as 0",
- 0, am.getProgress(), 0);
+ assertEquals(0, am.getProgress(), 0, "Progress was negative and should be reported as 0");
when(mockVertex.getProgress()).thenReturn(1.0000567f);
- Assert.assertEquals(
- "Progress was greater than 1 by a small float precision "
- + "1.0000567 and should be reported as 1",
- 1.0f, am.getProgress(), 0.0f);
+ assertEquals(1.0f, am.getProgress(), 0.0f,
+ "Progress was greater than 1 by a small float precision " + "1.0000567 and should be reported as 1");
when(mockVertex.getProgress()).thenReturn(10f);
- Assert.assertEquals(
- "Progress was greater than 1 and should be reported as 1",
- 1.0f, am.getProgress(), 0.0f);
+ assertEquals(1.0f, am.getProgress(), 0.0f, "Progress was greater than 1 and should be reported as 1");
}
@SuppressWarnings("deprecation")
@@ -614,10 +614,10 @@ public class TestDAGAppMaster {
Token<? extends TokenIdentifier> fetchedToken1 =
fetchedDagCreds.getToken(tokenAlias1);
if (doMerge) {
- assertNotNull("AM creds missing from DAG creds", fetchedToken1);
+ assertNotNull(fetchedToken1, "AM creds missing from DAG creds");
compareTestTokens(amToken1, fetchedDagCreds.getToken(tokenAlias1));
} else {
- assertNull("AM creds leaked to DAG creds", fetchedToken1);
+ assertNull(fetchedToken1, "AM creds leaked to DAG creds");
}
compareTestTokens(dagToken1, fetchedDagCreds.getToken(tokenAlias2));
compareTestTokens(dagToken2, fetchedDagCreds.getToken(tokenAlias3));
@@ -628,8 +628,7 @@ public class TestDAGAppMaster {
Token<? extends TokenIdentifier> actual) throws IOException {
TestTokenIdentifier expectedId = getTestTokenIdentifier(expected);
TestTokenIdentifier actualId = getTestTokenIdentifier(actual);
- assertEquals("Token id not preserved", expectedId.getTestId(),
- actualId.getTestId());
+ assertEquals(expectedId.getTestId(), actualId.getTestId(), "Token id not preserved");
}
private static TestTokenIdentifier getTestTokenIdentifier(
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java
index a99d15067..e4897ca2b 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java
@@ -18,6 +18,8 @@
*/
package org.apache.tez.dag.app;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -52,9 +54,9 @@ import org.apache.tez.util.StopWatch;
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
// The objective of these tests is to make sure the large job simulations pass
// within the memory limits set by the junit tests (1GB)
@@ -136,7 +138,7 @@ public class TestMemoryWithEvents {
mockLauncher.waitTillContainersLaunched();
mockLauncher.startScheduling(true);
DAGStatus status = dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
checkMemory(dag.getName(), mockApp);
stopwatch.stop();
System.out.println("Time taken(ms): " + stopwatch.now(TimeUnit.MILLISECONDS));
@@ -163,8 +165,9 @@ public class TestMemoryWithEvents {
}
}
- @Ignore
- @Test (timeout = 600000)
+ @Disabled
+ @Test
+ @Timeout(value = 600000, unit = TimeUnit.MILLISECONDS)
public void testMemoryRootInputEvents() throws Exception {
DAG dag = DAG.create("testMemoryRootInputEvents");
Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), numTasks);
@@ -177,8 +180,9 @@ public class TestMemoryWithEvents {
testMemory(dag, false);
}
- @Ignore
- @Test (timeout = 600000)
+ @Disabled
+ @Test
+ @Timeout(value = 600000, unit = TimeUnit.MILLISECONDS)
public void testMemoryOneToOne() throws Exception {
DAG dag = DAG.create("testMemoryOneToOne");
Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), numTasks);
@@ -192,8 +196,9 @@ public class TestMemoryWithEvents {
testMemory(dag, true);
}
- @Ignore
- @Test (timeout = 600000)
+ @Disabled
+ @Test
+ @Timeout(value = 600000, unit = TimeUnit.MILLISECONDS)
public void testMemoryBroadcast() throws Exception {
DAG dag = DAG.create("testMemoryBroadcast");
Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), numTasks);
@@ -207,8 +212,9 @@ public class TestMemoryWithEvents {
testMemory(dag, true);
}
- @Ignore
- @Test (timeout = 600000)
+ @Disabled
+ @Test
+ @Timeout(value = 600000, unit = TimeUnit.MILLISECONDS)
public void testMemoryScatterGather() throws Exception {
DAG dag = DAG.create("testMemoryScatterGather");
Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), numTasks);
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestMockDAGAppMaster.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestMockDAGAppMaster.java
index b696dae35..296e2c43a 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestMockDAGAppMaster.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestMockDAGAppMaster.java
@@ -18,6 +18,12 @@
*/
package org.apache.tez.dag.app;
+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.ByteArrayOutputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
@@ -27,6 +33,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -110,9 +117,9 @@ import org.apache.tez.serviceplugins.api.ContainerStopRequest;
import com.google.common.collect.Maps;
import com.google.common.primitives.Ints;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestMockDAGAppMaster {
private static final Log LOG = LogFactory.getLog(TestMockDAGAppMaster.class);
@@ -149,7 +156,8 @@ public class TestMockDAGAppMaster {
}
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLocalResourceSetup() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -179,16 +187,17 @@ public class TestMockDAGAppMaster {
ContainerLaunchContext launchContext = cData.launchContext;
Map<String, LocalResource> taskLR = launchContext.getLocalResources();
// verify tasks are launched with both DAG and task resources.
- Assert.assertTrue(taskLR.containsKey(lrName1));
- Assert.assertTrue(taskLR.containsKey(lrName2));
+ assertTrue(taskLR.containsKey(lrName1));
+ assertTrue(taskLR.containsKey(lrName2));
mockLauncher.startScheduling(true);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
tezClient.stop();
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInternalPreemption() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -211,16 +220,18 @@ public class TestMockDAGAppMaster {
mockLauncher.startScheduling(true);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
TezVertexID vertexId = TezVertexID.getInstance(dagImpl.getID(), 0);
TezTaskAttemptID killedTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 0);
TaskAttempt killedTa = dagImpl.getVertex(vA.getName()).getTask(0).getAttempt(killedTaId);
//Refer to TEZ-3950
- Assert.assertTrue(killedTa.getState().equals(TaskAttemptState.KILLED) || killedTa.getState().equals(TaskAttemptState.FAILED));
+ assertTrue(
+ killedTa.getState().equals(TaskAttemptState.KILLED) || killedTa.getState().equals(TaskAttemptState.FAILED));
tezClient.stop();
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicEvents() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -236,65 +247,56 @@ public class TestMockDAGAppMaster {
Vertex vB = Vertex.create("B", ProcessorDescriptor.create("Proc.class"), 2);
Vertex vC = Vertex.create("C", ProcessorDescriptor.create("Proc.class"), 2);
Vertex vD = Vertex.create("D", ProcessorDescriptor.create("Proc.class"), 2);
- dag.addVertex(vA)
- .addVertex(vB)
- .addVertex(vC)
- .addVertex(vD)
- .addEdge(
- Edge.create(vA, vB, EdgeProperty.create(DataMovementType.BROADCAST,
- DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
- OutputDescriptor.create("Out"), InputDescriptor.create("In"))))
- .addEdge(
- Edge.create(vA, vC, EdgeProperty.create(DataMovementType.SCATTER_GATHER,
- DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
- OutputDescriptor.create("Out"), InputDescriptor.create("In"))))
- .addEdge(
- Edge.create(vA, vD, EdgeProperty.create(DataMovementType.ONE_TO_ONE,
- DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
- OutputDescriptor.create("Out"), InputDescriptor.create("In"))));
+ dag.addVertex(vA).addVertex(vB).addVertex(vC).addVertex(vD).addEdge(Edge.create(vA, vB,
+ EdgeProperty.create(DataMovementType.BROADCAST, DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
+ OutputDescriptor.create("Out"), InputDescriptor.create("In")))).addEdge(Edge.create(vA, vC,
+ EdgeProperty.create(DataMovementType.SCATTER_GATHER, DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
+ OutputDescriptor.create("Out"), InputDescriptor.create("In")))).addEdge(Edge.create(vA, vD,
+ EdgeProperty.create(DataMovementType.ONE_TO_ONE, DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
+ OutputDescriptor.create("Out"), InputDescriptor.create("In"))));
DAGClient dagClient = tezClient.submitDAG(dag);
mockLauncher.waitTillContainersLaunched();
DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
mockLauncher.startScheduling(true);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
VertexImpl vImpl = (VertexImpl) dagImpl.getVertex(vB.getName());
TaskImpl tImpl = (TaskImpl) vImpl.getTask(1);
TezTaskAttemptID taId = TezTaskAttemptID.getInstance(tImpl.getTaskID(), 0);
List<TezEvent> tEvents = vImpl.getTaskAttemptTezEvents(taId, 0, 0, 1000).getEvents();
- Assert.assertEquals(2, tEvents.size()); // 2 from vA
- Assert.assertEquals(vA.getName(), tEvents.get(0).getDestinationInfo().getEdgeVertexName());
- Assert.assertEquals(0, ((DataMovementEvent)tEvents.get(0).getEvent()).getSourceIndex());
- Assert.assertEquals(vA.getName(), tEvents.get(1).getDestinationInfo().getEdgeVertexName());
- Assert.assertEquals(0, ((DataMovementEvent)tEvents.get(1).getEvent()).getSourceIndex());
- int targetIndex1 = ((DataMovementEvent)tEvents.get(0).getEvent()).getTargetIndex();
- int targetIndex2 = ((DataMovementEvent)tEvents.get(1).getEvent()).getTargetIndex();
+ assertEquals(2, tEvents.size()); // 2 from vA
+ assertEquals(vA.getName(), tEvents.get(0).getDestinationInfo().getEdgeVertexName());
+ assertEquals(0, ((DataMovementEvent) tEvents.get(0).getEvent()).getSourceIndex());
+ assertEquals(vA.getName(), tEvents.get(1).getDestinationInfo().getEdgeVertexName());
+ assertEquals(0, ((DataMovementEvent) tEvents.get(1).getEvent()).getSourceIndex());
+ int targetIndex1 = ((DataMovementEvent) tEvents.get(0).getEvent()).getTargetIndex();
+ int targetIndex2 = ((DataMovementEvent) tEvents.get(1).getEvent()).getTargetIndex();
// order of vA task completion can change order of events
- Assert.assertTrue("t1: " + targetIndex1 + " t2: " + targetIndex2,
- (targetIndex1 == 0 && targetIndex2 == 1) || (targetIndex1 == 1 && targetIndex2 == 0));
+ assertTrue((targetIndex1 == 0 && targetIndex2 == 1) || (targetIndex1 == 1 && targetIndex2 == 0),
+ "t1: " + targetIndex1 + " t2: " + targetIndex2);
vImpl = (VertexImpl) dagImpl.getVertex(vC.getName());
tImpl = (TaskImpl) vImpl.getTask(1);
taId = TezTaskAttemptID.getInstance(tImpl.getTaskID(), 0);
tEvents = vImpl.getTaskAttemptTezEvents(taId, 0, 0, 1000).getEvents();
- Assert.assertEquals(2, tEvents.size()); // 2 from vA
- Assert.assertEquals(vA.getName(), tEvents.get(0).getDestinationInfo().getEdgeVertexName());
- Assert.assertEquals(1, ((CompositeRoutedDataMovementEvent)tEvents.get(0).getEvent()).getSourceIndex());
- Assert.assertEquals(vA.getName(), tEvents.get(1).getDestinationInfo().getEdgeVertexName());
- Assert.assertEquals(1, ((CompositeRoutedDataMovementEvent)tEvents.get(1).getEvent()).getSourceIndex());
- targetIndex1 = ((CompositeRoutedDataMovementEvent)tEvents.get(0).getEvent()).getTargetIndex();
- targetIndex2 = ((CompositeRoutedDataMovementEvent)tEvents.get(1).getEvent()).getTargetIndex();
+ assertEquals(2, tEvents.size()); // 2 from vA
+ assertEquals(vA.getName(), tEvents.get(0).getDestinationInfo().getEdgeVertexName());
+ assertEquals(1, ((CompositeRoutedDataMovementEvent) tEvents.get(0).getEvent()).getSourceIndex());
+ assertEquals(vA.getName(), tEvents.get(1).getDestinationInfo().getEdgeVertexName());
+ assertEquals(1, ((CompositeRoutedDataMovementEvent) tEvents.get(1).getEvent()).getSourceIndex());
+ targetIndex1 = ((CompositeRoutedDataMovementEvent) tEvents.get(0).getEvent()).getTargetIndex();
+ targetIndex2 = ((CompositeRoutedDataMovementEvent) tEvents.get(1).getEvent()).getTargetIndex();
// order of vA task completion can change order of events
- Assert.assertTrue("t1: " + targetIndex1 + " t2: " + targetIndex2,
- (targetIndex1 == 0 && targetIndex2 == 1) || (targetIndex1 == 1 && targetIndex2 == 0));
+ assertTrue((targetIndex1 == 0 && targetIndex2 == 1) || (targetIndex1 == 1 && targetIndex2 == 0),
+ "t1: " + targetIndex1 + " t2: " + targetIndex2);
vImpl = (VertexImpl) dagImpl.getVertex(vD.getName());
tImpl = (TaskImpl) vImpl.getTask(1);
taId = TezTaskAttemptID.getInstance(tImpl.getTaskID(), 0);
tEvents = vImpl.getTaskAttemptTezEvents(taId, 0, 0, 1000).getEvents();
- Assert.assertEquals(1, tEvents.size()); // 1 from vA
- Assert.assertEquals(vA.getName(), tEvents.get(0).getDestinationInfo().getEdgeVertexName());
- Assert.assertEquals(0, ((DataMovementEvent)tEvents.get(0).getEvent()).getTargetIndex());
- Assert.assertEquals(0, ((DataMovementEvent)tEvents.get(0).getEvent()).getSourceIndex());
+ assertEquals(1, tEvents.size()); // 1 from vA
+ assertEquals(vA.getName(), tEvents.getFirst().getDestinationInfo().getEdgeVertexName());
+ assertEquals(0, ((DataMovementEvent) tEvents.getFirst().getEvent()).getTargetIndex());
+ assertEquals(0, ((DataMovementEvent) tEvents.getFirst().getEvent()).getSourceIndex());
tezClient.stop();
}
@@ -344,7 +346,8 @@ public class TestMockDAGAppMaster {
}
}
- @Test (timeout = 100000)
+ @Test
+ @Timeout(value = 100000, unit = TimeUnit.MILLISECONDS)
public void testMixedEdgeRouting() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -394,27 +397,28 @@ public class TestMockDAGAppMaster {
DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
mockLauncher.startScheduling(true);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
// vC uses on demand routing and its task does not provide events
VertexImpl vImpl = (VertexImpl) dagImpl.getVertex(vC.getName());
TaskImpl tImpl = (TaskImpl) vImpl.getTask(0);
TezTaskAttemptID taId = TezTaskAttemptID.getInstance(tImpl.getTaskID(), 0);
- Assert.assertEquals(0, tImpl.getTaskAttemptTezEvents(taId, 0, 1000).size());
+ assertEquals(0, tImpl.getTaskAttemptTezEvents(taId, 0, 1000).size());
// vD is mixed mode and only 1 out of 2 edges does legacy routing with task providing events
vImpl = (VertexImpl) dagImpl.getVertex(vD.getName());
tImpl = (TaskImpl) vImpl.getTask(0);
taId = TezTaskAttemptID.getInstance(tImpl.getTaskID(), 0);
- Assert.assertEquals(1, tImpl.getTaskAttemptTezEvents(taId, 0, 1000).size());
+ assertEquals(1, tImpl.getTaskAttemptTezEvents(taId, 0, 1000).size());
// vE has single legacy edge and does not use on demand routing and its task provides events
vImpl = (VertexImpl) dagImpl.getVertex(vE.getName());
tImpl = (TaskImpl) vImpl.getTask(0);
taId = TezTaskAttemptID.getInstance(tImpl.getTaskID(), 0);
- Assert.assertEquals(1, tImpl.getTaskAttemptTezEvents(taId, 0, 1000).size());
+ assertEquals(1, tImpl.getTaskAttemptTezEvents(taId, 0, 1000).size());
tezClient.stop();
}
- @Test (timeout = 100000)
+ @Test
+ @Timeout(value = 100000, unit = TimeUnit.MILLISECONDS)
public void testConcurrencyLimit() throws Exception {
// the test relies on local mode behavior of launching a new container per task.
// so task concurrency == container concurrency
@@ -454,8 +458,8 @@ public class TestMockDAGAppMaster {
mockLauncher.startScheduling(true);
DAGClient dagClient = tezClient.submitDAG(dag);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
- Assert.assertFalse(exceededConcurrency.get());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertFalse(exceededConcurrency.get());
tezClient.stop();
}
@@ -502,7 +506,7 @@ public class TestMockDAGAppMaster {
// the internal merges of counters covers the constructor code path.
counters.readFields(in);
} catch (IOException e) {
- Assert.fail(e.getMessage());
+ fail(e.getMessage());
}
counters.findCounter(vName, procCounterName).setValue(++counterValue);
for (OutputSpec output : taskSpec.getOutputs()) {
@@ -520,7 +524,7 @@ public class TestMockDAGAppMaster {
DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
mockLauncher.startScheduling(true);
DAGStatus status = dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
TezCounters counters = dagImpl.getAllCounters();
// verify processor counters
@@ -529,20 +533,21 @@ public class TestMockDAGAppMaster {
TezCounters vACounters = vAImpl.getAllCounters();
TezCounters vBCounters = vBImpl.getAllCounters();
- Assert.assertEquals(19, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, procCounterName)).getMax());
- Assert.assertEquals(1, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, procCounterName)).getMin());
- Assert.assertEquals(20, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, vBName)).getMax());
- Assert.assertEquals(2, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, vBName)).getMin());
+ assertEquals(19, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, procCounterName)).getMax());
+ assertEquals(1, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, procCounterName)).getMin());
+ assertEquals(20, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, vBName)).getMax());
+ assertEquals(2, ((AggregateTezCounterDelegate)vACounters.findCounter(vAName, vBName)).getMin());
- Assert.assertEquals(21, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, procCounterName)).getMin());
- Assert.assertEquals(21, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, procCounterName)).getMax());
- Assert.assertEquals(22, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, vAName)).getMin());
- Assert.assertEquals(22, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, vAName)).getMax());
+ assertEquals(21, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, procCounterName)).getMin());
+ assertEquals(21, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, procCounterName)).getMax());
+ assertEquals(22, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, vAName)).getMin());
+ assertEquals(22, ((AggregateTezCounterDelegate)vBCounters.findCounter(vBName, vAName)).getMax());
tezClient.stop();
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testBasicCounters() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null,
@@ -584,7 +589,7 @@ public class TestMockDAGAppMaster {
// the internal merges of counters covers the constructor code path.
counters.readFields(in);
} catch (IOException e) {
- Assert.fail(e.getMessage());
+ fail(e.getMessage());
}
counters.findCounter(vName, procCounterName).increment(1);
for (OutputSpec output : taskSpec.getOutputs()) {
@@ -602,22 +607,22 @@ public class TestMockDAGAppMaster {
DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
mockLauncher.startScheduling(true);
DAGStatus status = dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
TezCounters counters = dagImpl.getAllCounters();
String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
if (SystemUtils.IS_OS_LINUX) {
- Assert.assertTrue(counters.findCounter(DAGCounter.AM_CPU_MILLISECONDS).getValue() > 0);
+ assertTrue(counters.findCounter(DAGCounter.AM_CPU_MILLISECONDS).getValue() > 0);
}
// verify processor counters
- Assert.assertEquals(10, counters.findCounter(vAName, procCounterName).getValue());
- Assert.assertEquals(1, counters.findCounter(vBName, procCounterName).getValue());
+ assertEquals(10, counters.findCounter(vAName, procCounterName).getValue());
+ assertEquals(1, counters.findCounter(vBName, procCounterName).getValue());
// verify edge counters
- Assert.assertEquals(10, counters.findCounter(vAName, vBName).getValue());
- Assert.assertEquals(1, counters.findCounter(vBName, vAName).getValue());
+ assertEquals(10, counters.findCounter(vAName, vBName).getValue());
+ assertEquals(1, counters.findCounter(vBName, vAName).getValue());
// verify global counters
- Assert.assertEquals(11, counters.findCounter(globalCounterName, globalCounterName).getValue());
+ assertEquals(11, counters.findCounter(globalCounterName, globalCounterName).getValue());
VertexImpl vAImpl = (VertexImpl) dagImpl.getVertex(vAName);
VertexImpl vBImpl = (VertexImpl) dagImpl.getVertex(vBName);
TezCounters vACounters = vAImpl.getAllCounters();
@@ -625,20 +630,21 @@ public class TestMockDAGAppMaster {
String vACounterName = vACounters.findCounter(globalCounterName, globalCounterName).getName();
String vBCounterName = vBCounters.findCounter(globalCounterName, globalCounterName).getName();
if (vACounterName != vBCounterName) {
- Assert.fail("String counter name objects dont match despite interning.");
+ fail("String counter name objects dont match despite interning.");
}
CounterGroup vaGroup = vACounters.getGroup(globalCounterName);
String vaGrouName = vaGroup.getName();
CounterGroup vBGroup = vBCounters.getGroup(globalCounterName);
String vBGrouName = vBGroup.getName();
if (vaGrouName != vBGrouName) {
- Assert.fail("String group name objects dont match despite interning.");
+ fail("String group name objects dont match despite interning.");
}
tezClient.stop();
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testBasicStatistics() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null,
@@ -696,7 +702,7 @@ public class TestMockDAGAppMaster {
// this ensures that the serde code path is covered.
stats.readFields(in);
} catch (IOException e) {
- Assert.fail(e.getMessage());
+ fail(e.getMessage());
}
return stats;
}
@@ -707,21 +713,21 @@ public class TestMockDAGAppMaster {
DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
mockLauncher.startScheduling(true);
DAGStatus status = dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
// verify that the values have been correct aggregated
for (org.apache.tez.dag.app.dag.Vertex v : dagImpl.getVertices().values()) {
VertexStatistics vStats = v.getStatistics();
if (v.getName().equals(vAName)) {
- Assert.assertEquals(3, vStats.getOutputStatistics(vBName).getDataSize());
- Assert.assertEquals(3, vStats.getInputStatistics(sourceName).getDataSize());
- Assert.assertEquals(3, vStats.getOutputStatistics(vBName).getItemsProcessed());
- Assert.assertEquals(3, vStats.getInputStatistics(sourceName).getItemsProcessed());
+ assertEquals(3, vStats.getOutputStatistics(vBName).getDataSize());
+ assertEquals(3, vStats.getInputStatistics(sourceName).getDataSize());
+ assertEquals(3, vStats.getOutputStatistics(vBName).getItemsProcessed());
+ assertEquals(3, vStats.getInputStatistics(sourceName).getItemsProcessed());
} else {
- Assert.assertEquals(2, vStats.getInputStatistics(vAName).getDataSize());
- Assert.assertEquals(2, vStats.getOutputStatistics(sinkName).getDataSize());
- Assert.assertEquals(2, vStats.getInputStatistics(vAName).getItemsProcessed());
- Assert.assertEquals(2, vStats.getOutputStatistics(sinkName).getItemsProcessed());
+ assertEquals(2, vStats.getInputStatistics(vAName).getDataSize());
+ assertEquals(2, vStats.getOutputStatistics(sinkName).getDataSize());
+ assertEquals(2, vStats.getInputStatistics(vAName).getItemsProcessed());
+ assertEquals(2, vStats.getOutputStatistics(sinkName).getItemsProcessed());
}
}
@@ -753,8 +759,9 @@ public class TestMockDAGAppMaster {
System.out.println("##### Max Memory:" + runtime.maxMemory() / mb);
}
- @Ignore
- @Test (timeout = 60000)
+ @Disabled
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicCounterMemory() throws Exception {
Logger.getRootLogger().setLevel(Level.WARN);
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -791,15 +798,16 @@ public class TestMockDAGAppMaster {
DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
mockLauncher.startScheduling(true);
DAGStatus status = dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
TezCounters counters = dagImpl.getAllCounters();
- Assert.assertNotNull(counters);
+ assertNotNull(counters);
checkMemory(dag.getName(), mockApp);
tezClient.stop();
}
- @Ignore
- @Test (timeout = 60000)
+ @Disabled
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testTaskEventsProcessingSpeed() throws Exception {
Logger.getRootLogger().setLevel(Level.WARN);
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -818,12 +826,13 @@ public class TestMockDAGAppMaster {
mockApp.doSleep = false;
DAGClient dagClient = tezClient.submitDAG(dag);
DAGStatus status = dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
tezClient.stop();
}
- @Ignore
- @Test (timeout = 60000)
+ @Disabled
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicStatisticsMemory() throws Exception {
Logger.getRootLogger().setLevel(Level.WARN);
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -869,7 +878,7 @@ public class TestMockDAGAppMaster {
// this ensures that the serde code path is covered.
stats.readFields(in);
} catch (IOException e) {
- Assert.fail(e.getMessage());
+ fail(e.getMessage());
}
return stats;
}
@@ -880,16 +889,17 @@ public class TestMockDAGAppMaster {
DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
mockLauncher.startScheduling(true);
DAGStatus status = dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
- Assert.assertEquals(numTasks,
+ assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
+ assertEquals(numTasks,
dagImpl.getVertex(vAName).getStatistics().getInputStatistics(0+vAName).getDataSize());
- Assert.assertEquals(numTasks,
+ assertEquals(numTasks,
dagImpl.getVertex(vAName).getStatistics().getInputStatistics(0+vAName).getItemsProcessed());
checkMemory(dag.getName(), mockApp);
tezClient.stop();
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testMultipleSubmissions() throws Exception {
Map<String, LocalResource> lrDAG = Maps.newHashMap();
String lrName1 = "LR1";
@@ -910,7 +920,7 @@ public class TestMockDAGAppMaster {
tezClient.start();
DAGClient dagClient = tezClient.submitDAG(dag);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
tezClient.stop();
// submit the same DAG again to verify it can be done.
@@ -918,11 +928,12 @@ public class TestMockDAGAppMaster {
tezClient.start();
dagClient = tezClient.submitDAG(dag);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
tezClient.stop();
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSchedulerErrorHandling() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -945,10 +956,11 @@ public class TestMockDAGAppMaster {
while(!mockApp.getShutdownHandler().wasShutdownInvoked()) {
Thread.sleep(100);
}
- Assert.assertEquals(DAGState.RUNNING, mockApp.getContext().getCurrentDAG().getState());
+ assertEquals(DAGState.RUNNING, mockApp.getContext().getCurrentDAG().getState());
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testInitFailed() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true,
@@ -957,14 +969,15 @@ public class TestMockDAGAppMaster {
tezClient.start();
} catch (Exception e) {
e.printStackTrace();
- Assert.assertEquals("FailInit", e.getCause().getCause().getCause().getMessage());
+ assertEquals("FailInit", e.getCause().getCause().getCause().getMessage());
MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
// will timeout if DAGAppMasterShutdownHook is not invoked
mockApp.waitForServiceToStop(Integer.MAX_VALUE);
}
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testStartFailed() {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true,
@@ -973,7 +986,7 @@ public class TestMockDAGAppMaster {
tezClient.start();
} catch (Exception e) {
e.printStackTrace();
- Assert.assertEquals("FailStart", e.getCause().getCause().getCause().getMessage());
+ assertEquals("FailStart", e.getCause().getCause().getCause().getMessage());
MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
// will timeout if DAGAppMasterShutdownHook is not invoked
mockApp.waitForServiceToStop(Integer.MAX_VALUE);
@@ -1016,7 +1029,8 @@ public class TestMockDAGAppMaster {
return dag;
}
- @Test (timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testCommitOutputOnDAGSuccess() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null, null);
@@ -1026,49 +1040,50 @@ public class TestMockDAGAppMaster {
DAG dag1 = createDAG("testDAGBothCommitsSucceed", false, false);
DAGClient dagClient = tezClient.submitDAG(dag1);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
// vertexGroupCommiter fail (uv12)
DAG dag2 = createDAG("testDAGVertexGroupCommitFail", true, false);
dagClient = tezClient.submitDAG(dag2);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
LOG.info(dagClient.getDAGStatus(null).getDiagnostics());
- Assert.assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
+ assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
.contains("fail output committer:uv12Out"));
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v3", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v3", null).getState());
// vertex commit fail (v3)
DAG dag3 = createDAG("testDAGVertexCommitFail", false, true);
dagClient = tezClient.submitDAG(dag3);
dagClient.waitForCompletion();
LOG.info(dagClient.getDAGStatus(null).getDiagnostics());
- Assert.assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
- Assert.assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
+ assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
+ assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
.contains("fail output committer:v3Out"));
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v3", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v3", null).getState());
// both committers fail
DAG dag4 = createDAG("testDAGBothCommitsFail", true, true);
dagClient = tezClient.submitDAG(dag4);
dagClient.waitForCompletion();
LOG.info(dagClient.getDAGStatus(null).getDiagnostics());
- Assert.assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
String diag = StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",");
- Assert.assertTrue(diag.contains("fail output committer:uv12Out") ||
+ assertTrue(diag.contains("fail output committer:uv12Out") ||
diag.contains("fail output committer:v3Out"));
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v3", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v3", null).getState());
tezClient.stop();
}
- @Test (timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testCommitOutputOnVertexSuccess() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
tezconf.setBoolean(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, false);
@@ -1079,25 +1094,25 @@ public class TestMockDAGAppMaster {
DAG dag1 = createDAG("testDAGBothCommitsSucceed", false, false);
DAGClient dagClient = tezClient.submitDAG(dag1);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
// vertexGroupCommiter fail (uv12)
DAG dag2 = createDAG("testDAGVertexGroupCommitFail", true, false);
dagClient = tezClient.submitDAG(dag2);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
LOG.info(dagClient.getDAGStatus(null).getDiagnostics());
- Assert.assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
+ assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
.contains("fail output committer:uv12Out"));
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
VertexStatus.State v3State = dagClient.getVertexStatus("v3", null).getState();
// v3 either succeeded (commit completed before uv12 commit fails)
// or killed ( uv12 commit fail when v3 is in running/committing)
if (v3State.equals(VertexStatus.State.SUCCEEDED)) {
LOG.info("v3 is succeeded");
} else {
- Assert.assertEquals(VertexStatus.State.KILLED, v3State);
+ assertEquals(VertexStatus.State.KILLED, v3State);
}
// vertex commit fail (v3)
@@ -1105,36 +1120,36 @@ public class TestMockDAGAppMaster {
dagClient = tezClient.submitDAG(dag3);
dagClient.waitForCompletion();
LOG.info(dagClient.getDAGStatus(null).getDiagnostics());
- Assert.assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
- Assert.assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
+ assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
+ assertTrue(StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",")
.contains("Commit failed"));
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
- Assert.assertEquals(VertexStatus.State.FAILED, dagClient.getVertexStatus("v3", null).getState());
- Assert.assertTrue(StringUtils.join(dagClient.getVertexStatus("v3", null).getDiagnostics(),",")
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
+ assertEquals(VertexStatus.State.FAILED, dagClient.getVertexStatus("v3", null).getState());
+ assertTrue(StringUtils.join(dagClient.getVertexStatus("v3", null).getDiagnostics(),",")
.contains("fail output committer:v3Out"));
// both committers fail
DAG dag4 = createDAG("testDAGBothCommitsFail", true, true);
dagClient = tezClient.submitDAG(dag4);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
LOG.info(dagClient.getDAGStatus(null).getDiagnostics());
- Assert.assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
String diag = StringUtils.join(dagClient.getDAGStatus(null).getDiagnostics(),",");
- Assert.assertTrue(diag.contains("fail output committer:uv12Out") ||
+ assertTrue(diag.contains("fail output committer:uv12Out") ||
diag.contains("fail output committer:v3Out"));
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
- Assert.assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v1", null).getState());
+ assertEquals(VertexStatus.State.SUCCEEDED, dagClient.getVertexStatus("v2", null).getState());
v3State = dagClient.getVertexStatus("v3", null).getState();
// v3 either failed (commit of v3 fail before uv12 commit)
// or killed ( uv12 commit fail before commit of v3)
if (v3State.equals(VertexStatus.State.FAILED)) {
LOG.info("v3 is failed");
- Assert.assertTrue(StringUtils.join(dagClient.getVertexStatus("v3", null).getDiagnostics(),",")
+ assertTrue(StringUtils.join(dagClient.getVertexStatus("v3", null).getDiagnostics(),",")
.contains("fail output committer:v3Out"));
} else {
- Assert.assertEquals(VertexStatus.State.KILLED, v3State);
+ assertEquals(VertexStatus.State.KILLED, v3State);
}
tezClient.stop();
@@ -1200,7 +1215,8 @@ public class TestMockDAGAppMaster {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGFinishedRecoveryError() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -1221,10 +1237,9 @@ public class TestMockDAGAppMaster {
while(!mockApp.getShutdownHandler().wasShutdownInvoked()) {
Thread.sleep(100);
}
- Assert.assertEquals(DAGState.SUCCEEDED, mockApp.getContext().getCurrentDAG().getState());
- Assert.assertEquals(DAGAppMasterState.FAILED, mockApp.getState());
- Assert.assertTrue(StringUtils.join(mockApp.getDiagnostics(),",")
- .contains("Recovery had a fatal error, shutting down session after" +
- " DAG completion"));
+ assertEquals(DAGState.SUCCEEDED, mockApp.getContext().getCurrentDAG().getState());
+ assertEquals(DAGAppMasterState.FAILED, mockApp.getState());
+ assertTrue(StringUtils.join(mockApp.getDiagnostics(), ",")
+ .contains("Recovery had a fatal error, shutting down session after" + " DAG completion"));
}
}
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestPreemption.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestPreemption.java
index ad3aa2362..f056b803f 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestPreemption.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestPreemption.java
@@ -18,7 +18,10 @@
*/
package org.apache.tez.dag.app;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.conf.Configuration;
@@ -46,8 +49,8 @@ import org.apache.tez.dag.records.TezTaskAttemptID;
import org.apache.tez.dag.records.TezTaskID;
import org.apache.tez.dag.records.TezVertexID;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestPreemption {
@@ -85,7 +88,8 @@ public class TestPreemption {
return dag;
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPreemptionWithoutSession() throws Exception {
System.out.println("TestPreemptionWithoutSession");
TezConfiguration tezconf = new TezConfiguration(defaultConf);
@@ -113,18 +117,19 @@ public class TestPreemption {
mockLauncher.startScheduling(true);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
for (int i=0; i<=upToTaskVersion; ++i) {
TezTaskAttemptID testTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), i);
TaskAttemptImpl taImpl = dagImpl.getTaskAttempt(testTaId);
- Assert.assertEquals(TaskAttemptStateInternal.KILLED, taImpl.getInternalState());
+ assertEquals(TaskAttemptStateInternal.KILLED, taImpl.getInternalState());
}
tezClient.stop();
}
- @Test (timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testPreemptionWithSession() throws Exception {
System.out.println("TestPreemptionWithSession");
MockTezClient tezClient = createTezSession();
@@ -194,13 +199,13 @@ public class TestPreemption {
mockLauncher.startScheduling(true);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
for (int i=0; i<=upToTaskVersion; ++i) {
TezTaskAttemptID testTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), i);
TaskAttemptImpl taImpl = dagImpl.getTaskAttempt(testTaId);
- Assert.assertEquals(TaskAttemptStateInternal.KILLED, taImpl.getInternalState());
- Assert.assertEquals(TaskAttemptTerminationCause.EXTERNAL_PREEMPTION, taImpl.getTerminationCause());
+ assertEquals(TaskAttemptStateInternal.KILLED, taImpl.getInternalState());
+ assertEquals(TaskAttemptTerminationCause.EXTERNAL_PREEMPTION, taImpl.getTerminationCause());
}
System.out.println("TestPreemption - Done running - " + info);
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestRecoveryParser.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestRecoveryParser.java
index 9fc29cd10..510628f0e 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestRecoveryParser.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestRecoveryParser.java
@@ -18,7 +18,12 @@
*/
package org.apache.tez.dag.app;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.*;
import java.io.IOException;
@@ -29,6 +34,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -81,7 +87,9 @@ import org.apache.tez.runtime.api.impl.TezEvent;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import org.junit.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestRecoveryParser {
@@ -98,7 +106,7 @@ public class TestRecoveryParser {
// Protobuf message limit is 64 MB by default
private static final int PROTOBUF_DEFAULT_SIZE_LIMIT = 64 << 20;
- @Before
+ @BeforeEach
public void setUp() throws IllegalArgumentException, IOException {
this.conf = new Configuration();
this.localFS = FileSystem.getLocal(conf);
@@ -119,7 +127,8 @@ public class TestRecoveryParser {
return data;
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetLastCompletedDAG() {
Map<TezDAGID, DAGSummaryData> summaryDataMap =
new HashMap<TezDAGID, DAGSummaryData>();
@@ -135,7 +144,8 @@ public class TestRecoveryParser {
assertEquals(lastCompletedDAGId, lastCompletedDAG.dagId.getId());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetLastInProgressDAG() {
Map<TezDAGID, DAGSummaryData> summaryDataMap =
new HashMap<TezDAGID, DAGSummaryData>();
@@ -157,7 +167,8 @@ public class TestRecoveryParser {
}
// skipAllOtherEvents due to non-recoverable (in the middle of commit)
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSkipAllOtherEvents_1() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -192,7 +203,7 @@ public class TestRecoveryParser {
rService.stop();
DAGRecoveryData dagData = parser.parseRecoveryData();
- assertEquals(true, dagData.nonRecoverable);
+ assertTrue(dagData.nonRecoverable);
assertTrue(dagData.reason.contains("DAG Commit was in progress, not recoverable,"));
// DAGSubmittedEvent is handled but DAGInitializedEvent and DAGStartedEvent in the next attempt are both skipped
// due to the dag is not recoerable.
@@ -202,7 +213,8 @@ public class TestRecoveryParser {
}
// skipAllOtherEvents due to dag finished
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSkipAllOtherEvents_2() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
@@ -239,9 +251,9 @@ public class TestRecoveryParser {
rService.stop();
DAGRecoveryData dagData = parser.parseRecoveryData();
- assertEquals(false, dagData.nonRecoverable);
+ assertFalse(dagData.nonRecoverable);
assertEquals(DAGState.FAILED, dagData.dagState);
- assertEquals(true, dagData.isCompleted);
+ assertTrue(dagData.isCompleted);
// DAGSubmittedEvent, DAGInitializedEvent and DAGFinishedEvent is handled
verify(mockAppMaster).createDAG(any(), any());
// DAGInitializedEvent may not been handled before DAGFinishedEvent,
@@ -250,7 +262,8 @@ public class TestRecoveryParser {
assertNull(dagData.getDAGStartedEvent());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLastCorruptedRecoveryRecord() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -288,15 +301,16 @@ public class TestRecoveryParser {
// corrupted last records will be skipped but the whole recovery logs will be read
DAGRecoveryData dagData = parser.parseRecoveryData();
- assertEquals(false, dagData.isCompleted);
- assertEquals(null, dagData.reason);
- assertEquals(false, dagData.nonRecoverable);
+ assertFalse(dagData.isCompleted);
+ assertNull(dagData.reason);
+ assertFalse(dagData.nonRecoverable);
// verify DAGSubmitedEvent & DAGInititlizedEvent is handled.
verify(mockAppMaster).createDAG(any(), any());
assertNotNull(dagData.getDAGInitializedEvent());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLastCorruptedSummaryRecord() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -330,7 +344,8 @@ public class TestRecoveryParser {
}
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableSummary_DAGInCommitting() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -361,7 +376,8 @@ public class TestRecoveryParser {
assertTrue(dagData.reason.contains("DAG Commit was in progress"));
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableSummary_DAGFinishCommitting() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
@@ -398,7 +414,8 @@ public class TestRecoveryParser {
assertTrue(dagData.isCompleted);
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableSummary_VertexInCommitting() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -429,7 +446,8 @@ public class TestRecoveryParser {
assertTrue(dagData.reason.contains("Vertex Commit was in progress"));
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableSummary_VertexFinishCommitting() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -466,7 +484,8 @@ public class TestRecoveryParser {
assertFalse(dagData.nonRecoverable);
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableSummary_VertexGroupInCommitting() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -500,7 +519,8 @@ public class TestRecoveryParser {
assertTrue(dagData.reason.contains("Vertex Group Commit was in progress"));
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableSummary_VertexGroupFinishCommitting() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -548,7 +568,8 @@ public class TestRecoveryParser {
assertFalse(dagData.nonRecoverable);
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableNonSummary1() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -586,7 +607,8 @@ public class TestRecoveryParser {
assertTrue(dagData.reason.contains("Vertex has been committed, but its full recovery events are not seen"));
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoverableNonSummary2() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -623,7 +645,8 @@ public class TestRecoveryParser {
+ ", but its full recovery events are not seen"));
}
- @Test(timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testRecoveryLargeEventData() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
@@ -684,15 +707,16 @@ public class TestRecoveryParser {
DAGRecoveryData dagData = parser.parseRecoveryData();
VertexRecoveryData v0data = dagData.getVertexRecoveryData(v0Id);
- assertNotNull("Vertex Recovery Data should be non-null", v0data);
+ assertNotNull(v0data, "Vertex Recovery Data should be non-null");
VertexConfigurationDoneEvent parsedVertexConfigurationDoneEvent = v0data.getVertexConfigurationDoneEvent();
- assertNotNull("Vertex Configuration Done Event should be non-null", parsedVertexConfigurationDoneEvent);
+ assertNotNull(parsedVertexConfigurationDoneEvent, "Vertex Configuration Done Event should be non-null");
VertexLocationHint parsedVertexLocationHint = parsedVertexConfigurationDoneEvent.getVertexLocationHint();
- assertNotNull("Vertex Location Hint should be non-null", parsedVertexLocationHint);
+ assertNotNull(parsedVertexLocationHint, "Vertex Location Hint should be non-null");
assertEquals(parsedVertexLocationHint.getTaskLocationHints().size(), 100000);
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRecoveryData() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestSpeculation.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestSpeculation.java
index 67caf3b3c..e68d834ea 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestSpeculation.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestSpeculation.java
@@ -18,15 +18,15 @@
*/
package org.apache.tez.dag.app;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.IOException;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -45,6 +45,7 @@ import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.Vertex;
import org.apache.tez.dag.api.client.DAGClient;
import org.apache.tez.dag.api.client.DAGStatus;
+import org.apache.tez.dag.api.client.DAGStatus.State;
import org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher;
import org.apache.tez.dag.app.dag.Task;
import org.apache.tez.dag.app.dag.TaskAttempt;
@@ -61,23 +62,16 @@ import org.apache.tez.dag.records.TezVertexID;
import com.google.common.base.Joiner;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.model.Statement;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* test speculation behavior given the list of estimator classes.
*/
-@RunWith(Parameterized.class)
public class TestSpeculation {
private final static Logger LOG = LoggerFactory.getLogger(TezConfiguration.class);
@@ -109,72 +103,41 @@ public class TestSpeculation {
*/
MockContainerLauncher mockLauncher;
- /**
- * The interface Retry.
- */
- @Retention(RetentionPolicy.RUNTIME)
- public @interface Retry {}
-
- /**
- * The type Retry rule.
- */
- class RetryRule implements TestRule {
-
- private AtomicInteger retryCount;
-
- /**
- * Instantiates a new Retry rule.
- *
- * @param retries the retries
- */
- RetryRule(int retries) {
- super();
- this.retryCount = new AtomicInteger(retries);
- }
+ private interface TestTask {
+ void run() throws Exception;
+ }
- @Override
- public Statement apply(final Statement base,
- final Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- Throwable caughtThrowable = null;
-
- while (retryCount.getAndDecrement() > 0) {
- try {
- base.evaluate();
- return;
- } catch (Throwable t) {
- caughtThrowable = t;
- if (retryCount.get() > 0 &&
- description.getAnnotation(Retry.class) != null) {
- if (!((t instanceof AssertionError && t.getMessage()
- .contains(ASSERT_SPECULATIONS_COUNT_MSG))
- || (t instanceof Exception && t.getMessage()
- .contains(UNIT_EXCEPTION_MESSAGE)))) {
- throw caughtThrowable;
- }
- LOG.warn("{} : Failed. Retries remaining: {}", description.getDisplayName(), retryCount.toString());
- } else {
- throw caughtThrowable;
- }
- }
+ private void runWithRetry(TestTask task) throws Exception {
+ int retries = ASSERT_SPECULATIONS_COUNT_RETRIES;
+ while (true) {
+ retries--;
+ try {
+ task.run();
+ return;
+ } catch (Throwable t) {
+ if (retries > 0 && ((t instanceof AssertionError && t.getMessage().contains(ASSERT_SPECULATIONS_COUNT_MSG)) ||
+ (t instanceof Exception && t.getMessage().contains(UNIT_EXCEPTION_MESSAGE)))) {
+ LOG.warn("Test failed. Retries remaining: {}", retries);
+ } else {
+ if (t instanceof Exception) {
+ throw (Exception) t;
}
+ throw new RuntimeException(t);
}
- };
+ }
}
}
- /**
- * The Rule.
- */
- @Rule
- public RetryRule rule = new RetryRule(ASSERT_SPECULATIONS_COUNT_RETRIES);
+ private Class<? extends TaskRuntimeEstimator> estimatorClass;
+
+ public void setup(Class<? extends TaskRuntimeEstimator> estimatorClass) {
+ this.estimatorClass = estimatorClass;
+ setDefaultConf();
+ }
/**
* Sets default conf.
*/
- @Before
public void setDefaultConf() {
try {
defaultConf = new Configuration(false);
@@ -207,13 +170,19 @@ public class TestSpeculation {
/**
* Tear down.
*/
- @After
+ @AfterEach
public void tearDown() {
defaultConf = null;
try {
- localFs.close();
- mockLauncher.shutdown();
- mockApp.close();
+ if (localFs != null) {
+ localFs.close();
+ }
+ if (mockLauncher != null) {
+ mockLauncher.shutdown();
+ }
+ if (mockApp != null) {
+ mockApp.close();
+ }
} catch (Exception e) {
e.printStackTrace();
}
@@ -224,23 +193,8 @@ public class TestSpeculation {
*
* @return the test parameters
*/
- @Parameterized.Parameters(name = "{index}: TaskEstimator(EstimatorClass {0})")
- public static Collection<Object[]> getTestParameters() {
- return Arrays.asList(new Object[][]{
- {SimpleExponentialTaskRuntimeEstimator.class},
- {LegacyTaskRuntimeEstimator.class}
- });
- }
-
- private Class<? extends TaskRuntimeEstimator> estimatorClass;
-
- /**
- * Instantiates a new Test speculation.
- *
- * @param estimatorKlass the estimator klass
- */
- public TestSpeculation(Class<? extends TaskRuntimeEstimator> estimatorKlass) {
- this.estimatorClass = estimatorKlass;
+ public static Stream<Class<? extends TaskRuntimeEstimator>> getTestParameters() {
+ return Stream.of(SimpleExponentialTaskRuntimeEstimator.class, LegacyTaskRuntimeEstimator.class);
}
/**
@@ -252,8 +206,9 @@ public class TestSpeculation {
MockTezClient createTezSession() throws Exception {
TezConfiguration tezconf = new TezConfiguration(defaultConf);
AtomicBoolean mockAppLauncherGoFlag = new AtomicBoolean(false);
- MockTezClient tezClient = new MockTezClient("testspeculation", tezconf, true, null, null,
- new MockClock(), mockAppLauncherGoFlag, false, false, 1, 2);
+ MockTezClient tezClient =
+ new MockTezClient("testspeculation", tezconf, true, null, null, new MockClock(), mockAppLauncherGoFlag, false,
+ false, 1, 2);
tezClient.start();
syncWithMockAppLauncher(false, mockAppLauncherGoFlag, tezClient);
return tezClient;
@@ -285,54 +240,58 @@ public class TestSpeculation {
*
* @throws Exception the exception
*/
- @Retry
- @Test (timeout = 30000)
- public void testSingleTaskSpeculation() throws Exception {
- // Map<Timeout conf value, expected number of tasks>
- Map<Long, Integer> confToExpected = new HashMap<Long, Integer>();
- confToExpected.put(Long.MAX_VALUE >> 1, 1); // Really long time to speculate
- confToExpected.put(100L, 2);
- confToExpected.put(-1L, 1); // Don't speculate
- defaultConf.setLong(TezConfiguration.TEZ_AM_SOONEST_RETRY_AFTER_NO_SPECULATE, 50);
- for(Map.Entry<Long, Integer> entry : confToExpected.entrySet()) {
- defaultConf.setLong(
- TezConfiguration.TEZ_AM_LEGACY_SPECULATIVE_SINGLE_TASK_VERTEX_TIMEOUT,
- entry.getKey());
-
- DAG dag = DAG.create("DAG-testSingleTaskSpeculation");
- Vertex vA = Vertex.create("A",
- ProcessorDescriptor.create("Proc.class"),
- 1);
- dag.addVertex(vA);
-
- MockTezClient tezClient = createTezSession();
-
- DAGClient dagClient = tezClient.submitDAG(dag);
- DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
- TezVertexID vertexId = TezVertexID.getInstance(dagImpl.getID(), 0);
- // original attempt is killed and speculative one is successful
- TezTaskAttemptID killedTaId =
- TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 0);
- TezTaskAttemptID successTaId =
- TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 1);
- Thread.sleep(200);
- // cause speculation trigger
- mockLauncher.setStatusUpdatesForTask(killedTaId, NUM_UPDATES_FOR_TEST_TASK);
-
- mockLauncher.startScheduling(true);
- dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
- Task task = dagImpl.getTask(killedTaId.getTaskID());
- Assert.assertEquals(entry.getValue().intValue(), task.getAttempts().size());
- if (entry.getValue() > 1) {
- Assert.assertEquals(successTaId, task.getSuccessfulAttempt().getTaskAttemptID());
- TaskAttempt killedAttempt = task.getAttempt(killedTaId);
- Joiner.on(",").join(killedAttempt.getDiagnostics()).contains("Killed as speculative attempt");
- Assert.assertEquals(TaskAttemptTerminationCause.TERMINATED_EFFECTIVE_SPECULATION,
- killedAttempt.getTerminationCause());
+ @ParameterizedTest(name = "{index}: TaskEstimator(EstimatorClass {0})")
+ @MethodSource("getTestParameters")
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ public void testSingleTaskSpeculation(Class<? extends TaskRuntimeEstimator> estimatorClass) throws Exception {
+ setup(estimatorClass);
+ runWithRetry(() -> {
+ // Map<Timeout conf value, expected number of tasks>
+ Map<Long, Integer> confToExpected = new HashMap<Long, Integer>();
+ confToExpected.put(Long.MAX_VALUE >> 1, 1); // Really long time to speculate
+ confToExpected.put(100L, 2);
+ confToExpected.put(-1L, 1); // Don't speculate
+ defaultConf.setLong(TezConfiguration.TEZ_AM_SOONEST_RETRY_AFTER_NO_SPECULATE, 50);
+ for(Map.Entry<Long, Integer> entry : confToExpected.entrySet()) {
+ defaultConf.setLong(
+ TezConfiguration.TEZ_AM_LEGACY_SPECULATIVE_SINGLE_TASK_VERTEX_TIMEOUT,
+ entry.getKey());
+
+ DAG dag = DAG.create("DAG-testSingleTaskSpeculation");
+ Vertex vA = Vertex.create("A",
+ ProcessorDescriptor.create("Proc.class"),
+ 1);
+ dag.addVertex(vA);
+
+ MockTezClient tezClient = createTezSession();
+
+ DAGClient dagClient = tezClient.submitDAG(dag);
+ DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
+ TezVertexID vertexId = TezVertexID.getInstance(dagImpl.getID(), 0);
+ // original attempt is killed and speculative one is successful
+ TezTaskAttemptID killedTaId =
+ TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 0);
+ TezTaskAttemptID successTaId =
+ TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 1);
+ Thread.sleep(200);
+ // cause speculation trigger
+ mockLauncher.setStatusUpdatesForTask(killedTaId, NUM_UPDATES_FOR_TEST_TASK);
+
+ mockLauncher.startScheduling(true);
+ dagClient.waitForCompletion();
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ Task task = dagImpl.getTask(killedTaId.getTaskID());
+ assertEquals(entry.getValue().intValue(), task.getAttempts().size());
+ if (entry.getValue() > 1) {
+ assertEquals(successTaId, task.getSuccessfulAttempt().getTaskAttemptID());
+ TaskAttempt killedAttempt = task.getAttempt(killedTaId);
+ Joiner.on(",").join(killedAttempt.getDiagnostics()).contains("Killed as speculative attempt");
+ assertEquals(TaskAttemptTerminationCause.TERMINATED_EFFECTIVE_SPECULATION,
+ killedAttempt.getTerminationCause());
+ }
+ tezClient.stop();
}
- tezClient.stop();
- }
+ });
}
/**
@@ -363,34 +322,28 @@ public class TestSpeculation {
mockLauncher.startScheduling(true);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED,
- dagClient.getDAGStatus(null).getState());
+ assertEquals(State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
Task task = dagImpl.getTask(killedTaId.getTaskID());
- Assert.assertEquals(ASSERT_SPECULATIONS_COUNT_MSG, 2,
- task.getAttempts().size());
- Assert.assertEquals(successTaId, task.getSuccessfulAttempt().getTaskAttemptID());
+ assertEquals(2, task.getAttempts().size(), ASSERT_SPECULATIONS_COUNT_MSG);
+ assertEquals(successTaId, task.getSuccessfulAttempt().getTaskAttemptID());
TaskAttempt killedAttempt = task.getAttempt(killedTaId);
Joiner.on(",").join(killedAttempt.getDiagnostics()).contains("Killed as speculative attempt");
- Assert.assertEquals(TaskAttemptTerminationCause.TERMINATED_EFFECTIVE_SPECULATION,
- killedAttempt.getTerminationCause());
+ assertEquals(TaskAttemptTerminationCause.TERMINATED_EFFECTIVE_SPECULATION, killedAttempt.getTerminationCause());
if (withProgress) {
// without progress updates occasionally more than 1 task speculates
- Assert.assertEquals(1, task.getCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue());
- Assert.assertEquals(1, dagImpl.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue());
+ assertEquals(1, task.getCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue());
+ assertEquals(1, dagImpl.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue());
org.apache.tez.dag.app.dag.Vertex v = dagImpl.getVertex(killedTaId.getVertexID());
- Assert.assertEquals(1, v.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue());
+ assertEquals(1, v.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue());
}
LegacySpeculator speculator =
(LegacySpeculator)(dagImpl.getVertex(vA.getName())).getSpeculator();
- Assert.assertEquals(20, speculator.getMinimumAllowedSpeculativeTasks());
- Assert.assertEquals(.2, speculator.getProportionTotalTasksSpeculatable(), 0);
- Assert.assertEquals(.25, speculator.getProportionRunningTasksSpeculatable(), 0);
- Assert.assertEquals(25, speculator.getSoonestRetryAfterNoSpeculate());
- Assert.assertEquals(50, speculator.getSoonestRetryAfterSpeculate());
+ assertEquals(20, speculator.getMinimumAllowedSpeculativeTasks());
+ assertEquals(.2, speculator.getProportionTotalTasksSpeculatable(), 0);
+ assertEquals(.25, speculator.getProportionRunningTasksSpeculatable(), 0);
+ assertEquals(25, speculator.getSoonestRetryAfterNoSpeculate());
+ assertEquals(50, speculator.getSoonestRetryAfterSpeculate());
tezClient.stop();
}
@@ -400,10 +353,12 @@ public class TestSpeculation {
*
* @throws Exception the exception
*/
- @Retry
- @Test (timeout=30000)
- public void testBasicSpeculationWithProgress() throws Exception {
- testBasicSpeculation(true);
+ @ParameterizedTest(name = "{index}: TaskEstimator(EstimatorClass {0})")
+ @MethodSource("getTestParameters")
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ public void testBasicSpeculationWithProgress(Class<? extends TaskRuntimeEstimator> estimatorClass) throws Exception {
+ setup(estimatorClass);
+ runWithRetry(() -> testBasicSpeculation(true));
}
/**
@@ -411,10 +366,13 @@ public class TestSpeculation {
*
* @throws Exception the exception
*/
- @Retry
- @Test (timeout=30000)
- public void testBasicSpeculationWithoutProgress() throws Exception {
- testBasicSpeculation(false);
+ @ParameterizedTest(name = "{index}: TaskEstimator(EstimatorClass {0})")
+ @MethodSource("getTestParameters")
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ public void testBasicSpeculationWithoutProgress(Class<? extends TaskRuntimeEstimator> estimatorClass)
+ throws Exception {
+ setup(estimatorClass);
+ runWithRetry(() -> testBasicSpeculation(false));
}
/**
@@ -422,60 +380,61 @@ public class TestSpeculation {
*
* @throws Exception the exception
*/
- @Retry
- @Test (timeout=30000)
- public void testBasicSpeculationPerVertexConf() throws Exception {
- DAG dag = DAG.create("DAG-testBasicSpeculationPerVertexConf");
- String vNameNoSpec = "A";
- String vNameSpec = "B";
- Vertex vA = Vertex.create(vNameNoSpec, ProcessorDescriptor.create("Proc.class"), 5);
- Vertex vB = Vertex.create(vNameSpec, ProcessorDescriptor.create("Proc.class"), 5);
- vA.setConf(TezConfiguration.TEZ_AM_SPECULATION_ENABLED, "false");
- dag.addVertex(vA);
- dag.addVertex(vB);
- // min/max src fraction is set to 1. So vertices will run sequentially
- dag.addEdge(
- Edge.create(vA, vB,
- EdgeProperty.create(DataMovementType.SCATTER_GATHER, DataSourceType.PERSISTED,
- SchedulingType.SEQUENTIAL, OutputDescriptor.create("O"),
- InputDescriptor.create("I"))));
+ @ParameterizedTest(name = "{index}: TaskEstimator(EstimatorClass {0})")
+ @MethodSource("getTestParameters")
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ public void testBasicSpeculationPerVertexConf(Class<? extends TaskRuntimeEstimator> estimatorClass) throws Exception {
+ setup(estimatorClass);
+ runWithRetry(() -> {
+ DAG dag = DAG.create("DAG-testBasicSpeculationPerVertexConf");
+ String vNameNoSpec = "A";
+ String vNameSpec = "B";
+ Vertex vA = Vertex.create(vNameNoSpec, ProcessorDescriptor.create("Proc.class"), 5);
+ Vertex vB = Vertex.create(vNameSpec, ProcessorDescriptor.create("Proc.class"), 5);
+ vA.setConf(TezConfiguration.TEZ_AM_SPECULATION_ENABLED, "false");
+ dag.addVertex(vA);
+ dag.addVertex(vB);
+ // min/max src fraction is set to 1. So vertices will run sequentially
+ dag.addEdge(
+ Edge.create(vA, vB,
+ EdgeProperty.create(DataMovementType.SCATTER_GATHER, DataSourceType.PERSISTED,
+ SchedulingType.SEQUENTIAL, OutputDescriptor.create("O"),
+ InputDescriptor.create("I"))));
- MockTezClient tezClient = createTezSession();
+ MockTezClient tezClient = createTezSession();
- DAGClient dagClient = tezClient.submitDAG(dag);
- DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
- TezVertexID vertexIdSpec = dagImpl.getVertex(vNameSpec).getVertexId();
- TezVertexID vertexIdNoSpec = dagImpl.getVertex(vNameNoSpec).getVertexId();
- // original attempt is killed and speculative one is successful
- TezTaskAttemptID killedTaId =
- TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexIdSpec, 0), 0);
- TezTaskAttemptID successfulTaId = TezTaskAttemptID
- .getInstance(TezTaskID.getInstance(vertexIdNoSpec, 0), 0);
+ DAGClient dagClient = tezClient.submitDAG(dag);
+ DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
+ TezVertexID vertexIdSpec = dagImpl.getVertex(vNameSpec).getVertexId();
+ TezVertexID vertexIdNoSpec = dagImpl.getVertex(vNameNoSpec).getVertexId();
+ // original attempt is killed and speculative one is successful
+ TezTaskAttemptID killedTaId =
+ TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexIdSpec, 0), 0);
+ TezTaskAttemptID successfulTaId = TezTaskAttemptID
+ .getInstance(TezTaskID.getInstance(vertexIdNoSpec, 0), 0);
- // cause speculation trigger for both
- mockLauncher.setStatusUpdatesForTask(killedTaId, NUM_UPDATES_FOR_TEST_TASK);
- mockLauncher.setStatusUpdatesForTask(successfulTaId, NUM_UPDATES_FOR_TEST_TASK);
+ // cause speculation trigger for both
+ mockLauncher.setStatusUpdatesForTask(killedTaId, NUM_UPDATES_FOR_TEST_TASK);
+ mockLauncher.setStatusUpdatesForTask(successfulTaId, NUM_UPDATES_FOR_TEST_TASK);
- mockLauncher.startScheduling(true);
- org.apache.tez.dag.app.dag.Vertex vSpec = dagImpl.getVertex(vertexIdSpec);
- org.apache.tez.dag.app.dag.Vertex vNoSpec = dagImpl.getVertex(vertexIdNoSpec);
- // Wait enough time to give chance for the speculator to trigger
- // speculation on VB.
- // This would fail because of JUnit time out.
- do {
- Thread.sleep(100);
- } while (vSpec.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue() <= 0);
- dagClient.waitForCompletion();
- // speculation for vA but not for vB
- Assert.assertTrue("Num Speculations is not higher than 0",
- vSpec.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue() > 0);
- Assert.assertEquals(0,
- vNoSpec.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue());
+ mockLauncher.startScheduling(true);
+ org.apache.tez.dag.app.dag.Vertex vSpec = dagImpl.getVertex(vertexIdSpec);
+ org.apache.tez.dag.app.dag.Vertex vNoSpec = dagImpl.getVertex(vertexIdNoSpec);
+ // Wait enough time to give chance for the speculator to trigger
+ // speculation on VB.
+ // This would fail because of JUnit time out.
+ do {
+ Thread.sleep(100);
+ } while (vSpec.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
+ .getValue() <= 0);
+ dagClient.waitForCompletion();
+ // speculation for vA but not for vB
+ assertTrue(vSpec.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue() > 0,
+ "Num Speculations is not higher than 0");
+ assertEquals(0, vNoSpec.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue());
- tezClient.stop();
+ tezClient.stop();
+ });
}
/**
@@ -483,42 +442,42 @@ public class TestSpeculation {
*
* @throws Exception the exception
*/
- @Retry
- @Test (timeout=30000)
- public void testBasicSpeculationNotUseful() throws Exception {
- DAG dag = DAG.create("DAG-testBasicSpeculationNotUseful");
- Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), 5);
- dag.addVertex(vA);
+ @ParameterizedTest(name = "{index}: TaskEstimator(EstimatorClass {0})")
+ @MethodSource("getTestParameters")
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ public void testBasicSpeculationNotUseful(Class<? extends TaskRuntimeEstimator> estimatorClass) throws Exception {
+ setup(estimatorClass);
+ runWithRetry(() -> {
+ DAG dag = DAG.create("DAG-testBasicSpeculationNotUseful");
+ Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), 5);
+ dag.addVertex(vA);
- MockTezClient tezClient = createTezSession();
+ MockTezClient tezClient = createTezSession();
- DAGClient dagClient = tezClient.submitDAG(dag);
- DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
- TezVertexID vertexId = TezVertexID.getInstance(dagImpl.getID(), 0);
- // original attempt is successful and speculative one is killed
- TezTaskAttemptID successTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 0);
- TezTaskAttemptID killedTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 1);
+ DAGClient dagClient = tezClient.submitDAG(dag);
+ DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
+ TezVertexID vertexId = TezVertexID.getInstance(dagImpl.getID(), 0);
+ // original attempt is successful and speculative one is killed
+ TezTaskAttemptID successTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 0);
+ TezTaskAttemptID killedTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 1);
- mockLauncher.setStatusUpdatesForTask(successTaId, NUM_UPDATES_FOR_TEST_TASK);
- mockLauncher.setStatusUpdatesForTask(killedTaId, NUM_UPDATES_FOR_TEST_TASK);
+ mockLauncher.setStatusUpdatesForTask(successTaId, NUM_UPDATES_FOR_TEST_TASK);
+ mockLauncher.setStatusUpdatesForTask(killedTaId, NUM_UPDATES_FOR_TEST_TASK);
- mockLauncher.startScheduling(true);
- dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
- Task task = dagImpl.getTask(killedTaId.getTaskID());
- Assert.assertEquals(2, task.getAttempts().size());
- Assert.assertEquals(successTaId, task.getSuccessfulAttempt().getTaskAttemptID());
- TaskAttempt killedAttempt = task.getAttempt(killedTaId);
- Joiner.on(",").join(killedAttempt.getDiagnostics()).contains("Killed speculative attempt as");
- Assert.assertEquals(TaskAttemptTerminationCause.TERMINATED_INEFFECTIVE_SPECULATION,
- killedAttempt.getTerminationCause());
- Assert.assertEquals(1, task.getCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue());
- Assert.assertEquals(1, dagImpl.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue());
- org.apache.tez.dag.app.dag.Vertex v = dagImpl.getVertex(killedTaId.getVertexID());
- Assert.assertEquals(1, v.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS)
- .getValue());
- tezClient.stop();
+ mockLauncher.startScheduling(true);
+ dagClient.waitForCompletion();
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ Task task = dagImpl.getTask(killedTaId.getTaskID());
+ assertEquals(2, task.getAttempts().size());
+ assertEquals(successTaId, task.getSuccessfulAttempt().getTaskAttemptID());
+ TaskAttempt killedAttempt = task.getAttempt(killedTaId);
+ Joiner.on(",").join(killedAttempt.getDiagnostics()).contains("Killed speculative attempt as");
+ assertEquals(TaskAttemptTerminationCause.TERMINATED_INEFFECTIVE_SPECULATION, killedAttempt.getTerminationCause());
+ assertEquals(1, task.getCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue());
+ assertEquals(1, dagImpl.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue());
+ org.apache.tez.dag.app.dag.Vertex v = dagImpl.getVertex(killedTaId.getVertexID());
+ assertEquals(1, v.getAllCounters().findCounter(TaskCounter.NUM_SPECULATIONS).getValue());
+ tezClient.stop();
+ });
}
}
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorContextImpl.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorContextImpl.java
index df9f975d4..a07f5528d 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorContextImpl.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorContextImpl.java
@@ -18,8 +18,9 @@
*/
package org.apache.tez.dag.app;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -27,6 +28,8 @@ import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.util.concurrent.TimeUnit;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -35,12 +38,13 @@ import org.apache.tez.dag.app.dag.DAG;
import org.apache.tez.dag.app.rm.container.AMContainerMap;
import org.apache.tez.serviceplugins.api.TaskCommunicatorContext;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestTaskCommunicatorContextImpl {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testIsKnownContainer() {
AppContext appContext = mock(AppContext.class);
when(appContext.getAMConf()).thenReturn(new Configuration());
@@ -104,16 +108,15 @@ public class TestTaskCommunicatorContextImpl {
TaskCommunicatorContextImpl commContext = new TaskCommunicatorContextImpl(null, null, null, 0);
commContext.dag = dag;
- Assert.assertEquals("DAG config should be exposed via context.dag.getConf()",
- commContext.getCurrentDagInfo().getConf().get("dagkey"), "dagvalue");
+ assertEquals("dagvalue", commContext.getCurrentDagInfo().getConf().get("dagkey"),
+ "DAG config should be exposed via context.dag.getConf()");
// TaskCommunicatorContextImpl.appContext.getCurrentDAG() is present
AppContext appContext = mock(AppContext.class);
when(appContext.getCurrentDAG()).thenReturn(dag);
commContext = new TaskCommunicatorContextImpl(appContext, null, null, 0);
- Assert.assertEquals(
- "DAG config should be exposed via context.appContext.getCurrentDAG().getConf()",
- commContext.getCurrentDagInfo().getConf().get("dagkey"), "dagvalue");
+ assertEquals("dagvalue", commContext.getCurrentDagInfo().getConf().get("dagkey"),
+ "DAG config should be exposed via context.appContext.getCurrentDAG().getConf()");
}
}
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager.java
index fe4431c36..d304100cd 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager.java
@@ -18,10 +18,11 @@
*/
package org.apache.tez.dag.app;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.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.doReturn;
@@ -42,6 +43,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -77,22 +79,24 @@ import org.apache.tez.serviceplugins.api.TaskCommunicator;
import org.apache.tez.serviceplugins.api.TaskCommunicatorContext;
import org.apache.tez.serviceplugins.api.TaskCommunicatorDescriptor;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
public class TestTaskCommunicatorManager {
- @Before
- @After
+ @BeforeEach
+ @AfterEach
public void resetForNextTest() {
TaskCommManagerForMultipleCommTest.reset();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNoTaskCommSpecified() throws IOException, TezException {
AppContext appContext = mock(AppContext.class);
@@ -109,7 +113,8 @@ public class TestTaskCommunicatorManager {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCustomTaskCommSpecified() throws IOException, TezException {
AppContext appContext = mock(AppContext.class);
@@ -144,7 +149,8 @@ public class TestTaskCommunicatorManager {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleTaskComms() throws IOException, TezException {
AppContext appContext = mock(AppContext.class);
@@ -188,7 +194,8 @@ public class TestTaskCommunicatorManager {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEventRouting() throws Exception {
AppContext appContext = mock(AppContext.class, RETURNS_DEEP_STUBS);
@@ -247,7 +254,8 @@ public class TestTaskCommunicatorManager {
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testReportFailureFromTaskCommunicator() throws TezException {
String dagName = DAG_NAME;
EventHandler eventHandler = mock(EventHandler.class);
@@ -279,7 +287,7 @@ public class TestTaskCommunicatorManager {
verify(eventHandler, times(1)).handle(argumentCaptor.capture());
Event rawEvent = argumentCaptor.getValue();
- assertTrue(rawEvent instanceof DAGEventTerminateDag);
+ assertInstanceOf(DAGEventTerminateDag.class, rawEvent);
DAGEventTerminateDag killEvent = (DAGEventTerminateDag) rawEvent;
assertTrue(killEvent.getDiagnosticInfo().contains("ReportError"));
assertTrue(killEvent.getDiagnosticInfo()
@@ -296,7 +304,7 @@ public class TestTaskCommunicatorManager {
verify(eventHandler, times(1)).handle(argumentCaptor.capture());
rawEvent = argumentCaptor.getValue();
- assertTrue(rawEvent instanceof DAGAppMasterEventUserServiceFatalError);
+ assertInstanceOf(DAGAppMasterEventUserServiceFatalError.class, rawEvent);
DAGAppMasterEventUserServiceFatalError event =
(DAGAppMasterEventUserServiceFatalError) rawEvent;
assertEquals(DAGAppMasterEventType.TASK_COMMUNICATOR_SERVICE_FATAL_ERROR, event.getType());
@@ -312,7 +320,8 @@ public class TestTaskCommunicatorManager {
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskCommunicatorUserError() {
TaskCommunicatorContextImpl taskCommContext = mock(TaskCommunicatorContextImpl.class);
TaskCommunicator taskCommunicator = mock(TaskCommunicator.class, new ExceptionAnswer());
@@ -344,7 +353,7 @@ public class TestTaskCommunicatorManager {
verify(eventHandler, times(1)).handle(argumentCaptor.capture());
Event rawEvent = argumentCaptor.getValue();
- assertTrue(rawEvent instanceof DAGAppMasterEventUserServiceFatalError);
+ assertInstanceOf(DAGAppMasterEventUserServiceFatalError.class, rawEvent);
DAGAppMasterEventUserServiceFatalError event =
(DAGAppMasterEventUserServiceFatalError) rawEvent;
@@ -362,7 +371,7 @@ public class TestTaskCommunicatorManager {
verify(eventHandler, times(2)).handle(argumentCaptor.capture());
rawEvent = argumentCaptor.getAllValues().get(1);
- assertTrue(rawEvent instanceof DAGAppMasterEventUserServiceFatalError);
+ assertInstanceOf(DAGAppMasterEventUserServiceFatalError.class, rawEvent);
event = (DAGAppMasterEventUserServiceFatalError) rawEvent;
assertEquals(DAGAppMasterEventType.TASK_COMMUNICATOR_SERVICE_FATAL_ERROR, event.getType());
@@ -432,7 +441,7 @@ public class TestTaskCommunicatorManager {
int taskCommIndex) throws TezException {
numTaskComms.incrementAndGet();
boolean added = taskCommIndices.add(taskCommIndex);
- assertTrue("Cannot add multiple taskComms with the same index", added);
+ assertTrue(added, "Cannot add multiple taskComms with the same index");
taskCommNames.add(taskCommDescriptor.getEntityName());
return super.createTaskCommunicator(taskCommDescriptor, taskCommIndex);
}
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager1.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager1.java
index bf7acb7d7..165025477 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager1.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager1.java
@@ -18,11 +18,11 @@
*/
package org.apache.tez.dag.app;
-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 static org.mockito.Mockito.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -37,6 +37,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
@@ -96,8 +97,9 @@ import org.apache.tez.serviceplugins.api.TaskHeartbeatResponse;
import com.google.common.collect.Lists;
-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;
@SuppressWarnings("unchecked")
@@ -118,7 +120,7 @@ public class TestTaskCommunicatorManager1 {
TezTaskID taskID;
TezTaskAttemptID taskAttemptID;
- @Before
+ @BeforeEach
public void setUp() throws TezException {
appId = ApplicationId.newInstance(1000, 1);
appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
@@ -171,7 +173,8 @@ public class TestTaskCommunicatorManager1 {
containerTask = null;
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetTask() throws IOException {
TezTaskCommunicatorImpl taskCommunicator =
@@ -220,7 +223,8 @@ public class TestTaskCommunicatorManager1 {
assertTrue(containerTask.shouldDie());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetTaskMultiplePulls() throws IOException {
TezTaskCommunicatorImpl taskCommunicator =
(TezTaskCommunicatorImpl) taskAttemptListener.getTaskCommunicator(0).getTaskCommunicator();
@@ -244,7 +248,8 @@ public class TestTaskCommunicatorManager1 {
assertNull(containerTask);
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskEventRouting() throws Exception {
List<TezEvent> events = Arrays.asList(
new TezEvent(new TaskStatusUpdateEvent(null, 0.0f, null, false), new EventMetaData(EventProducerConsumerType.PROCESSOR,
@@ -262,24 +267,23 @@ public class TestTaskCommunicatorManager1 {
final List<Event> argAllValues = arg.getAllValues();
final Event statusUpdateEvent = argAllValues.get(0);
- assertEquals("First event should be status update", TaskAttemptEventType.TA_STATUS_UPDATE,
- statusUpdateEvent.getType());
- assertEquals(false, ((TaskAttemptEventStatusUpdate)statusUpdateEvent).getReadErrorReported());
+ assertEquals(TaskAttemptEventType.TA_STATUS_UPDATE, statusUpdateEvent.getType(),
+ "First event should be status update");
+ assertFalse(((TaskAttemptEventStatusUpdate) statusUpdateEvent).getReadErrorReported());
final TaskAttemptEventTezEventUpdate taEvent = (TaskAttemptEventTezEventUpdate)argAllValues.get(1);
assertEquals(1, taEvent.getTezEvents().size());
- assertEquals(EventType.DATA_MOVEMENT_EVENT,
- taEvent.getTezEvents().get(0).getEventType());
+ assertEquals(EventType.DATA_MOVEMENT_EVENT, taEvent.getTezEvents().getFirst().getEventType());
final TaskAttemptEvent taCompleteEvent = (TaskAttemptEvent)argAllValues.get(2);
assertEquals(TaskAttemptEventType.TA_DONE, taCompleteEvent.getType());
final VertexEventRouteEvent vertexRouteEvent = (VertexEventRouteEvent)argAllValues.get(3);
assertEquals(1, vertexRouteEvent.getEvents().size());
- assertEquals(EventType.DATA_MOVEMENT_EVENT,
- vertexRouteEvent.getEvents().get(0).getEventType());
+ assertEquals(EventType.DATA_MOVEMENT_EVENT, vertexRouteEvent.getEvents().getFirst().getEventType());
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskEventRoutingWithReadError() throws Exception {
List<TezEvent> events = Arrays.asList(
new TezEvent(new TaskStatusUpdateEvent(null, 0.0f, null, false), null),
@@ -296,29 +300,24 @@ public class TestTaskCommunicatorManager1 {
final List<Event> argAllValues = arg.getAllValues();
final Event statusUpdateEvent = argAllValues.get(0);
- assertEquals("First event should be status update", TaskAttemptEventType.TA_STATUS_UPDATE,
- statusUpdateEvent.getType());
- assertEquals(true, ((TaskAttemptEventStatusUpdate)statusUpdateEvent).getReadErrorReported());
+ assertEquals(TaskAttemptEventType.TA_STATUS_UPDATE, statusUpdateEvent.getType(),
+ "First event should be status update");
+ assertTrue(((TaskAttemptEventStatusUpdate) statusUpdateEvent).getReadErrorReported());
final Event taFinishedEvent = argAllValues.get(1);
- assertEquals("Second event should be TA_DONE", TaskAttemptEventType.TA_DONE,
- taFinishedEvent.getType());
+ assertEquals(TaskAttemptEventType.TA_DONE, taFinishedEvent.getType(), "Second event should be TA_DONE");
final Event vertexEvent = argAllValues.get(2);
final VertexEventRouteEvent vertexRouteEvent = (VertexEventRouteEvent)vertexEvent;
- assertEquals("Third event should be routed to vertex", VertexEventType.V_ROUTE_EVENT,
- vertexEvent.getType());
- assertEquals(EventType.INPUT_READ_ERROR_EVENT,
- vertexRouteEvent.getEvents().get(0).getEventType());
+ assertEquals(VertexEventType.V_ROUTE_EVENT, vertexEvent.getType(), "Third event should be routed to vertex");
+ assertEquals(EventType.INPUT_READ_ERROR_EVENT, vertexRouteEvent.getEvents().get(0).getEventType());
}
-
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskEventRoutingTaskAttemptOnly() throws Exception {
- List<TezEvent> events = Arrays.asList(
- new TezEvent(new TaskAttemptCompletedEvent(), new EventMetaData(EventProducerConsumerType.SYSTEM,
- "v1", "v2", taskAttemptID))
- );
+ List<TezEvent> events = Arrays.asList(new TezEvent(new TaskAttemptCompletedEvent(),
+ new EventMetaData(EventProducerConsumerType.SYSTEM, "v1", "v2", taskAttemptID)));
generateHeartbeat(events, 0, 1, 0, new ArrayList<TezEvent>());
ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
@@ -327,14 +326,14 @@ public class TestTaskCommunicatorManager1 {
final Event event = argAllValues.get(0);
// Route to TaskAttempt directly rather than through Vertex
- assertEquals("only event should be route event", TaskAttemptEventType.TA_DONE,
- event.getType());
+ assertEquals(TaskAttemptEventType.TA_DONE, event.getType(), "only event should be route event");
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskHeartbeatResponse() throws Exception {
- List<TezEvent> events = new ArrayList<TezEvent>();
- List<TezEvent> eventsToSend = new ArrayList<TezEvent>();
+ List<TezEvent> events = new ArrayList<>();
+ List<TezEvent> eventsToSend = new ArrayList<>();
TaskHeartbeatResponse response = generateHeartbeat(events, 0, 1, 2, eventsToSend);
assertEquals(2, response.getNextFromEventId());
@@ -342,7 +341,8 @@ public class TestTaskCommunicatorManager1 {
}
//try 10 times to allocate random port, fail it if no one is succeed.
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPortRange() {
boolean succeedToAllocate = false;
Random rand = new Random();
@@ -359,7 +359,8 @@ public class TestTaskCommunicatorManager1 {
}
// TODO TEZ-2003 Move this into TestTezTaskCommunicator. Potentially other tests as well.
- @Test (timeout= 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPortRange_NotSpecified() throws IOException, TezException {
Configuration conf = new Configuration();
JobTokenIdentifier identifier = new JobTokenIdentifier(new Text(
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager2.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager2.java
index a4151087b..e077310f0 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager2.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorManager2.java
@@ -18,8 +18,9 @@
*/
package org.apache.tez.dag.app;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doReturn;
@@ -34,6 +35,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
@@ -75,13 +77,15 @@ import org.apache.tez.serviceplugins.api.TaskHeartbeatRequest;
import com.google.common.collect.Lists;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.ArgumentCaptor;
public class TestTaskCommunicatorManager2 {
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskAttemptFailedKilled() throws IOException, TezException {
TaskCommunicatorManagerWrapperForTest wrapper = new TaskCommunicatorManagerWrapperForTest();
@@ -107,8 +111,8 @@ public class TestTaskCommunicatorManager2 {
ArgumentCaptor<Event> argumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(wrapper.getEventHandler(), times(2)).handle(argumentCaptor.capture());
- assertTrue(argumentCaptor.getAllValues().get(0) instanceof TaskAttemptEventAttemptFailed);
- assertTrue(argumentCaptor.getAllValues().get(1) instanceof TaskAttemptEventAttemptKilled);
+ assertInstanceOf(TaskAttemptEventAttemptFailed.class, argumentCaptor.getAllValues().get(0));
+ assertInstanceOf(TaskAttemptEventAttemptKilled.class, argumentCaptor.getAllValues().get(1));
TaskAttemptEventAttemptFailed failedEvent =
(TaskAttemptEventAttemptFailed) argumentCaptor.getAllValues().get(0);
TaskAttemptEventAttemptKilled killedEvent =
@@ -125,7 +129,8 @@ public class TestTaskCommunicatorManager2 {
// Tests fatal and non fatal
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskAttemptFailureViaHeartbeat() throws IOException, TezException {
TaskCommunicatorManagerWrapperForTest wrapper = new TaskCommunicatorManagerWrapperForTest();
@@ -160,7 +165,7 @@ public class TestTaskCommunicatorManager2 {
ArgumentCaptor<Event> argumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(wrapper.getEventHandler(), times(1)).handle(argumentCaptor.capture());
- assertTrue(argumentCaptor.getAllValues().get(0) instanceof TaskAttemptEventAttemptFailed);
+ assertInstanceOf(TaskAttemptEventAttemptFailed.class, argumentCaptor.getAllValues().get(0));
TaskAttemptEventAttemptFailed failedEvent =
(TaskAttemptEventAttemptFailed) argumentCaptor.getAllValues().get(0);
assertEquals(TaskFailureType.NON_FATAL, failedEvent.getTaskFailureType());
@@ -183,7 +188,7 @@ public class TestTaskCommunicatorManager2 {
argumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(wrapper.getEventHandler(), times(1)).handle(argumentCaptor.capture());
- assertTrue(argumentCaptor.getAllValues().get(0) instanceof TaskAttemptEventAttemptFailed);
+ assertInstanceOf(TaskAttemptEventAttemptFailed.class, argumentCaptor.getAllValues().get(0));
failedEvent = (TaskAttemptEventAttemptFailed) argumentCaptor.getAllValues().get(0);
assertEquals(TaskFailureType.FATAL, failedEvent.getTaskFailureType());
assertTrue(failedEvent.getDiagnosticInfo().contains("-fatal-"));
@@ -191,7 +196,8 @@ public class TestTaskCommunicatorManager2 {
// Tests fatal and non fatal
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskAttemptFailureViaContext() throws IOException, TezException {
TaskCommunicatorManagerWrapperForTest wrapper = new TaskCommunicatorManagerWrapperForTest();
@@ -216,7 +222,7 @@ public class TestTaskCommunicatorManager2 {
TaskAttemptEndReason.CONTAINER_EXITED, "--non-fatal--");
ArgumentCaptor<Event> argumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(wrapper.getEventHandler(), times(1)).handle(argumentCaptor.capture());
- assertTrue(argumentCaptor.getAllValues().get(0) instanceof TaskAttemptEventAttemptFailed);
+ assertInstanceOf(TaskAttemptEventAttemptFailed.class, argumentCaptor.getAllValues().get(0));
TaskAttemptEventAttemptFailed failedEvent =
(TaskAttemptEventAttemptFailed) argumentCaptor.getAllValues().get(0);
assertEquals(TaskFailureType.NON_FATAL, failedEvent.getTaskFailureType());
@@ -230,7 +236,7 @@ public class TestTaskCommunicatorManager2 {
"--fatal--");
argumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(wrapper.getEventHandler(), times(1)).handle(argumentCaptor.capture());
- assertTrue(argumentCaptor.getAllValues().get(0) instanceof TaskAttemptEventAttemptFailed);
+ assertInstanceOf(TaskAttemptEventAttemptFailed.class, argumentCaptor.getAllValues().get(0));
failedEvent = (TaskAttemptEventAttemptFailed) argumentCaptor.getAllValues().get(0);
assertEquals(TaskFailureType.FATAL, failedEvent.getTaskFailureType());
assertTrue(failedEvent.getDiagnosticInfo().contains("--fatal--"));
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorWrapper.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorWrapper.java
index b225e2569..877fb1bce 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorWrapper.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestTaskCommunicatorWrapper.java
@@ -18,15 +18,19 @@
*/
package org.apache.tez.dag.app;
+import java.util.concurrent.TimeUnit;
+
import org.apache.tez.serviceplugins.api.TaskCommunicator;
import com.google.common.collect.Sets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
public class TestTaskCommunicatorWrapper {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDelegation() throws Exception {
PluginWrapperTestHelpers.testDelegation(TaskCommunicatorWrapper.class, TaskCommunicator.class,
Sets.newHashSet("getTaskCommunicator"));
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/dag/TestRootInputInitializerManager.java b/tez-dag/src/test/java/org/apache/tez/dag/app/dag/TestRootInputInitializerManager.java
index 34621b20d..f6a5492b2 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/dag/TestRootInputInitializerManager.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/dag/TestRootInputInitializerManager.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.dag.app.dag;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doReturn;
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.api.records.ApplicationId;
@@ -56,7 +57,8 @@ import org.apache.tez.runtime.api.impl.TezEvent;
import com.google.common.collect.Lists;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.ArgumentCaptor;
public class TestRootInputInitializerManager {
@@ -66,7 +68,8 @@ public class TestRootInputInitializerManager {
// Primarily a failure scenario, when a Task moves back to running from success
// Order event1, success1, event2, success2
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEventBeforeSuccess() throws Exception {
InputDescriptor id = mock(InputDescriptor.class);
InputInitializerDescriptor iid = mock(InputInitializerDescriptor.class);
@@ -141,7 +144,8 @@ public class TestRootInputInitializerManager {
// Order event1 success1, success2, event2
// Primarily a failure scenario, when a Task moves back to running from success
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSuccessBeforeEvent() throws Exception {
InputDescriptor id = mock(InputDescriptor.class);
InputInitializerDescriptor iid = mock(InputInitializerDescriptor.class);
@@ -213,7 +217,8 @@ public class TestRootInputInitializerManager {
}
... 35311 lines suppressed ...