diff --git a/.codespellrc b/.codespellrc
new file mode 100644
index 0000000000..fee7e92ef2
--- /dev/null
+++ b/.codespellrc
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+[codespell]
+ignore-words-list = thirdparty,afterall,AfterAll
diff --git a/hadoop-shim-impls/hadoop-shim-2.7/pom.xml b/hadoop-shim-impls/hadoop-shim-2.7/pom.xml
index 441c253310..53cff14e8e 100644
--- a/hadoop-shim-impls/hadoop-shim-2.7/pom.xml
+++ b/hadoop-shim-impls/hadoop-shim-2.7/pom.xml
@@ -1,18 +1,22 @@
-
@@ -29,10 +33,6 @@
org.slf4j
slf4j-api
-
- junit
- junit
-
org.apache.tez
hadoop-shim
diff --git a/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim25_26_27Provider.java b/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim25_26_27Provider.java
index bd1eabfa32..df363348a4 100644
--- a/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim25_26_27Provider.java
+++ b/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim25_26_27Provider.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -6,16 +6,16 @@
* 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.
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.tez.hadoop.shim;
import org.apache.hadoop.classification.InterfaceAudience.Private;
diff --git a/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim27.java b/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim27.java
index c5163036a1..61cdfa8d38 100644
--- a/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim27.java
+++ b/hadoop-shim-impls/hadoop-shim-2.7/src/main/java/org/apache/tez/hadoop/shim/HadoopShim27.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -6,16 +6,16 @@
* 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.
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.tez.hadoop.shim;
import java.util.EnumSet;
diff --git a/hadoop-shim-impls/hadoop-shim-2.7/src/test/java/org/apache/tez/hadoop/shim/TestHadoop25_26_27ShimProvider.java b/hadoop-shim-impls/hadoop-shim-2.7/src/test/java/org/apache/tez/hadoop/shim/TestHadoop25_26_27ShimProvider.java
index c9937f8b94..a1af80bb07 100644
--- a/hadoop-shim-impls/hadoop-shim-2.7/src/test/java/org/apache/tez/hadoop/shim/TestHadoop25_26_27ShimProvider.java
+++ b/hadoop-shim-impls/hadoop-shim-2.7/src/test/java/org/apache/tez/hadoop/shim/TestHadoop25_26_27ShimProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -6,37 +6,39 @@
* 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.
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.tez.hadoop.shim;
+import static org.junit.jupiter.api.Assertions.*;
+
import org.apache.hadoop.conf.Configuration;
-import org.junit.Assert;
-import org.junit.Test;
+
+import org.junit.jupiter.api.*;
public class TestHadoop25_26_27ShimProvider {
@Test
public void testShimProvider() {
HadoopShim25_26_27Provider provider = new HadoopShim25_26_27Provider();
- Assert.assertNull(provider.createHadoopShim("foo", 2, 2));
- Assert.assertNull(provider.createHadoopShim("foo", 2, 1));
- Assert.assertNull(provider.createHadoopShim("foo", 2, 3));
- Assert.assertNull(provider.createHadoopShim("foo", 2, 8));
- Assert.assertNull(provider.createHadoopShim("foo", 3, 3));
- Assert.assertNotNull(provider.createHadoopShim("foo", 2, 5));
- Assert.assertNotNull(provider.createHadoopShim("foo", 2, 6));
- Assert.assertNotNull(provider.createHadoopShim("foo", 2, 7));
+ assertNull(provider.createHadoopShim("foo", 2, 2));
+ assertNull(provider.createHadoopShim("foo", 2, 1));
+ assertNull(provider.createHadoopShim("foo", 2, 3));
+ assertNull(provider.createHadoopShim("foo", 2, 8));
+ assertNull(provider.createHadoopShim("foo", 3, 3));
+ assertNotNull(provider.createHadoopShim("foo", 2, 5));
+ assertNotNull(provider.createHadoopShim("foo", 2, 6));
+ assertNotNull(provider.createHadoopShim("foo", 2, 7));
- Assert.assertEquals(HadoopShim27.class,
+ assertEquals(HadoopShim27.class,
provider.createHadoopShim("foo", 2, 7).getClass());
}
@@ -50,8 +52,8 @@ public void testLoaderOverride() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_HADOOP_VERSION_OVERRIDE, "2.7.0");
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(HadoopShim27.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(HadoopShim27.class, shim.getClass());
}
@Test
@@ -61,8 +63,8 @@ public void testInvalidVersion() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_HADOOP_VERSION_OVERRIDE, "2.9.0");
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(DefaultHadoopShim.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(DefaultHadoopShim.class, shim.getClass());
}
@Test
@@ -74,8 +76,8 @@ public void testLoaderOverrideInvalidVersion() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_HADOOP_VERSION_OVERRIDE, "2.1.0");
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(DefaultHadoopShim.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(DefaultHadoopShim.class, shim.getClass());
}
}
diff --git a/hadoop-shim-impls/hadoop-shim-2.8/pom.xml b/hadoop-shim-impls/hadoop-shim-2.8/pom.xml
index 58d4c1ea5e..0b8d92e720 100644
--- a/hadoop-shim-impls/hadoop-shim-2.8/pom.xml
+++ b/hadoop-shim-impls/hadoop-shim-2.8/pom.xml
@@ -33,10 +33,6 @@
org.slf4j
slf4j-api
-
- junit
- junit
-
org.apache.tez
hadoop-shim
diff --git a/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28.java b/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28.java
index f3117c89dd..71fac1f871 100644
--- a/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28.java
+++ b/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28.java
@@ -18,10 +18,12 @@
*/
package org.apache.tez.hadoop.shim;
+import static org.junit.jupiter.api.Assertions.*;
+
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestHadoopShim28 {
@@ -29,33 +31,33 @@ public class TestHadoopShim28 {
public void testApplyFinalApplicationStatusCorrection() {
HadoopShim shim = new HadoopShim28();
// Session mode success/failure, change to ended
- Assert.assertEquals(FinalApplicationStatus.ENDED,
+ assertEquals(FinalApplicationStatus.ENDED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.SUCCEEDED, true, false));
- Assert.assertEquals(FinalApplicationStatus.ENDED,
+ assertEquals(FinalApplicationStatus.ENDED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, true, false));
// Non-session mode success/failure, retain success/failure
- Assert.assertEquals(FinalApplicationStatus.SUCCEEDED,
+ assertEquals(FinalApplicationStatus.SUCCEEDED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.SUCCEEDED, false, false));
- Assert.assertEquals(FinalApplicationStatus.FAILED,
+ assertEquals(FinalApplicationStatus.FAILED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, false, false));
// Session and non-session mode error, retain failed.
- Assert.assertEquals(FinalApplicationStatus.FAILED,
+ assertEquals(FinalApplicationStatus.FAILED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, true, true));
- Assert.assertEquals(FinalApplicationStatus.FAILED,
+ assertEquals(FinalApplicationStatus.FAILED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, false, true));
// Session and non-session mode killed is killed.
- Assert.assertEquals(FinalApplicationStatus.KILLED,
+ assertEquals(FinalApplicationStatus.KILLED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.KILLED, true, false));
- Assert.assertEquals(FinalApplicationStatus.KILLED,
+ assertEquals(FinalApplicationStatus.KILLED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.KILLED, false, false));
// Session and non-session mode undefined is undefined.
- Assert.assertEquals(FinalApplicationStatus.UNDEFINED,
+ assertEquals(FinalApplicationStatus.UNDEFINED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.UNDEFINED, true, false));
- Assert.assertEquals(FinalApplicationStatus.UNDEFINED,
+ assertEquals(FinalApplicationStatus.UNDEFINED,
shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.UNDEFINED, false, false));
}
}
diff --git a/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28Provider.java b/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28Provider.java
index f2f5e5ff71..145c33db8e 100644
--- a/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28Provider.java
+++ b/hadoop-shim-impls/hadoop-shim-2.8/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShim28Provider.java
@@ -18,25 +18,27 @@
*/
package org.apache.tez.hadoop.shim;
+import static org.junit.jupiter.api.Assertions.*;
+
import org.apache.hadoop.conf.Configuration;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestHadoopShim28Provider {
@Test
public void testShimProvider() {
HadoopShim28Provider provider = new HadoopShim28Provider();
- Assert.assertNull(provider.createHadoopShim("foo", 2, 2));
- Assert.assertNull(provider.createHadoopShim("foo", 2, 7));
- Assert.assertNull(provider.createHadoopShim("foo", 2, 5));
- Assert.assertNull(provider.createHadoopShim("foo", 2, 6));
- Assert.assertNull(provider.createHadoopShim("foo", 3, 3));
- Assert.assertNotNull(provider.createHadoopShim("foo", 2, 8));
- Assert.assertNotNull(provider.createHadoopShim("foo", 2, 111));
+ assertNull(provider.createHadoopShim("foo", 2, 2));
+ assertNull(provider.createHadoopShim("foo", 2, 7));
+ assertNull(provider.createHadoopShim("foo", 2, 5));
+ assertNull(provider.createHadoopShim("foo", 2, 6));
+ assertNull(provider.createHadoopShim("foo", 3, 3));
+ assertNotNull(provider.createHadoopShim("foo", 2, 8));
+ assertNotNull(provider.createHadoopShim("foo", 2, 111));
- Assert.assertEquals(HadoopShim28.class,
+ assertEquals(HadoopShim28.class,
provider.createHadoopShim("foo", 2, 9).getClass());
}
@@ -50,8 +52,8 @@ public void testLoaderOverride() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_HADOOP_VERSION_OVERRIDE, "2.8.0");
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(HadoopShim28.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(HadoopShim28.class, shim.getClass());
}
@Test
@@ -61,8 +63,8 @@ public void testInvalidVersion() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_HADOOP_VERSION_OVERRIDE, "2.2.0");
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(DefaultHadoopShim.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(DefaultHadoopShim.class, shim.getClass());
}
@Test
@@ -74,8 +76,8 @@ public void testLoaderOverrideInvalidVersion() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_HADOOP_VERSION_OVERRIDE, "2.1.0");
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(DefaultHadoopShim.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(DefaultHadoopShim.class, shim.getClass());
}
}
diff --git a/hadoop-shim/pom.xml b/hadoop-shim/pom.xml
index e1a82a60ee..149fd63bc4 100644
--- a/hadoop-shim/pom.xml
+++ b/hadoop-shim/pom.xml
@@ -33,10 +33,6 @@
org.slf4j
slf4j-api
-
- junit
- junit
-
org.apache.hadoop
hadoop-yarn-api
diff --git a/hadoop-shim/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShimsLoader.java b/hadoop-shim/src/test/java/org/apache/tez/hadoop/shim/TestHadoopShimsLoader.java
index 8c65135a82..f3299b9630 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,13 @@
*/
package org.apache.tez.hadoop.shim;
+import static org.junit.jupiter.api.Assertions.*;
+
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.*;
+
public class TestHadoopShimsLoader {
@@ -30,8 +32,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 +42,19 @@ public void testLoaderOverride() {
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_PROVIDER_CLASS, DummyShimProvider.class.getName());
HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
HadoopShim shim = loader.getHadoopShim();
- Assert.assertNotNull(shim);
- Assert.assertEquals(DummyShim.class, shim.getClass());
+ assertNotNull(shim);
+ assertEquals(DummyShim.class, shim.getClass());
}
- @Test(expected = RuntimeException.class)
+ @Test
public void testInvalidOverride() {
Configuration conf = new Configuration(false);
conf.set(HadoopShimsLoader.TEZ_HADOOP_SHIM_PROVIDER_CLASS, "org.apache.tez.foo");
- HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
- HadoopShim shim = loader.getHadoopShim();
+ assertThrows(
+ RuntimeException.class,
+ () -> {
+ HadoopShimsLoader loader = new HadoopShimsLoader(conf, true);
+ HadoopShim shim = loader.getHadoopShim();
+ });
}
-
}
diff --git a/pom.xml b/pom.xml
index ba08baeea5..8ee13815f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,7 +85,7 @@
1.19.4
1.5.4
3.0.0
- 4.13.2
+ 6.1.0
1.8
1.0.0
3.1.0
@@ -571,8 +571,8 @@
${hadoop.version}
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
com.google.inject
@@ -768,8 +768,8 @@
${commons-cli.version}
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
${junit.version}
test
@@ -822,6 +822,14 @@
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+
hadoop-shim
tez-api
diff --git a/tez-api/pom.xml b/tez-api/pom.xml
index 58da12ae21..fc92b99c57 100644
--- a/tez-api/pom.xml
+++ b/tez-api/pom.xml
@@ -89,10 +89,6 @@
com.google.protobuf
protobuf-java
-
- junit
- junit
-
com.sun.jersey
jersey-client
diff --git a/tez-api/src/test/java/org/apache/tez/client/TestTezClient.java b/tez-api/src/test/java/org/apache/tez/client/TestTezClient.java
index 07121cf1ee..b0e1e54d00 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,7 @@
*/
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.*;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeast;
@@ -99,9 +94,7 @@
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.*;
import org.mockito.ArgumentCaptor;
public class TestTezClient {
@@ -211,27 +204,36 @@ TezClientForTest configureAndCreateTezClient(Map lrs, boo
return client;
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientApp() throws Exception {
testTezClient(false, true, "testTezClientApp");
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientSession() throws Exception {
testTezClient(true, true, "testTezClientSession");
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientReconnect() throws Exception {
testTezClientReconnect(true);
}
- @Test (timeout = 5000, expected = IllegalStateException.class)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientReconnectNoSession() throws Exception {
- testTezClientReconnect(false);
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ testTezClientReconnect(false);
+ });
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientSessionLargeDAGPlan() throws Exception {
// request size is within threshold of being serialized
_testTezClientSessionLargeDAGPlan(10*1024*1024, 10, 10, false);
@@ -294,7 +296,8 @@ private void _testTezClientSessionLargeDAGPlan(int maxIPCMsgSize, int payloadSiz
}
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetClient() throws Exception {
/* BEGIN first TezClient usage without calling stop() */
TezClientForTest client = testTezClient(true, false, "testGetClient");
@@ -354,7 +357,7 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
if (isSession) {
verify(client.mockYarnClient, times(1)).submitApplication(captor.capture());
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -387,7 +390,7 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
} else {
verify(client.mockYarnClient, times(1)).submitApplication(captor.capture());
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(4, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(4, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -424,8 +427,8 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
ArgumentCaptor captor1 = ArgumentCaptor.forClass(SubmitDAGRequestProto.class);
verify(client.sessionAmProxy, times(2)).submitDAG(any(), captor1.capture());
SubmitDAGRequestProto proto = captor1.getValue();
- Assert.assertEquals(1, proto.getAdditionalAmResources().getLocalResourcesCount());
- Assert.assertEquals(lrName2, proto.getAdditionalAmResources().getLocalResources(0).getName());
+ assertEquals(1, proto.getAdditionalAmResources().getLocalResourcesCount());
+ assertEquals(lrName2, proto.getAdditionalAmResources().getLocalResources(0).getName());
} else {
// new app master
assertTrue(dagClient.getExecutionContext().contains(appId2.toString()));
@@ -433,7 +436,7 @@ public TezClientForTest testTezClient(boolean isSession, boolean shouldStop, Str
verify(client.mockYarnClient, times(2)).submitApplication(captor.capture());
// additional resource is added
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(5, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(5, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -482,7 +485,7 @@ public void testTezClientReconnect(boolean isSession) throws Exception {
if (isSession) {
verify(client.mockYarnClient, times(1)).submitApplication(captor.capture());
ApplicationSubmissionContext context = captor.getValue();
- Assert.assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
+ assertEquals(3, context.getAMContainerSpec().getLocalResources().size());
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
assertTrue(context.getAMContainerSpec().getLocalResources().containsKey(
@@ -550,7 +553,8 @@ public void testTezClientReconnect(boolean isSession) throws Exception {
client2.stop();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPreWarm() throws Exception {
TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -575,7 +579,8 @@ public void testPreWarm() throws Exception {
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPreWarmCloseStuck() throws Exception {
TezClientForTest client = configureAndCreateTezClient();
client.setPrewarmTimeoutMs(10L); // Don't wait too long.
@@ -604,7 +609,8 @@ private void setClientToReportStoppedDags(TezClientForTest client) throws Except
.setSucceededTaskCount(1).setTotalTaskCount(1).build()).build()).build());
}
- @Test (timeout=30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testPreWarmWithTimeout() throws Exception {
long startTime = 0 , endTime = 0;
TezClientForTest client = configureAndCreateTezClient();
@@ -632,12 +638,11 @@ public void testPreWarmWithTimeout() throws Exception {
fail("PreWarm should have encountered an Exception!");
} catch (SessionNotReady te) {
endTime = Time.monotonicNow();
- assertTrue("Time taken is not as expected",
- (endTime - startTime) > timeout);
+ assertTrue((endTime - startTime) > timeout, "Time taken is not as expected");
verify(spyClient, times(0)).submitDAG(any());
- Assert.assertTrue("Unexpected Exception message: " + te.getMessage(),
- te.getMessage().contains("Tez AM not ready"));
-
+ assertTrue(
+ te.getMessage().contains("Tez AM not ready"),
+ "Unexpected Exception message: " + te.getMessage());
}
when(
@@ -650,8 +655,7 @@ public void testPreWarmWithTimeout() throws Exception {
startTime = Time.monotonicNow();
spyClient.preWarm(vertex, timeout, TimeUnit.MILLISECONDS);
endTime = Time.monotonicNow();
- assertTrue("Time taken is not as expected",
- (endTime - startTime) <= timeout);
+ assertTrue((endTime - startTime) <= timeout, "Time taken is not as expected");
verify(spyClient, times(1)).submitDAG(any());
} catch (TezException te) {
fail("PreWarm should have succeeded!");
@@ -685,15 +689,15 @@ public void run() {
startTime = Time.monotonicNow();
spyClient.preWarm(vertex, timeout, TimeUnit.MILLISECONDS);
endTime = Time.monotonicNow();
- assertTrue("Time taken is not as expected",
- (endTime - startTime) <= timeout);
+ assertTrue((endTime - startTime) <= timeout, "Time taken is not as expected");
verify(spyClient, times(2)).submitDAG(any());
setClientToReportStoppedDags(client);
spyClient.stop();
client.stop();
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testMultipleSubmissions() throws Exception {
testMultipleSubmissionsJob(false);
testMultipleSubmissionsJob(true);
@@ -735,7 +739,8 @@ public void testMultipleSubmissionsJob(boolean isSession) throws Exception {
client2.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitTillReady_Interrupt() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -757,11 +762,12 @@ public void run() {
thread.join(250);
thread.interrupt();
thread.join();
- Assert.assertThat(exceptionReference.get(), CoreMatchers.instanceOf(InterruptedException.class));
+ assertInstanceOf(InterruptedException.class, exceptionReference.get());
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitTillReadyAppFailed() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -779,7 +785,8 @@ public void testWaitTillReadyAppFailed() throws Exception {
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitTillReadyAppFailedNoDiagnostics() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -794,7 +801,8 @@ public void testWaitTillReadyAppFailedNoDiagnostics() throws Exception {
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSubmitDAGAppFailed() throws Exception {
final TezClientForTest client = configureAndCreateTezClient();
client.start();
@@ -819,7 +827,8 @@ public void testSubmitDAGAppFailed() throws Exception {
client.stop();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezClientCounterLimits() throws YarnException, IOException, ServiceException {
Limits.reset();
int defaultCounterLimit = TezConfiguration.TEZ_COUNTERS_MAX_DEFAULT;
@@ -843,7 +852,8 @@ public void testTezClientCounterLimits() throws YarnException, IOException, Serv
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testClientBuilder() {
TezConfiguration tezConfWitSession = new TezConfiguration();
tezConfWitSession.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
@@ -914,7 +924,8 @@ public static class InvalidChecker {
// No-op class
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidJavaOptsChecker1() throws YarnException, IOException, ServiceException,
TezException {
TezConfiguration conf = new TezConfiguration();
@@ -923,7 +934,8 @@ public void testInvalidJavaOptsChecker1() throws YarnException, IOException, Ser
client.start();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidJavaOptsChecker2() throws YarnException, IOException, ServiceException,
TezException {
TezConfiguration conf = new TezConfiguration();
@@ -932,7 +944,8 @@ public void testInvalidJavaOptsChecker2() throws YarnException, IOException, Ser
client.start();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testStopRetriesUntilTerminalState() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.setBoolean(TezConfiguration.TEZ_CLIENT_ASYNCHRONOUS_STOP, false);
@@ -944,12 +957,13 @@ public void testStopRetriesUntilTerminalState() throws Exception {
try {
client.stop();
} catch (Exception e) {
- Assert.fail("Expected ApplicationNotFoundException");
+ fail("Expected ApplicationNotFoundException");
}
verify(client.mockYarnClient, atLeast(2)).getApplicationReport(client.mockAppId);
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testStopRetriesUntilTimeout() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.setBoolean(TezConfiguration.TEZ_CLIENT_ASYNCHRONOUS_STOP, false);
@@ -962,28 +976,30 @@ public void testStopRetriesUntilTimeout() throws Exception {
try {
client.stop();
} catch (Exception e) {
- Assert.fail("Stop should complete without exception: " + e);
+ fail("Stop should complete without exception: " + e);
}
long end = System.currentTimeMillis();
verify(client.mockYarnClient, atLeast(2)).getApplicationReport(client.mockAppId);
- Assert.assertTrue("Stop ended before timeout", end - start > HARD_KILL_TIMEOUT);
+ assertTrue(end - start > HARD_KILL_TIMEOUT, "Stop ended before timeout");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSubmitHostPopulated() throws YarnException, IOException, ServiceException, TezException {
TezConfiguration conf = new TezConfiguration();
configureAndCreateTezClient(conf);
InetAddress ip = InetAddress.getLocalHost();
if (ip != null) {
- Assert.assertEquals(ip.getCanonicalHostName(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST));
- Assert.assertEquals(ip.getHostAddress(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST_ADDRESS));
+ assertEquals(ip.getCanonicalHostName(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST));
+ assertEquals(ip.getHostAddress(), conf.get(TezConfigurationConstants.TEZ_SUBMIT_HOST_ADDRESS));
} else {
- Assert.fail("Failed to retrieve local host information");
+ fail("Failed to retrieve local host information");
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testClientResubmit() throws Exception {
TezClientForTest client = configureAndCreateTezClient(null, true, null);
client.start();
@@ -1002,15 +1018,16 @@ public void testClientResubmit() throws Exception {
for (int i = 0; i < 3; ++i) {
try {
client.submitDAG(dag);
- Assert.fail("Expected TezUncheckedException here.");
+ fail("Expected TezUncheckedException here.");
} catch(TezUncheckedException ex) {
- Assert.assertTrue(ex.getMessage().contains("Invalid/conflicting GC options found"));
+ assertTrue(ex.getMessage().contains("Invalid/conflicting GC options found"));
}
}
client.stop();
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testMissingYarnAppStatus() throws Exception {
// verify an app not found exception is thrown when YARN reports a null app status
ApplicationId appId1 = ApplicationId.newInstance(0, 1);
@@ -1029,7 +1046,8 @@ public void testMissingYarnAppStatus() throws Exception {
}
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testAMClientHeartbeat() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS, 10);
@@ -1059,7 +1077,8 @@ public void testAMClientHeartbeat() throws Exception {
verify(client2.sessionAmProxy, times(0)).getAMStatus(any(), any());
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testAMHeartbeatFailOnGetAMProxy_AppNotStarted() throws Exception {
int amHeartBeatTimeoutSecs = 3;
TezConfiguration conf = new TezConfiguration();
@@ -1075,7 +1094,8 @@ public void testAMHeartbeatFailOnGetAMProxy_AppNotStarted() throws Exception {
assertFalse(client.getAMKeepAliveService().isTerminated());
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testAMHeartbeatFailOnGetAMProxy_AppFailed() throws Exception {
int amHeartBeatTimeoutSecs = 3;
TezConfiguration conf = new TezConfiguration();
@@ -1091,7 +1111,8 @@ public void testAMHeartbeatFailOnGetAMProxy_AppFailed() throws Exception {
assertTrue(client.getAMKeepAliveService().isTerminated());
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testAMHeartbeatFailOnGetAMStatus() throws Exception {
int amHeartBeatTimeoutSecs = 3;
TezConfiguration conf = new TezConfiguration();
@@ -1109,7 +1130,8 @@ public void testAMHeartbeatFailOnGetAMStatus() throws Exception {
}
//See TEZ-3874
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testYarnZkDeprecatedConf() {
Configuration conf = new Configuration(false);
String val = "hostname:2181";
diff --git a/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java b/tez-api/src/test/java/org/apache/tez/client/TestTezClientUtils.java
index af6c4f29f7..50e91196fc 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,7 @@
*/
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.*;
import java.io.File;
import java.io.FileNotFoundException;
@@ -31,7 +27,6 @@
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -39,6 +34,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
@@ -77,8 +73,7 @@
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.*;
/**
*
*/
@@ -90,7 +85,8 @@ public class TestTezClientUtils {
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesNotDefined() throws Exception {
TezConfiguration conf = new TezConfiguration(false);
@@ -98,40 +94,40 @@ public void validateSetTezJarLocalResourcesNotDefined() throws Exception {
try {
Map resources = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
- Assert.fail("Expected TezUncheckedException");
+ fail("Expected TezUncheckedException");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Invalid configuration of tez jars"));
+ assertTrue(e.getMessage().contains("Invalid configuration of tez jars"));
}
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedButEmpty() throws Exception {
File emptyDir = new File(TEST_ROOT_DIR, "emptyDir");
emptyDir.deleteOnExit();
- Assert.assertTrue(emptyDir.mkdirs());
+ assertTrue(emptyDir.mkdirs());
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_LIB_URIS, emptyDir.toURI().toURL().toString());
Credentials credentials = new Credentials();
try {
Map resources = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
- Assert.fail("Expected TezUncheckedException");
+ fail("Expected TezUncheckedException");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("No files found in locations"));
+ assertTrue(e.getMessage().contains("No files found in locations"));
}
}
- /**
- *
- */
- @Test(expected=FileNotFoundException.class, timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedNonExistingDirectory() throws Exception {
-
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_LIB_URIS, "file:///foo");
Credentials credentials = new Credentials();
- Map resources = new HashMap();
- TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources);
+ Map resources = new HashMap<>();
+ assertThrows(
+ FileNotFoundException.class,
+ () -> TezClientUtils.setupTezJarsLocalResources(conf, credentials, resources));
}
private static List getDirAndFileURL() throws MalformedURLException {
@@ -154,7 +150,8 @@ private static List getDirAndFileURL() throws MalformedURLException {
return urls;
}
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectory() throws Exception {
List cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -168,7 +165,7 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectory() throws Exc
Map localizedMap = new HashMap();
boolean usingArchive = TezClientUtils.setupTezJarsLocalResources(conf, credentials,
localizedMap);
- Assert.assertFalse(usingArchive);
+ assertFalse(usingArchive);
Set resourceNames = localizedMap.keySet();
boolean assertedDir = false;
boolean assertedFile = false;
@@ -197,7 +194,8 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectory() throws Exc
*
* @throws Exception
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnored() throws Exception {
List cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -210,7 +208,7 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnored() thr
conf.setBoolean(TezConfiguration.TEZ_IGNORE_LIB_URIS, true);
Credentials credentials = new Credentials();
Map localizedMap = new HashMap();
- Assert.assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
+ assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
assertTrue(localizedMap.isEmpty());
}
@@ -218,7 +216,8 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnored() thr
*
* @throws Exception
*/
- @Test (timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnoredSetToFalse() throws Exception {
List cp = getDirAndFileURL();
StringBuffer buffer = new StringBuffer();
@@ -231,7 +230,7 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnoredSetToF
conf.setBoolean(TezConfiguration.TEZ_IGNORE_LIB_URIS, false);
Credentials credentials = new Credentials();
Map localizedMap = new HashMap();
- Assert.assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
+ assertFalse(TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap));
assertFalse(localizedMap.isEmpty());
}
@@ -239,7 +238,8 @@ public void validateSetTezJarLocalResourcesDefinedExistingDirectoryIgnoredSetToF
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezDefaultFS() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
StringBuilder tezLibUris = new StringBuilder();
@@ -252,7 +252,7 @@ public void testTezDefaultFS() throws Exception {
Path file = new Path(topDir, "file.jar");
- Assert.assertTrue(localFs.createNewFile(file));
+ assertTrue(localFs.createNewFile(file));
tezLibUris.append(localFs.makeQualified(file).toString());
TezConfiguration conf = new TezConfiguration();
@@ -262,14 +262,15 @@ public void testTezDefaultFS() throws Exception {
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
- Assert.assertTrue(localFs.delete(file, true));
- Assert.assertTrue(localFs.delete(topDir, true));
+ assertTrue(localFs.delete(file, true));
+ assertTrue(localFs.delete(topDir, true));
}
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesMultipleTarballs() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
StringBuilder tezLibUris = new StringBuilder();
@@ -284,8 +285,8 @@ public void validateSetTezJarLocalResourcesMultipleTarballs() throws Exception {
Path tarFile1 = new Path(topDir, "f1.tar.gz");
Path tarFile2 = new Path(topDir, "f2.tar.gz");
- Assert.assertTrue(localFs.createNewFile(tarFile1));
- Assert.assertTrue(localFs.createNewFile(tarFile2));
+ assertTrue(localFs.createNewFile(tarFile1));
+ assertTrue(localFs.createNewFile(tarFile2));
tezLibUris.append(localFs.makeQualified(tarFile1).toString()).append("#tar1").append(",");
tezLibUris.append(localFs.makeQualified(tarFile2).toString()).append("#tar2").append(",");
@@ -295,22 +296,23 @@ public void validateSetTezJarLocalResourcesMultipleTarballs() throws Exception {
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set resourceNames = localizedMap.keySet();
- Assert.assertEquals(2, resourceNames.size());
- Assert.assertTrue(resourceNames.contains("tar1"));
- Assert.assertTrue(resourceNames.contains("tar2"));
- Assert.assertFalse(resourceNames.contains("f1.tar.gz"));
- Assert.assertFalse(resourceNames.contains("f2.tar.gz"));
+ assertEquals(2, resourceNames.size());
+ assertTrue(resourceNames.contains("tar1"));
+ assertTrue(resourceNames.contains("tar2"));
+ assertFalse(resourceNames.contains("f1.tar.gz"));
+ assertFalse(resourceNames.contains("f2.tar.gz"));
- Assert.assertTrue(localFs.delete(tarFile1, true));
- Assert.assertTrue(localFs.delete(tarFile2, true));
- Assert.assertTrue(localFs.delete(topDir, true));
+ assertTrue(localFs.delete(tarFile1, true));
+ assertTrue(localFs.delete(tarFile2, true));
+ assertTrue(localFs.delete(topDir, true));
}
/**
*
*/
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezJarLocalResourcesMixTarballAndJar() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
StringBuilder tezLibUris = new StringBuilder();
@@ -326,9 +328,9 @@ public void validateSetTezJarLocalResourcesMixTarballAndJar() throws Exception {
Path jarFile2 = new Path(topDir, "f2.jar");
Path jarFile3 = new Path(topDir, "f3.jar");
- Assert.assertTrue(localFs.createNewFile(tarFile1));
- Assert.assertTrue(localFs.createNewFile(jarFile2));
- Assert.assertTrue(localFs.createNewFile(jarFile3));
+ assertTrue(localFs.createNewFile(tarFile1));
+ assertTrue(localFs.createNewFile(jarFile2));
+ assertTrue(localFs.createNewFile(jarFile3));
tezLibUris.append(localFs.makeQualified(topDir).toString()).append(",");
tezLibUris.append(localFs.makeQualified(tarFile1).toString()).append("#tar1").append(",");
@@ -339,19 +341,20 @@ public void validateSetTezJarLocalResourcesMixTarballAndJar() throws Exception {
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set resourceNames = localizedMap.keySet();
- Assert.assertEquals(4, resourceNames.size());
- Assert.assertTrue(resourceNames.contains("tar1"));
- Assert.assertTrue(resourceNames.contains("f1.tar.gz"));
- Assert.assertTrue(resourceNames.contains("f2.jar"));
- Assert.assertTrue(resourceNames.contains("f3.jar"));
-
- Assert.assertTrue(localFs.delete(tarFile1, true));
- Assert.assertTrue(localFs.delete(jarFile2, true));
- Assert.assertTrue(localFs.delete(jarFile3, true));
- Assert.assertTrue(localFs.delete(topDir, true));
+ assertEquals(4, resourceNames.size());
+ assertTrue(resourceNames.contains("tar1"));
+ assertTrue(resourceNames.contains("f1.tar.gz"));
+ assertTrue(resourceNames.contains("f2.jar"));
+ assertTrue(resourceNames.contains("f3.jar"));
+
+ assertTrue(localFs.delete(tarFile1, true));
+ assertTrue(localFs.delete(jarFile2, true));
+ assertTrue(localFs.delete(jarFile3, true));
+ assertTrue(localFs.delete(topDir, true));
}
- @Test(timeout = 2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
// this test checks if the priority field is set properly in the
// ApplicationSubmissionContext
public void testAppSubmissionContextForPriority() throws Exception {
@@ -376,7 +379,8 @@ public void testAppSubmissionContextForPriority() throws Exception {
assertEquals(testpriority, appcontext.getPriority().getPriority());
}
- @Test(timeout=1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
// when tez config property for app priority not set,
// tez should not set app priority and let YARN deal with it.
public void testSetApplicationPriority() {
@@ -388,7 +392,8 @@ public void testSetApplicationPriority() {
assertNull(appContext.getPriority());
}
- @Test(timeout=1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
public void testSetApplicationTags() {
TezConfiguration conf = new TezConfiguration(false);
conf.set(TezConfiguration.TEZ_APPLICATION_TAGS, "foo,bar");
@@ -403,7 +408,8 @@ public void testSetApplicationTags() {
assertTrue(appContext.getApplicationTags().contains("bar"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSessionTokenInAmClc() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
@@ -437,10 +443,11 @@ public void testSessionTokenInAmClc() throws IOException, YarnException {
Token jtSent = new Token();
jtSent.readFields(dibb);
- assertTrue(Arrays.equals(jobToken.getIdentifier(), jtSent.getIdentifier()));
+ assertArrayEquals(jobToken.getIdentifier(), jtSent.getIdentifier());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMLoggingOptsSimple() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
@@ -480,7 +487,8 @@ public void testAMLoggingOptsSimple() throws IOException, YarnException {
assertNull(logEnv);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMLoggingOptsPerLogger() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
@@ -522,7 +530,8 @@ public void testAMLoggingOptsPerLogger() throws IOException, YarnException {
assertEquals("org.apache.hadoop.ipc=DEBUG;org.apache.hadoop.security=DEBUG", logEnv);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMCommandOpts() {
Path tmpDir = new Path(Environment.PWD.$(),
YarnConfiguration.DEFAULT_CONTAINER_TEMP_DIR);
@@ -572,7 +581,8 @@ public void testAMCommandOpts() {
+ TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_JDK17_CMD_OPTS_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,30 +594,28 @@ public void testTaskCommandOpts() throws TezException {
expected =
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT + " " + taskCommandOpts;
assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test2: Setup cluster-default command opts explicitly
String taskClusterDefaultCommandOpts =
"-server -Djava.net.preferIPv4Stack=true -XX:+PrintGCDetails -verbose:gc ";
- tezConf.set(TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS,
- taskClusterDefaultCommandOpts);
- taskOptsConstructed =
- TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
+ tezConf.set(
+ 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));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test3: Don't setup Xmx explicitly
taskCommandOpts = "-Dtest.property";
tezConf.set(TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS, taskCommandOpts);
- taskOptsConstructed =
- TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
+ taskOptsConstructed = TezClientUtils.addDefaultsToTaskLaunchCmdOpts("", tezConf);
expected = taskClusterDefaultCommandOpts + " " + taskCommandOpts;
assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
// Test4: Pass in a dag-configured value.
String programmaticTaskOpts = "-Dset.programatically=true -Djava.net.preferIPv4Stack=false";
@@ -616,72 +624,73 @@ public void testTaskCommandOpts() throws TezException {
// Container logging is always added at the end, if it's required.
expected = taskClusterDefaultCommandOpts + " " + taskCommandOpts + " " + programmaticTaskOpts;
assertTrue(
- "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed +
- "]", taskOptsConstructed.startsWith(expected));
+ taskOptsConstructed.startsWith(expected),
+ "Did not find Expected prefix: [" + expected + "] in string [" + taskOptsConstructed + "]");
}
-
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultMemoryJavaOpts() {
final double factor = 0.8;
String origJavaOpts = "-Xmx";
String javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1000, 1), factor);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1000, 1), factor);
- Assert.assertTrue(javaOpts.contains("-Xmx800m"));
+ assertTrue(javaOpts.contains("-Xmx800m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1, 1), factor);
- Assert.assertTrue(javaOpts.contains("-Xmx1m"));
+ assertTrue(javaOpts.contains("-Xmx1m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(-1, 1), factor);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), factor);
- Assert.assertTrue(javaOpts.contains("-Xmx284m"));
+ assertTrue(javaOpts.contains("-Xmx284m"));
origJavaOpts = " -Xms100m ";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), factor);
- Assert.assertFalse(javaOpts.contains("-Xmx284m"));
- Assert.assertTrue(javaOpts.contains("-Xms100m"));
+ assertFalse(javaOpts.contains("-Xmx284m"));
+ assertTrue(javaOpts.contains("-Xms100m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), 0);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(355, 1), 100);
- Assert.assertEquals(origJavaOpts, javaOpts);
+ assertEquals(origJavaOpts, javaOpts);
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(1000, 1), -1);
- Assert.assertTrue(javaOpts.contains("-Xmx700m"));
+ assertTrue(javaOpts.contains("-Xmx700m"));
origJavaOpts = "";
javaOpts = TezClientUtils.maybeAddDefaultMemoryJavaOpts(origJavaOpts,
Resource.newInstance(5000, 1), -1);
- Assert.assertTrue(javaOpts.contains("-Xmx4000m"));
+ assertTrue(javaOpts.contains("-Xmx4000m"));
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultLoggingJavaOpts() {
String origJavaOpts = null;
String javaOpts = TezClientUtils.maybeAddDefaultLoggingJavaOpts("FOOBAR", origJavaOpts);
- Assert.assertNotNull(javaOpts);
- Assert.assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR")
+ assertNotNull(javaOpts);
+ assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR")
&& javaOpts.contains(TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE)
&&
javaOpts.contains("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator"));
@@ -691,14 +700,15 @@ public void testDefaultLoggingJavaOpts() {
public void testDefaultLoggingJavaOptsWithRootLogger() {
String origJavaOpts = "-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=INFO -DtestProperty=value";
String javaOpts = TezClientUtils.maybeAddDefaultLoggingJavaOpts("FOOBAR", origJavaOpts);
- Assert.assertNotNull(javaOpts);
- Assert.assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR"));
- Assert.assertTrue(javaOpts.contains(TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE)
+ assertNotNull(javaOpts);
+ assertTrue(javaOpts.contains("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=FOOBAR"));
+ assertTrue(javaOpts.contains(TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE)
&& javaOpts.contains("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator"));
- Assert.assertTrue(javaOpts.contains("-DtestProperty=value"));
+ assertTrue(javaOpts.contains("-DtestProperty=value"));
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfYarnZkWorkaround() {
Configuration conf = new Configuration(false);
String val = "localhost:2181";
@@ -714,13 +724,14 @@ public void testConfYarnZkWorkaround() {
String v = expected.remove(kvPair.getKey());
// this way the test still validates that the original
// key/value pairs can be found in the proto's conf
- assertEquals("Unexpected value for key: " + kvPair.getKey(), v, kvPair.getValue());
+ assertEquals(v, kvPair.getValue(), "Unexpected value for key: " + kvPair.getKey());
}
}
- assertTrue("Expected keys not found in conf: " + expected.keySet(), expected.isEmpty());
+ assertTrue(expected.isEmpty(), "Expected keys not found in conf: " + expected.keySet());
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfSerializationForAm() {
Configuration conf =new Configuration(false);
String val1 = "fixedProperty";
@@ -758,24 +769,24 @@ public static void testLocalResourceVisibility(DistributedFileSystem remoteFs, C
String fsURI = remoteFs.getUri().toString();
topLevelDir = new Path(fsURI, "/testLRVisibility");
- Assert.assertTrue(remoteFs.mkdirs(topLevelDir, publicDirPerms));
+ assertTrue(remoteFs.mkdirs(topLevelDir, publicDirPerms));
Path publicSubDir = new Path(topLevelDir, "public_sub_dir");
- Assert.assertTrue(remoteFs.mkdirs(publicSubDir, publicDirPerms));
+ assertTrue(remoteFs.mkdirs(publicSubDir, publicDirPerms));
Path privateSubDir = new Path(topLevelDir, "private_sub_dir");
- Assert.assertTrue(remoteFs.mkdirs(privateSubDir, privateDirPerms));
+ assertTrue(remoteFs.mkdirs(privateSubDir, privateDirPerms));
Path publicFile = new Path(publicSubDir, "public_file");
- Assert.assertTrue(remoteFs.createNewFile(publicFile));
+ assertTrue(remoteFs.createNewFile(publicFile));
remoteFs.setPermission(publicFile, publicFilePerms);
Path privateFile = new Path(publicSubDir, "private_file");
- Assert.assertTrue(remoteFs.createNewFile(privateFile));
+ assertTrue(remoteFs.createNewFile(privateFile));
remoteFs.setPermission(privateFile, privateFilePerms);
Path publicFileInPrivateSubdir = new Path(privateSubDir, "public_file_in_private_subdir");
- Assert.assertTrue(remoteFs.createNewFile(publicFileInPrivateSubdir));
+ assertTrue(remoteFs.createNewFile(publicFileInPrivateSubdir));
remoteFs.setPermission(publicFileInPrivateSubdir, publicFilePerms);
TezConfiguration tezConf = new TezConfiguration(conf);
@@ -786,35 +797,41 @@ public static void testLocalResourceVisibility(DistributedFileSystem remoteFs, C
Map lrMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(tezConf, new Credentials(), lrMap);
- Assert.assertEquals(publicFile.getName(), LocalResourceVisibility.PUBLIC,
- lrMap.get(publicFile.getName()).getVisibility());
+ assertEquals(
+ LocalResourceVisibility.PUBLIC,
+ lrMap.get(publicFile.getName()).getVisibility(),
+ publicFile.getName());
- Assert.assertEquals(privateFile.getName(), LocalResourceVisibility.PRIVATE,
- lrMap.get(privateFile.getName()).getVisibility());
+ assertEquals(
+ LocalResourceVisibility.PRIVATE,
+ lrMap.get(privateFile.getName()).getVisibility(),
+ privateFile.getName());
- Assert.assertEquals(publicFileInPrivateSubdir.getName(), LocalResourceVisibility.PRIVATE,
- lrMap.get(publicFileInPrivateSubdir.getName()).getVisibility());
+ assertEquals(
+ LocalResourceVisibility.PRIVATE,
+ lrMap.get(publicFileInPrivateSubdir.getName()).getVisibility(),
+ publicFileInPrivateSubdir.getName());
// test tar.gz
tezConf = new TezConfiguration(conf);
Path tarFile = new Path(topLevelDir, "foo.tar.gz");
- Assert.assertTrue(remoteFs.createNewFile(tarFile));
+ assertTrue(remoteFs.createNewFile(tarFile));
//public
remoteFs.setPermission(tarFile, publicFilePerms);
tezConf.set(TezConfiguration.TEZ_LIB_URIS, tarFile.toString());
lrMap.clear();
- Assert.assertTrue(
+ assertTrue(
TezClientUtils.setupTezJarsLocalResources(tezConf, new Credentials(), lrMap));
- Assert.assertEquals(LocalResourceVisibility.PUBLIC,
+ assertEquals(LocalResourceVisibility.PUBLIC,
lrMap.get(TezConstants.TEZ_TAR_LR_NAME).getVisibility());
//private
remoteFs.setPermission(tarFile, privateFilePerms);
lrMap.clear();
TezClientUtils.setupTezJarsLocalResources(tezConf, new Credentials(), lrMap);
- Assert.assertEquals(LocalResourceVisibility.PRIVATE,
+ assertEquals(LocalResourceVisibility.PRIVATE,
lrMap.get(TezConstants.TEZ_TAR_LR_NAME).getVisibility());
} finally {
@@ -824,7 +841,8 @@ public static void testLocalResourceVisibility(DistributedFileSystem remoteFs, C
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfigurationAllowAll() {
Configuration srcConf = new Configuration(false);
@@ -855,7 +873,8 @@ private Path createFile(FileSystem fs, Path dir, String fileName) throws IOExcep
return fs.makeQualified(f1);
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void validateSetTezAuxLocalResourcesWithFilesAndFolders() throws Exception {
FileSystem localFs = FileSystem.getLocal(new Configuration());
List resources = new ArrayList();
@@ -889,12 +908,13 @@ public void validateSetTezAuxLocalResourcesWithFilesAndFolders() throws Exceptio
Map localizedMap = new HashMap();
TezClientUtils.setupTezJarsLocalResources(conf, credentials, localizedMap);
Set resourceNames = localizedMap.keySet();
- Assert.assertEquals(2, resourceNames.size());
- Assert.assertTrue(resourceNames.contains("f1.txt"));
- Assert.assertTrue(resourceNames.contains("dir2-f.txt"));
+ assertEquals(2, resourceNames.size());
+ assertTrue(resourceNames.contains("f1.txt"));
+ assertTrue(resourceNames.contains("dir2-f.txt"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testServiceDescriptorSerializationForAM() {
Configuration conf = new Configuration(false);
ServicePluginsDescriptor servicePluginsDescriptor = ServicePluginsDescriptor.create(true);
@@ -906,33 +926,35 @@ public void testServiceDescriptorSerializationForAM() {
assertTrue(confProto.getAmPluginDescriptor().getUberEnabled());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskLaunchCmdOptsSetup() throws TezException {
Configuration conf = new Configuration(false);
String vOpts = "";
String opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
+ assertEquals(opts,
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT + " "
+ TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS_DEFAULT + " " + vOpts);
vOpts = "foo";
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
+ assertEquals(opts,
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT + " " + vOpts);
String taskOpts = "taskOpts";
conf.set(TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS, taskOpts);
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
+ assertEquals(opts,
TezConfiguration.TEZ_TASK_LAUNCH_CLUSTER_DEFAULT_CMD_OPTS_DEFAULT
+ " " + taskOpts + " " + vOpts);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testClusterTaskLaunchCmdOptsSetup() throws TezException {
Configuration conf = new Configuration(false);
String adminOpts = "adminOpts";
@@ -941,20 +963,20 @@ public void testClusterTaskLaunchCmdOptsSetup() throws TezException {
String vOpts = "";
String opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts,
+ assertEquals(opts,
adminOpts + " "
+ TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS_DEFAULT + " " + vOpts);
vOpts = "foo";
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts, adminOpts + " " + vOpts);
+ assertEquals(opts, adminOpts + " " + vOpts);
String taskOpts = "taskOpts";
conf.set(TezConfiguration.TEZ_TASK_LAUNCH_CMD_OPTS, taskOpts);
opts = TezClientUtils.addDefaultsToTaskLaunchCmdOpts(vOpts, conf);
- Assert.assertEquals(opts, adminOpts + " " + taskOpts + " " + vOpts);
+ assertEquals(opts, adminOpts + " " + taskOpts + " " + vOpts);
}
@@ -981,6 +1003,6 @@ public void testSessionCredentialsMergedBeforeAmConfigCredentials() throws Excep
// if there is another token in am conf creds of the same token type,
// session token should be applied while creating ContainerLaunchContext
- Assert.assertEquals(sessionToken, amLaunchCredentials.getToken(tokenType));
+ assertEquals(sessionToken, amLaunchCredentials.getToken(tokenType));
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/client/registry/TestAMRecord.java b/tez-api/src/test/java/org/apache/tez/client/registry/TestAMRecord.java
index fc9c05dd7d..9412b2b0ea 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,7 @@
*/
package org.apache.tez.client.registry;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -26,7 +26,8 @@
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.tez.client.registry.zookeeper.ZkConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestAMRecord {
@@ -228,12 +229,12 @@ public void testToString() {
assertNotNull(str);
// Validate actual JSON-like snippets from the string
- assertTrue("Should contain appId=value snippet", str.contains("appId=" + appId.toString()));
- assertTrue("Should contain hostName=value snippet", str.contains("hostName=" + hostName));
- assertTrue("Should contain hostIp=value snippet", str.contains("hostIp=" + hostIp));
- assertTrue("Should contain port=value snippet", str.contains("port=" + port));
- assertTrue("Should contain externalId=value snippet", str.contains("externalId=" + externalId));
- assertTrue("Should contain computeName=value snippet", str.contains("computeName=" + computeName));
+ assertTrue(str.contains("appId=" + appId.toString()), "Should contain appId=value snippet");
+ assertTrue(str.contains("hostName=" + hostName), "Should contain hostName=value snippet");
+ assertTrue(str.contains("hostIp=" + hostIp), "Should contain hostIp=value snippet");
+ assertTrue(str.contains("port=" + port), "Should contain port=value snippet");
+ assertTrue(str.contains("externalId=" + externalId), "Should contain externalId=value snippet");
+ assertTrue(str.contains("computeName=" + computeName), "Should contain computeName=value snippet");
}
@Test
diff --git a/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkConfig.java b/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkConfig.java
index 9f943feba0..b87eefd341 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,7 @@
*/
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.*;
import java.util.concurrent.TimeUnit;
@@ -28,7 +27,8 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.TezConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestZkConfig {
@@ -189,34 +189,36 @@ public void testCreateCuratorFramework() {
assertEquals(zkConfig.getZkQuorum(), curator.getZookeeperClient().getCurrentConnectionString());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullZkQuorum() {
TezConfiguration conf = new TezConfiguration();
// Don't set zkQuorum
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> new ZkConfig(conf));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testEmptyZkQuorum() {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "");
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> new ZkConfig(conf));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullNamespace() {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "localhost:2181");
- conf.set(TezConfiguration.TEZ_AM_REGISTRY_NAMESPACE, null);
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> {
+ conf.set(TezConfiguration.TEZ_AM_REGISTRY_NAMESPACE, null);
+ new ZkConfig(conf);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testEmptyNamespace() {
TezConfiguration conf = new TezConfiguration();
conf.set(TezConfiguration.TEZ_AM_ZOOKEEPER_QUORUM, "localhost:2181");
conf.set(TezConfiguration.TEZ_AM_REGISTRY_NAMESPACE, "");
- new ZkConfig(conf);
+ assertThrows(IllegalArgumentException.class, () -> new ZkConfig(conf));
}
@Test
diff --git a/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkFrameworkClient.java b/tez-api/src/test/java/org/apache/tez/client/registry/zookeeper/TestZkFrameworkClient.java
index 70cc75c669..541b378778 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,7 @@
*/
package org.apache.tez.client.registry.zookeeper;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -37,9 +37,7 @@
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.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,22 +53,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 +86,13 @@ public void testInitAndLifecycle() throws Exception {
zkFrameworkClient = new ZkFrameworkClient();
zkFrameworkClient.init(tezConf);
- assertFalse("Client should not be running after init", zkFrameworkClient.isRunning());
+ assertFalse(zkFrameworkClient.isRunning(), "Client should not be running after init");
zkFrameworkClient.start();
- assertTrue("Client should be running after start", zkFrameworkClient.isRunning());
+ assertTrue(zkFrameworkClient.isRunning(), "Client should be running after start");
zkFrameworkClient.stop();
- assertFalse("Client should not be running after stop", zkFrameworkClient.isRunning());
+ assertFalse(zkFrameworkClient.isRunning(), "Client should not be running after stop");
}
/**
@@ -114,12 +116,12 @@ public void testGetApplicationReportWithRegisteredAM() throws Exception {
ApplicationReport report = zkFrameworkClient.getApplicationReport(appId);
- assertNotNull("Application report should not be null", report);
- assertEquals("Application ID should match", appId, report.getApplicationId());
- assertEquals("Host should match", testHostName, report.getHost());
- assertEquals("Port should match", testPort, report.getRpcPort());
- assertEquals("AM host should be cached", testHostName, zkFrameworkClient.getAmHost());
- assertEquals("AM port should be cached", testPort, zkFrameworkClient.getAmPort());
+ assertNotNull(report, "Application report should not be null");
+ assertEquals(appId, report.getApplicationId(), "Application ID should match");
+ assertEquals(testHostName, report.getHost(), "Host should match");
+ assertEquals(testPort, report.getRpcPort(), "Port should match");
+ assertEquals(testHostName, zkFrameworkClient.getAmHost(), "AM host should be cached");
+ assertEquals(testPort, zkFrameworkClient.getAmPort(), "AM port should be cached");
}
/**
@@ -139,12 +141,10 @@ public void testGetApplicationReportWithMissingAM() throws Exception {
ApplicationReport report = zkFrameworkClient.getApplicationReport(appId);
- assertNotNull("Application report should not be null", report);
- assertEquals("Application ID should match", appId, report.getApplicationId());
- assertEquals("Final status should be FAILED", FinalApplicationStatus.FAILED,
- report.getFinalApplicationStatus());
- assertTrue("Diagnostics should mention missing AM",
- report.getDiagnostics().contains("AM record not found"));
+ assertNotNull(report, "Application report should not be null");
+ assertEquals(appId, report.getApplicationId(), "Application ID should match");
+ assertEquals(FinalApplicationStatus.FAILED, report.getFinalApplicationStatus(), "Final status should be FAILED");
+ assertTrue(report.getDiagnostics().contains("AM record not found"), "Diagnostics should mention missing AM");
}
/**
@@ -169,12 +169,20 @@ public void testCreateApplication() throws Exception {
YarnClientApplication clientApp = zkFrameworkClient.createApplication();
- assertNotNull("YarnClientApplication should not be null", clientApp);
- assertNotNull("ApplicationSubmissionContext should not be null", clientApp.getApplicationSubmissionContext());
- assertEquals("Application ID should match", appId, clientApp.getApplicationSubmissionContext().getApplicationId());
- assertNotNull("GetNewApplicationResponse should not be null", clientApp.getNewApplicationResponse());
- assertEquals("Response application ID should match",
- appId, clientApp.getNewApplicationResponse().getApplicationId());
+ assertNotNull(clientApp, "YarnClientApplication should not be null");
+ assertNotNull(
+ clientApp.getApplicationSubmissionContext(),
+ "ApplicationSubmissionContext should not be null");
+ assertEquals(
+ appId,
+ clientApp.getApplicationSubmissionContext().getApplicationId(),
+ "Application ID should match");
+ assertNotNull(
+ clientApp.getNewApplicationResponse(), "GetNewApplicationResponse should not be null");
+ assertEquals(
+ appId,
+ clientApp.getNewApplicationResponse().getApplicationId(),
+ "Response application ID should match");
}
/**
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestJavaOptsChecker.java b/tez-api/src/test/java/org/apache/tez/common/TestJavaOptsChecker.java
index c945c89b8d..646020b412 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,66 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.*;
+
+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.*;
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:+UseConcMarkSweepGC -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:+UseConcMarkSweepGC -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
@@ -85,10 +87,10 @@ public void testPositiveNegativeOpts() throws TezException {
// Invalid negative can be ignored
opts = " -XX:+UseG1GC -XX:+UseParallelGC -XX:-UseG1GC -XX:-UseConcMarkSweepGC ";
javaOptsChecker.checkOpts(opts);
-
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSpecialCaseNonConflictingGCOptions() throws TezException {
String opts = " -XX:+UseParNewGC -XX:+UseConcMarkSweepGC ";
javaOptsChecker.checkOpts(opts);
@@ -102,13 +104,9 @@ public void testSpecialCaseNonConflictingGCOptions() throws TezException {
opts += " -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());
}
-
-
}
-
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestRPCUtil.java b/tez-api/src/test/java/org/apache/tez/common/TestRPCUtil.java
index b8facb5d1d..057cd86fa6 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.*;
+
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,12 @@
import com.google.protobuf.ServiceException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
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 +100,8 @@ public void testRPCServiceExceptionUnwrapping() {
t = thrown;
}
- Assert.assertTrue(IOException.class.isInstance(t));
- Assert.assertTrue(t.getMessage().contains(message));
+ assertTrue(IOException.class.isInstance(t));
+ assertTrue(t.getMessage().contains(message));
}
@Test
@@ -113,8 +116,8 @@ public void testRPCIOExceptionUnwrapping() {
} catch (Throwable thrown) {
t = thrown;
}
- Assert.assertTrue(FileNotFoundException.class.isInstance(t));
- Assert.assertTrue(t.getMessage().contains(message));
+ assertTrue(FileNotFoundException.class.isInstance(t));
+ assertTrue(t.getMessage().contains(message));
}
@Test
@@ -130,8 +133,8 @@ public void testRPCRuntimeExceptionUnwrapping() {
t = thrown;
}
- Assert.assertTrue(NullPointerException.class.isInstance(t));
- Assert.assertTrue(t.getMessage().contains(message));
+ assertTrue(NullPointerException.class.isInstance(t));
+ assertTrue(t.getMessage().contains(message));
}
private void verifyRemoteExceptionUnwrapping(
@@ -158,15 +161,16 @@ private void verifyRemoteExceptionUnwrapping(
t = thrown;
}
- Assert.assertTrue("Expected exception [" + expectedLocalException
- + "] but found " + t, expectedLocalException.isInstance(t));
- Assert.assertTrue(
- "Expected message [" + message + "] but found " + t.getMessage(), t
- .getMessage().contains(message));
+ assertTrue(
+ expectedLocalException.isInstance(t),
+ "Expected exception [" + expectedLocalException + "] but found " + t);
+ assertTrue(
+ t.getMessage().contains(message),
+ "Expected message [" + message + "] but found " + t.getMessage());
}
-
- @Test (timeout=1000)
+ @Test
+ @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS)
public void testRemoteNonIOExceptionUnwrapping() {
Class extends Throwable> exception = TezException.class;
verifyRemoteExceptionUnwrapping(exception, IOException.class.getName(), false);
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestReflectionUtils.java b/tez-api/src/test/java/org/apache/tez/common/TestReflectionUtils.java
index 774aa79621..671be8bc29 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,14 +18,12 @@
*/
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.*;
import java.io.IOException;
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;
@@ -33,7 +31,7 @@
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.api.TezReflectionException;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestReflectionUtils {
@@ -46,18 +44,20 @@ public ParameterizedConstructorClass(String first, int second) {
}
}
- @Test(timeout = 5000)
- public void testConstructorWithParameters() throws TezReflectionException
- {
- Class>[] parameterTypes = new Class[] { String.class, Integer.TYPE };
- Object[] parameters = new Object[] { new String("test"), 1 };
- ParameterizedConstructorClass instance = ReflectionUtils.createClazzInstance(
- ParameterizedConstructorClass.class.getName(), parameterTypes, parameters);
- assertEquals("Class not constructed with first parameter correctly", instance.first, "test");
- assertEquals("Class not constructed with second parameter correctly", instance.second, 1);
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testConstructorWithParameters() throws TezReflectionException {
+ Class>[] parameterTypes = new Class[] {String.class, Integer.TYPE};
+ Object[] parameters = new Object[] {new String("test"), 1};
+ ParameterizedConstructorClass instance =
+ ReflectionUtils.createClazzInstance(
+ ParameterizedConstructorClass.class.getName(), parameterTypes, parameters);
+ assertEquals(instance.first, "test", "Class not constructed with first parameter correctly");
+ assertEquals(instance.second, 1, "Class not constructed with second parameter correctly");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAddResourceToClasspath() throws IOException, TezException {
TezClassLoader.setupTezClassLoader();
String rsrcName = "dummyfile.xml";
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestTezCommonUtils.java b/tez-api/src/test/java/org/apache/tez/common/TestTezCommonUtils.java
index 30c3ed6759..2186c8c3e0 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,12 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.*;
+
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 +41,7 @@
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.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,7 +58,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 +74,7 @@ public static void setup() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (dfsCluster != null) {
try {
@@ -87,23 +87,25 @@ public static void afterClass() throws InterruptedException {
}
// Testing base staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezBaseStagingPath() throws Exception {
Configuration localConf = new Configuration();
// Check if default works with localFS
localConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, LOCAL_STAGING_DIR.getAbsolutePath());
localConf.set("fs.defaultFS", "file:///");
Path stageDir = TezCommonUtils.getTezBaseStagingPath(localConf);
- Assert.assertEquals("file:" + LOCAL_STAGING_DIR, stageDir.toString());
+ assertEquals("file:" + LOCAL_STAGING_DIR, stageDir.toString());
// check if user set something, indeed works
conf.set(TezConfiguration.TEZ_AM_STAGING_DIR, STAGE_DIR);
stageDir = TezCommonUtils.getTezBaseStagingPath(conf);
- Assert.assertEquals(stageDir.toString(), RESOLVED_STAGE_DIR);
+ assertEquals(stageDir.toString(), RESOLVED_STAGE_DIR);
}
// Testing System staging dir if createed
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCreateTezSysStagingPath() throws Exception {
String strAppId = "testAppId";
String expectedStageDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
@@ -116,24 +118,26 @@ public void testCreateTezSysStagingPath() throws Exception {
if (fs.exists(stagePath)) {
fs.delete(stagePath, true);
}
- Assert.assertFalse(fs.exists(stagePath));
+ assertFalse(fs.exists(stagePath));
Path stageDir = TezCommonUtils.createTezSystemStagingPath(conf, strAppId);
- Assert.assertEquals(stageDir.toString(), expectedStageDir);
- Assert.assertTrue(fs.exists(stagePath));
+ assertEquals(stageDir.toString(), expectedStageDir);
+ assertTrue(fs.exists(stagePath));
}
// Testing System staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezSysStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
String expectedStageDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId;
- Assert.assertEquals(stageDir.toString(), expectedStageDir);
+ assertEquals(stageDir.toString(), expectedStageDir);
}
// Testing conf staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezConfStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -141,11 +145,12 @@ public void testTezConfStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.TEZ_PB_BINARY_CONF_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing session jars staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezSessionJarStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -153,11 +158,12 @@ public void testTezSessionJarStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing bin plan staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezBinPlanStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -165,11 +171,12 @@ public void testTezBinPlanStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.TEZ_PB_PLAN_BINARY_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing text plan staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezTextPlanStagingPath() throws Exception {
String strAppId = "testAppId";
String dagPBName = "testDagPBName";
@@ -179,11 +186,12 @@ public void testTezTextPlanStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ strAppId + "-" + dagPBName + "-" + TezConstants.TEZ_PB_PLAN_TEXT_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -191,11 +199,12 @@ public void testTezRecoveryStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME;
- Assert.assertEquals(confStageDir.toString(), expectedDir);
+ assertEquals(confStageDir.toString(), expectedDir);
}
// Testing app attempt specific recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezAttemptRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -205,11 +214,12 @@ public void testTezAttemptRecoveryStagingPath() throws Exception {
String expectedDir = RESOLVED_STAGE_DIR + Path.SEPARATOR
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME + Path.SEPARATOR + "2";
- Assert.assertEquals(recoveryStageDir.toString(), expectedDir);
+ assertEquals(recoveryStageDir.toString(), expectedDir);
}
// Testing DAG specific recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezDAGRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -222,11 +232,12 @@ public void testTezDAGRecoveryStagingPath() throws Exception {
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME + Path.SEPARATOR + "2" + Path.SEPARATOR
+ "dag_123" + TezConstants.DAG_RECOVERY_RECOVER_FILE_SUFFIX;
- Assert.assertEquals(expectedDir, dagRecoveryPathj.toString());
+ assertEquals(expectedDir, dagRecoveryPathj.toString());
}
// Testing Summary recovery path staging dir
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezSummaryRecoveryStagingPath() throws Exception {
String strAppId = "testAppId";
Path stageDir = TezCommonUtils.getTezSystemStagingPath(conf, strAppId);
@@ -238,26 +249,29 @@ public void testTezSummaryRecoveryStagingPath() throws Exception {
+ TezCommonUtils.TEZ_SYSTEM_SUB_DIR + Path.SEPARATOR + strAppId + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_DATA_DIR_NAME + Path.SEPARATOR + "2" + Path.SEPARATOR
+ TezConstants.DAG_RECOVERY_SUMMARY_FILE_SUFFIX;
- Assert.assertEquals(expectedDir, summaryRecoveryPathj.toString());
+ assertEquals(expectedDir, summaryRecoveryPathj.toString());
}
// This test is running here to leverage existing mini cluster
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLocalResourceVisibility() throws Exception {
TestTezClientUtils.testLocalResourceVisibility(dfsCluster.getFileSystem(), conf);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testStringTokenize() {
String s = "foo:bar:xyz::too";
String[] expectedTokens = { "foo", "bar" , "xyz" , "too"};
String[] tokens = new String[4];
TezCommonUtils.tokenizeString(s, ":").toArray(tokens);
- Assert.assertArrayEquals(expectedTokens, tokens);
+ assertArrayEquals(expectedTokens, tokens);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAddAdditionalLocalResources() {
String lrName = "LR";
Map originalLrs;
@@ -289,9 +303,9 @@ public void testAddAdditionalLocalResources() {
LocalResourceType.FILE, LocalResourceVisibility.PUBLIC, 100, 1));
try {
TezCommonUtils.addAdditionalLocalResources(additionalLrs, originalLrs, "");
- Assert.fail("Duplicate LRs with different sizes expected to fail");
+ fail("Duplicate LRs with different sizes expected to fail");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
// Different path, same size, diff timestamp
@@ -314,56 +328,57 @@ public void testAddAdditionalLocalResources() {
LocalResourceType.FILE, LocalResourceVisibility.PUBLIC, 100, 1));
try {
TezCommonUtils.addAdditionalLocalResources(additionalLrs, originalLrs, "");
- Assert.fail("Duplicate LRs with different sizes expected to fail");
+ fail("Duplicate LRs with different sizes expected to fail");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAMClientHeartBeatTimeout() {
TezConfiguration conf = new TezConfiguration(false);
// -1 for any negative value
- Assert.assertEquals(-1,
+ assertEquals(-1,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS, -2);
- Assert.assertEquals(-1,
+ assertEquals(-1,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
// For any value > 0 but less than min, revert to min
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS,
TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM - 1);
- Assert.assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 1000,
+ assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 1000,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
// For val > min, should remain val as configured
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS,
TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 2);
- Assert.assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 2000,
+ assertEquals(TezConstants.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS_MINIMUM * 2000,
TezCommonUtils.getAMClientHeartBeatTimeoutMillis(conf));
conf = new TezConfiguration(false);
- Assert.assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -1, 10));
- Assert.assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -123, 10));
- Assert.assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 0, 10));
+ assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -1, 10));
+ assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, -123, 10));
+ assertEquals(-1, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 0, 10));
// min poll interval is 1000
- Assert.assertEquals(1000, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 600, 10));
+ assertEquals(1000, TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 600, 10));
// Poll interval is heartbeat interval/10
- Assert.assertEquals(2000,
+ assertEquals(2000,
TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 20000, 10));
// Configured poll interval ignored
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_POLL_INTERVAL_MILLIS, -1);
- Assert.assertEquals(4000,
+ assertEquals(4000,
TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 20000, 5));
// Positive poll interval is allowed
conf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_POLL_INTERVAL_MILLIS, 2000);
- Assert.assertEquals(2000,
+ assertEquals(2000,
TezCommonUtils.getAMClientHeartBeatPollIntervalMillis(conf, 20000, 5));
@@ -376,7 +391,7 @@ public void testLogSystemProperties() throws Exception {
conf.set(TezConfiguration.TEZ_JVM_SYSTEM_PROPERTIES_TO_LOG, " ");
String value = TezCommonUtils.getSystemPropertiesToLog(conf);
for(String key: TezConfiguration.TEZ_JVM_SYSTEM_PROPERTIES_TO_LOG_DEFAULT) {
- Assert.assertTrue(value.contains(key));
+ assertTrue(value.contains(key));
}
// test logging of selected keys
@@ -385,32 +400,33 @@ public void testLogSystemProperties() throws Exception {
String version = "java.version";
conf.set(TezConfiguration.TEZ_JVM_SYSTEM_PROPERTIES_TO_LOG, classpath + ", " + os);
value = TezCommonUtils.getSystemPropertiesToLog(conf);
- Assert.assertNotNull(value);
- Assert.assertTrue(value.contains(classpath));
- Assert.assertTrue(value.contains(os));
- Assert.assertFalse(value.contains(version));
+ assertNotNull(value);
+ assertTrue(value.contains(classpath));
+ assertTrue(value.contains(os));
+ assertFalse(value.contains(version));
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetDAGSessionTimeout() {
Configuration conf = new Configuration(false);
- Assert.assertEquals(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS_DEFAULT*1000,
+ assertEquals(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS_DEFAULT*1000,
TezCommonUtils.getDAGSessionTimeout(conf));
// set to 1 month - * 1000 guaranteed to cross positive integer boundary
conf.setInt(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS,
24 * 60 * 60 * 30);
- Assert.assertEquals(86400l*1000*30,
+ assertEquals(86400l*1000*30,
TezCommonUtils.getDAGSessionTimeout(conf));
// set to negative val
conf.setInt(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS,
-24 * 60 * 60 * 30);
- Assert.assertEquals(-1,
+ assertEquals(-1,
TezCommonUtils.getDAGSessionTimeout(conf));
conf.setInt(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS, 0);
- Assert.assertEquals(1000,
+ assertEquals(1000,
TezCommonUtils.getDAGSessionTimeout(conf));
}
@@ -426,7 +442,7 @@ public void testMkDirForAM() throws IOException {
FileSystem remoteFileSystem = miniDFS.getFileSystem();
Path path = new Path(TEST_ROOT_DIR + "/testMkDirForAM");
TezCommonUtils.mkDirForAM(remoteFileSystem, path);
- Assert.assertEquals(TezCommonUtils.TEZ_AM_DIR_PERMISSION, remoteFileSystem.getFileStatus(path).getPermission());
+ assertEquals(TezCommonUtils.TEZ_AM_DIR_PERMISSION, remoteFileSystem.getFileStatus(path).getPermission());
miniDFS.shutdown();
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestTezYARNUtils.java b/tez-api/src/test/java/org/apache/tez/common/TestTezYARNUtils.java
index 84d9d47b16..95aff499c3 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,13 @@
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.*;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.Shell;
@@ -32,97 +33,113 @@
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.*;
public class TestTezYARNUtils {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAuxClasspath() {
Configuration conf = new Configuration(false);
conf.set(TezConfiguration.TEZ_CLUSTER_ADDITIONAL_CLASSPATH_PREFIX, "foobar");
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains("foobar"));
- Assert.assertTrue(classpath.indexOf("foobar") <
+ assertTrue(classpath.contains("foobar"));
+ assertTrue(classpath.indexOf("foobar") <
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
- Assert.assertTrue(classpath.indexOf("foobar") <
+ assertTrue(classpath.indexOf("foobar") <
classpath.indexOf(Environment.PWD.$()));
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testUserClasspathFirstFalse() {
Configuration conf = new Configuration(false);
conf.setBoolean(TezConfiguration.TEZ_USER_CLASSPATH_FIRST, false);
conf.set(TezConfiguration.TEZ_CLUSTER_ADDITIONAL_CLASSPATH_PREFIX, "foobar");
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains("foobar"));
- Assert.assertTrue(classpath.indexOf("foobar") >
+ assertTrue(classpath.contains("foobar"));
+ assertTrue(classpath.indexOf("foobar") >
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
- Assert.assertTrue(classpath.indexOf("foobar") >
+ assertTrue(classpath.indexOf("foobar") >
classpath.indexOf(Environment.PWD.$()));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicArchiveClasspath() {
Configuration conf = new Configuration(false);
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains(Environment.PWD.$()));
- Assert.assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ assertTrue(classpath.contains(Environment.PWD.$()));
+ assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ "lib" + File.separator + "*"));
- Assert.assertTrue(!classpath.contains(Environment.HADOOP_CONF_DIR.$()));
- Assert.assertTrue(classpath.indexOf(Environment.PWD.$()) <
+ assertFalse(classpath.contains(Environment.HADOOP_CONF_DIR.$()));
+ assertTrue(classpath.indexOf(Environment.PWD.$()) <
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNoHadoopConfInClasspath() {
Configuration conf = new Configuration(false);
conf.setBoolean(TezConfiguration.TEZ_CLASSPATH_ADD_HADOOP_CONF, true);
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains(Environment.PWD.$()));
- Assert.assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
- Assert.assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ assertTrue(classpath.contains(Environment.PWD.$()));
+ assertTrue(classpath.contains(Environment.PWD.$() + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator + "*"));
+ assertTrue(classpath.contains(TezConstants.TEZ_TAR_LR_NAME + File.separator
+ "lib" + File.separator + "*"));
- Assert.assertTrue(classpath.contains(Environment.HADOOP_CONF_DIR.$()));
- Assert.assertTrue(classpath.indexOf(Environment.PWD.$()) <
+ assertTrue(classpath.contains(Environment.HADOOP_CONF_DIR.$()));
+ assertTrue(classpath.indexOf(Environment.PWD.$()) <
classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME));
- Assert.assertTrue(classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME) <
+ assertTrue(classpath.indexOf(TezConstants.TEZ_TAR_LR_NAME) <
classpath.indexOf(Environment.HADOOP_CONF_DIR.$()));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetupDefaultEnvironment() {
Configuration conf = new Configuration(false);
conf.set(TezConfiguration.TEZ_AM_LAUNCH_ENV, "LD_LIBRARY_PATH=USER_PATH,USER_KEY=USER_VALUE");
- conf.set(TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV, "LD_LIBRARY_PATH=DEFAULT_PATH,DEFAULT_KEY=DEFAULT_VALUE");
+ conf.set(
+ TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV,
+ "LD_LIBRARY_PATH=DEFAULT_PATH,DEFAULT_KEY=DEFAULT_VALUE");
Map environment = new TreeMap();
- TezYARNUtils.setupDefaultEnv(environment, conf,
+ TezYARNUtils.setupDefaultEnv(
+ environment,
+ conf,
TezConfiguration.TEZ_AM_LAUNCH_ENV,
TezConfiguration.TEZ_AM_LAUNCH_ENV_DEFAULT,
TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV,
- TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV_DEFAULT, false);
+ TezConfiguration.TEZ_AM_LAUNCH_CLUSTER_DEFAULT_ENV_DEFAULT,
+ false);
String value1 = environment.get("USER_KEY");
- Assert.assertEquals("User env should merge with default env", "USER_VALUE", value1);
+ assertEquals("USER_VALUE", value1, "User env should merge with default env");
String value2 = environment.get("DEFAULT_KEY");
- Assert.assertEquals("User env should merge with default env", "DEFAULT_VALUE", value2);
+ assertEquals("DEFAULT_VALUE", value2, "User env should merge with default env");
String value3 = environment.get("LD_LIBRARY_PATH");
- Assert.assertEquals("User env should append default env",
- Environment.PWD.$() + File.pathSeparator + "USER_PATH" + File.pathSeparator + "DEFAULT_PATH", value3);
- }
+ assertEquals(
+ Environment.PWD.$()
+ + File.pathSeparator
+ + "USER_PATH"
+ + File.pathSeparator
+ + "DEFAULT_PATH",
+ value3,
+ "User env should append default env");
+ }
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTezLibUrisClasspath() {
Configuration conf = new Configuration(false);
conf.set(TezConfiguration.TEZ_LIB_URIS_CLASSPATH, "foobar");
String classpath = TezYARNUtils.getFrameworkClasspath(conf, true);
- Assert.assertTrue(classpath.contains("foobar"));
- Assert.assertTrue(classpath.contains(Environment.PWD.$()));
- Assert.assertTrue(classpath.indexOf("foobar") >
+ assertTrue(classpath.contains("foobar"));
+ assertTrue(classpath.contains(Environment.PWD.$()));
+ assertTrue(classpath.indexOf("foobar") >
classpath.indexOf(Environment.PWD.$()));
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java b/tez-api/src/test/java/org/apache/tez/common/TestVersionInfo.java
index 7050d3aff3..5fa08913af 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,11 @@
*/
package org.apache.tez.common;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.*;
public class TestVersionInfo {
@@ -28,34 +31,38 @@ public class TestVersionInfo {
private static final String BUILD_TIME = "20141024-1052";
private static final String SCM_URL = "scm:git:https://gitbox.apache.org/repos/asf/tez.git";
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTest1File() {
VersionInfo versionInfo = new VersionInfo("test1");
- Assert.assertEquals(VERSION, versionInfo.getVersion());
- Assert.assertEquals(REVISION, versionInfo.getRevision());
- Assert.assertEquals(BUILD_TIME, versionInfo.getBuildTime());
- Assert.assertEquals(SCM_URL, versionInfo.getSCMURL());
+ assertEquals(VERSION, versionInfo.getVersion());
+ assertEquals(REVISION, versionInfo.getRevision());
+ assertEquals(BUILD_TIME, versionInfo.getBuildTime());
+ assertEquals(SCM_URL, versionInfo.getSCMURL());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTest2File() {
VersionInfo versionInfo = new VersionInfo("test2");
- Assert.assertEquals(VERSION, versionInfo.getVersion());
- Assert.assertEquals(REVISION, versionInfo.getRevision());
- Assert.assertEquals(BUILD_TIME, versionInfo.getBuildTime());
- Assert.assertEquals(VersionInfo.UNKNOWN, versionInfo.getSCMURL());
+ assertEquals(VERSION, versionInfo.getVersion());
+ assertEquals(REVISION, versionInfo.getRevision());
+ assertEquals(BUILD_TIME, versionInfo.getBuildTime());
+ assertEquals(VersionInfo.UNKNOWN, versionInfo.getSCMURL());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTest3File() {
VersionInfo versionInfo = new VersionInfo("test3");
- Assert.assertEquals(VERSION, versionInfo.getVersion());
- Assert.assertEquals(REVISION, versionInfo.getRevision());
- Assert.assertEquals("", versionInfo.getBuildTime());
- Assert.assertEquals(SCM_URL, versionInfo.getSCMURL());
+ assertEquals(VERSION, versionInfo.getVersion());
+ assertEquals(REVISION, versionInfo.getRevision());
+ assertEquals("", versionInfo.getBuildTime());
+ assertEquals(SCM_URL, versionInfo.getSCMURL());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNonExistentFile() {
VersionInfo versionInfo = new VersionInfo("test4");
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestACLConfigurationParser.java b/tez-api/src/test/java/org/apache/tez/common/security/TestACLConfigurationParser.java
index de2c6ade33..05b7131ff7 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,21 @@
*/
package org.apache.tez.common.security;
+import static org.junit.jupiter.api.Assertions.*;
+
+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.*;
public class TestACLConfigurationParser {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testACLConfigParser() {
Configuration conf = new Configuration(false);
@@ -39,43 +43,44 @@ public void testACLConfigParser() {
conf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewACLs);
ACLConfigurationParser parser = new ACLConfigurationParser(conf);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
- Assert.assertFalse(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
+ assertFalse(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
conf.set(TezConfiguration.TEZ_AM_MODIFY_ACLS, modifyACLs);
parser = new ACLConfigurationParser(conf);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user3"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_VIEW_ACL));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.AM_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_VIEW_ACL).contains("user4"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.AM_MODIFY_ACL).contains("user3"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGroupsOnly() {
Configuration conf = new Configuration(false);
String adminACLs = "admin1,admin4, admgrp3,admgrp4,admgrp5 ";
@@ -84,20 +89,21 @@ public void testGroupsOnly() {
conf.set(YarnConfiguration.YARN_ADMIN_ACL, adminACLs);
ACLConfigurationParser parser = new ACLConfigurationParser(conf);
- Assert.assertFalse(parser.getAllowedUsers().isEmpty());
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertFalse(parser.getAllowedUsers().isEmpty());
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.AM_VIEW_ACL).contains("grp5"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGACLConfigParser() {
Configuration conf = new Configuration(false);
@@ -108,44 +114,44 @@ public void testDAGACLConfigParser() {
conf.set(YarnConfiguration.YARN_ADMIN_ACL, adminACLs);
ACLConfigurationParser parser = new ACLConfigurationParser(conf, true);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
- Assert.assertFalse(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
+ assertFalse(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
conf.set(TezConstants.TEZ_DAG_MODIFY_ACLS, modifyACLs);
parser = new ACLConfigurationParser(conf, true);
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
- Assert.assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
- Assert.assertFalse(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user3"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
- Assert.assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
- Assert.assertFalse(parser.getAllowedGroups().isEmpty());
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
- Assert.assertNotNull(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL));
- Assert.assertFalse(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp6"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
- Assert.assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_VIEW_ACL));
+ assertTrue(parser.getAllowedUsers().containsKey(ACLType.DAG_MODIFY_ACL));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user1"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_VIEW_ACL).contains("user4"));
+ assertFalse(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.DAG_MODIFY_ACL).contains("user3"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin1"));
+ assertTrue(parser.getAllowedUsers().get(ACLType.YARN_ADMIN_ACL).contains("admin4"));
+ assertFalse(parser.getAllowedGroups().isEmpty());
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp3"));
+ assertFalse(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_VIEW_ACL).contains("grp5"));
+ assertNotNull(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL));
+ assertFalse(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp6"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.DAG_MODIFY_ACL).contains("grp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp3"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp4"));
+ assertTrue(parser.getAllowedGroups().get(ACLType.YARN_ADMIN_ACL).contains("admgrp5"));
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestACLManager.java b/tez-api/src/test/java/org/apache/tez/common/security/TestACLManager.java
index eeaf50091c..343b7af702 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,11 @@
*/
package org.apache.tez.common.security;
+import static org.junit.jupiter.api.Assertions.*;
+
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 +31,15 @@
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.*;
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 +49,37 @@ public void testCurrentUserACLChecks() {
UserGroupInformation user = user1;
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
user = currentUser;
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
aclManager = new ACLManager(currentUser.getShortUserName(), new Configuration(false));
user = user1;
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
user = currentUser;
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
ACLManager dagAclManager = new ACLManager(aclManager, dagUser.getShortUserName(),
ACLInfo.getDefaultInstance());
user = dagUser;
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
- Assert.assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.AM_VIEW_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.AM_MODIFY_ACL));
+ assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
+ assertTrue(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
user = user1;
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
- Assert.assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_VIEW_ACL));
+ assertFalse(dagAclManager.checkAccess(user, ACLType.DAG_MODIFY_ACL));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOtherUserACLChecks() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -100,24 +104,25 @@ public void testOtherUserACLChecks() throws IOException {
ACLManager aclManager = new ACLManager(currentUser.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
-
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
+
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNoGroupsACLChecks() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -140,24 +145,25 @@ public void testNoGroupsACLChecks() throws IOException {
conf.set(TezConfiguration.TEZ_AM_MODIFY_ACLS, modifyACLs);
ACLManager aclManager = new ACLManager(currentUser.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
- Assert.assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
-
- Assert.assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
- Assert.assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
- Assert.assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user1, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user2, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user3, ACLType.AM_VIEW_ACL));
+ assertTrue(aclManager.checkAccess(user4, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user5, ACLType.AM_VIEW_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_VIEW_ACL));
+
+ assertTrue(aclManager.checkAccess(currentUser, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user1, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user2, ACLType.AM_MODIFY_ACL));
+ assertTrue(aclManager.checkAccess(user3, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user4, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user5, ACLType.AM_MODIFY_ACL));
+ assertFalse(aclManager.checkAccess(user6, ACLType.AM_MODIFY_ACL));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void checkAMACLs() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -187,48 +193,49 @@ public void checkAMACLs() throws IOException {
ACLManager aclManager = new ACLManager(currentUser.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(currentUser));
- Assert.assertTrue(aclManager.checkAMViewAccess(user1));
- Assert.assertTrue(aclManager.checkAMViewAccess(user2));
- Assert.assertFalse(aclManager.checkAMViewAccess(user3));
- Assert.assertTrue(aclManager.checkAMViewAccess(user4));
- Assert.assertFalse(aclManager.checkAMViewAccess(user5));
- Assert.assertFalse(aclManager.checkAMViewAccess(user6));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkAMModifyAccess(currentUser));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user1));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user2));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user3));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user4));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user5));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user6));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGViewAccess(currentUser));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user2));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user3));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user4));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user5));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user6));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGModifyAccess(currentUser));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user1));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user2));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user3));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user4));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user5));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user6));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser2));
+ assertTrue(aclManager.checkAMViewAccess(currentUser));
+ assertTrue(aclManager.checkAMViewAccess(user1));
+ assertTrue(aclManager.checkAMViewAccess(user2));
+ assertFalse(aclManager.checkAMViewAccess(user3));
+ assertTrue(aclManager.checkAMViewAccess(user4));
+ assertFalse(aclManager.checkAMViewAccess(user5));
+ assertFalse(aclManager.checkAMViewAccess(user6));
+ assertTrue(aclManager.checkAMViewAccess(admuser1));
+ assertTrue(aclManager.checkAMViewAccess(admuser2));
+
+ assertTrue(aclManager.checkAMModifyAccess(currentUser));
+ assertFalse(aclManager.checkAMModifyAccess(user1));
+ assertFalse(aclManager.checkAMModifyAccess(user2));
+ assertTrue(aclManager.checkAMModifyAccess(user3));
+ assertFalse(aclManager.checkAMModifyAccess(user4));
+ assertTrue(aclManager.checkAMModifyAccess(user5));
+ assertFalse(aclManager.checkAMModifyAccess(user6));
+ assertTrue(aclManager.checkAMModifyAccess(admuser1));
+ assertTrue(aclManager.checkAMModifyAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGViewAccess(currentUser));
+ assertTrue(aclManager.checkDAGViewAccess(user1));
+ assertTrue(aclManager.checkDAGViewAccess(user2));
+ assertFalse(aclManager.checkDAGViewAccess(user3));
+ assertTrue(aclManager.checkDAGViewAccess(user4));
+ assertFalse(aclManager.checkDAGViewAccess(user5));
+ assertFalse(aclManager.checkDAGViewAccess(user6));
+ assertTrue(aclManager.checkDAGViewAccess(admuser1));
+ assertTrue(aclManager.checkDAGViewAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGModifyAccess(currentUser));
+ assertFalse(aclManager.checkDAGModifyAccess(user1));
+ assertFalse(aclManager.checkDAGModifyAccess(user2));
+ assertTrue(aclManager.checkDAGModifyAccess(user3));
+ assertFalse(aclManager.checkDAGModifyAccess(user4));
+ assertTrue(aclManager.checkDAGModifyAccess(user5));
+ assertFalse(aclManager.checkDAGModifyAccess(user6));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser1));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser2));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void checkDAGACLs() throws IOException {
String[] groups1 = new String[] {"grp1", "grp2"};
String[] groups2 = new String[] {"grp3", "grp4"};
@@ -271,53 +278,54 @@ public void checkDAGACLs() throws IOException {
ACLManager aclManager = new ACLManager(amAclManager, dagUser.getShortUserName(),
builder.build());
- Assert.assertTrue(aclManager.checkAMViewAccess(currentUser));
- Assert.assertFalse(aclManager.checkAMViewAccess(dagUser));
- Assert.assertTrue(aclManager.checkAMViewAccess(user1));
- Assert.assertTrue(aclManager.checkAMViewAccess(user2));
- Assert.assertFalse(aclManager.checkAMViewAccess(user3));
- Assert.assertTrue(aclManager.checkAMViewAccess(user4));
- Assert.assertFalse(aclManager.checkAMViewAccess(user5));
- Assert.assertFalse(aclManager.checkAMViewAccess(user6));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkAMModifyAccess(currentUser));
- Assert.assertFalse(aclManager.checkAMModifyAccess(dagUser));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user1));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user2));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user3));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user4));
- Assert.assertTrue(aclManager.checkAMModifyAccess(user5));
- Assert.assertFalse(aclManager.checkAMModifyAccess(user6));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGViewAccess(currentUser));
- Assert.assertTrue(aclManager.checkDAGViewAccess(dagUser));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user2));
- Assert.assertFalse(aclManager.checkDAGViewAccess(user3));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user4));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user5));
- Assert.assertTrue(aclManager.checkDAGViewAccess(user6));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(admuser2));
-
- Assert.assertTrue(aclManager.checkDAGModifyAccess(currentUser));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(dagUser));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user1));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user2));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user3));
- Assert.assertFalse(aclManager.checkDAGModifyAccess(user4));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user5));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(user6));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(admuser2));
+ assertTrue(aclManager.checkAMViewAccess(currentUser));
+ assertFalse(aclManager.checkAMViewAccess(dagUser));
+ assertTrue(aclManager.checkAMViewAccess(user1));
+ assertTrue(aclManager.checkAMViewAccess(user2));
+ assertFalse(aclManager.checkAMViewAccess(user3));
+ assertTrue(aclManager.checkAMViewAccess(user4));
+ assertFalse(aclManager.checkAMViewAccess(user5));
+ assertFalse(aclManager.checkAMViewAccess(user6));
+ assertTrue(aclManager.checkAMViewAccess(admuser1));
+ assertTrue(aclManager.checkAMViewAccess(admuser2));
+
+ assertTrue(aclManager.checkAMModifyAccess(currentUser));
+ assertFalse(aclManager.checkAMModifyAccess(dagUser));
+ assertFalse(aclManager.checkAMModifyAccess(user1));
+ assertFalse(aclManager.checkAMModifyAccess(user2));
+ assertTrue(aclManager.checkAMModifyAccess(user3));
+ assertFalse(aclManager.checkAMModifyAccess(user4));
+ assertTrue(aclManager.checkAMModifyAccess(user5));
+ assertFalse(aclManager.checkAMModifyAccess(user6));
+ assertTrue(aclManager.checkAMModifyAccess(admuser1));
+ assertTrue(aclManager.checkAMModifyAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGViewAccess(currentUser));
+ assertTrue(aclManager.checkDAGViewAccess(dagUser));
+ assertTrue(aclManager.checkDAGViewAccess(user1));
+ assertTrue(aclManager.checkDAGViewAccess(user2));
+ assertFalse(aclManager.checkDAGViewAccess(user3));
+ assertTrue(aclManager.checkDAGViewAccess(user4));
+ assertTrue(aclManager.checkDAGViewAccess(user5));
+ assertTrue(aclManager.checkDAGViewAccess(user6));
+ assertTrue(aclManager.checkDAGViewAccess(admuser1));
+ assertTrue(aclManager.checkDAGViewAccess(admuser2));
+
+ assertTrue(aclManager.checkDAGModifyAccess(currentUser));
+ assertTrue(aclManager.checkDAGModifyAccess(dagUser));
+ assertFalse(aclManager.checkDAGModifyAccess(user1));
+ assertFalse(aclManager.checkDAGModifyAccess(user2));
+ assertTrue(aclManager.checkDAGModifyAccess(user3));
+ assertFalse(aclManager.checkDAGModifyAccess(user4));
+ assertTrue(aclManager.checkDAGModifyAccess(user5));
+ assertTrue(aclManager.checkDAGModifyAccess(user6));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser1));
+ assertTrue(aclManager.checkDAGModifyAccess(admuser2));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWildCardCheck() {
Configuration conf = new Configuration(false);
String viewACLs = " * ";
@@ -329,17 +337,18 @@ public void testWildCardCheck() {
UserGroupInformation u1 = UserGroupInformation.createUserForTesting("u1", noGroups);
ACLManager aclManager = new ACLManager(a1.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(a1));
- Assert.assertTrue(aclManager.checkAMViewAccess(u1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(u1));
+ assertTrue(aclManager.checkAMViewAccess(a1));
+ assertTrue(aclManager.checkAMViewAccess(u1));
+ assertTrue(aclManager.checkAMModifyAccess(a1));
+ assertTrue(aclManager.checkAMModifyAccess(u1));
+ assertTrue(aclManager.checkDAGViewAccess(a1));
+ assertTrue(aclManager.checkDAGViewAccess(u1));
+ assertTrue(aclManager.checkDAGModifyAccess(a1));
+ assertTrue(aclManager.checkDAGModifyAccess(u1));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAdminWildCardCheck() {
Configuration conf = new Configuration(false);
String yarnAdminACLs = " * ";
@@ -349,17 +358,18 @@ public void testAdminWildCardCheck() {
UserGroupInformation u1 = UserGroupInformation.createUserForTesting("u1", noGroups);
ACLManager aclManager = new ACLManager(a1.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(a1));
- Assert.assertTrue(aclManager.checkAMViewAccess(u1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(u1));
+ assertTrue(aclManager.checkAMViewAccess(a1));
+ assertTrue(aclManager.checkAMViewAccess(u1));
+ assertTrue(aclManager.checkAMModifyAccess(a1));
+ assertTrue(aclManager.checkAMModifyAccess(u1));
+ assertTrue(aclManager.checkDAGViewAccess(a1));
+ assertTrue(aclManager.checkDAGViewAccess(u1));
+ assertTrue(aclManager.checkDAGModifyAccess(a1));
+ assertTrue(aclManager.checkDAGModifyAccess(u1));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testACLsDisabled() {
Configuration conf = new Configuration(false);
conf.setBoolean(TezConfiguration.TEZ_AM_ACLS_ENABLED, false);
@@ -372,27 +382,28 @@ public void testACLsDisabled() {
UserGroupInformation u1 = UserGroupInformation.createUserForTesting("u1", noGroups);
ACLManager aclManager = new ACLManager(a1.getShortUserName(), conf);
- Assert.assertTrue(aclManager.checkAMViewAccess(a1));
- Assert.assertTrue(aclManager.checkAMViewAccess(u1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(aclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(aclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(aclManager.checkDAGModifyAccess(u1));
+ assertTrue(aclManager.checkAMViewAccess(a1));
+ assertTrue(aclManager.checkAMViewAccess(u1));
+ assertTrue(aclManager.checkAMModifyAccess(a1));
+ assertTrue(aclManager.checkAMModifyAccess(u1));
+ assertTrue(aclManager.checkDAGViewAccess(a1));
+ assertTrue(aclManager.checkDAGViewAccess(u1));
+ assertTrue(aclManager.checkDAGModifyAccess(a1));
+ assertTrue(aclManager.checkDAGModifyAccess(u1));
ACLManager dagAclManager = new ACLManager(aclManager, "dagUser", null);
- Assert.assertTrue(dagAclManager.checkAMViewAccess(a1));
- Assert.assertTrue(dagAclManager.checkAMViewAccess(u1));
- Assert.assertTrue(dagAclManager.checkAMModifyAccess(a1));
- Assert.assertTrue(dagAclManager.checkAMModifyAccess(u1));
- Assert.assertTrue(dagAclManager.checkDAGViewAccess(a1));
- Assert.assertTrue(dagAclManager.checkDAGViewAccess(u1));
- Assert.assertTrue(dagAclManager.checkDAGModifyAccess(a1));
- Assert.assertTrue(dagAclManager.checkDAGModifyAccess(u1));
+ assertTrue(dagAclManager.checkAMViewAccess(a1));
+ assertTrue(dagAclManager.checkAMViewAccess(u1));
+ assertTrue(dagAclManager.checkAMModifyAccess(a1));
+ assertTrue(dagAclManager.checkAMModifyAccess(u1));
+ assertTrue(dagAclManager.checkDAGViewAccess(a1));
+ assertTrue(dagAclManager.checkDAGViewAccess(u1));
+ assertTrue(dagAclManager.checkDAGModifyAccess(a1));
+ assertTrue(dagAclManager.checkDAGModifyAccess(u1));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertToYARNACLs() {
String currentUser = "c1";
Configuration conf = new Configuration(false);
@@ -402,18 +413,18 @@ public void testConvertToYARNACLs() {
ACLManager aclManager = new ACLManager(currentUser, conf);
Map yarnAcls = aclManager.toYARNACls();
- Assert.assertTrue(yarnAcls.containsKey(ApplicationAccessType.VIEW_APP));
- Assert.assertEquals("c1,user1,user4 grp3,grp4",
+ assertTrue(yarnAcls.containsKey(ApplicationAccessType.VIEW_APP));
+ assertEquals("c1,user1,user4 grp3,grp4",
yarnAcls.get(ApplicationAccessType.VIEW_APP));
- Assert.assertTrue(yarnAcls.containsKey(ApplicationAccessType.MODIFY_APP));
- Assert.assertEquals("*",
+ assertTrue(yarnAcls.containsKey(ApplicationAccessType.MODIFY_APP));
+ assertEquals("*",
yarnAcls.get(ApplicationAccessType.MODIFY_APP));
viewACLs = " grp3,grp4 ";
conf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewACLs);
ACLManager aclManager1 = new ACLManager(currentUser, conf);
yarnAcls = aclManager1.toYARNACls();
- Assert.assertEquals("c1 grp3,grp4",
+ assertEquals("c1 grp3,grp4",
yarnAcls.get(ApplicationAccessType.VIEW_APP));
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestDAGAccessControls.java b/tez-api/src/test/java/org/apache/tez/common/security/TestDAGAccessControls.java
index e9c89a32ce..1f450517b2 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,38 @@
*/
package org.apache.tez.common.security;
+import static org.junit.jupiter.api.Assertions.*;
+
+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.*;
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 +138,15 @@ public void assertACLS(String expected, String obtained) {
String [] parts1 = expected.split(" ");
String [] parts2 = obtained.split(" ");
- Assert.assertEquals(parts1.length, parts2.length);
+ assertEquals(parts1.length, parts2.length);
- Assert.assertEquals(
+ assertEquals(
Sets.newHashSet(parts1[0].split(",")), Sets.newHashSet(parts2[0].split(",")));
if (parts1.length < 2) {
return;
}
- Assert.assertEquals(
+ assertEquals(
Sets.newHashSet(parts1[1].split(",")), Sets.newHashSet(parts2[1].split(",")));
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/common/security/TestTokenCache.java b/tez-api/src/test/java/org/apache/tez/common/security/TestTokenCache.java
index 867eb26398..611dd96773 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,7 @@
*/
package org.apache.tez.common.security;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -28,6 +29,7 @@
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -40,9 +42,7 @@
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.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -52,7 +52,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 +61,8 @@ public static void setup() throws Exception {
renewer = Master.getMasterPrincipal(conf);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
@SuppressWarnings("deprecation")
public void testBinaryCredentials() throws Exception {
String binaryTokenFile = null;
@@ -85,7 +86,7 @@ public void testBinaryCredentials() throws Exception {
Credentials newCreds = new Credentials();
TokenCache.mergeBinaryTokens(newCreds, conf, binaryTokenFile);
- Assert.assertTrue(newCreds.getAllTokens().size() > 0);
+ assertTrue(newCreds.getAllTokens().size() > 0);
checkTokens(creds, newCreds);
} finally {
if (binaryTokenFile != null) {
@@ -98,7 +99,8 @@ public void testBinaryCredentials() throws Exception {
}
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testObtainTokensForFileSystems() throws Exception {
Path[] paths = makePaths(100, "test://dir/file");
Credentials creds = new Credentials();
@@ -171,12 +173,12 @@ public Token> answer(InvocationOnMock invocation) throws Throwable {
}
private void checkTokens(Credentials creds, Credentials newCreds) {
- Assert.assertEquals(creds.getAllTokens().size(),
+ assertEquals(creds.getAllTokens().size(),
newCreds.getAllTokens().size());
for (Token> token : newCreds.getAllTokens()) {
Token> credsToken = creds.getToken(token.getService());
- Assert.assertTrue(credsToken != null);
- Assert.assertEquals(token, credsToken);
+ assertNotNull(credsToken);
+ assertEquals(token, credsToken);
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAG.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAG.java
index 6fcd25bc12..3e838726a0 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,11 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.*;
+
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 +37,15 @@
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.*;
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 +55,15 @@ public void testDuplicatedVertices() {
dag.addVertex(v1);
try {
dag.addVertex(v2);
- Assert.fail("should fail it due to duplicated vertices");
+ fail("should fail it due to duplicated vertices");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertEquals("Vertex v1 already defined!", e.getMessage());
+ assertEquals("Vertex v1 already defined!", e.getMessage());
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedEdges() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("Processor"),
dummyTaskCount, dummyTaskResource);
@@ -81,14 +85,15 @@ public void testDuplicatedEdges() {
dag.addEdge(edge1);
try {
dag.addEdge(edge2);
- Assert.fail("should fail it due to duplicated edges");
+ fail("should fail it due to duplicated edges");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertTrue(e.getMessage().contains("already defined!"));
+ assertTrue(e.getMessage().contains("already defined!"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedVertexGroup() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("Processor"),
dummyTaskCount, dummyTaskResource);
@@ -102,17 +107,18 @@ public void testDuplicatedVertexGroup() {
try {
dag.createVertexGroup("group_1", v2, v3);
- Assert.fail("should fail it due to duplicated VertexGroups");
+ fail("should fail it due to duplicated VertexGroups");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertEquals("VertexGroup group_1 already defined!", e.getMessage());
+ assertEquals("VertexGroup group_1 already defined!", e.getMessage());
}
// it is possible to create vertex group with same member but different group name
dag.createVertexGroup("group_2", v1, v2);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedGroupInputEdge() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -148,14 +154,15 @@ public void testDuplicatedGroupInputEdge() {
dag.addEdge(e1);
try {
dag.addEdge(e2);
- Assert.fail("should fail it due to duplicated GroupInputEdge");
+ fail("should fail it due to duplicated GroupInputEdge");
} catch (Exception e) {
e.printStackTrace();
- Assert.assertTrue(e.getMessage().contains("already defined"));
+ assertTrue(e.getMessage().contains("already defined"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGConf() {
DAG dag = DAG.create("DAG-testDAGConf");
// it's OK to set custom configuration
@@ -164,9 +171,9 @@ public void testDAGConf() {
// set invalid AM level configuration
try {
dag.setConf(TezConfiguration.TEZ_AM_SESSION_MODE, true+"");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertEquals("tez.am.mode.session is set at the scope of DAG,"
+ assertEquals("tez.am.mode.session is set at the scope of DAG,"
+ " but it is only valid in the scope of AM",
e.getMessage());
}
@@ -176,7 +183,8 @@ public void testDAGConf() {
dag.setConf(TezConfiguration.TEZ_AM_TASK_MAX_FAILED_ATTEMPTS, 3 + "");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexConf() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
// it's OK to set custom property
@@ -185,9 +193,9 @@ public void testVertexConf() {
// set invalid AM level configuration
try {
v1.setConf(TezConfiguration.TEZ_AM_SESSION_MODE, true+"");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertEquals("tez.am.mode.session is set at the scope of VERTEX,"
+ assertEquals("tez.am.mode.session is set at the scope of VERTEX,"
+ " but it is only valid in the scope of AM",
e.getMessage());
}
@@ -195,9 +203,9 @@ public void testVertexConf() {
// set invalid DAG level configuration
try {
v1.setConf(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, false + "");
- Assert.fail("should fail due to invalid configuration set");
+ fail("should fail due to invalid configuration set");
} catch (IllegalStateException e) {
- Assert.assertEquals("tez.am.commit-all-outputs-on-dag-success is set at the scope of VERTEX,"
+ assertEquals("tez.am.commit-all-outputs-on-dag-success is set at the scope of VERTEX,"
+ " but it is only valid in the scope of DAG",
e.getMessage());
}
@@ -205,30 +213,31 @@ public void testVertexConf() {
v1.setConf(TezConfiguration.TEZ_AM_TASK_MAX_FAILED_ATTEMPTS, 3 + "");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedInput() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
DataSourceDescriptor dataSource =
DataSourceDescriptor.create(InputDescriptor.create("dummyInput"), null, null);
try {
v1.addDataSource(null, dataSource);
- Assert.fail("Should fail due to invalid inputName");
+ fail("Should fail due to invalid inputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("InputName should not be null, empty or white space only,"));
}
try {
v1.addDataSource("", dataSource);
- Assert.fail("Should fail due to invalid inputName");
+ fail("Should fail due to invalid inputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("InputName should not be null, empty or white space only,"));
}
try {
v1.addDataSource(" ", dataSource);
- Assert.fail("Should fail due to invalid inputName");
+ fail("Should fail due to invalid inputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("InputName should not be null, empty or white space only,"));
}
@@ -236,36 +245,37 @@ public void testDuplicatedInput() {
try {
v1.addDataSource("input_1",
DataSourceDescriptor.create(InputDescriptor.create("dummyInput"), null, null));
- Assert.fail("Should fail due to duplicated input");
+ fail("Should fail due to duplicated input");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Duplicated input:input_1, vertexName=v1", e.getMessage());
+ assertEquals("Duplicated input:input_1, vertexName=v1", e.getMessage());
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedOutput_1() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
DataSinkDescriptor dataSink =
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null);
try {
v1.addDataSink(null, dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink("", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink(" ", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
@@ -274,13 +284,14 @@ public void testDuplicatedOutput_1() {
try {
v1.addDataSink("output_1",
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null));
- Assert.fail("Should fail due to duplicated output");
+ fail("Should fail due to duplicated output");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
+ assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDuplicatedOutput_2() {
DAG dag = DAG.create("DAG-testDuplicatedOutput_2");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create("dummyProcessor"));
@@ -288,23 +299,23 @@ public void testDuplicatedOutput_2() {
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null);
try {
v1.addDataSink(null, dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink("", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
try {
v1.addDataSink(" ", dataSink);
- Assert.fail("Should fail due to invalid outputName");
+ fail("Should fail due to invalid outputName");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage()
+ assertTrue(e.getMessage()
.contains("OutputName should not be null, empty or white space only,"));
}
@@ -314,9 +325,9 @@ public void testDuplicatedOutput_2() {
try {
vGroup.addDataSink("output_1",
DataSinkDescriptor.create(OutputDescriptor.create("dummyOutput"), null, null));
- Assert.fail("Should fail due to duplicated output");
+ fail("Should fail due to duplicated output");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
+ assertEquals("Duplicated output:output_1, vertexName=v1", e.getMessage());
}
}
@@ -324,13 +335,13 @@ public void testDuplicatedOutput_2() {
public void testCallerContext() {
try {
CallerContext.create("ctxt", "", "", "desc");
- Assert.fail("Expected failure for invalid args");
+ fail("Expected failure for invalid args");
} catch (Exception e) {
// Expected
}
try {
CallerContext.create("", "desc");
- Assert.fail("Expected failure for invalid args");
+ fail("Expected failure for invalid args");
} catch (Exception e) {
// Expected
}
@@ -339,8 +350,8 @@ public void testCallerContext() {
CallerContext.create("ctxt", null);
CallerContext callerContext = CallerContext.create("ctxt", "desc");
- Assert.assertTrue(callerContext.toString().contains("desc"));
- Assert.assertFalse(callerContext.contextAsSimpleString().contains("desc"));
+ assertTrue(callerContext.toString().contains("desc"));
+ assertFalse(callerContext.contextAsSimpleString().contains("desc"));
}
@@ -361,7 +372,7 @@ public void testRecreateDAG() {
DAGPlan firstPlan = dag.createDag(tezConf, null, null, null, false);
for (int i = 0; i < 3; ++i) {
DAGPlan dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals(dagPlan, firstPlan);
+ assertEquals(dagPlan, firstPlan);
}
}
@@ -383,43 +394,43 @@ public void testCreateDAGForHistoryLogLevel() {
// Expect null when history log level is not set in both dag and tezConf
DAGPlan dagPlan = dag.createDag(tezConf, null, null, null, false);
Builder builder = DAGPlan.newBuilder(dagPlan);
- Assert.assertNull(findKVP(builder.getDagConf(), TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
+ assertNull(findKVP(builder.getDagConf(), TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set tezConf but not dag, expect value in tezConf.
tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, "TASK");
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals("TASK", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
+ assertEquals("TASK", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set invalid value in tezConf, expect exception.
tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, "invalid");
try {
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.fail("Expected illegal argument exception");
+ fail("Expected illegal argument exception");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
+ assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
" is set to invalid value: invalid", e.getMessage());
}
// Set value in dag, should override tez conf value.
dag.setHistoryLogLevel(HistoryLogLevel.VERTEX);
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals("VERTEX", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
+ assertEquals("VERTEX", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set value directly into dagConf.
dag.setConf(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, HistoryLogLevel.DAG.name());
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.assertEquals("DAG", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
+ assertEquals("DAG", findKVP(DAGPlan.newBuilder(dagPlan).getDagConf(),
TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL));
// Set value invalid directly into dagConf and expect exception.
dag.setConf(TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL, "invalid");
try {
dagPlan = dag.createDag(tezConf, null, null, null, false);
- Assert.fail("Expected illegal argument exception");
+ fail("Expected illegal argument exception");
} catch (IllegalArgumentException e) {
- Assert.assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
+ assertEquals("Config: " + TezConfiguration.TEZ_HISTORY_LOGGING_LOGLEVEL +
" is set to invalid value: invalid", e.getMessage());
}
}
@@ -431,7 +442,7 @@ private String findKVP(ConfigurationProto conf, String key) {
if (foundValue == null) {
foundValue = conf.getConfKeyValues(i).getValue();
} else {
- Assert.fail("Multiple values found: " + foundValue + ", " +
+ fail("Multiple values found: " + foundValue + ", " +
conf.getConfKeyValues(i).getValue());
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGPlan.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGPlan.java
index 0a348c4c55..05aaff673f 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,16 @@
*/
package org.apache.tez.dag.api;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
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 +52,17 @@
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.*;
+import org.junit.jupiter.api.io.*;
// based on TestDAGLocationHint
public class TestDAGPlan {
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder(); //TODO: doesn't seem to be deleting this folder automatically as expected.
- @Test(timeout = 5000)
+ @TempDir
+ public Path tempFolder;
+
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicJobPlanSerde() throws IOException {
DAGPlan job = DAGPlan.newBuilder()
@@ -81,7 +82,7 @@ public void testBasicJobPlanSerde() throws IOException {
.build())
.build())
.build();
- File file = tempFolder.newFile("jobPlan");
+ File file = tempFolder.resolve("jobPlan").toFile();
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(file);
@@ -103,10 +104,11 @@ public void testBasicJobPlanSerde() throws IOException {
outStream.close();
}
- Assert.assertEquals(job, inJob);
+ assertEquals(job, inJob);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEdgeManagerSerde() {
DAG dag = DAG.create("DAG-testEdgeManagerSerde");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -137,13 +139,13 @@ public void testEdgeManagerSerde() {
.getEdgeList().get(0));
EdgeManagerPluginDescriptor emDesc = edgeProperty.getEdgeManagerDescriptor();
- Assert.assertNotNull(emDesc);
- Assert.assertEquals("emClass", emDesc.getClassName());
- Assert.assertTrue(
- Arrays.equals("emPayload".getBytes(), emDesc.getUserPayload().deepCopyAsArray()));
+ assertNotNull(emDesc);
+ assertEquals("emClass", emDesc.getClassName());
+ assertArrayEquals("emPayload".getBytes(), emDesc.getUserPayload().deepCopyAsArray());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testUserPayloadSerde() {
DAG dag = DAG.create("DAG-testUserPayloadSerde");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -204,7 +206,8 @@ public void testUserPayloadSerde() {
assertEquals("output", edgeProperty.getEdgeSource().getClassName());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void userVertexOrderingIsMaintained() {
DAG dag = DAG.create("DAG-userVertexOrderingIsMaintained");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -277,7 +280,8 @@ public void userVertexOrderingIsMaintained() {
assertEquals("output", edgeProperty.getEdgeSource().getClassName());
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCredentialsSerde() {
DAG dag = DAG.create("DAG-testCredentialsSerde");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -321,7 +325,8 @@ public void testCredentialsSerde() {
assertNotNull(fetchedCredentials.getToken(new Text("Token2")));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidExecContext_1() {
DAG dag = DAG.create("DAG-testInvalidExecContext_1");
dag.setExecutionContext(VertexExecutionContext.createExecuteInAm(true));
@@ -346,7 +351,8 @@ public void testInvalidExecContext_1() {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidExecContext_2() {
ServicePluginsDescriptor servicePluginsDescriptor = ServicePluginsDescriptor
@@ -428,7 +434,8 @@ public void testInvalidExecContext_2() {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testServiceDescriptorPropagation() {
DAG dag = DAG.create("DAG-testServiceDescriptorPropagation");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").
@@ -491,7 +498,8 @@ public void testServiceDescriptorPropagation() {
assertFalse(v2Proto.hasExecutionContext());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidJavaOpts() {
DAG dag = DAG.create("DAG-testInvalidJavaOpts");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -507,7 +515,7 @@ public void testInvalidJavaOpts() {
dag.createDag(conf, null, null, null, true, null, new JavaOptsChecker());
fail("Expected dag creation to fail for invalid java opts");
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Invalid/conflicting GC options"));
+ assertTrue(e.getMessage().contains("Invalid/conflicting GC options"));
}
// Should not fail as java opts valid
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDAGVerify.java
index 4c4390a451..a170d42748 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,8 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
@@ -25,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.LocalResource;
@@ -45,8 +48,7 @@
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.*;
public class TestDAGVerify {
@@ -61,7 +63,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 +84,8 @@ public void testVerifyScatterGather() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyCustomEdge() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -102,7 +106,8 @@ public void testVerifyCustomEdge() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyOneToOne() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -122,7 +127,8 @@ public void testVerifyOneToOne() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (known) -> v2 (-1) -> v3 (-1)
public void testVerifyOneToOneInferParallelism() {
Vertex v1 = Vertex.create("v1",
@@ -151,11 +157,12 @@ public void testVerifyOneToOneInferParallelism() {
dag.addEdge(e1);
dag.addEdge(e2);
dag.verify();
- Assert.assertEquals(dummyTaskCount, v2.getParallelism());
- Assert.assertEquals(dummyTaskCount, v3.getParallelism());
+ assertEquals(dummyTaskCount, v2.getParallelism());
+ assertEquals(dummyTaskCount, v3.getParallelism());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (known) -> v2 (-1) -> v3 (-1)
// The test checks resiliency to ordering of the vertices/edges
public void testVerifyOneToOneInferParallelismReverseOrder() {
@@ -185,11 +192,12 @@ public void testVerifyOneToOneInferParallelismReverseOrder() {
dag.addEdge(e2);
dag.addEdge(e1);
dag.verify();
- Assert.assertEquals(dummyTaskCount, v2.getParallelism());
- Assert.assertEquals(dummyTaskCount, v3.getParallelism());
+ assertEquals(dummyTaskCount, v2.getParallelism());
+ assertEquals(dummyTaskCount, v3.getParallelism());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyOneToOneNoInferParallelism() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -210,10 +218,11 @@ public void testVerifyOneToOneNoInferParallelism() {
dag.addVertex(v2);
dag.addEdge(e1);
dag.verify();
- Assert.assertEquals(-1, v2.getParallelism());
+ assertEquals(-1, v2.getParallelism());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (-1) -> v2 (known) -> v3 (-1)
public void testVerifyOneToOneIncorrectParallelism1() {
Vertex v1 = Vertex.create("v1",
@@ -243,14 +252,15 @@ public void testVerifyOneToOneIncorrectParallelism1() {
dag.addEdge(e2);
try {
dag.verify();
- Assert.assertTrue(false);
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"1-1 Edge. Destination vertex parallelism must match source vertex"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// v1 (-1) -> v3 (-1), v2 (known) -> v3 (-1)
// order of edges should not matter
public void testVerifyOneToOneIncorrectParallelism2() {
@@ -291,14 +301,15 @@ public void testVerifyOneToOneIncorrectParallelism2() {
dag.addEdge(e3);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"1-1 Edge. Destination vertex parallelism must match source vertex"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerifyBroadcast() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -318,7 +329,8 @@ public void testVerifyBroadcast() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerify3() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -338,7 +350,8 @@ public void testVerify3() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVerify4() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -363,7 +376,8 @@ public void testVerify4() {
// v2 ^
// | | ^
// v3 v4
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCycle1() {
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -413,9 +427,9 @@ public void testCycle1() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
+ assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
}
// v1
@@ -423,7 +437,8 @@ public void testCycle1() {
// -> v2
// ^ | |
// v3 v4
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCycle2() {
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -473,13 +488,14 @@ public void testCycle2() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
+ assertTrue(ex.getMessage().startsWith("DAG contains a cycle"));
}
// v1 -> v1
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSelfCycle(){
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -499,12 +515,13 @@ public void testSelfCycle(){
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("DAG contains a self-cycle"));
+ assertTrue(ex.getMessage().startsWith("DAG contains a self-cycle"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void repeatedVertexName() {
IllegalStateException ex=null;
Vertex v1 = Vertex.create("v1",
@@ -522,12 +539,13 @@ public void repeatedVertexName() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage().startsWith("Vertex v1 already defined"));
+ assertTrue(ex.getMessage().startsWith("Vertex v1 already defined"));
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAndInputVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -548,10 +566,11 @@ public void testInputAndInputVertexNameCollision() {
dag.addVertex(v1);
dag.addVertex(v2);
dag.addEdge(e1);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOutputAndOutputVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -572,10 +591,11 @@ public void testOutputAndOutputVertexNameCollision() {
dag.addVertex(v1);
dag.addVertex(v2);
dag.addEdge(e1);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOutputAndVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -589,10 +609,11 @@ public void testOutputAndVertexNameCollision() {
DAG dag = DAG.create("DAG-testOutputAndVertexNameCollision");
dag.addVertex(v1);
dag.addVertex(v2);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
- @Test(expected = IllegalStateException.class, timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAndVertexNameCollision() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -606,13 +627,14 @@ public void testInputAndVertexNameCollision() {
DAG dag = DAG.create("DAG-testInputAndVertexNameCollision");
dag.addVertex(v1);
dag.addVertex(v2);
- dag.verify();
+ assertThrows(IllegalStateException.class, dag::verify);
}
// v1 v2
// | |
// v3
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void BinaryInputAllowed() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
@@ -642,7 +664,8 @@ public void BinaryInputAllowed() {
dag.verify();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexGroupWithMultipleOutputEdges() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -687,15 +710,16 @@ public void testVertexGroupWithMultipleOutputEdges() {
dag.verify(); // should be OK when called multiple times
}
- Assert.assertEquals(2, v1.getOutputVertices().size());
- Assert.assertEquals(2, v2.getOutputVertices().size());
- Assert.assertTrue(v1.getOutputVertices().contains(v3));
- Assert.assertTrue(v1.getOutputVertices().contains(v4));
- Assert.assertTrue(v2.getOutputVertices().contains(v3));
- Assert.assertTrue(v2.getOutputVertices().contains(v4));
+ assertEquals(2, v1.getOutputVertices().size());
+ assertEquals(2, v2.getOutputVertices().size());
+ assertTrue(v1.getOutputVertices().contains(v3));
+ assertTrue(v1.getOutputVertices().contains(v4));
+ assertTrue(v2.getOutputVertices().contains(v3));
+ assertTrue(v2.getOutputVertices().contains(v4));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexGroup() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -749,35 +773,36 @@ public void testVertexGroup() {
// for the first Group v1 and v2 should get connected to v4 and also have 1 output
// for the second Group v2 and v3 should get connected to v5
// the Group place holders should disappear
- Assert.assertNull(dag.getVertex(uv12.getGroupName()));
- Assert.assertNull(dag.getVertex(uv23.getGroupName()));
- Assert.assertFalse(dag.edges.contains(e1));
- Assert.assertFalse(dag.edges.contains(e2));
- Assert.assertEquals(1, v1.getOutputs().size());
- Assert.assertEquals(1, v2.getOutputs().size());
- Assert.assertEquals(outDesc, v1.getOutputs().get(0).getIODescriptor());
- Assert.assertEquals(outDesc, v2.getOutputs().get(0).getIODescriptor());
- Assert.assertEquals(1, v1.getOutputVertices().size());
- Assert.assertEquals(1, v3.getOutputVertices().size());
- Assert.assertEquals(2, v2.getOutputVertices().size());
- Assert.assertTrue(v1.getOutputVertices().contains(v4));
- Assert.assertTrue(v3.getOutputVertices().contains(v5));
- Assert.assertTrue(v2.getOutputVertices().contains(v4));
- Assert.assertTrue(v2.getOutputVertices().contains(v5));
- Assert.assertEquals(2, v4.getInputVertices().size());
- Assert.assertTrue(v4.getInputVertices().contains(v1));
- Assert.assertTrue(v4.getInputVertices().contains(v2));
- Assert.assertEquals(2, v5.getInputVertices().size());
- Assert.assertTrue(v5.getInputVertices().contains(v2));
- Assert.assertTrue(v5.getInputVertices().contains(v3));
- Assert.assertEquals(1, v4.getGroupInputs().size());
- Assert.assertTrue(v4.getGroupInputs().containsKey(groupName1));
- Assert.assertEquals(1, v5.getGroupInputs().size());
- Assert.assertTrue(v5.getGroupInputs().containsKey(groupName2));
- Assert.assertEquals(2, dag.vertexGroups.size());
+ assertNull(dag.getVertex(uv12.getGroupName()));
+ assertNull(dag.getVertex(uv23.getGroupName()));
+ assertFalse(dag.edges.contains(e1));
+ assertFalse(dag.edges.contains(e2));
+ assertEquals(1, v1.getOutputs().size());
+ assertEquals(1, v2.getOutputs().size());
+ assertEquals(outDesc, v1.getOutputs().get(0).getIODescriptor());
+ assertEquals(outDesc, v2.getOutputs().get(0).getIODescriptor());
+ assertEquals(1, v1.getOutputVertices().size());
+ assertEquals(1, v3.getOutputVertices().size());
+ assertEquals(2, v2.getOutputVertices().size());
+ assertTrue(v1.getOutputVertices().contains(v4));
+ assertTrue(v3.getOutputVertices().contains(v5));
+ assertTrue(v2.getOutputVertices().contains(v4));
+ assertTrue(v2.getOutputVertices().contains(v5));
+ assertEquals(2, v4.getInputVertices().size());
+ assertTrue(v4.getInputVertices().contains(v1));
+ assertTrue(v4.getInputVertices().contains(v2));
+ assertEquals(2, v5.getInputVertices().size());
+ assertTrue(v5.getInputVertices().contains(v2));
+ assertTrue(v5.getInputVertices().contains(v3));
+ assertEquals(1, v4.getGroupInputs().size());
+ assertTrue(v4.getGroupInputs().containsKey(groupName1));
+ assertEquals(1, v5.getGroupInputs().size());
+ assertTrue(v5.getGroupInputs().containsKey(groupName2));
+ assertEquals(2, dag.vertexGroups.size());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexGroupOneToOne() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("Processor"),
@@ -828,13 +853,14 @@ public void testVertexGroupOneToOne() {
dag.verify(); // should be OK when called multiple times
}
- Assert.assertEquals(dummyTaskCount, v5.getParallelism());
+ assertEquals(dummyTaskCount, v5.getParallelism());
}
// v1
// | |
// v2 v3
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void BinaryOutput() {
IllegalStateException ex = null;
try {
@@ -868,10 +894,11 @@ public void BinaryOutput() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNull(ex);
+ assertNull(ex);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDagWithNoVertices() {
IllegalStateException ex=null;
try {
@@ -881,14 +908,15 @@ public void testDagWithNoVertices() {
catch (IllegalStateException e){
ex = e;
}
- Assert.assertNotNull(ex);
+ assertNotNull(ex);
System.out.println(ex.getMessage());
- Assert.assertTrue(ex.getMessage()
+ assertTrue(ex.getMessage()
.startsWith("Invalid dag containing 0 vertices"));
}
@SuppressWarnings("unused")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidVertexConstruction() {
{
Vertex v1 = Vertex.create("v1",
@@ -902,11 +930,10 @@ public void testInvalidVertexConstruction() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
-2, dummyTaskResource);
- Assert.fail("Expected exception for 0 parallelism");
+ fail("Expected exception for 0 parallelism");
} catch (IllegalArgumentException e) {
- Assert
- .assertTrue(e
- .getMessage()
+ assertTrue(
+ e.getMessage()
.startsWith(
"Parallelism should be -1 if determined by the AM, otherwise should be >= 0"));
}
@@ -914,13 +941,14 @@ public void testInvalidVertexConstruction() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create("MapProcessor"),
1, null);
- Assert.fail("Expected exception for 0 parallelism");
+ fail("Expected exception for 0 parallelism");
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().startsWith("Resource cannot be null"));
+ assertTrue(e.getMessage().startsWith("Resource cannot be null"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleRootInputsAllowed() {
DAG dag = DAG.create("DAG-testMultipleRootInputsAllowed");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -944,7 +972,8 @@ public void testMultipleRootInputsAllowed() {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGCreateDataInference() {
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
Map lrs1 = Maps.newHashMap();
@@ -971,16 +1000,17 @@ public void testDAGCreateDataInference() {
dag.addVertex(v1);
dag.addTaskLocalFiles(lrs1);
DAGPlan dagPlan = dag.createDag(new TezConfiguration(), null, null, null, true);
- Assert.assertEquals(lrName1, dagPlan.getLocalResource(0).getName());
+ assertEquals(lrName1, dagPlan.getLocalResource(0).getName());
VertexPlan vPlan = dagPlan.getVertex(0);
PlanTaskConfiguration taskPlan = vPlan.getTaskConfig();
- Assert.assertEquals(dummyTaskCount, taskPlan.getNumTasks());
- Assert.assertEquals(TezConfiguration.TEZ_TASK_RESOURCE_MEMORY_MB_DEFAULT, taskPlan.getMemoryMb());
- Assert.assertEquals(lrName2, taskPlan.getLocalResource(0).getName());
- Assert.assertEquals(dummyTaskCount, vPlan.getTaskLocationHintCount());
+ assertEquals(dummyTaskCount, taskPlan.getNumTasks());
+ assertEquals(TezConfiguration.TEZ_TASK_RESOURCE_MEMORY_MB_DEFAULT, taskPlan.getMemoryMb());
+ assertEquals(lrName2, taskPlan.getLocalResource(0).getName());
+ assertEquals(dummyTaskCount, vPlan.getTaskLocationHintCount());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInferredFilesFail() {
Vertex v1 = Vertex.create("v1",
ProcessorDescriptor.create(dummyProcessorClassName),
@@ -999,9 +1029,9 @@ public void testInferredFilesFail() {
// Allowed since the LR is the same.
try {
v1.addTaskLocalFiles(lrs2);
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
DataSourceDescriptor ds = DataSourceDescriptor.create(InputDescriptor.create("I.class"),
@@ -1013,20 +1043,21 @@ public void testInferredFilesFail() {
dag.addTaskLocalFiles(lrs);
try {
dag.addTaskLocalFiles(lrs2);
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
try {
// data source will add duplicate common files to vertex
dag.createDag(new TezConfiguration(), null, null, null, true);
- Assert.fail();
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
+ assertTrue(e.getMessage().contains("Duplicate Resources found with different size"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGAccessControls() {
DAG dag = DAG.create("DAG-testDAGAccessControls");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1")
@@ -1043,27 +1074,28 @@ public void testDAGAccessControls() {
Configuration conf = new Configuration(false);
DAGPlan dagPlan = dag.createDag(conf, null, null, null, true);
- Assert.assertNull(conf.get(TezConstants.TEZ_DAG_VIEW_ACLS));
- Assert.assertNull(conf.get(TezConstants.TEZ_DAG_MODIFY_ACLS));
+ assertNull(conf.get(TezConstants.TEZ_DAG_VIEW_ACLS));
+ assertNull(conf.get(TezConstants.TEZ_DAG_MODIFY_ACLS));
ACLInfo aclInfo = dagPlan.getAclInfo();
- Assert.assertEquals(Collections.singletonList("u1"), aclInfo.getUsersWithViewAccessList());
- Assert.assertEquals(Collections.singletonList("g1"), aclInfo.getGroupsWithViewAccessList());
- Assert.assertEquals(Collections.singletonList("*"), aclInfo.getUsersWithModifyAccessList());
- Assert.assertEquals(Collections.singletonList("g2"), aclInfo.getGroupsWithModifyAccessList());
+ assertEquals(Collections.singletonList("u1"), aclInfo.getUsersWithViewAccessList());
+ assertEquals(Collections.singletonList("g1"), aclInfo.getGroupsWithViewAccessList());
+ assertEquals(Collections.singletonList("*"), aclInfo.getUsersWithModifyAccessList());
+ assertEquals(Collections.singletonList("g2"), aclInfo.getGroupsWithModifyAccessList());
}
// v1 has input initializer
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGInvalidParallelism1() {
DAG dag = DAG.create("DAG-testDAGInvalidParallelism1");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1075,16 +1107,17 @@ public void testDAGInvalidParallelism1() {
}
// v1 has custom vertex manager
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGInvalidParallelism2() {
DAG dag = DAG.create("DAG-testDAGInvalidParallelism2");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1094,16 +1127,17 @@ public void testDAGInvalidParallelism2() {
}
// v1 has 1-1 united source vertex v0 which has input initializer
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGInvalidParallelism3() {
DAG dag = DAG.create("DAG-testDAGInvalidParallelism3");
Vertex v1 = Vertex.create("v1", ProcessorDescriptor.create(dummyProcessorClassName));
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1128,9 +1162,9 @@ public void testDAGInvalidParallelism4() {
dag.addVertex(v1);
try {
dag.verify();
- Assert.fail();
+ fail();
} catch (Exception e) {
- Assert.assertEquals(
+ assertEquals(
"v1 has -1 tasks but does not have input initializers, 1-1 uninited sources or custom vertex manager to set it at runtime",
e.getMessage());
}
@@ -1169,7 +1203,8 @@ public void testDAGWithSplitsOnClient() {
}
// Verifies failure in case of a file size difference. Does not verify sha differences.
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGWithConflictingResource() {
DAG dag = DAG.create("DAG-testDAGWithConflictingResource");
Map localResourceMap = new HashMap<>();
@@ -1188,9 +1223,9 @@ public void testDAGWithConflictingResource() {
try {
dag.verifyLocalResources(new TezConfiguration());
- Assert.fail("should report failure on conflict resources");
+ fail("should report failure on conflict resources");
} catch (Exception e) {
- Assert.assertTrue(e.getMessage().contains("There is conflicting local resource"));
+ assertTrue(e.getMessage().contains("There is conflicting local resource"));
}
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestDagTypeConverters.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestDagTypeConverters.java
index a9cc1e2dd1..cd668f1469 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,12 @@
*/
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.*;
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 +45,12 @@
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
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 +59,25 @@ public void testTezEntityDescriptorSerialization() throws IOException {
.setHistoryText(historytext);
TezEntityDescriptorProto proto =
DagTypeConverters.convertToDAGPlan(entityDescriptor);
- Assert.assertEquals(payload.getVersion(), proto.getTezUserPayload().getVersion());
- Assert.assertArrayEquals(payload.deepCopyAsArray(), proto.getTezUserPayload().getUserPayload().toByteArray());
+ assertEquals(payload.getVersion(), proto.getTezUserPayload().getVersion());
+ assertArrayEquals(payload.deepCopyAsArray(), proto.getTezUserPayload().getUserPayload().toByteArray());
assertTrue(proto.hasHistoryText());
- Assert.assertNotEquals(historytext, proto.getHistoryText());
- Assert.assertEquals(historytext, new String(
+ assertNotEquals(historytext, proto.getHistoryText());
+ assertEquals(historytext, new String(
TezCommonUtils.decompressByteStringToByteArray(proto.getHistoryText())));
// Ensure that the history text is not deserialized
InputDescriptor inputDescriptor =
DagTypeConverters.convertInputDescriptorFromDAGPlan(proto);
- Assert.assertNull(inputDescriptor.getHistoryText());
+ assertNull(inputDescriptor.getHistoryText());
// Check history text value
String actualHistoryText = DagTypeConverters.getHistoryTextFromProto(proto, TezCommonUtils.newInflater());
- Assert.assertEquals(historytext, actualHistoryText);
+ assertEquals(historytext, actualHistoryText);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testYarnPathTranslation() {
// Without port
String p1String = "hdfs://mycluster/file";
@@ -89,9 +88,9 @@ public void testYarnPathTranslation() {
String p1StringSerialized = DagTypeConverters.convertToDAGPlan(lr1Url);
// Deserialize
URL lr1UrlDeserialized = DagTypeConverters.convertToYarnURL(p1StringSerialized);
- Assert.assertEquals("mycluster", lr1UrlDeserialized.getHost());
- Assert.assertEquals("/file", lr1UrlDeserialized.getFile());
- Assert.assertEquals("hdfs", lr1UrlDeserialized.getScheme());
+ assertEquals("mycluster", lr1UrlDeserialized.getHost());
+ assertEquals("/file", lr1UrlDeserialized.getFile());
+ assertEquals("hdfs", lr1UrlDeserialized.getScheme());
// With port
@@ -103,14 +102,15 @@ public void testYarnPathTranslation() {
String p2StringSerialized = DagTypeConverters.convertToDAGPlan(lr2Url);
// Deserialize
URL lr2UrlDeserialized = DagTypeConverters.convertToYarnURL(p2StringSerialized);
- Assert.assertEquals("mycluster", lr2UrlDeserialized.getHost());
- Assert.assertEquals("/file", lr2UrlDeserialized.getFile());
- Assert.assertEquals("hdfs", lr2UrlDeserialized.getScheme());
- Assert.assertEquals(2311, lr2UrlDeserialized.getPort());
+ assertEquals("mycluster", lr2UrlDeserialized.getHost());
+ assertEquals("/file", lr2UrlDeserialized.getFile());
+ assertEquals("hdfs", lr2UrlDeserialized.getScheme());
+ assertEquals(2311, lr2UrlDeserialized.getPort());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexExecutionContextTranslation() {
VertexExecutionContext originalContext;
VertexExecutionContextProto contextProto;
@@ -142,7 +142,8 @@ public void testVertexExecutionContextTranslation() {
static final String testComm = "testComm";
static final String classSuffix = "_class";
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testServiceDescriptorTranslation() {
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestEntityDescriptor.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestEntityDescriptor.java
index 366edde5a5..96256253db 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,7 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.spy;
@@ -28,25 +29,25 @@
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.*;
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 +75,8 @@ public void testSegmentedWrite(InputDescriptor entityDescriptor, InputDescriptor
verifyResults(entityDescriptor, deserialized, payload, confVal);
}
- @Test (timeout=3000)
+ @Test
+ @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
public void testEntityDescriptorHadoopSerialization() throws IOException {
/* This tests the alternate serialization code path
* if the DataOutput is not DataOutputBuffer
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestHistoryLogLevel.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestHistoryLogLevel.java
index e73ca9079c..5dcac479b2 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,12 @@
*/
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.*;
import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestHistoryLogLevel {
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestTaskLocationHint.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestTaskLocationHint.java
index e2330beefb..481c18d582 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,18 @@
*/
package org.apache.tez.dag.api;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.concurrent.TimeUnit;
+
import com.google.common.collect.Sets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
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 +46,21 @@ public void testEquality() {
TaskLocationHint t10 = TaskLocationHint.createTaskLocationHint(
Sets.newHashSet(new String[] {"n1"}), Sets.newHashSet(new String[] {"r1", "r2"}));
- Assert.assertEquals(t1, t2);
- Assert.assertEquals(t5, t6);
- Assert.assertEquals(t7, t8);
- Assert.assertEquals(t2, t1);
- Assert.assertEquals(t6, t5);
- Assert.assertEquals(t8, t7);
- Assert.assertNotEquals(t1, t3);
- Assert.assertNotEquals(t3, t1);
- Assert.assertNotEquals(t1, t4);
- Assert.assertNotEquals(t4, t1);
- Assert.assertNotEquals(t1, t5);
- Assert.assertNotEquals(t5, t1);
- Assert.assertNotEquals(t8, t9);
- Assert.assertNotEquals(t9, t8);
- Assert.assertNotEquals(t9, t10);
- Assert.assertNotEquals(t10, t9);
+ assertEquals(t1, t2);
+ assertEquals(t5, t6);
+ assertEquals(t7, t8);
+ assertEquals(t2, t1);
+ assertEquals(t6, t5);
+ assertEquals(t8, t7);
+ assertNotEquals(t1, t3);
+ assertNotEquals(t3, t1);
+ assertNotEquals(t1, t4);
+ assertNotEquals(t4, t1);
+ assertNotEquals(t1, t5);
+ assertNotEquals(t5, t1);
+ assertNotEquals(t8, t9);
+ assertNotEquals(t9, t8);
+ assertNotEquals(t9, t10);
+ assertNotEquals(t10, t9);
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/TestTezConfiguration.java b/tez-api/src/test/java/org/apache/tez/dag/api/TestTezConfiguration.java
index a49fa3c86c..354638141e 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,56 @@
*/
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.*;
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.*;
public class TestTezConfiguration {
private static final String expectedValue = "tez.tar.gz";
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConstruction() {
TezConfiguration tezConf1 = new TezConfiguration();
- Assert.assertEquals(expectedValue, tezConf1.get(TezConfiguration.TEZ_LIB_URIS));
+ assertEquals(expectedValue, tezConf1.get(TezConfiguration.TEZ_LIB_URIS));
Configuration tezConf2 = new Configuration(true);
- Assert.assertNull(tezConf2.get(TezConfiguration.TEZ_LIB_URIS));
+ assertNull(tezConf2.get(TezConfiguration.TEZ_LIB_URIS));
TezConfiguration tezConf3 = new TezConfiguration(new Configuration());
- Assert.assertEquals(expectedValue, tezConf3.get(TezConfiguration.TEZ_LIB_URIS));
+ assertEquals(expectedValue, tezConf3.get(TezConfiguration.TEZ_LIB_URIS));
TezConfiguration tezConf4 = new TezConfiguration(false);
- Assert.assertNull(tezConf4.get(TezConfiguration.TEZ_LIB_URIS));
+ assertNull(tezConf4.get(TezConfiguration.TEZ_LIB_URIS));
Configuration tezConf5 = new Configuration(true);
- Assert.assertNull(tezConf5.get(TezConfiguration.TEZ_LIB_URIS));
+ assertNull(tezConf5.get(TezConfiguration.TEZ_LIB_URIS));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testKeySet() throws IllegalAccessException {
Class> c = TezConfiguration.class;
Set expectedKeys = new HashSet();
for (Field f : c.getFields()) {
- if (!f.getName().endsWith("DEFAULT") && f.getType() == String.class
+ if (!f.getName().endsWith("DEFAULT")
+ && f.getType() == String.class
&& !f.getName().equals("TEZ_SITE_XML")) {
- String value = (String)f.get(null);
+ String value = (String) f.get(null);
// not prefix
if (!value.endsWith(".")) {
expectedKeys.add((String) f.get(null));
- Assert.assertNotNull("field " + f.getName() + " do not have annotation of ConfigurationScope.",
- f.getAnnotation(ConfigurationScope.class));
+ assertNotNull(
+ f.getAnnotation(ConfigurationScope.class),
+ "field " + f.getName() + " do not have annotation of ConfigurationScope.");
}
}
}
@@ -75,6 +78,6 @@ public void testKeySet() throws IllegalAccessException {
fail("Found unexpected key: " + key + " in key set");
}
}
- assertTrue("Missing keys in key set: " + expectedKeys, expectedKeys.size() == 0);
+ assertEquals(0, expectedKeys.size(), "Missing keys in key set: " + expectedKeys);
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestATSHttpClient.java b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestATSHttpClient.java
index a4cab8f1fc..9f841878f9 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,8 @@
*/
package org.apache.tez.dag.api.client;
-import static junit.framework.TestCase.fail;
+import static org.junit.jupiter.api.Assertions.*;
+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 +29,32 @@
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.*;
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 +74,12 @@ public void testGetDagStatusThrowsExceptionOnEmptyJson() throws TezException {
fail("should not come here");
}
- Assert.assertTrue("Expected TezException but did not happen", exceptionHappened);
+ assertTrue(exceptionHappened, "Expected TezException but did not happen");
verify(spyClient).getJsonRootEntity(expectedDagUrl);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetDagStatusSimple() throws TezException, JSONException, IOException {
DAGClientTimelineImpl
httpClient = new DAGClientTimelineImpl(mock(ApplicationId.class),"EXAMPLE_DAG_ID",
@@ -119,25 +121,24 @@ public void testGetDagStatusSimple() throws TezException, JSONException, IOExcep
DAGStatus dagStatus = spyClient.getDAGStatus(statusOptions);
- Assert.assertEquals("DAG State", DAGStatus.State.SUCCEEDED, dagStatus.getState());
- Assert.assertEquals("DAG Diagnostics size", 1, dagStatus.getDiagnostics().size());
- Assert.assertEquals("DAG diagnostics detail", "SAMPLE_DIAGNOSTICS",
- dagStatus.getDiagnostics().get(0));
- Assert.assertEquals("Counters Size", 2, dagStatus.getDAGCounters().countCounters());
- Assert.assertEquals("Counter Value", 1,
- dagStatus.getDAGCounters().getGroup("CG1").findCounter("C1").getValue());
- Assert.assertEquals("total tasks", 15, dagStatus.getDAGProgress().getTotalTaskCount());
- Assert.assertEquals("failed tasks", 2, dagStatus.getDAGProgress().getFailedTaskCount());
- Assert.assertEquals("killed tasks", 6, dagStatus.getDAGProgress().getKilledTaskCount());
- Assert.assertEquals("succeeded tasks", 7, dagStatus.getDAGProgress().getSucceededTaskCount());
- Assert.assertEquals("running tasks", 8, dagStatus.getDAGProgress().getRunningTaskCount());
+ assertEquals(State.SUCCEEDED, dagStatus.getState(), "DAG State");
+ assertEquals(1, dagStatus.getDiagnostics().size(), "DAG Diagnostics size");
+ assertEquals("SAMPLE_DIAGNOSTICS", dagStatus.getDiagnostics().get(0), "DAG diagnostics detail");
+ assertEquals(2, dagStatus.getDAGCounters().countCounters(), "Counters Size");
+ assertEquals(1, dagStatus.getDAGCounters().getGroup("CG1").findCounter("C1").getValue(), "Counter Value");
+ assertEquals(15, dagStatus.getDAGProgress().getTotalTaskCount(), "total tasks");
+ assertEquals(2, dagStatus.getDAGProgress().getFailedTaskCount(), "failed tasks");
+ assertEquals(6, dagStatus.getDAGProgress().getKilledTaskCount(), "killed tasks");
+ assertEquals(7, dagStatus.getDAGProgress().getSucceededTaskCount(), "succeeded tasks");
+ assertEquals(8, dagStatus.getDAGProgress().getRunningTaskCount(), "running tasks");
final Map vertexProgress = dagStatus.getVertexProgress();
- Assert.assertEquals("vertex progress count", 2, vertexProgress.size());
- Assert.assertTrue("vertex name1", vertexProgress.containsKey("v1"));
- Assert.assertTrue("vertex name2", vertexProgress.containsKey("v2"));
+ assertEquals(2, vertexProgress.size(), "vertex progress count");
+ assertTrue(vertexProgress.containsKey("v1"), "vertex name1");
+ assertTrue(vertexProgress.containsKey("v2"), "vertex name2");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetVertexStatusSimple() throws JSONException, TezException, IOException {
DAGClientTimelineImpl
httpClient = new DAGClientTimelineImpl(mock(ApplicationId.class), "EXAMPLE_DAG_ID",
@@ -165,16 +166,15 @@ public void testGetVertexStatusSimple() throws JSONException, TezException, IOEx
doReturn(new JSONObject(jsonData)).when(spyClient).getJsonRootEntity(expectedVertexUrl);
VertexStatus vertexStatus = spyClient.getVertexStatus("vertex1name", statusOptions);
- Assert.assertEquals("status check", VertexStatus.State.SUCCEEDED, vertexStatus.getState());
- Assert.assertEquals("diagnostics", "diagnostics1", vertexStatus.getDiagnostics().get(0));
+ assertEquals(VertexStatus.State.SUCCEEDED, vertexStatus.getState(), "status check");
+ assertEquals("diagnostics1", vertexStatus.getDiagnostics().get(0), "diagnostics");
final Progress progress = vertexStatus.getProgress();
final TezCounters vertexCounters = vertexStatus.getVertexCounters();
- Assert.assertEquals("failed task count", 1, progress.getFailedTaskCount());
- Assert.assertEquals("suceeded task count", 2, progress.getSucceededTaskCount());
- Assert.assertEquals("killed task count", 3, progress.getKilledTaskCount());
- Assert.assertEquals("total task count", 4, progress.getTotalTaskCount());
- Assert.assertEquals("Counters Size", 2, vertexCounters.countCounters());
- Assert.assertEquals("Counter Value", 1,
- vertexCounters.getGroup("CG1").findCounter("C1").getValue());
+ assertEquals(1, progress.getFailedTaskCount(), "failed task count");
+ assertEquals(2, progress.getSucceededTaskCount(), "suceeded task count");
+ assertEquals(3, progress.getKilledTaskCount(), "killed task count");
+ assertEquals(4, progress.getTotalTaskCount(), "total task count");
+ assertEquals(2, vertexCounters.countCounters(), "Counters Size");
+ assertEquals(1, vertexCounters.getGroup("CG1").findCounter("C1").getValue(), "Counter Value");
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java
index 8c8d2abb49..52ef50348f 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
@@ -18,10 +18,12 @@
*/
package org.apache.tez.dag.api.client;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
@@ -29,25 +31,27 @@
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.*;
public class TestTimelineReaderFactory {
// ensure on hadoop 2.6+ TimelineReaderTokenAuthenticatedStrategy is used.
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testShouldUseTokenDelegationAuthStrategyForHadoop26() throws TezException {
String returnedClassName =
TimelineReaderFactory.getTimelineReaderStrategy(mock(Configuration.class), false, 0)
.getClass()
.getCanonicalName();
- Assert.assertEquals("should use pseudo auth on hadoop2.4",
+ assertEquals(
"org.apache.tez.dag.api.client.TimelineReaderFactory.TimelineReaderTokenAuthenticatedStrategy",
- returnedClassName);
+ returnedClassName,
+ "should use pseudo auth on hadoop2.4");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPseudoAuthenticatorConnectionUrlShouldHaveUserName() throws Exception {
ConnectionConfigurator connConf = mock(ConnectionConfigurator.class);
TimelineReaderPseudoAuthenticatedStrategy.PseudoAuthenticatedURLConnectionFactory
@@ -56,7 +60,7 @@ public void testPseudoAuthenticatorConnectionUrlShouldHaveUserName() throws Exce
String inputUrl = "http://host:8080/path";
String expectedUrl = inputUrl + "?user.name=" + UserGroupInformation.getCurrentUser().getShortUserName();
HttpURLConnection httpURLConnection = connectionFactory.getHttpURLConnection(new URL(inputUrl));
- Assert.assertEquals(expectedUrl, httpURLConnection.getURL().toString());
+ assertEquals(expectedUrl, httpURLConnection.getURL().toString());
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClient.java b/tez-api/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClient.java
index 168fdc0939..aa1d57dd86 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,7 @@
*/
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.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.doAnswer;
@@ -34,6 +33,7 @@
import java.lang.reflect.Field;
import java.util.EnumSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;
@@ -77,9 +77,7 @@
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.*;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.internal.util.collections.Sets;
@@ -187,7 +185,7 @@ public boolean matches(GetVertexStatusRequestProto requestProto) {
}
}
- @Before
+ @BeforeEach
public void setUp() throws YarnException, IOException, TezException, ServiceException{
setUpData();
@@ -216,7 +214,8 @@ public void setUp() throws YarnException, IOException, TezException, ServiceExce
realClient.proxy = mockProxy;
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testApp() throws IOException, TezException, ServiceException{
assertTrue(dagClient.getExecutionContext().contains(mockAppId.toString()));
assertEquals(mockAppId.toString(), dagClient.getSessionIdentifierString());
@@ -225,7 +224,8 @@ public void testApp() throws IOException, TezException, ServiceException{
assertEquals(mockAppReport, realClient.getApplicationReportInternal());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGStatus() throws Exception{
DAGStatus resultDagStatus = dagClient.getDAGStatus(null);
verify(mockProxy, times(1)).getDAGStatus(null, GetDAGStatusRequestProto.newBuilder()
@@ -240,7 +240,8 @@ public void testDAGStatus() throws Exception{
System.out.println("DAGStatusWithCounter:" + resultDagStatus);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testVertexStatus() throws Exception{
VertexStatus resultVertexStatus = dagClient.getVertexStatus("v1", null);
verify(mockProxy).getVertexStatus(null, GetVertexStatusRequestProto.newBuilder()
@@ -256,14 +257,16 @@ public void testVertexStatus() throws Exception{
System.out.println("VertexWithCounter:" + resultVertexStatus);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTryKillDAG() throws Exception{
dagClient.tryKillDAG();
verify(mockProxy, times(1)).tryKillDAG(null, TryKillDAGRequestProto.newBuilder()
.setDagId(dagIdStr).build());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitForCompletion() throws Exception{
// first time return DAG_RUNNING, second time return DAG_SUCCEEDED
when(mockProxy.getDAGStatus(isNull(), any()))
@@ -283,7 +286,8 @@ public void testWaitForCompletion() throws Exception{
.getDAGStatus(rpcControllerArgumentCaptor.capture(), argumentCaptor.capture());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWaitForCompletionWithStatusUpdates() throws Exception{
// first time and second time return DAG_RUNNING, third time return DAG_SUCCEEDED
@@ -338,7 +342,8 @@ public void testWaitForCompletionWithStatusUpdates() throws Exception{
.getDAGStatus(rpcControllerArgumentCaptor.capture(), argumentCaptor.capture());
}
- @Test(timeout = 50000)
+ @Test
+ @Timeout(value = 50000, unit = TimeUnit.MILLISECONDS)
public void testGetDagStatusWithTimeout() throws Exception {
long startTime;
long endTime;
@@ -412,7 +417,8 @@ public void testGetDagStatusWithTimeout() throws Exception {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDagClientTimelineEnabledCondition() throws IOException {
String historyLoggingClass = "org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService";
@@ -591,7 +597,7 @@ public void testTimelineClientCleanup() throws Exception {
reloaderThread = thread;
}
}
- Assert.assertTrue("Reloader is not alive", reloaderThread.isAlive());
+ assertTrue(reloaderThread.isAlive(), "Reloader is not alive");
dagClient.close();
boolean reloaderStillAlive = true;
@@ -602,10 +608,11 @@ public void testTimelineClientCleanup() throws Exception {
}
Thread.sleep(1000);
}
- Assert.assertFalse("Reloader is still alive", reloaderStillAlive);
+ assertFalse(reloaderStillAlive, "Reloader is still alive");
}
- @Test(timeout = 50000)
+ @Test
+ @Timeout(value = 50000, unit = TimeUnit.MILLISECONDS)
public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
long startTime;
long endTime;
@@ -625,8 +632,8 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
// Fetch from AM. RUNNING
rmDagStatus =
- new DAGStatus(constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING),
- DagStatusSource.RM);
+ new DAGStatus(
+ constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING), DagStatusSource.RM);
dagClientImpl.setRmDagStatus(rmDagStatus);
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_RUNNING, -1));
@@ -639,14 +646,14 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
assertEquals(0, dagClientImpl.numGetStatusViaRmInvocations);
// Directly from AM - one refresh. One with timeout.
assertEquals(2, dagClientRpc.numGetStatusViaAmInvocations);
- assertEquals(DAGStatus.State.RUNNING, dagStatus.getState());
+ assertEquals(State.RUNNING, dagStatus.getState());
// Fetch from AM. Success.
dagClientImpl.resetCounters();
dagClientRpc.resetCounters();
rmDagStatus =
- new DAGStatus(constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING),
- DagStatusSource.RM);
+ new DAGStatus(
+ constructDagStatusProto(DAGStatusStateProto.DAG_RUNNING), DagStatusSource.RM);
dagClientImpl.setRmDagStatus(rmDagStatus);
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_SUCCEEDED, 1000L));
@@ -654,17 +661,17 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
dagStatus = dagClientImpl.getDAGStatus(EnumSet.noneOf(StatusGetOpts.class), 2000L);
endTime = System.currentTimeMillis();
diff = endTime - startTime;
- assertTrue("diff is " + diff, diff > 500L && diff < 1500L);
+ assertTrue(diff > 500L && diff < 1500L, "diff is " + diff);
// Directly from AM
assertEquals(0, dagClientImpl.numGetStatusViaRmInvocations);
// Directly from AM - previous request cached, so single invocation only.
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
- assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
+ assertEquals(State.SUCCEEDED, dagStatus.getState());
// verify that the cachedDAGStatus is correct
DAGStatus cachedDagStatus = dagClientImpl.getCachedDAGStatus();
- Assert.assertNotNull(cachedDagStatus);
- Assert.assertSame(dagStatus, cachedDagStatus);
+ assertNotNull(cachedDagStatus);
+ assertSame(dagStatus, cachedDagStatus);
// When AM proxy throws an exception, the cachedDAGStatus should be returned
dagClientImpl.resetCounters();
@@ -675,8 +682,8 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
assertEquals(0, dagClientImpl.numGetStatusViaRmInvocations);
// Directly from AM - previous request cached, so single invocation only.
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
- assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
- Assert.assertSame(dagStatus, cachedDagStatus);
+ assertEquals(State.SUCCEEDED, dagStatus.getState());
+ assertSame(dagStatus, cachedDagStatus);
// test that RM is invoked when the cacheExpires and the AM fails.
dagClientRpc.setAMProxy(createMockProxy(DAGStatusStateProto.DAG_SUCCEEDED, 1000L));
@@ -689,13 +696,13 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
assertEquals(1, dagClientImpl.numGetStatusViaRmInvocations);
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
assertEquals(State.RUNNING, dagStatus.getState());
- Assert.assertNotSame(dagStatus, cachedDagStatus);
+ assertNotSame(dagStatus, cachedDagStatus);
// verify that the cachedDAGStatus is null because AM threw exception before setting the
// cache.
cachedDagStatus = dagClientImpl.getCachedDAGStatus();
- Assert.assertNull(cachedDagStatus);
- Assert.assertNotNull(dagStatus);
+ assertNull(cachedDagStatus);
+ assertNotNull(dagStatus);
// inject fault in RM too. getDAGStatus should return null;
dagClientImpl.resetCounters();
@@ -704,9 +711,9 @@ public void testGetDagStatusWithCachedStatusExpiration() throws Exception {
dagClientImpl.injectFault();
try {
dagClientImpl.getDAGStatus(EnumSet.noneOf(StatusGetOpts.class));
- Assert.fail("The RM should throw IOException");
+ fail("The RM should throw IOException");
} catch (IOException ioException) {
- Assert.assertEquals(ioException.getMessage(), "Fault Injected for RM");
+ assertEquals(ioException.getMessage(), "Fault Injected for RM");
assertEquals(1, dagClientImpl.numGetStatusViaRmInvocations);
assertEquals(1, dagClientRpc.numGetStatusViaAmInvocations);
}
diff --git a/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestCompositeDataMovementEvent.java b/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestCompositeDataMovementEvent.java
index 23f94c956f..f32895b0bd 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,29 @@
*/
package org.apache.tez.runtime.api.events;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.nio.ByteBuffer;
+import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
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 +49,7 @@ public void testGetEvents(){
for(DataMovementEvent dme: cdme2.getEvents()){
numOutputs++;
}
- Assert.assertEquals(numOutputs, cdme2.getCount());
+ assertEquals(numOutputs, cdme2.getCount());
}
}
diff --git a/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestInputDataInformationEvent.java b/tez-api/src/test/java/org/apache/tez/runtime/api/events/TestInputDataInformationEvent.java
index 52bf9a2341..0d92ad8c88 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,12 +18,14 @@
*/
package org.apache.tez.runtime.api.events;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.nio.ByteBuffer;
import com.google.common.base.Charsets;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestInputDataInformationEvent {
@@ -33,22 +35,22 @@ public void testApiPayloadOrPath() {
InputDataInformationEvent.createWithSerializedPayload(0, ByteBuffer.wrap("payload1".getBytes()));
// event created by createWithSerializedPayload should contain serialized payload
// but not a path or a deserialized payload
- Assert.assertEquals("payload1", Charsets.UTF_8.decode(eventWithSerializedPayload.getUserPayload()).toString());
- Assert.assertNull(eventWithSerializedPayload.getSerializedPath());
- Assert.assertNull(eventWithSerializedPayload.getDeserializedUserPayload());
+ assertEquals("payload1", Charsets.UTF_8.decode(eventWithSerializedPayload.getUserPayload()).toString());
+ assertNull(eventWithSerializedPayload.getSerializedPath());
+ assertNull(eventWithSerializedPayload.getDeserializedUserPayload());
InputDataInformationEvent eventWithObjectPayload = InputDataInformationEvent.createWithObjectPayload(0, "payload2");
// event created by eventWithObjectPayload should contain a deserialized payload
// but not a path or serialized payload
- Assert.assertEquals("payload2", eventWithObjectPayload.getDeserializedUserPayload());
- Assert.assertNull(eventWithObjectPayload.getSerializedPath());
- Assert.assertNull(eventWithObjectPayload.getUserPayload());
+ assertEquals("payload2", eventWithObjectPayload.getDeserializedUserPayload());
+ assertNull(eventWithObjectPayload.getSerializedPath());
+ assertNull(eventWithObjectPayload.getUserPayload());
InputDataInformationEvent eventWithPath = InputDataInformationEvent.createWithSerializedPath(0, "file://hello");
// event created by createWithSerializedPath should contain a path
// but neither serialized nor deserialized payload
- Assert.assertEquals("file://hello", eventWithPath.getSerializedPath());
- Assert.assertNull(eventWithPath.getUserPayload());
- Assert.assertNull(eventWithPath.getDeserializedUserPayload());
+ assertEquals("file://hello", eventWithPath.getSerializedPath());
+ assertNull(eventWithPath.getUserPayload());
+ assertNull(eventWithPath.getDeserializedUserPayload());
}
}
diff --git a/tez-common/pom.xml b/tez-common/pom.xml
index 700100df70..acec164252 100644
--- a/tez-common/pom.xml
+++ b/tez-common/pom.xml
@@ -70,11 +70,6 @@
mockito-core
test
-
- junit
- junit
- test
-
diff --git a/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java b/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java
index 2068490358..bbd4abc275 100644
--- a/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java
+++ b/tez-common/src/test/java/org/apache/tez/common/MockDNSToSwitchMapping.java
@@ -30,6 +30,8 @@
import org.apache.hadoop.net.DNSToSwitchMapping;
import org.apache.hadoop.yarn.util.RackResolver;
+import org.junit.jupiter.api.*;
+
/**
* Mock RackResolver
* Overrides CachedDNSToSwitchMapping to ensure that it does not try to resolve hostnames
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcher.java b/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcher.java
index f9cbd7a2f1..93a8262efe 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,16 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.*;
+
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.*;
public class TestAsyncDispatcher {
@@ -79,7 +81,8 @@ public void handle(TestEvent3 event) {
}
@SuppressWarnings("unchecked")
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasic() throws Exception {
CountDownLatch latch = new CountDownLatch(4);
CountDownEventHandler.latch = latch;
@@ -99,15 +102,16 @@ public void testBasic() throws Exception {
central.close();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleRegisterFail() throws Exception {
AsyncDispatcher central = new AsyncDispatcher("Type1");
try {
central.register(TestEventType1.class, new TestEventHandler1());
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
+ assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
} finally {
central.close();
}
@@ -116,9 +120,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
central.register(TestEventType1.class, new TestEventHandler1());
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
+ assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
} finally {
central.close();
}
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcherConcurrent.java b/tez-common/src/test/java/org/apache/tez/common/TestAsyncDispatcherConcurrent.java
index 89f346bdca..336dc8ff29 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,15 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.*;
+
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.*;
@SuppressWarnings("unchecked")
public class TestAsyncDispatcherConcurrent {
@@ -94,7 +96,8 @@ public void handle(TestEvent3 event) {
}
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasic() throws Exception {
CountDownLatch latch = new CountDownLatch(4);
CountDownEventHandler.init(latch);
@@ -115,7 +118,8 @@ public void testBasic() throws Exception {
central.close();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultiThreads() throws Exception {
CountDownLatch latch = new CountDownLatch(4);
CountDownEventHandler.init(latch);
@@ -134,15 +138,16 @@ public void testMultiThreads() throws Exception {
central.close();
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleRegisterFail() throws Exception {
AsyncDispatcher central = new AsyncDispatcher("Type1");
try {
central.register(TestEventType1.class, new TestEventHandler1());
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
+ assertTrue(e.getMessage().contains("Cannot register same event on multiple dispatchers"));
} finally {
central.close();
}
@@ -151,9 +156,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
central.register(TestEventType1.class, new TestEventHandler1());
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
+ assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
} finally {
central.close();
}
@@ -162,9 +167,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2", 1);
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
+ assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
} finally {
central.close();
}
@@ -173,9 +178,9 @@ public void testMultipleRegisterFail() throws Exception {
try {
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
central.registerAndCreateDispatcher(TestEventType1.class, new TestEventHandler2(), "Type2");
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
+ assertTrue(e.getMessage().contains("Multiple dispatchers cannot be registered for"));
} finally {
central.close();
}
@@ -186,9 +191,9 @@ public void testMultipleRegisterFail() throws Exception {
TestEventType1.class, new TestEventHandler2(), "Type2", 1);
central.registerWithExistingDispatcher(TestEventType1.class, new TestEventHandler1(),
concDispatcher);
- Assert.fail();
+ fail();
} catch (IllegalStateException e) {
- Assert.assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
+ assertTrue(e.getMessage().contains("Multiple concurrent dispatchers cannot be registered"));
} finally {
central.close();
}
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestTezSharedExecutor.java b/tez-common/src/test/java/org/apache/tez/common/TestTezSharedExecutor.java
index 35b814d93d..68cb02eed6 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,8 @@
*/
package org.apache.tez.common;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -34,10 +36,7 @@
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.*;
public class TestTezSharedExecutor {
@@ -113,18 +112,19 @@ public void run() {
private TezSharedExecutor sharedExecutor;
- @Before
+ @BeforeEach
public void setup() {
sharedExecutor = new TezSharedExecutor(new Configuration());
}
- @After
+ @AfterEach
public void cleanup() {
sharedExecutor.shutdownNow();
sharedExecutor = null;
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSimpleExecution() throws Exception {
ConcurrentHashMap map = new ConcurrentHashMap<>();
@@ -132,13 +132,13 @@ public void testSimpleExecution() throws Exception {
// Test runnable
service.submit(new Counter(map, "test")).get();
- Assert.assertEquals(1, map.get("test").get());
+ assertEquals(1, map.get("test").get());
// Test runnable with a result
final Object expected = new Object();
Object val = service.submit(new Counter(map, "test"), expected).get();
- Assert.assertEquals(expected, val);
- Assert.assertEquals(2, map.get("test").get());
+ assertEquals(expected, val);
+ assertEquals(2, map.get("test").get());
// Test callable.
val = service.submit(new Callable
diff --git a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryLoggingService.java b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryLoggingService.java
index 3c6ea4ffd3..f05f453678 100644
--- a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryLoggingService.java
+++ b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryLoggingService.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.dag.history.logging.ats;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -29,6 +30,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
@@ -54,10 +56,7 @@
import org.apache.tez.dag.records.TezTaskID;
import org.apache.tez.dag.records.TezVertexID;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
@@ -77,7 +76,7 @@ public class TestATSHistoryLoggingService {
private static ApplicationId appId = ApplicationId.newInstance(1000l, 1);
private static ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1);
- @Before
+ @BeforeEach
public void setup() throws Exception {
appContext = mock(AppContext.class);
historyACLPolicyManager = mock(HistoryACLPolicyManager.class);
@@ -116,13 +115,14 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
);
}
- @After
+ @AfterEach
public void teardown() {
atsHistoryLoggingService.stop();
atsHistoryLoggingService = null;
}
- @Test(timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testATSHistoryLoggingServiceShutdown() {
atsHistoryLoggingService.start();
TezDAGID tezDAGID = TezDAGID.getInstance(
@@ -144,12 +144,13 @@ public void testATSHistoryLoggingServiceShutdown() {
LOG.info("ATS entitiesSent=" + atsEntitiesCounter
+ ", timelineInvocations=" + atsInvokeCounter);
- Assert.assertTrue(atsEntitiesCounter >= 4);
- Assert.assertTrue(atsEntitiesCounter < 20);
+ assertTrue(atsEntitiesCounter >= 4);
+ assertTrue(atsEntitiesCounter < 20);
}
- @Test(timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testATSEventBatching() {
atsHistoryLoggingService.start();
TezDAGID tezDAGID = TezDAGID.getInstance(
@@ -169,11 +170,12 @@ public void testATSEventBatching() {
LOG.info("ATS entitiesSent=" + atsEntitiesCounter
+ ", timelineInvocations=" + atsInvokeCounter);
- Assert.assertTrue(atsEntitiesCounter > atsInvokeCounter);
- Assert.assertEquals(atsEntitiesCounter/2, atsInvokeCounter);
+ assertTrue(atsEntitiesCounter > atsInvokeCounter);
+ assertEquals(atsEntitiesCounter/2, atsInvokeCounter);
}
- @Test(timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testTimelineServiceDisable() throws Exception {
atsHistoryLoggingService.start();
ATSHistoryLoggingService atsHistoryLoggingService1;
@@ -215,13 +217,14 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
}
LOG.info("ATS entitiesSent=" + atsEntitiesCounter
+ ", timelineInvocations=" + atsInvokeCounter);
- Assert.assertEquals(atsInvokeCounter, 0);
- Assert.assertEquals(atsEntitiesCounter, 0);
- Assert.assertNull(atsHistoryLoggingService1.timelineClient);
+ assertEquals(atsInvokeCounter, 0);
+ assertEquals(atsEntitiesCounter, 0);
+ assertNull(atsHistoryLoggingService1.timelineClient);
atsHistoryLoggingService1.close();
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testNonSessionDomains() throws Exception {
when(historyACLPolicyManager.setupSessionACLs(any(), any()))
.thenReturn(
@@ -246,7 +249,8 @@ public void testNonSessionDomains() throws Exception {
verify(historyACLPolicyManager, times(6)).updateTimelineEntityDomain(any(), eq("session-id"));
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testNonSessionDomainsFailed() throws Exception {
when(historyACLPolicyManager.setupSessionACLs(any(), any()))
.thenThrow(new IOException());
@@ -267,10 +271,11 @@ public void testNonSessionDomainsFailed() throws Exception {
// All calls made with session domain id.
verify(historyACLPolicyManager, times(0)).updateTimelineEntityDomain(any(), eq("session-id"));
- Assert.assertEquals(0, atsEntitiesCounter);
+ assertEquals(0, atsEntitiesCounter);
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testNonSessionDomainsAclNull() throws Exception {
when(historyACLPolicyManager.setupSessionACLs(any(), any()))
.thenReturn(null);
@@ -292,10 +297,11 @@ public void testNonSessionDomainsAclNull() throws Exception {
// All calls made with session domain id.
verify(historyACLPolicyManager, times(0)).updateTimelineEntityDomain(any(), eq("session-id"));
- Assert.assertEquals(6, atsEntitiesCounter);
+ assertEquals(6, atsEntitiesCounter);
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSessionDomains() throws Exception {
when(historyACLPolicyManager.setupSessionACLs(any(), any()))
.thenReturn(Collections.singletonMap(TezConfiguration.YARN_ATS_ACL_SESSION_DOMAIN_ID, "test-domain"));
@@ -325,7 +331,8 @@ public void testSessionDomains() throws Exception {
verify(historyACLPolicyManager, times(5)).updateTimelineEntityDomain(any(), eq("dag-domain"));
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSessionDomainsFailed() throws Exception {
when(historyACLPolicyManager.setupSessionACLs(any(), any()))
.thenThrow(new IOException());
@@ -351,10 +358,11 @@ public void testSessionDomainsFailed() throws Exception {
// No calls were made for domains.
verify(historyACLPolicyManager, times(0)).updateTimelineEntityDomain(any(), any());
- Assert.assertEquals(0, atsEntitiesCounter);
+ assertEquals(0, atsEntitiesCounter);
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSessionDomainsDagFailed() throws Exception {
when(historyACLPolicyManager.setupSessionACLs(any(), any()))
.thenReturn(Collections.singletonMap(TezConfiguration.YARN_ATS_ACL_SESSION_DOMAIN_ID, "session-domain"));
@@ -384,10 +392,11 @@ public void testSessionDomainsDagFailed() throws Exception {
.updateTimelineEntityDomain(any(), eq("session-domain"));
verify(historyACLPolicyManager, times(1))
.updateTimelineEntityDomain(any(), any());
- Assert.assertEquals(1, atsEntitiesCounter);
+ assertEquals(1, atsEntitiesCounter);
}
- @Test(timeout=10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSessionDomainsAclNull() throws Exception {
when(historyACLPolicyManager.setupSessionACLs(any(), any()))
.thenReturn(null);
@@ -414,7 +423,7 @@ public void testSessionDomainsAclNull() throws Exception {
// All calls made with session domain id.
verify(historyACLPolicyManager, times(0)).updateTimelineEntityDomain(any(), any());
- Assert.assertEquals(6, atsEntitiesCounter);
+ assertEquals(6, atsEntitiesCounter);
}
private List makeHistoryEvents(TezDAGID dagId,
diff --git a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java
index 1ff3bfd8d7..6e231a7e67 100644
--- a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java
+++ b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java
@@ -18,8 +18,11 @@
*/
package org.apache.tez.dag.history.logging.ats;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.IOException;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import javax.ws.rs.core.MediaType;
@@ -44,10 +47,7 @@
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,7 +66,7 @@ public class TestATSHistoryWithMiniCluster {
private static String TEST_ROOT_DIR = "target" + Path.SEPARATOR
+ TestATSHistoryWithMiniCluster.class.getName() + "-tmpDir";
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException {
try {
conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR);
@@ -99,7 +99,7 @@ public static void setup() throws IOException {
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws InterruptedException {
LOG.info("Shutdown invoked");
Thread.sleep(10000);
@@ -120,15 +120,16 @@ private K getTimelineData(String url, Class clazz) {
ClientResponse response = resource.accept(MediaType.APPLICATION_JSON)
.get(ClientResponse.class);
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
+ assertEquals(200, response.getStatus());
+ assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
K entity = response.getEntity(clazz);
- Assert.assertNotNull(entity);
+ assertNotNull(entity);
return entity;
}
- @Test (timeout=50000)
+ @Test
+ @Timeout(value = 50000, unit = TimeUnit.MILLISECONDS)
public void testDisabledACls() throws Exception {
TezClient tezSession = null;
try {
@@ -161,7 +162,7 @@ public void testDisabledACls() throws Exception {
Thread.sleep(500l);
dagStatus = dagClient.getDAGStatus(null);
}
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState());
} finally {
if (tezSession != null) {
tezSession.stop();
diff --git a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestHistoryEventTimelineConversion.java b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestHistoryEventTimelineConversion.java
index 8a6b1bee54..330d6b67f9 100644
--- a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestHistoryEventTimelineConversion.java
+++ b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestHistoryEventTimelineConversion.java
@@ -18,11 +18,14 @@
*/
package org.apache.tez.dag.history.logging.ats;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.conf.Configuration;
@@ -89,9 +92,7 @@
import com.google.common.collect.Lists;
import org.codehaus.jettison.json.JSONException;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestHistoryEventTimelineConversion {
@@ -109,7 +110,7 @@ public class TestHistoryEventTimelineConversion {
private String containerLogs = "containerLogs";
@SuppressWarnings("deprecation")
- @Before
+ @BeforeEach
public void setup() {
applicationId = ApplicationId.newInstance(9999l, 1);
applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 1);
@@ -128,7 +129,8 @@ public void setup() {
nodeId = NodeId.newInstance("node", 13435);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testHandlerExists() throws JSONException {
for (HistoryEventType eventType : HistoryEventType.values()) {
HistoryEvent event = null;
@@ -217,7 +219,7 @@ public void testHandlerExists() throws JSONException {
event = new DAGKillRequestEvent();
break;
default:
- Assert.fail("Unhandled event type " + eventType);
+ fail("Unhandled event type " + eventType);
}
if (event == null || !event.isHistoryEvent()) {
continue;
@@ -234,7 +236,8 @@ static class MockVersionInfo extends VersionInfo {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertAppLaunchedEventConcurrentModificationException()
throws InterruptedException {
long launchTime = random.nextLong();
@@ -268,7 +271,8 @@ public void run() {
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertAppLaunchedEvent() {
long launchTime = random.nextLong();
long submitTime = random.nextLong();
@@ -281,209 +285,215 @@ public void testConvertAppLaunchedEvent() {
submitTime, user, conf, mockVersionInfo);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(launchTime, timelineEntity.getStartTime().longValue());
+ assertEquals(launchTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(EntityTypes.TEZ_APPLICATION.name(), timelineEntity.getEntityType());
- Assert.assertEquals("tez_" + applicationId.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_APPLICATION.name(), timelineEntity.getEntityType());
+ assertEquals("tez_" + applicationId.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
+ assertEquals(0, timelineEntity.getRelatedEntities().size());
- Assert.assertEquals(1, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.USER).contains(user));
+ assertEquals(1, timelineEntity.getPrimaryFilters().size());
+ assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.USER).contains(user));
- Assert.assertEquals(5, timelineEntity.getOtherInfo().size());
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.CONFIG));
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.TEZ_VERSION));
- Assert.assertEquals(user, timelineEntity.getOtherInfo().get(ATSConstants.USER));
- Assert.assertEquals(applicationId.toString(),
+ assertEquals(5, timelineEntity.getOtherInfo().size());
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.CONFIG));
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.TEZ_VERSION));
+ assertEquals(user, timelineEntity.getOtherInfo().get(ATSConstants.USER));
+ assertEquals(applicationId.toString(),
timelineEntity.getOtherInfo().get(ATSConstants.APPLICATION_ID));
- Assert.assertEquals(AMWebController.VERSION,
+ assertEquals(AMWebController.VERSION,
timelineEntity.getOtherInfo().get(ATSConstants.DAG_AM_WEB_SERVICE_VERSION));
Map config =
(Map) timelineEntity.getOtherInfo().get(ATSConstants.CONFIG);
- Assert.assertEquals(conf.get("foo"), config.get("foo"));
- Assert.assertEquals(conf.get("applicationId"), config.get("applicationId"));
+ assertEquals(conf.get("foo"), config.get("foo"));
+ assertEquals(conf.get("applicationId"), config.get("applicationId"));
Map versionInfo =
(Map) timelineEntity.getOtherInfo().get(ATSConstants.TEZ_VERSION);
- Assert.assertEquals(mockVersionInfo.getVersion(),
+ assertEquals(mockVersionInfo.getVersion(),
versionInfo.get(ATSConstants.VERSION));
- Assert.assertEquals(mockVersionInfo.getRevision(),
+ assertEquals(mockVersionInfo.getRevision(),
versionInfo.get(ATSConstants.REVISION));
- Assert.assertEquals(mockVersionInfo.getBuildTime(),
+ assertEquals(mockVersionInfo.getBuildTime(),
versionInfo.get(ATSConstants.BUILD_TIME));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertAMLaunchedEvent() {
long launchTime = random.nextLong();
long submitTime = random.nextLong();
AMLaunchedEvent event = new AMLaunchedEvent(applicationAttemptId, launchTime, submitTime, user);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals("tez_" + applicationAttemptId.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(EntityTypes.TEZ_APPLICATION_ATTEMPT.name(), timelineEntity.getEntityType());
+ assertEquals("tez_" + applicationAttemptId.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_APPLICATION_ATTEMPT.name(), timelineEntity.getEntityType());
final Map> relatedEntities = timelineEntity.getRelatedEntities();
- Assert.assertEquals(0, relatedEntities.size());
+ assertEquals(0, relatedEntities.size());
final Map> primaryFilters = timelineEntity.getPrimaryFilters();
- Assert.assertEquals(2, primaryFilters.size());
- Assert.assertTrue(primaryFilters.get(ATSConstants.USER).contains(user));
- Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
+ assertEquals(2, primaryFilters.size());
+ assertTrue(primaryFilters.get(ATSConstants.USER).contains(user));
+ assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertEquals(launchTime, timelineEntity.getStartTime().longValue());
+ assertEquals(launchTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent evt = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.AM_LAUNCHED.name(), evt.getEventType());
- Assert.assertEquals(launchTime, evt.getTimestamp());
+ assertEquals(HistoryEventType.AM_LAUNCHED.name(), evt.getEventType());
+ assertEquals(launchTime, evt.getTimestamp());
final Map otherInfo = timelineEntity.getOtherInfo();
- Assert.assertEquals(4, otherInfo.size());
- Assert.assertEquals(submitTime, otherInfo.get(ATSConstants.APP_SUBMIT_TIME));
- Assert.assertEquals(applicationId.toString(), otherInfo.get(ATSConstants.APPLICATION_ID));
- Assert.assertEquals(applicationAttemptId.toString(), otherInfo.get(ATSConstants.APPLICATION_ATTEMPT_ID));
- Assert.assertEquals(user, otherInfo.get(ATSConstants.USER));
+ assertEquals(4, otherInfo.size());
+ assertEquals(submitTime, otherInfo.get(ATSConstants.APP_SUBMIT_TIME));
+ assertEquals(applicationId.toString(), otherInfo.get(ATSConstants.APPLICATION_ID));
+ assertEquals(applicationAttemptId.toString(), otherInfo.get(ATSConstants.APPLICATION_ATTEMPT_ID));
+ assertEquals(user, otherInfo.get(ATSConstants.USER));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertAMStartedEvent() {
long startTime = random.nextLong();
AMStartedEvent event = new AMStartedEvent(applicationAttemptId, startTime, user);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals("tez_" + applicationAttemptId.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(EntityTypes.TEZ_APPLICATION_ATTEMPT.name(), timelineEntity.getEntityType());
+ assertEquals("tez_" + applicationAttemptId.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_APPLICATION_ATTEMPT.name(), timelineEntity.getEntityType());
final Map> relatedEntities = timelineEntity.getRelatedEntities();
- Assert.assertEquals(0, relatedEntities.size());
+ assertEquals(0, relatedEntities.size());
final Map> primaryFilters = timelineEntity.getPrimaryFilters();
- Assert.assertEquals(2, primaryFilters.size());
- Assert.assertTrue(primaryFilters.get(ATSConstants.USER).contains(user));
- Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
+ assertEquals(2, primaryFilters.size());
+ assertTrue(primaryFilters.get(ATSConstants.USER).contains(user));
+ assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent evt = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.AM_STARTED.name(), evt.getEventType());
- Assert.assertEquals(startTime, evt.getTimestamp());
+ assertEquals(HistoryEventType.AM_STARTED.name(), evt.getEventType());
+ assertEquals(startTime, evt.getTimestamp());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertContainerLaunchedEvent() {
long launchTime = random.nextLong();
ContainerLaunchedEvent event = new ContainerLaunchedEvent(containerId, launchTime,
applicationAttemptId);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_CONTAINER_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals("tez_" + containerId.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_CONTAINER_ID.name(), timelineEntity.getEntityType());
+ assertEquals("tez_" + containerId.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(1, timelineEntity.getRelatedEntities().size());
- Assert.assertTrue(
+ assertEquals(1, timelineEntity.getRelatedEntities().size());
+ assertTrue(
timelineEntity.getRelatedEntities().get(EntityTypes.TEZ_APPLICATION_ATTEMPT.name()).contains(
"tez_" + applicationAttemptId.toString()));
- Assert.assertEquals(1, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
+ assertEquals(1, timelineEntity.getPrimaryFilters().size());
+ assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationAttemptId.getApplicationId().toString()));
- Assert.assertEquals(containerId.toString(), timelineEntity.getOtherInfo().get(ATSConstants.CONTAINER_ID));
+ assertEquals(containerId.toString(), timelineEntity.getOtherInfo().get(ATSConstants.CONTAINER_ID));
- Assert.assertEquals(launchTime, timelineEntity.getStartTime().longValue());
+ assertEquals(launchTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
- Assert.assertEquals(HistoryEventType.CONTAINER_LAUNCHED.name(),
+ assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(HistoryEventType.CONTAINER_LAUNCHED.name(),
timelineEntity.getEvents().get(0).getEventType());
- Assert.assertEquals(launchTime,
+ assertEquals(launchTime,
timelineEntity.getEvents().get(0).getTimestamp());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertContainerStoppedEvent() {
long stopTime = random.nextLong();
int exitStatus = random.nextInt();
ContainerStoppedEvent event = new ContainerStoppedEvent(containerId, stopTime, exitStatus,
applicationAttemptId);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals("tez_" + containerId.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(EntityTypes.TEZ_CONTAINER_ID.name(), timelineEntity.getEntityType());
+ assertEquals("tez_" + containerId.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_CONTAINER_ID.name(), timelineEntity.getEntityType());
final Map> relatedEntities = timelineEntity.getRelatedEntities();
- Assert.assertEquals(1, relatedEntities.size());
- Assert.assertTrue(relatedEntities.get(EntityTypes.TEZ_APPLICATION_ATTEMPT.name())
+ assertEquals(1, relatedEntities.size());
+ assertTrue(relatedEntities.get(EntityTypes.TEZ_APPLICATION_ATTEMPT.name())
.contains("tez_" + applicationAttemptId.toString()));
final Map> primaryFilters = timelineEntity.getPrimaryFilters();
- Assert.assertEquals(2, primaryFilters.size());
- Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
+ assertEquals(2, primaryFilters.size());
+ assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertTrue(primaryFilters.get(ATSConstants.EXIT_STATUS).contains(exitStatus));
+ assertTrue(primaryFilters.get(ATSConstants.EXIT_STATUS).contains(exitStatus));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
final TimelineEvent evt = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.CONTAINER_STOPPED.name(), evt.getEventType());
- Assert.assertEquals(stopTime, evt.getTimestamp());
+ assertEquals(HistoryEventType.CONTAINER_STOPPED.name(), evt.getEventType());
+ assertEquals(stopTime, evt.getTimestamp());
final Map otherInfo = timelineEntity.getOtherInfo();
- Assert.assertEquals(2, otherInfo.size());
- Assert.assertEquals(exitStatus, otherInfo.get(ATSConstants.EXIT_STATUS));
- Assert.assertEquals(stopTime, otherInfo.get(ATSConstants.FINISH_TIME));
+ assertEquals(2, otherInfo.size());
+ assertEquals(exitStatus, otherInfo.get(ATSConstants.EXIT_STATUS));
+ assertEquals(stopTime, otherInfo.get(ATSConstants.FINISH_TIME));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertDAGStartedEvent() {
long startTime = random.nextLong();
String dagName = "testDagName";
DAGStartedEvent event = new DAGStartedEvent(tezDAGID, startTime, user, dagName);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent evt = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_STARTED.name(), evt.getEventType());
- Assert.assertEquals(startTime, evt.getTimestamp());
+ assertEquals(HistoryEventType.DAG_STARTED.name(), evt.getEventType());
+ assertEquals(startTime, evt.getTimestamp());
final Map> primaryFilters = timelineEntity.getPrimaryFilters();
- Assert.assertEquals(3, primaryFilters.size());
- Assert.assertTrue(primaryFilters.get(ATSConstants.USER).contains(user));
- Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
+ assertEquals(3, primaryFilters.size());
+ assertTrue(primaryFilters.get(ATSConstants.USER).contains(user));
+ assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertTrue(primaryFilters.get(ATSConstants.DAG_NAME).contains(dagName));
+ assertTrue(primaryFilters.get(ATSConstants.DAG_NAME).contains(dagName));
final Map otherInfo = timelineEntity.getOtherInfo();
- Assert.assertEquals(2, otherInfo.size());
- Assert.assertEquals(startTime, otherInfo.get(ATSConstants.START_TIME));
- Assert.assertEquals(DAGState.RUNNING.name(), otherInfo.get(ATSConstants.STATUS));
+ assertEquals(2, otherInfo.size());
+ assertEquals(startTime, otherInfo.get(ATSConstants.START_TIME));
+ assertEquals(DAGState.RUNNING.name(), otherInfo.get(ATSConstants.STATUS));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertDAGSubmittedEvent() {
long submitTime = random.nextLong();
@@ -492,7 +502,7 @@ public void testConvertDAGSubmittedEvent() {
applicationAttemptId, null, user, null, containerLogs, queueName);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(2, entities.size());
+ assertEquals(2, entities.size());
if (entities.get(0).getEntityType().equals(EntityTypes.TEZ_DAG_ID.name())) {
@@ -506,90 +516,91 @@ public void testConvertDAGSubmittedEvent() {
private void assertDagSubmittedEntity(long submitTime, DAGSubmittedEvent event,
TimelineEntity timelineEntity) {
- Assert.assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(2, timelineEntity.getRelatedEntities().size());
- Assert.assertTrue(
+ assertEquals(2, timelineEntity.getRelatedEntities().size());
+ assertTrue(
timelineEntity.getRelatedEntities().get(EntityTypes.TEZ_APPLICATION.name()).contains(
"tez_" + applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getRelatedEntities().get(EntityTypes.TEZ_APPLICATION_ATTEMPT.name()).contains(
"tez_" + applicationAttemptId.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_SUBMITTED.name(), timelineEvent.getEventType());
- Assert.assertEquals(submitTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.DAG_SUBMITTED.name(), timelineEvent.getEventType());
+ assertEquals(submitTime, timelineEvent.getTimestamp());
- Assert.assertEquals(submitTime, timelineEntity.getStartTime().longValue());
+ assertEquals(submitTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(5, timelineEntity.getPrimaryFilters().size());
+ assertEquals(5, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.DAG_NAME).contains(
dagPlan.getName()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.CALLER_CONTEXT_ID).contains(
dagPlan.getCallerContext().getCallerId()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationAttemptId.getApplicationId().toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.USER).contains(user));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.DAG_QUEUE_NAME)
.contains(event.getQueueName()));
- Assert.assertEquals(9, timelineEntity.getOtherInfo().size());
- Assert.assertEquals(applicationId.toString(),
+ assertEquals(9, timelineEntity.getOtherInfo().size());
+ assertEquals(applicationId.toString(),
timelineEntity.getOtherInfo().get(ATSConstants.APPLICATION_ID));
- Assert.assertEquals(applicationAttemptId.toString(),
+ assertEquals(applicationAttemptId.toString(),
timelineEntity.getOtherInfo().get(ATSConstants.APPLICATION_ATTEMPT_ID));
- Assert.assertEquals(applicationAttemptId.getApplicationId().toString(),
+ assertEquals(applicationAttemptId.getApplicationId().toString(),
timelineEntity.getOtherInfo().get(ATSConstants.APPLICATION_ID));
- Assert.assertEquals(AMWebController.VERSION,
+ assertEquals(AMWebController.VERSION,
timelineEntity.getOtherInfo().get(ATSConstants.DAG_AM_WEB_SERVICE_VERSION));
- Assert.assertEquals(user,
+ assertEquals(user,
timelineEntity.getOtherInfo().get(ATSConstants.USER));
- Assert.assertEquals(containerLogs,
+ assertEquals(containerLogs,
timelineEntity.getOtherInfo().get(ATSConstants.IN_PROGRESS_LOGS_URL + "_"
+ applicationAttemptId.getAttemptId()));
- Assert.assertEquals(
+ assertEquals(
timelineEntity.getOtherInfo().get(ATSConstants.CALLER_CONTEXT_ID),
dagPlan.getCallerContext().getCallerId());
- Assert.assertEquals(
+ assertEquals(
timelineEntity.getOtherInfo().get(ATSConstants.CALLER_CONTEXT_TYPE),
dagPlan.getCallerContext().getCallerType());
- Assert.assertEquals(dagPlan.getCallerContext().getContext(),
+ assertEquals(dagPlan.getCallerContext().getContext(),
timelineEntity.getOtherInfo().get(ATSConstants.CALLER_CONTEXT));
- Assert.assertEquals(
+ assertEquals(
event.getQueueName(), timelineEntity.getOtherInfo().get(ATSConstants.DAG_QUEUE_NAME));
}
private void assertDagSubmittedExtraInfoEntity(long submitTime, DAGSubmittedEvent event,
TimelineEntity timelineEntity) {
- Assert.assertEquals(EntityTypes.TEZ_DAG_EXTRA_INFO.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_EXTRA_INFO.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(1, timelineEntity.getRelatedEntities().size());
- Assert.assertTrue(timelineEntity.getRelatedEntities()
+ assertEquals(1, timelineEntity.getRelatedEntities().size());
+ assertTrue(timelineEntity.getRelatedEntities()
.get(EntityTypes.TEZ_DAG_ID.name()).contains(tezDAGID.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_SUBMITTED.name(), timelineEvent.getEventType());
- Assert.assertEquals(submitTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.DAG_SUBMITTED.name(), timelineEvent.getEventType());
+ assertEquals(submitTime, timelineEvent.getTimestamp());
- Assert.assertEquals(submitTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(0, timelineEntity.getPrimaryFilters().size());
- Assert.assertEquals(1, timelineEntity.getOtherInfo().size());
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.DAG_PLAN));
+ assertEquals(submitTime, timelineEntity.getStartTime().longValue());
+ assertEquals(0, timelineEntity.getPrimaryFilters().size());
+ assertEquals(1, timelineEntity.getOtherInfo().size());
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.DAG_PLAN));
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertTaskAttemptFinishedEvent() {
String vertexName = "testVertex";
long creationTime = random.nextLong();
@@ -611,53 +622,53 @@ public void testConvertTaskAttemptFinishedEvent() {
startTime, finishTime, state, TaskFailureType.FATAL, error, diagnostics, counters, events, null, creationTime,
tezTaskAttemptID, allocationTime, containerId, nodeId, "inProgressURL", "logsURL", "nodeHttpAddress");
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(tezTaskAttemptID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezTaskAttemptID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), timelineEntity.getEntityType());
final Map> primaryFilters = timelineEntity.getPrimaryFilters();
- Assert.assertEquals(5, primaryFilters.size());
- Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
+ assertEquals(5, primaryFilters.size());
+ assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_DAG_ID.name())
+ assertTrue(primaryFilters.get(EntityTypes.TEZ_DAG_ID.name())
.contains(tezDAGID.toString()));
- Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_VERTEX_ID.name())
+ assertTrue(primaryFilters.get(EntityTypes.TEZ_VERTEX_ID.name())
.contains(tezVertexID.toString()));
- Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_TASK_ID.name())
+ assertTrue(primaryFilters.get(EntityTypes.TEZ_TASK_ID.name())
.contains(tezTaskID.toString()));
- Assert.assertTrue(primaryFilters.get(ATSConstants.STATUS).contains(state.toString()));
+ assertTrue(primaryFilters.get(ATSConstants.STATUS).contains(state.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent evt = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.TASK_ATTEMPT_FINISHED.name(), evt.getEventType());
- Assert.assertEquals(finishTime, evt.getTimestamp());
+ assertEquals(HistoryEventType.TASK_ATTEMPT_FINISHED.name(), evt.getEventType());
+ assertEquals(finishTime, evt.getTimestamp());
final Map otherInfo = timelineEntity.getOtherInfo();
- Assert.assertEquals(17, otherInfo.size());
- Assert.assertEquals(tezTaskAttemptID.toString(),
+ assertEquals(17, otherInfo.size());
+ assertEquals(tezTaskAttemptID.toString(),
timelineEntity.getOtherInfo().get(ATSConstants.CREATION_CAUSAL_ATTEMPT));
- Assert.assertEquals(creationTime, timelineEntity.getOtherInfo().get(ATSConstants.CREATION_TIME));
- Assert.assertEquals(allocationTime, timelineEntity.getOtherInfo().get(ATSConstants.ALLOCATION_TIME));
- Assert.assertEquals(startTime, timelineEntity.getOtherInfo().get(ATSConstants.START_TIME));
- Assert.assertEquals(finishTime, otherInfo.get(ATSConstants.FINISH_TIME));
- Assert.assertEquals(finishTime - startTime, otherInfo.get(ATSConstants.TIME_TAKEN));
- Assert.assertEquals(state.name(), otherInfo.get(ATSConstants.STATUS));
- Assert.assertEquals(TaskFailureType.FATAL.name(), otherInfo.get(ATSConstants.TASK_FAILURE_TYPE));
- Assert.assertEquals(error.name(), otherInfo.get(ATSConstants.TASK_ATTEMPT_ERROR_ENUM));
- Assert.assertEquals(diagnostics, otherInfo.get(ATSConstants.DIAGNOSTICS));
+ assertEquals(creationTime, timelineEntity.getOtherInfo().get(ATSConstants.CREATION_TIME));
+ assertEquals(allocationTime, timelineEntity.getOtherInfo().get(ATSConstants.ALLOCATION_TIME));
+ assertEquals(startTime, timelineEntity.getOtherInfo().get(ATSConstants.START_TIME));
+ assertEquals(finishTime, otherInfo.get(ATSConstants.FINISH_TIME));
+ assertEquals(finishTime - startTime, otherInfo.get(ATSConstants.TIME_TAKEN));
+ assertEquals(state.name(), otherInfo.get(ATSConstants.STATUS));
+ assertEquals(TaskFailureType.FATAL.name(), otherInfo.get(ATSConstants.TASK_FAILURE_TYPE));
+ assertEquals(error.name(), otherInfo.get(ATSConstants.TASK_ATTEMPT_ERROR_ENUM));
+ assertEquals(diagnostics, otherInfo.get(ATSConstants.DIAGNOSTICS));
Map obj1 = (Map)otherInfo.get(ATSConstants.LAST_DATA_EVENTS);
List obj2 = (List) obj1.get(ATSConstants.LAST_DATA_EVENTS);
- Assert.assertEquals(2, obj2.size());
+ assertEquals(2, obj2.size());
Map obj3 = (Map) obj2.get(0);
- Assert.assertEquals(events.get(0).getTimestamp(), obj3.get(ATSConstants.TIMESTAMP));
- Assert.assertTrue(otherInfo.containsKey(ATSConstants.COUNTERS));
- Assert.assertEquals("inProgressURL", otherInfo.get(ATSConstants.IN_PROGRESS_LOGS_URL));
- Assert.assertEquals("logsURL", otherInfo.get(ATSConstants.COMPLETED_LOGS_URL));
- Assert.assertEquals(nodeId.toString(), otherInfo.get(ATSConstants.NODE_ID));
- Assert.assertEquals(containerId.toString(), otherInfo.get(ATSConstants.CONTAINER_ID));
- Assert.assertEquals("nodeHttpAddress", otherInfo.get(ATSConstants.NODE_HTTP_ADDRESS));
+ assertEquals(events.get(0).getTimestamp(), obj3.get(ATSConstants.TIMESTAMP));
+ assertTrue(otherInfo.containsKey(ATSConstants.COUNTERS));
+ assertEquals("inProgressURL", otherInfo.get(ATSConstants.IN_PROGRESS_LOGS_URL));
+ assertEquals("logsURL", otherInfo.get(ATSConstants.COMPLETED_LOGS_URL));
+ assertEquals(nodeId.toString(), otherInfo.get(ATSConstants.NODE_ID));
+ assertEquals(containerId.toString(), otherInfo.get(ATSConstants.CONTAINER_ID));
+ assertEquals("nodeHttpAddress", otherInfo.get(ATSConstants.NODE_HTTP_ADDRESS));
TaskAttemptFinishedEvent eventWithNullFailureType =
new TaskAttemptFinishedEvent(tezTaskAttemptID, vertexName,
@@ -667,15 +678,16 @@ public void testConvertTaskAttemptFinishedEvent() {
"nodeHttpAddress");
List evtEntities = HistoryEventTimelineConversion.convertToTimelineEntities(
eventWithNullFailureType);
- Assert.assertEquals(1, evtEntities.size());
+ assertEquals(1, evtEntities.size());
TimelineEntity timelineEntityWithNullFailureType = evtEntities.get(0);
- Assert.assertNull(
+ assertNull(
timelineEntityWithNullFailureType.getOtherInfo().get(ATSConstants.TASK_FAILURE_TYPE));
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertDAGInitializedEvent() {
long initTime = random.nextLong();
@@ -687,39 +699,40 @@ public void testConvertDAGInitializedEvent() {
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
+ assertEquals(0, timelineEntity.getRelatedEntities().size());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_INITIALIZED.name(), timelineEvent.getEventType());
- Assert.assertEquals(initTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.DAG_INITIALIZED.name(), timelineEvent.getEventType());
+ assertEquals(initTime, timelineEvent.getTimestamp());
- Assert.assertEquals(3, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertEquals(3, timelineEntity.getPrimaryFilters().size());
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.DAG_NAME).contains("dagName"));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.USER).contains(user));
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(
+ assertTrue(timelineEntity.getOtherInfo().containsKey(
ATSConstants.VERTEX_NAME_ID_MAPPING));
Map vIdMap = (Map) timelineEntity.getOtherInfo().get(
ATSConstants.VERTEX_NAME_ID_MAPPING);
- Assert.assertEquals(1, vIdMap.size());
- Assert.assertNotNull(vIdMap.containsKey("foo"));
- Assert.assertEquals(tezVertexID.toString(), vIdMap.get("foo"));
+ assertEquals(1, vIdMap.size());
+ assertNotNull(vIdMap.containsKey("foo"));
+ assertEquals(tezVertexID.toString(), vIdMap.get("foo"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertDAGFinishedEvent() {
long finishTime = random.nextLong();
long startTime = random.nextLong();
@@ -731,7 +744,7 @@ public void testConvertDAGFinishedEvent() {
"diagnostics", null, user, dagPlan.getName(), taskStats, applicationAttemptId, dagPlan);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(2, entities.size());
+ assertEquals(2, entities.size());
if (entities.get(0).getEntityType().equals(EntityTypes.TEZ_DAG_ID.name())) {
assertDagFinishedEntity(finishTime, startTime, event, entities.get(0));
@@ -744,69 +757,70 @@ public void testConvertDAGFinishedEvent() {
private void assertDagFinishedEntity(long finishTime, long startTime, DAGFinishedEvent event,
TimelineEntity timelineEntity) {
- Assert.assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
+ assertEquals(0, timelineEntity.getRelatedEntities().size());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_FINISHED.name(), timelineEvent.getEventType());
- Assert.assertEquals(finishTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.DAG_FINISHED.name(), timelineEvent.getEventType());
+ assertEquals(finishTime, timelineEvent.getTimestamp());
- Assert.assertEquals(5, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertEquals(5, timelineEntity.getPrimaryFilters().size());
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.DAG_NAME).contains(dagPlan.getName()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.USER).contains(user));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.STATUS).contains(
DAGState.ERROR.name()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.CALLER_CONTEXT_ID).contains(
dagPlan.getCallerContext().getCallerId()));
- Assert.assertEquals(startTime,
+ assertEquals(startTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.START_TIME)).longValue());
- Assert.assertEquals(finishTime,
+ assertEquals(finishTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.FINISH_TIME)).longValue());
- Assert.assertEquals(finishTime - startTime,
+ assertEquals(finishTime - startTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.TIME_TAKEN)).longValue());
- Assert.assertEquals(DAGState.ERROR.name(),
+ assertEquals(DAGState.ERROR.name(),
timelineEntity.getOtherInfo().get(ATSConstants.STATUS));
- Assert.assertEquals("diagnostics",
+ assertEquals("diagnostics",
timelineEntity.getOtherInfo().get(ATSConstants.DIAGNOSTICS));
- Assert.assertEquals(applicationAttemptId.toString(),
+ assertEquals(applicationAttemptId.toString(),
timelineEntity.getOtherInfo().get(ATSConstants.COMPLETION_APPLICATION_ATTEMPT_ID));
- Assert.assertEquals(100,
+ assertEquals(100,
((Integer) timelineEntity.getOtherInfo().get("FOO")).intValue());
- Assert.assertEquals(200,
+ assertEquals(200,
((Integer) timelineEntity.getOtherInfo().get("BAR")).intValue());
}
private void assertDagFinishedExtraInfoEntity(long finishTime, TimelineEntity timelineEntity) {
- Assert.assertEquals(EntityTypes.TEZ_DAG_EXTRA_INFO.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_EXTRA_INFO.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(1, timelineEntity.getRelatedEntities().size());
- Assert.assertTrue(
+ assertEquals(1, timelineEntity.getRelatedEntities().size());
+ assertTrue(
timelineEntity.getRelatedEntities().get(ATSConstants.TEZ_DAG_ID).contains(
tezDAGID.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_FINISHED.name(), timelineEvent.getEventType());
- Assert.assertEquals(finishTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.DAG_FINISHED.name(), timelineEvent.getEventType());
+ assertEquals(finishTime, timelineEvent.getTimestamp());
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.COUNTERS));
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.COUNTERS));
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertVertexInitializedEvent() {
long initRequestedTime = random.nextLong();
long initedTime = random.nextLong();
@@ -821,65 +835,66 @@ public void testConvertVertexInitializedEvent() {
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(initedTime, timelineEntity.getStartTime().longValue());
+ assertEquals(initedTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(1, timelineEntity.getRelatedEntities().size());
- Assert.assertTrue(
+ assertEquals(1, timelineEntity.getRelatedEntities().size());
+ assertTrue(
timelineEntity.getRelatedEntities().get(EntityTypes.TEZ_DAG_ID.name()).contains(
tezDAGID.toString()));
- Assert.assertEquals(2, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertEquals(2, timelineEntity.getPrimaryFilters().size());
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_DAG_ID.name()).contains(
tezDAGID.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.VERTEX_INITIALIZED.name(), timelineEvent.getEventType());
- Assert.assertEquals(initedTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.VERTEX_INITIALIZED.name(), timelineEvent.getEventType());
+ assertEquals(initedTime, timelineEvent.getTimestamp());
- Assert.assertEquals("v1", timelineEntity.getOtherInfo().get(ATSConstants.VERTEX_NAME));
- Assert.assertEquals("proc", timelineEntity.getOtherInfo().get(ATSConstants.PROCESSOR_CLASS_NAME));
+ assertEquals("v1", timelineEntity.getOtherInfo().get(ATSConstants.VERTEX_NAME));
+ assertEquals("proc", timelineEntity.getOtherInfo().get(ATSConstants.PROCESSOR_CLASS_NAME));
- Assert.assertEquals(initedTime,
+ assertEquals(initedTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.INIT_TIME)).longValue());
- Assert.assertEquals(initRequestedTime,
+ assertEquals(initRequestedTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.INIT_REQUESTED_TIME)).longValue());
- Assert.assertEquals(initedTime,
+ assertEquals(initedTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.INIT_TIME)).longValue());
- Assert.assertEquals(numTasks,
+ assertEquals(numTasks,
((Integer) timelineEntity.getOtherInfo().get(ATSConstants.NUM_TASKS)).intValue());
- Assert.assertNotNull(timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN));
- Assert.assertEquals("abc",
+ assertNotNull(timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN));
+ assertEquals("abc",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.CONTAINER_LAUNCHER_NAME));
- Assert.assertEquals("def",
+ assertEquals("def",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_SCHEDULER_NAME));
- Assert.assertEquals("ghi",
+ assertEquals("ghi",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_COMMUNICATOR_NAME));
- Assert.assertEquals("abc1",
+ assertEquals("abc1",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.CONTAINER_LAUNCHER_CLASS_NAME));
- Assert.assertEquals("def1",
+ assertEquals("def1",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_SCHEDULER_CLASS_NAME));
- Assert.assertEquals("ghi1",
+ assertEquals("ghi1",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_COMMUNICATOR_CLASS_NAME));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertVertexStartedEvent() {
long startRequestedTime = random.nextLong();
long startTime = random.nextLong();
@@ -887,37 +902,38 @@ public void testConvertVertexStartedEvent() {
VertexStartedEvent event = new VertexStartedEvent(tezVertexID, startRequestedTime, startTime);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
+ assertEquals(0, timelineEntity.getRelatedEntities().size());
- Assert.assertEquals(2, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID)
+ assertEquals(2, timelineEntity.getPrimaryFilters().size());
+ assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_DAG_ID.name()).contains(
tezDAGID.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.VERTEX_STARTED.name(), timelineEvent.getEventType());
- Assert.assertEquals(startTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.VERTEX_STARTED.name(), timelineEvent.getEventType());
+ assertEquals(startTime, timelineEvent.getTimestamp());
- Assert.assertEquals(3, timelineEntity.getOtherInfo().size());
- Assert.assertEquals(startRequestedTime,
+ assertEquals(3, timelineEntity.getOtherInfo().size());
+ assertEquals(startRequestedTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.START_REQUESTED_TIME)).longValue());
- Assert.assertEquals(startTime,
+ assertEquals(startTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.START_TIME)).longValue());
- Assert.assertEquals(VertexState.RUNNING.name(),
+ assertEquals(VertexState.RUNNING.name(),
timelineEntity.getOtherInfo().get(ATSConstants.STATUS));
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertVertexFinishedEvent() {
String vertexName = "v1";
long initRequestedTime = random.nextLong();
@@ -940,169 +956,172 @@ public void testConvertVertexFinishedEvent() {
.setTaskCommunicatorClassName("ghi1"));
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_VERTEX_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezVertexID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
+ assertEquals(0, timelineEntity.getRelatedEntities().size());
- Assert.assertEquals(3, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID)
+ assertEquals(3, timelineEntity.getPrimaryFilters().size());
+ assertTrue(timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_DAG_ID.name()).contains(
tezDAGID.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.STATUS).contains(
VertexState.ERROR.name()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.VERTEX_FINISHED.name(), timelineEvent.getEventType());
- Assert.assertEquals(finishTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.VERTEX_FINISHED.name(), timelineEvent.getEventType());
+ assertEquals(finishTime, timelineEvent.getTimestamp());
- Assert.assertEquals(vertexName,
+ assertEquals(vertexName,
timelineEntity.getOtherInfo().get(ATSConstants.VERTEX_NAME));
- Assert.assertEquals(finishTime,
+ assertEquals(finishTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.FINISH_TIME)).longValue());
- Assert.assertEquals(finishTime - startTime,
+ assertEquals(finishTime - startTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.TIME_TAKEN)).longValue());
- Assert.assertEquals(VertexState.ERROR.name(),
+ assertEquals(VertexState.ERROR.name(),
timelineEntity.getOtherInfo().get(ATSConstants.STATUS));
- Assert.assertEquals("diagnostics",
+ assertEquals("diagnostics",
timelineEntity.getOtherInfo().get(ATSConstants.DIAGNOSTICS));
- Assert.assertNotNull(timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN));
- Assert.assertEquals("abc",
+ assertNotNull(timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN));
+ assertEquals("abc",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.CONTAINER_LAUNCHER_NAME));
- Assert.assertEquals("def",
+ assertEquals("def",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_SCHEDULER_NAME));
- Assert.assertEquals("ghi",
+ assertEquals("ghi",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_COMMUNICATOR_NAME));
- Assert.assertEquals("abc1",
+ assertEquals("abc1",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.CONTAINER_LAUNCHER_CLASS_NAME));
- Assert.assertEquals("def1",
+ assertEquals("def1",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_SCHEDULER_CLASS_NAME));
- Assert.assertEquals("ghi1",
+ assertEquals("ghi1",
((Map)timelineEntity.getOtherInfo().get(ATSConstants.SERVICE_PLUGIN)).get(
ATSConstants.TASK_COMMUNICATOR_CLASS_NAME));
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.STATS));
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.STATS));
- Assert.assertEquals(100,
+ assertEquals(100,
((Integer) timelineEntity.getOtherInfo().get("FOO")).intValue());
- Assert.assertEquals(200,
+ assertEquals(200,
((Integer) timelineEntity.getOtherInfo().get("BAR")).intValue());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertTaskStartedEvent() {
long scheduleTime = random.nextLong();
long startTime = random.nextLong();
TaskStartedEvent event = new TaskStartedEvent(tezTaskID, "v1", scheduleTime, startTime);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_TASK_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezTaskID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_TASK_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezTaskID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(startTime, timelineEntity.getStartTime().longValue());
+ assertEquals(startTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(1, timelineEntity.getRelatedEntities().size());
- Assert.assertTrue(
+ assertEquals(1, timelineEntity.getRelatedEntities().size());
+ assertTrue(
timelineEntity.getRelatedEntities().get(EntityTypes.TEZ_VERTEX_ID.name()).contains(
tezVertexID.toString()));
- Assert.assertEquals(3, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertEquals(3, timelineEntity.getPrimaryFilters().size());
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_DAG_ID.name()).contains(
tezDAGID.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_VERTEX_ID.name()).contains(
tezVertexID.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.TASK_STARTED.name(), timelineEvent.getEventType());
- Assert.assertEquals(startTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.TASK_STARTED.name(), timelineEvent.getEventType());
+ assertEquals(startTime, timelineEvent.getTimestamp());
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.SCHEDULED_TIME));
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.START_TIME));
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.SCHEDULED_TIME));
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.START_TIME));
- Assert.assertEquals(scheduleTime,
+ assertEquals(scheduleTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.SCHEDULED_TIME)).longValue());
- Assert.assertEquals(startTime,
+ assertEquals(startTime,
((Long) timelineEntity.getOtherInfo().get(ATSConstants.START_TIME)).longValue());
- Assert.assertTrue(TaskState.SCHEDULED.name()
- .equals(timelineEntity.getOtherInfo().get(ATSConstants.STATUS)));
+ assertEquals(TaskState.SCHEDULED.name(),
+ timelineEntity.getOtherInfo().get(ATSConstants.STATUS));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertTaskAttemptStartedEvent() {
long startTime = random.nextLong();
TaskAttemptStartedEvent event = new TaskAttemptStartedEvent(tezTaskAttemptID, "v1",
startTime, containerId, nodeId, "inProgressURL", "logsURL", "nodeHttpAddress");
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezTaskAttemptID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezTaskAttemptID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(startTime, timelineEntity.getStartTime().longValue());
+ assertEquals(startTime, timelineEntity.getStartTime().longValue());
- Assert.assertEquals(1, timelineEntity.getRelatedEntities().size());
- Assert.assertTrue(
+ assertEquals(1, timelineEntity.getRelatedEntities().size());
+ assertTrue(
timelineEntity.getRelatedEntities().get(EntityTypes.TEZ_TASK_ID.name()).contains(
tezTaskID.toString()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.TASK_ATTEMPT_STARTED.name(), timelineEvent.getEventType());
- Assert.assertEquals(startTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.TASK_ATTEMPT_STARTED.name(), timelineEvent.getEventType());
+ assertEquals(startTime, timelineEvent.getTimestamp());
- Assert.assertEquals(4, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertEquals(4, timelineEntity.getPrimaryFilters().size());
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_DAG_ID.name()).contains(
tezDAGID.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_VERTEX_ID.name()).contains(
tezVertexID.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(EntityTypes.TEZ_TASK_ID.name()).contains(
tezTaskID.toString()));
- Assert.assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.START_TIME));
- Assert.assertEquals("inProgressURL",
+ assertTrue(timelineEntity.getOtherInfo().containsKey(ATSConstants.START_TIME));
+ assertEquals("inProgressURL",
timelineEntity.getOtherInfo().get(ATSConstants.IN_PROGRESS_LOGS_URL));
- Assert.assertEquals("logsURL",
+ assertEquals("logsURL",
timelineEntity.getOtherInfo().get(ATSConstants.COMPLETED_LOGS_URL));
- Assert.assertEquals(nodeId.toString(),
+ assertEquals(nodeId.toString(),
timelineEntity.getOtherInfo().get(ATSConstants.NODE_ID));
- Assert.assertEquals(containerId.toString(),
+ assertEquals(containerId.toString(),
timelineEntity.getOtherInfo().get(ATSConstants.CONTAINER_ID));
- Assert.assertEquals("nodeHttpAddress",
+ assertEquals("nodeHttpAddress",
timelineEntity.getOtherInfo().get(ATSConstants.NODE_HTTP_ADDRESS));
- Assert.assertTrue(TaskAttemptState.RUNNING.name()
- .equals(timelineEntity.getOtherInfo().get(ATSConstants.STATUS)));
+ assertEquals(TaskAttemptState.RUNNING.name(),
+ timelineEntity.getOtherInfo().get(ATSConstants.STATUS));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertTaskFinishedEvent() {
String vertexName = "testVertexName";
long startTime = random.nextLong();
@@ -1114,41 +1133,42 @@ public void testConvertTaskFinishedEvent() {
TaskFinishedEvent event = new TaskFinishedEvent(tezTaskID, vertexName, startTime, finishTime,
tezTaskAttemptID, state, diagnostics, counters, 3);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(tezTaskID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(EntityTypes.TEZ_TASK_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezTaskID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_TASK_ID.name(), timelineEntity.getEntityType());
final Map> primaryFilters = timelineEntity.getPrimaryFilters();
- Assert.assertEquals(4, primaryFilters.size());
- Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
+ assertEquals(4, primaryFilters.size());
+ assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_DAG_ID.name())
+ assertTrue(primaryFilters.get(EntityTypes.TEZ_DAG_ID.name())
.contains(tezDAGID.toString()));
- Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_VERTEX_ID.name())
+ assertTrue(primaryFilters.get(EntityTypes.TEZ_VERTEX_ID.name())
.contains(tezVertexID.toString()));
- Assert.assertTrue(primaryFilters.get(ATSConstants.STATUS).contains(state.name()));
+ assertTrue(primaryFilters.get(ATSConstants.STATUS).contains(state.name()));
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent evt = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.TASK_FINISHED.name(), evt.getEventType());
- Assert.assertEquals(finishTime, evt.getTimestamp());
+ assertEquals(HistoryEventType.TASK_FINISHED.name(), evt.getEventType());
+ assertEquals(finishTime, evt.getTimestamp());
final Map otherInfo = timelineEntity.getOtherInfo();
- Assert.assertEquals(7, otherInfo.size());
- Assert.assertEquals(finishTime, otherInfo.get(ATSConstants.FINISH_TIME));
- Assert.assertEquals(finishTime - startTime, otherInfo.get(ATSConstants.TIME_TAKEN));
- Assert.assertEquals(state.name(), otherInfo.get(ATSConstants.STATUS));
- Assert.assertEquals(tezTaskAttemptID.toString(),
+ assertEquals(7, otherInfo.size());
+ assertEquals(finishTime, otherInfo.get(ATSConstants.FINISH_TIME));
+ assertEquals(finishTime - startTime, otherInfo.get(ATSConstants.TIME_TAKEN));
+ assertEquals(state.name(), otherInfo.get(ATSConstants.STATUS));
+ assertEquals(tezTaskAttemptID.toString(),
otherInfo.get(ATSConstants.SUCCESSFUL_ATTEMPT_ID));
- Assert.assertEquals(3, otherInfo.get(ATSConstants.NUM_FAILED_TASKS_ATTEMPTS));
- Assert.assertEquals(diagnostics, otherInfo.get(ATSConstants.DIAGNOSTICS));
- Assert.assertTrue(otherInfo.containsKey(ATSConstants.COUNTERS));
+ assertEquals(3, otherInfo.get(ATSConstants.NUM_FAILED_TASKS_ATTEMPTS));
+ assertEquals(diagnostics, otherInfo.get(ATSConstants.DIAGNOSTICS));
+ assertTrue(otherInfo.containsKey(ATSConstants.COUNTERS));
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertVertexReconfigreDoneEvent() {
TezVertexID vId = tezVertexID;
Map edgeMgrs =
@@ -1161,40 +1181,41 @@ public void testConvertVertexReconfigreDoneEvent() {
edgeMgrs, null, true);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(ATSConstants.TEZ_VERTEX_ID, timelineEntity.getEntityType());
- Assert.assertEquals(vId.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(ATSConstants.TEZ_VERTEX_ID, timelineEntity.getEntityType());
+ assertEquals(vId.toString(), timelineEntity.getEntityId());
+ assertEquals(1, timelineEntity.getEvents().size());
final Map> primaryFilters = timelineEntity.getPrimaryFilters();
- Assert.assertEquals(2, primaryFilters.size());
- Assert.assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
+ assertEquals(2, primaryFilters.size());
+ assertTrue(primaryFilters.get(ATSConstants.APPLICATION_ID)
.contains(applicationId.toString()));
- Assert.assertTrue(primaryFilters.get(EntityTypes.TEZ_DAG_ID.name())
+ assertTrue(primaryFilters.get(EntityTypes.TEZ_DAG_ID.name())
.contains(tezDAGID.toString()));
TimelineEvent evt = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.VERTEX_CONFIGURE_DONE.name(), evt.getEventType());
- Assert.assertEquals(1, evt.getEventInfo().get(ATSConstants.NUM_TASKS));
- Assert.assertNotNull(evt.getEventInfo().get(ATSConstants.UPDATED_EDGE_MANAGERS));
+ assertEquals(HistoryEventType.VERTEX_CONFIGURE_DONE.name(), evt.getEventType());
+ assertEquals(1, evt.getEventInfo().get(ATSConstants.NUM_TASKS));
+ assertNotNull(evt.getEventInfo().get(ATSConstants.UPDATED_EDGE_MANAGERS));
Map updatedEdgeMgrs = (Map)
evt.getEventInfo().get(ATSConstants.UPDATED_EDGE_MANAGERS);
- Assert.assertEquals(1, updatedEdgeMgrs.size());
- Assert.assertTrue(updatedEdgeMgrs.containsKey("a"));
+ assertEquals(1, updatedEdgeMgrs.size());
+ assertTrue(updatedEdgeMgrs.containsKey("a"));
Map updatedEdgeMgr = (Map) updatedEdgeMgrs.get("a");
- Assert.assertEquals(DataMovementType.CUSTOM.name(),
+ assertEquals(DataMovementType.CUSTOM.name(),
updatedEdgeMgr.get(DAGUtils.DATA_MOVEMENT_TYPE_KEY));
- Assert.assertEquals("In", updatedEdgeMgr.get(DAGUtils.EDGE_DESTINATION_CLASS_KEY));
- Assert.assertEquals("a.class", updatedEdgeMgr.get(DAGUtils.EDGE_MANAGER_CLASS_KEY));
+ assertEquals("In", updatedEdgeMgr.get(DAGUtils.EDGE_DESTINATION_CLASS_KEY));
+ assertEquals("a.class", updatedEdgeMgr.get(DAGUtils.EDGE_MANAGER_CLASS_KEY));
- Assert.assertEquals(1, timelineEntity.getOtherInfo().get(ATSConstants.NUM_TASKS));
+ assertEquals(1, timelineEntity.getOtherInfo().get(ATSConstants.NUM_TASKS));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertDAGRecoveredEvent() {
long recoverTime = random.nextLong();
@@ -1202,37 +1223,38 @@ public void testConvertDAGRecoveredEvent() {
dagPlan.getName(), user, recoverTime, containerLogs);
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
+ assertEquals(0, timelineEntity.getRelatedEntities().size());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_RECOVERED.name(), timelineEvent.getEventType());
- Assert.assertEquals(recoverTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.DAG_RECOVERED.name(), timelineEvent.getEventType());
+ assertEquals(recoverTime, timelineEvent.getTimestamp());
- Assert.assertTrue(timelineEvent.getEventInfo().containsKey(ATSConstants.APPLICATION_ATTEMPT_ID));
- Assert.assertEquals(applicationAttemptId.toString(),
+ assertTrue(timelineEvent.getEventInfo().containsKey(ATSConstants.APPLICATION_ATTEMPT_ID));
+ assertEquals(applicationAttemptId.toString(),
timelineEvent.getEventInfo().get(ATSConstants.APPLICATION_ATTEMPT_ID));
- Assert.assertEquals(3, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertEquals(3, timelineEntity.getPrimaryFilters().size());
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.DAG_NAME).contains("DAGPlanMock"));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.USER).contains(user));
- Assert.assertEquals(containerLogs,
+ assertEquals(containerLogs,
timelineEntity.getOtherInfo().get(ATSConstants.IN_PROGRESS_LOGS_URL + "_"
+ applicationAttemptId.getAttemptId()));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConvertDAGRecoveredEvent2() {
long recoverTime = random.nextLong();
@@ -1241,36 +1263,36 @@ public void testConvertDAGRecoveredEvent2() {
List entities = HistoryEventTimelineConversion.convertToTimelineEntities(event);
- Assert.assertEquals(1, entities.size());
+ assertEquals(1, entities.size());
TimelineEntity timelineEntity = entities.get(0);
- Assert.assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
- Assert.assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
+ assertEquals(EntityTypes.TEZ_DAG_ID.name(), timelineEntity.getEntityType());
+ assertEquals(tezDAGID.toString(), timelineEntity.getEntityId());
- Assert.assertEquals(0, timelineEntity.getRelatedEntities().size());
+ assertEquals(0, timelineEntity.getRelatedEntities().size());
- Assert.assertEquals(1, timelineEntity.getEvents().size());
+ assertEquals(1, timelineEntity.getEvents().size());
TimelineEvent timelineEvent = timelineEntity.getEvents().get(0);
- Assert.assertEquals(HistoryEventType.DAG_RECOVERED.name(), timelineEvent.getEventType());
- Assert.assertEquals(recoverTime, timelineEvent.getTimestamp());
+ assertEquals(HistoryEventType.DAG_RECOVERED.name(), timelineEvent.getEventType());
+ assertEquals(recoverTime, timelineEvent.getTimestamp());
- Assert.assertTrue(timelineEvent.getEventInfo().containsKey(ATSConstants.APPLICATION_ATTEMPT_ID));
- Assert.assertEquals(applicationAttemptId.toString(),
+ assertTrue(timelineEvent.getEventInfo().containsKey(ATSConstants.APPLICATION_ATTEMPT_ID));
+ assertEquals(applicationAttemptId.toString(),
timelineEvent.getEventInfo().get(ATSConstants.APPLICATION_ATTEMPT_ID));
- Assert.assertEquals(DAGState.ERROR.name(),
+ assertEquals(DAGState.ERROR.name(),
timelineEvent.getEventInfo().get(ATSConstants.DAG_STATE));
- Assert.assertEquals("mock reason",
+ assertEquals("mock reason",
timelineEvent.getEventInfo().get(ATSConstants.RECOVERY_FAILURE_REASON));
- Assert.assertEquals(3, timelineEntity.getPrimaryFilters().size());
- Assert.assertTrue(
+ assertEquals(3, timelineEntity.getPrimaryFilters().size());
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.APPLICATION_ID).contains(
applicationId.toString()));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.DAG_NAME).contains("DAGPlanMock"));
- Assert.assertTrue(
+ assertTrue(
timelineEntity.getPrimaryFilters().get(ATSConstants.USER).contains(user));
- Assert.assertEquals(containerLogs,
+ assertEquals(containerLogs,
timelineEntity.getOtherInfo().get(ATSConstants.IN_PROGRESS_LOGS_URL + "_"
+ applicationAttemptId.getAttemptId()));
}
diff --git a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/tests/MiniTezClusterWithTimeline.java b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/tests/MiniTezClusterWithTimeline.java
index 2348b20943..0927a2735d 100644
--- a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/tests/MiniTezClusterWithTimeline.java
+++ b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/tests/MiniTezClusterWithTimeline.java
@@ -57,6 +57,7 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/tez-runtime-internals/pom.xml b/tez-runtime-internals/pom.xml
index b5a79393b1..f5308c84dc 100644
--- a/tez-runtime-internals/pom.xml
+++ b/tez-runtime-internals/pom.xml
@@ -85,10 +85,6 @@
com.google.guava
guava
-
-
- junit
- junit
org.mockito
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestInputReadyTracker.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestInputReadyTracker.java
index 2384885736..0ec3c14191 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestInputReadyTracker.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestInputReadyTracker.java
@@ -18,16 +18,14 @@
*/
package org.apache.tez.runtime;
-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.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.runtime.api.AbstractLogicalInput;
import org.apache.tez.runtime.api.Event;
@@ -40,14 +38,15 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestInputReadyTracker {
private static final long SLEEP_TIME = 200l;
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testWithoutGrouping1() throws InterruptedException {
InputReadyTracker inputReadyTracker = new InputReadyTracker();
@@ -78,7 +77,8 @@ public void testWithoutGrouping1() throws InterruptedException {
assertTrue(input1.isReady);
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testWithoutGrouping2() throws InterruptedException {
InputReadyTracker inputReadyTracker = new InputReadyTracker();
@@ -140,7 +140,8 @@ public void testWithoutGrouping2() throws InterruptedException {
assertTrue(input2.isReady);
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testGrouped() throws InterruptedException {
InputReadyTracker inputReadyTracker = new InputReadyTracker();
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java
index ee72400895..29edf28cd9 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/TestLogicalIOProcessorRuntimeTask.java
@@ -18,10 +18,7 @@
*/
package org.apache.tez.runtime;
-import static org.junit.Assert.assertEquals;
-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.*;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -36,6 +33,7 @@
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.security.UserGroupInformation;
@@ -78,12 +76,13 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestLogicalIOProcessorRuntimeTask {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAutoStart() throws Exception {
TezDAGID dagId = createTezDagId();
TezVertexID vertexId = createTezVertexId(dagId);
@@ -120,8 +119,8 @@ public void testAutoStart() throws Exception {
assertEquals(1, TestInput.startCount);
assertEquals(0, TestOutput.startCount);
// test that invocations of progress are counted correctly
- assertEquals(true, lio1.getAndClearProgressNotification());
- assertEquals(false, lio1.getAndClearProgressNotification()); // cleared after getting
+ assertTrue(lio1.getAndClearProgressNotification());
+ assertFalse(lio1.getAndClearProgressNotification()); // cleared after getting
assertEquals(30, TestInput.vertexParallelism);
assertEquals(0, TestOutput.vertexParallelism);
assertEquals(30, lio1.getProcessorContext().getVertexParallelism());
@@ -251,17 +250,17 @@ private void cleanupAndTest(LogicalIOProcessorRuntimeTask lio) throws Interrupte
lio.cleanup();
- assertTrue(procContext.getUserPayload() == null);
- assertTrue(procContext.getObjectRegistry() == null);
+ assertNull(procContext.getUserPayload());
+ assertNull(procContext.getObjectRegistry());
for (InputContext inputContext : inputContexts) {
- assertTrue(inputContext.getUserPayload() == null);
- assertTrue(inputContext.getObjectRegistry() == null);
+ assertNull(inputContext.getUserPayload());
+ assertNull(inputContext.getObjectRegistry());
}
for (OutputContext outputContext : outputContexts) {
- assertTrue(outputContext.getUserPayload() == null);
- assertTrue(outputContext.getObjectRegistry() == null);
+ assertNull(outputContext.getUserPayload());
+ assertNull(outputContext.getObjectRegistry());
}
boolean localMode = lio.tezConf.getBoolean(TezConfiguration.TEZ_LOCAL_MODE,
TezConfiguration.TEZ_LOCAL_MODE_DEFAULT);
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestProcessorContext.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestProcessorContext.java
index c5d0821037..9076e73bd9 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestProcessorContext.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestProcessorContext.java
@@ -18,15 +18,14 @@
*/
package org.apache.tez.runtime.api.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.ApplicationId;
@@ -46,11 +45,12 @@
import com.google.common.collect.Maps;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestProcessorContext {
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDagNumber() throws IOException {
String[] localDirs = new String[] {"dummyLocalDir"};
int appAttemptNumber = 1;
@@ -111,7 +111,7 @@ public void testDagNumber() throws IOException {
assertEquals(dagName, procContext.getDAGName());
assertEquals(vertexName, procContext.getTaskVertexName());
assertEquals(vertexId.getId(), procContext.getTaskVertexIndex());
- assertTrue(Arrays.equals(localDirs, procContext.getWorkDirs()));
+ assertArrayEquals(localDirs, procContext.getWorkDirs());
// test auto call of notifyProgress
procContext.setProgress(0.1f);
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTaskSpec.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTaskSpec.java
index 211c006d86..de8db81b6d 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTaskSpec.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTaskSpec.java
@@ -18,6 +18,8 @@
*/
package org.apache.tez.runtime.api.impl;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
@@ -28,6 +30,7 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.InputDescriptor;
@@ -39,12 +42,12 @@
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.*;
public class TestTaskSpec {
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSerDe() throws IOException {
ByteBuffer payload = null;
ProcessorDescriptor procDesc = ProcessorDescriptor.create("proc").setUserPayload(
@@ -75,18 +78,18 @@ public void testSerDe() throws IOException {
DataInput in = new DataInputStream(bis);
deSerTaskSpec.readFields(in);
- Assert.assertEquals(taskSpec.getDAGName(), deSerTaskSpec.getDAGName());
- Assert.assertEquals(taskSpec.getVertexName(), deSerTaskSpec.getVertexName());
- Assert.assertEquals(taskSpec.getVertexParallelism(), deSerTaskSpec.getVertexParallelism());
- Assert.assertEquals(taskSpec.getInputs().size(), deSerTaskSpec.getInputs().size());
- Assert.assertEquals(taskSpec.getOutputs().size(), deSerTaskSpec.getOutputs().size());
- Assert.assertNull(deSerTaskSpec.getGroupInputs());
- Assert.assertEquals(taskSpec.getInputs().get(0).getSourceVertexName(),
+ assertEquals(taskSpec.getDAGName(), deSerTaskSpec.getDAGName());
+ assertEquals(taskSpec.getVertexName(), deSerTaskSpec.getVertexName());
+ assertEquals(taskSpec.getVertexParallelism(), deSerTaskSpec.getVertexParallelism());
+ assertEquals(taskSpec.getInputs().size(), deSerTaskSpec.getInputs().size());
+ assertEquals(taskSpec.getOutputs().size(), deSerTaskSpec.getOutputs().size());
+ assertNull(deSerTaskSpec.getGroupInputs());
+ assertEquals(taskSpec.getInputs().get(0).getSourceVertexName(),
deSerTaskSpec.getInputs().get(0).getSourceVertexName());
- Assert.assertEquals(taskSpec.getOutputs().get(0).getDestinationVertexName(),
+ assertEquals(taskSpec.getOutputs().get(0).getDestinationVertexName(),
deSerTaskSpec.getOutputs().get(0).getDestinationVertexName());
- Assert.assertEquals(taskConf.get("foo"), deSerTaskSpec.getTaskConf().get("foo"));
+ assertEquals(taskConf.get("foo"), deSerTaskSpec.getTaskConf().get("foo"));
}
}
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTezEvent.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTezEvent.java
index 62859ae11e..f60a3cb52d 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTezEvent.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/api/impl/TestTezEvent.java
@@ -18,6 +18,8 @@
*/
package org.apache.tez.runtime.api.impl;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
@@ -41,8 +43,8 @@
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestTezEvent {
@@ -122,31 +124,31 @@ private ArrayList deserializeEvents(DataInput in) throws IOException {
}
private void assertEventEquals(ArrayList expectedList, ArrayList actualList) {
- Assert.assertEquals(expectedList.size(), actualList.size());
+ assertEquals(expectedList.size(), actualList.size());
for (int i = 0; i < expectedList.size(); i++) {
TezEvent expected = expectedList.get(i);
TezEvent actual = actualList.get(i);
- Assert.assertEquals(expected.getEventReceivedTime(), actual.getEventReceivedTime());
- Assert.assertEquals(expected.getSourceInfo(), actual.getSourceInfo());
- Assert.assertEquals(expected.getDestinationInfo(), actual.getDestinationInfo());
- Assert.assertEquals(expected.getEventType(), actual.getEventType());
+ assertEquals(expected.getEventReceivedTime(), actual.getEventReceivedTime());
+ assertEquals(expected.getSourceInfo(), actual.getSourceInfo());
+ assertEquals(expected.getDestinationInfo(), actual.getDestinationInfo());
+ assertEquals(expected.getEventType(), actual.getEventType());
// Doing this instead of implementing equals methods for events
if (i == 0) {
- Assert.assertTrue(actual.getEvent() instanceof TaskAttemptCompletedEvent);
+ assertInstanceOf(TaskAttemptCompletedEvent.class, actual.getEvent());
} else if (i == 1) {
DataMovementEvent dmeExpected = (DataMovementEvent) expected.getEvent();
DataMovementEvent dmeActual = (DataMovementEvent) actual.getEvent();
- Assert.assertEquals(dmeExpected.getSourceIndex(), dmeActual.getSourceIndex());
- Assert.assertEquals(dmeExpected.getTargetIndex(), dmeActual.getTargetIndex());
- Assert.assertEquals(dmeExpected.getVersion(), dmeActual.getVersion());
- Assert.assertEquals(dmeExpected.getUserPayload(), dmeActual.getUserPayload());
+ assertEquals(dmeExpected.getSourceIndex(), dmeActual.getSourceIndex());
+ assertEquals(dmeExpected.getTargetIndex(), dmeActual.getTargetIndex());
+ assertEquals(dmeExpected.getVersion(), dmeActual.getVersion());
+ assertEquals(dmeExpected.getUserPayload(), dmeActual.getUserPayload());
} else {
TaskStatusUpdateEvent tsuExpected = (TaskStatusUpdateEvent) expected.getEvent();
TaskStatusUpdateEvent tsuActual = (TaskStatusUpdateEvent) actual.getEvent();
- Assert.assertEquals(tsuExpected.getCounters(), tsuActual.getCounters());
- Assert.assertEquals(tsuExpected.getProgress(), tsuActual.getProgress(), 0);
- Assert.assertEquals(tsuExpected.getProgressNotified(), tsuActual.getProgressNotified());
- Assert.assertEquals(tsuExpected.getStatistics(), tsuActual.getStatistics());
+ assertEquals(tsuExpected.getCounters(), tsuActual.getCounters());
+ assertEquals(tsuExpected.getProgress(), tsuActual.getProgress(), 0);
+ assertEquals(tsuExpected.getProgressNotified(), tsuActual.getProgressNotified());
+ assertEquals(tsuExpected.getStatistics(), tsuActual.getStatistics());
}
}
}
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/objectregistry/TestObjectRegistry.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/objectregistry/TestObjectRegistry.java
index 472f3d2394..f7fe76e08b 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/objectregistry/TestObjectRegistry.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/objectregistry/TestObjectRegistry.java
@@ -18,39 +18,44 @@
*/
package org.apache.tez.runtime.common.objectregistry;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.concurrent.TimeUnit;
+
import org.apache.tez.runtime.api.ObjectRegistry;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestObjectRegistry {
private void testCRUD(ObjectRegistry objectRegistry) {
- Assert.assertNotNull(objectRegistry);
+ assertNotNull(objectRegistry);
- Assert.assertNull(objectRegistry.get("foo"));
- Assert.assertFalse(objectRegistry.delete("foo"));
+ assertNull(objectRegistry.get("foo"));
+ assertFalse(objectRegistry.delete("foo"));
Integer one = new Integer(1);
Integer two_1 = new Integer(2);
Integer two_2 = new Integer(3);
- Assert.assertNull(objectRegistry.cacheForDAG("one", one));
- Assert.assertEquals(one, objectRegistry.get("one"));
- Assert.assertNull(objectRegistry.cacheForDAG("two", two_1));
- Assert.assertNotNull(objectRegistry.cacheForSession("two", two_2));
- Assert.assertNotEquals(two_1, objectRegistry.get("two"));
- Assert.assertEquals(two_2, objectRegistry.get("two"));
- Assert.assertTrue(objectRegistry.delete("one"));
- Assert.assertFalse(objectRegistry.delete("one"));
+ assertNull(objectRegistry.cacheForDAG("one", one));
+ assertEquals(one, objectRegistry.get("one"));
+ assertNull(objectRegistry.cacheForDAG("two", two_1));
+ assertNotNull(objectRegistry.cacheForSession("two", two_2));
+ assertNotEquals(two_1, objectRegistry.get("two"));
+ assertEquals(two_2, objectRegistry.get("two"));
+ assertTrue(objectRegistry.delete("one"));
+ assertFalse(objectRegistry.delete("one"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicCRUD() {
ObjectRegistry objectRegistry = new ObjectRegistryImpl();
testCRUD(objectRegistry);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testClearCache() {
ObjectRegistry objectRegistry = new ObjectRegistryImpl();
testCRUD(objectRegistry);
@@ -61,12 +66,12 @@ public void testClearCache() {
objectRegistry.cacheForDAG(two, two);
((ObjectRegistryImpl)objectRegistry).clearCache(ObjectRegistryImpl.ObjectLifeCycle.VERTEX);
- Assert.assertNull(objectRegistry.get(one));
- Assert.assertNotNull(objectRegistry.get(two));
+ assertNull(objectRegistry.get(one));
+ assertNotNull(objectRegistry.get(two));
objectRegistry.cacheForVertex(one, one);
((ObjectRegistryImpl)objectRegistry).clearCache(ObjectRegistryImpl.ObjectLifeCycle.DAG);
- Assert.assertNotNull(objectRegistry.get(one));
- Assert.assertNull(objectRegistry.get(two));
+ assertNotNull(objectRegistry.get(one));
+ assertNull(objectRegistry.get(two));
}
}
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/resources/TestMemoryDistributor.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/resources/TestMemoryDistributor.java
index c67b68a0e4..8967a83261 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/resources/TestMemoryDistributor.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/common/resources/TestMemoryDistributor.java
@@ -18,11 +18,12 @@
*/
package org.apache.tez.runtime.common.resources;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import java.util.concurrent.TimeUnit;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.InputDescriptor;
import org.apache.tez.dag.api.OutputDescriptor;
@@ -34,21 +35,21 @@
import org.apache.tez.runtime.api.OutputContext;
import org.apache.tez.runtime.api.ProcessorContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestMemoryDistributor {
protected Configuration conf = new Configuration();
- @Before
+ @BeforeEach
public void setup() {
conf.setBoolean(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ENABLED, true);
conf.set(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ALLOCATOR_CLASS,
ScalingAllocator.class.getName());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testScalingNoProcessor() throws TezException {
MemoryDistributor dist = new MemoryDistributor(2, 1, conf);
@@ -82,7 +83,8 @@ public void testScalingNoProcessor() throws TezException {
assertEquals(1400, e3Callback.assigned);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testScalingNoProcessor2() throws TezException {
// Real world values
MemoryDistributor dist = new MemoryDistributor(2, 0, conf);
@@ -107,7 +109,8 @@ public void testScalingNoProcessor2() throws TezException {
assertEquals(88080384l, e2Callback.assigned);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testScalingProcessor() throws TezException {
MemoryDistributor dist = new MemoryDistributor(2, 1, conf);
@@ -149,7 +152,8 @@ public void testScalingProcessor() throws TezException {
assertTrue(e4Callback.assigned >= 1166 && e4Callback.assigned <= 1167);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testScalingDisabled() throws TezException {
// Real world values
Configuration conf = new Configuration(this.conf);
@@ -176,7 +180,8 @@ public void testScalingDisabled() throws TezException {
assertEquals(144965632l, e2Callback.assigned);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testReserveFractionConfigured() throws TezException {
Configuration conf = new Configuration(this.conf);
conf.setDouble(TezConfiguration.TEZ_TASK_SCALE_MEMORY_RESERVE_FRACTION, 0.5d);
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestFileSystemStatisticUpdater.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestFileSystemStatisticUpdater.java
index bcec3bc857..f473b48eed 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestFileSystemStatisticUpdater.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestFileSystemStatisticUpdater.java
@@ -18,6 +18,8 @@
*/
package org.apache.tez.runtime.metrics;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
@@ -29,11 +31,7 @@
import org.apache.tez.common.counters.TezCounter;
import org.apache.tez.common.counters.TezCounters;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,12 +48,12 @@ public class TestFileSystemStatisticUpdater {
private static final String TEST_ROOT_DIR = "target" + Path.SEPARATOR +
TestFileSystemStatisticUpdater.class.getName() + "-tmpDir";
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
CONF.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR);
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
if (dfsCluster != null) {
dfsCluster.shutdown();
@@ -63,7 +61,7 @@ public static void tearDown() {
}
}
- @Before
+ @BeforeEach
public void setup() throws IOException {
FileSystem.clearStatistics();
try {
@@ -113,7 +111,7 @@ public void basicTest() throws IOException {
private void assertCounter(TezCounters counters, FileSystemCounter fsCounter, int value) {
TezCounter counter = counters.findCounter(remoteFs.getScheme(), fsCounter);
- Assert.assertNotNull(counter);
- Assert.assertEquals(value, counter.getValue());
+ assertNotNull(counter);
+ assertEquals(value, counter.getValue());
}
}
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestTaskCounterUpdater.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestTaskCounterUpdater.java
index 2def50eecb..81d0eca2b0 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestTaskCounterUpdater.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/metrics/TestTaskCounterUpdater.java
@@ -18,13 +18,14 @@
*/
package org.apache.tez.runtime.metrics;
+import static org.junit.jupiter.api.Assertions.*;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.common.counters.TaskCounter;
import org.apache.tez.common.counters.TezCounter;
import org.apache.tez.common.counters.TezCounters;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,17 +45,18 @@ public void basicTest() {
TezCounter cpuCounter = assertCounter(counters, TaskCounter.CPU_MILLISECONDS);
long oldVal = cpuCounter.getValue();
- Assert.assertTrue(cpuCounter.getValue() > 0);
+ assertTrue(cpuCounter.getValue() > 0);
updater.updateCounters();
LOG.info("Counters (after second update): {}", counters);
- Assert.assertTrue("Counter not updated, old=" + oldVal
- + ", new=" + cpuCounter.getValue(), cpuCounter.getValue() > oldVal);
+ assertTrue(
+ cpuCounter.getValue() > oldVal,
+ "Counter not updated, old=" + oldVal + ", new=" + cpuCounter.getValue());
}
private TezCounter assertCounter(TezCounters counters, TaskCounter taskCounter) {
TezCounter counter = counters.findCounter(taskCounter);
- Assert.assertNotNull(counter);
+ assertNotNull(counter);
return counter;
}
}
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TaskExecutionTestHelpers.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TaskExecutionTestHelpers.java
index f589b3d1ea..b7829c6bd6 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TaskExecutionTestHelpers.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TaskExecutionTestHelpers.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.runtime.task;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.util.LinkedList;
@@ -52,7 +51,7 @@
import org.apache.tez.runtime.api.impl.TezHeartbeatRequest;
import org.apache.tez.runtime.api.impl.TezHeartbeatResponse;
-import org.junit.Assert;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -531,7 +530,7 @@ private static String getDiagnosticsWithoutNodeIp(String diagnostics) {
if (diagnostics != null && diagnostics.startsWith("Node:")) {
diagnosticsWithoutIP = diagnostics.substring(diagnostics.indexOf(" : ") + 3);
String nodeIp = diagnostics.substring(5, diagnostics.indexOf(" : "));
- Assert.assertFalse(nodeIp.isEmpty());
+ assertFalse(nodeIp.isEmpty());
}
return diagnosticsWithoutIP;
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestContainerExecution.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestContainerExecution.java
index ac5a9d9ec4..63c7dfc6f8 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestContainerExecution.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestContainerExecution.java
@@ -18,11 +18,12 @@
*/
package org.apache.tez.runtime.task;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
@@ -34,11 +35,12 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestContainerExecution {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGetTaskShouldDie() throws InterruptedException, ExecutionException {
ListeningExecutorService executor = null;
try {
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskExecution2.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskExecution2.java
index 6b28046626..4018478da0 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskExecution2.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskExecution2.java
@@ -19,11 +19,7 @@
package org.apache.tez.runtime.task;
import static org.apache.tez.runtime.task.TaskExecutionTestHelpers.*;
-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.*;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -36,6 +32,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Condition;
@@ -84,9 +81,7 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -117,17 +112,18 @@ public class TestTaskExecution2 {
}
}
- @Before
+ @BeforeEach
public void reset() {
TestProcessor.reset();
}
- @AfterClass
+ @AfterAll
public static void shutdown() {
taskExecutor.shutdownNow();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSingleSuccessfulTask() throws IOException, InterruptedException, TezException,
ExecutionException {
ListeningExecutorService executor = null;
@@ -156,7 +152,8 @@ public void testSingleSuccessfulTask() throws IOException, InterruptedException,
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleSuccessfulTasks() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -209,7 +206,8 @@ public void testMultipleSuccessfulTasks() throws IOException, InterruptedExcepti
// test task failed due to exception in Processor
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testFailedTaskTezException() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -247,7 +245,8 @@ public void testFailedTaskTezException() throws IOException, InterruptedExceptio
// Test task failed due to Processor class not found
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testFailedTask2() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -283,7 +282,8 @@ public void testFailedTask2() throws IOException, InterruptedException, TezExcep
}
// test task failed due to exception in Processor
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testFailedTaskIOException() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -321,7 +321,8 @@ public void testFailedTaskIOException() throws IOException, InterruptedException
}
// test that makes sure errors aren't reported when the container is already failing
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testIgnoreErrorsDuringFailure() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -357,7 +358,8 @@ protected boolean isShuttingDown() {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testHeartbeatException() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -397,7 +399,8 @@ public void testHeartbeatException() throws IOException, InterruptedException, T
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testHeartbeatShouldDie() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -438,7 +441,8 @@ public void testHeartbeatShouldDie() throws IOException, InterruptedException, T
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSignalDeprecatedFatalErrorAndLoop() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -479,7 +483,8 @@ public void testSignalDeprecatedFatalErrorAndLoop() throws IOException, Interrup
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSignalFatalAndThrow() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -515,7 +520,8 @@ public void testSignalFatalAndThrow() throws IOException, InterruptedException,
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSignalNonFatalAndThrow() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -551,7 +557,8 @@ public void testSignalNonFatalAndThrow() throws IOException, InterruptedExceptio
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskSelfKill() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -588,7 +595,8 @@ public void testTaskSelfKill() throws IOException, InterruptedException, TezExce
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskKilled() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -624,7 +632,8 @@ public void testTaskKilled() throws IOException, InterruptedException, TezExcept
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testKilledAfterComplete() throws IOException, InterruptedException, TezException,
ExecutionException {
@@ -714,8 +723,8 @@ private void verifySysCounters(TezCounters tezCounters, int minTaskCounterCount,
// If Target <=0, assert counter count is exactly 0
if (minTaskCounterCount <= 0) {
- assertEquals(tezCounters.toString(), 0, numTaskCounters);
- assertEquals(tezCounters.toString(), 0, numFsCounters);
+ assertEquals(0, numTaskCounters, tezCounters.toString());
+ assertEquals(0, numFsCounters, tezCounters.toString());
} else {
assertTrue(numTaskCounters >= minTaskCounterCount);
assertTrue(numFsCounters >= minFsCounterCount);
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskReporter.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskReporter.java
index 7bb41a0e31..a470689ca4 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskReporter.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTaskReporter.java
@@ -19,6 +19,7 @@
package org.apache.tez.runtime.task;
import static org.apache.tez.dag.api.TezConfiguration.TEZ_TASK_LOCAL_FS_WRITE_LIMIT_BYTES;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
@@ -36,6 +37,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
@@ -61,8 +63,7 @@
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -73,7 +74,8 @@ public class TestTaskReporter {
private static final File TEST_DIR =
new File(System.getProperty("test.build.data"), TestTaskReporter.class.getName()).getAbsoluteFile();
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testContinuousHeartbeatsOnMaxEvents() throws Exception {
final Object lock = new Object();
@@ -133,7 +135,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testEventThrottling() throws Exception {
TezTaskAttemptID mockTaskAttemptId = mock(TezTaskAttemptID.class);
LogicalIOProcessorRuntimeTask mockTask = mock(LogicalIOProcessorRuntimeTask.class);
@@ -158,7 +161,7 @@ public void testEventThrottling() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
Future result = executor.submit(heartbeatCallable);
- Assert.assertFalse(result.get());
+ assertFalse(result.get());
} finally {
executor.shutdownNow();
}
@@ -166,11 +169,12 @@ public void testEventThrottling() throws Exception {
ArgumentCaptor captor = ArgumentCaptor.forClass(TezHeartbeatRequest.class);
verify(mockUmbilical, times(2)).heartbeat(captor.capture());
TezHeartbeatRequest req = captor.getValue();
- Assert.assertEquals(2, req.getRequestId());
- Assert.assertEquals(1, req.getMaxEvents());
+ assertEquals(2, req.getRequestId());
+ assertEquals(1, req.getMaxEvents());
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testStatusUpdateAfterInitializationAndCounterFlag() {
TezTaskAttemptID mockTaskAttemptId = mock(TezTaskAttemptID.class);
LogicalIOProcessorRuntimeTask mockTask = mock(LogicalIOProcessorRuntimeTask.class);
@@ -201,10 +205,10 @@ public void testStatusUpdateAfterInitializationAndCounterFlag() {
verify(mockTask, times(0)).getAndClearProgressNotification();
verify(mockTask, times(0)).getTaskStatistics();
verify(mockTask, times(0)).getCounters();
- Assert.assertEquals(0, event.getProgress(), 0);
- Assert.assertEquals(false, event.getProgressNotified());
- Assert.assertNull(event.getCounters());
- Assert.assertNull(event.getStatistics());
+ assertEquals(0, event.getProgress(), 0);
+ assertFalse(event.getProgressNotified());
+ assertNull(event.getCounters());
+ assertNull(event.getStatistics());
// task is initialized - progress obtained but not counters since flag is false
doReturn(true).when(mockTask).hasInitialized();
@@ -214,10 +218,10 @@ public void testStatusUpdateAfterInitializationAndCounterFlag() {
verify(mockTask, times(1)).getAndClearProgressNotification();
verify(mockTask, times(0)).getTaskStatistics();
verify(mockTask, times(0)).getCounters();
- Assert.assertEquals(progress, event.getProgress(), 0);
- Assert.assertEquals(progressNotified, event.getProgressNotified());
- Assert.assertNull(event.getCounters());
- Assert.assertNull(event.getStatistics());
+ assertEquals(progress, event.getProgress(), 0);
+ assertEquals(progressNotified, event.getProgressNotified());
+ assertNull(event.getCounters());
+ assertNull(event.getStatistics());
// task is initialized - progress obtained and also counters since flag is true
progressNotified = true;
@@ -229,10 +233,10 @@ public void testStatusUpdateAfterInitializationAndCounterFlag() {
verify(mockTask, times(2)).getAndClearProgressNotification();
verify(mockTask, times(1)).getTaskStatistics();
verify(mockTask, times(1)).getCounters();
- Assert.assertEquals(progress, event.getProgress(), 0);
- Assert.assertEquals(progressNotified, event.getProgressNotified());
- Assert.assertEquals(counters, event.getCounters());
- Assert.assertEquals(stats, event.getStatistics());
+ assertEquals(progress, event.getProgress(), 0);
+ assertEquals(progressNotified, event.getProgressNotified());
+ assertEquals(counters, event.getCounters());
+ assertEquals(stats, event.getStatistics());
}
@@ -262,9 +266,9 @@ public void testLocalFileSystemBytesWrittenLimit() throws IOException {
try {
lio1.checkTaskLimits();
- Assert.fail("Expected to throw LocalWriteLimitException");
+ fail("Expected to throw LocalWriteLimitException");
} catch (LocalWriteLimitException localWriteLimitException) {
- Assert.assertTrue(localWriteLimitException.getMessage().contains("Too much write to local file system"));
+ assertTrue(localWriteLimitException.getMessage().contains("Too much write to local file system"));
}
}
diff --git a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTezTaskRunner2.java b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTezTaskRunner2.java
index bbffe60223..973dcfa63b 100644
--- a/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTezTaskRunner2.java
+++ b/tez-runtime-internals/src/test/java/org/apache/tez/runtime/task/TestTezTaskRunner2.java
@@ -18,10 +18,12 @@
*/
package org.apache.tez.runtime.task;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
@@ -38,13 +40,13 @@
import org.apache.tez.runtime.api.impl.OutputSpec;
import org.apache.tez.runtime.api.impl.TaskSpec;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestTezTaskRunner2 {
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTaskConfUsage() throws Exception {
Configuration conf = new Configuration(false);
conf.set("global", "global1");
@@ -68,9 +70,9 @@ public void testTaskConfUsage() throws Exception {
localDirs, taskSpec, 1, null, null, null, mock(TaskReporter.class), null, null, "pid",
null, 1000, false, new DefaultHadoopShim(), sharedExecutor);
- Assert.assertEquals("global1", taskRunner2.task.getTaskConf().get("global"));
- Assert.assertEquals("task1", taskRunner2.task.getTaskConf().get("global_override"));
- Assert.assertEquals("task1", taskRunner2.task.getTaskConf().get("task"));
+ assertEquals("global1", taskRunner2.task.getTaskConf().get("global"));
+ assertEquals("task1", taskRunner2.task.getTaskConf().get("global_override"));
+ assertEquals("task1", taskRunner2.task.getTaskConf().get("task"));
sharedExecutor.shutdownNow();
}
diff --git a/tez-runtime-library/pom.xml b/tez-runtime-library/pom.xml
index 3170715dec..492982da85 100644
--- a/tez-runtime-library/pom.xml
+++ b/tez-runtime-library/pom.xml
@@ -57,10 +57,6 @@
com.google.protobuf
protobuf-java
-
- junit
- junit
-
com.google.guava
guava
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestFairShuffleVertexManager.java b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestFairShuffleVertexManager.java
index c051e885d9..68acb09ae4 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestFairShuffleVertexManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestFairShuffleVertexManager.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.dag.library.vertexmanager;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyList;
@@ -31,6 +32,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.EdgeManagerPlugin;
@@ -49,15 +51,15 @@
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class TestFairShuffleVertexManager
extends TestShuffleVertexManagerUtils {
List emptyCompletions = null;
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAutoParallelismConfig() throws Exception {
FairShuffleVertexManager manager;
@@ -69,24 +71,25 @@ public void testAutoParallelismConfig() throws Exception {
manager = createManager(null, mockContext, null, 0.5f);
verify(mockContext, times(1)).vertexReconfigurationPlanned(); // Tez notified of reconfig
- Assert.assertTrue(manager.config.isAutoParallelismEnabled());
- Assert.assertTrue(manager.config.getDesiredTaskInputDataSize() == 1000l * MB);
- Assert.assertTrue(manager.config.getMinFraction() == 0.25f);
- Assert.assertTrue(manager.config.getMaxFraction() == 0.5f);
+ assertTrue(manager.config.isAutoParallelismEnabled());
+ assertEquals(manager.config.getDesiredTaskInputDataSize(), 1000l * MB);
+ assertEquals(0.25f, manager.config.getMinFraction());
+ assertEquals(0.5f, manager.config.getMaxFraction());
manager = createManager(null, mockContext, null, null, null, null);
verify(mockContext, times(1)).vertexReconfigurationPlanned(); // Tez not notified of reconfig
- Assert.assertTrue(!manager.config.isAutoParallelismEnabled());
- Assert.assertTrue(manager.config.getDesiredTaskInputDataSize() ==
+ assertFalse(manager.config.isAutoParallelismEnabled());
+ assertEquals(manager.config.getDesiredTaskInputDataSize(),
FairShuffleVertexManager.TEZ_FAIR_SHUFFLE_VERTEX_MANAGER_DESIRED_TASK_INPUT_SIZE_DEFAULT);
- Assert.assertTrue(manager.config.getMinFraction() ==
- FairShuffleVertexManager.TEZ_FAIR_SHUFFLE_VERTEX_MANAGER_MIN_SRC_FRACTION_DEFAULT);
- Assert.assertTrue(manager.config.getMaxFraction() ==
- FairShuffleVertexManager.TEZ_FAIR_SHUFFLE_VERTEX_MANAGER_MAX_SRC_FRACTION_DEFAULT);
+ assertEquals(FairShuffleVertexManager.TEZ_FAIR_SHUFFLE_VERTEX_MANAGER_MIN_SRC_FRACTION_DEFAULT,
+ manager.config.getMinFraction());
+ assertEquals(FairShuffleVertexManager.TEZ_FAIR_SHUFFLE_VERTEX_MANAGER_MAX_SRC_FRACTION_DEFAULT,
+ manager.config.getMaxFraction());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInvalidSetup() {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -102,15 +105,16 @@ public void testInvalidSetup() {
manager = createFairShuffleVertexManager(conf, mockContext,
FairRoutingType.FAIR_PARALLELISM, 1000 * MB, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertFalse(true);
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"Having more than one destination task process same partition(s) " +
"only works with one bipartite source."));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testReduceSchedulingWithPartitionStats() throws Exception {
final int numScatherAndGatherSourceTasks = 300;
final Map newEdgeManagers =
@@ -124,7 +128,7 @@ public void testReduceSchedulingWithPartitionStats() throws Exception {
// The first destination task fetches two partitions from all source tasks.
// Thus the # of inputs == # of source tasks * 2 merged partitions
- Assert.assertEquals(numScatherAndGatherSourceTasks * 2,
+ assertEquals(numScatherAndGatherSourceTasks * 2,
edgeManager.getNumDestinationTaskPhysicalInputs(0));
for (int sourceTaskIndex = 0;
sourceTaskIndex < numScatherAndGatherSourceTasks; sourceTaskIndex++) {
@@ -132,14 +136,14 @@ public void testReduceSchedulingWithPartitionStats() throws Exception {
if (j == 0) {
EdgeManagerPluginOnDemand.CompositeEventRouteMetadata routeMetadata =
edgeManager.routeCompositeDataMovementEventToDestination(sourceTaskIndex, 0);
- Assert.assertEquals(2, routeMetadata.getCount());
- Assert.assertEquals(0, routeMetadata.getSource());
- Assert.assertEquals(sourceTaskIndex*2, routeMetadata.getTarget());
+ assertEquals(2, routeMetadata.getCount());
+ assertEquals(0, routeMetadata.getSource());
+ assertEquals(sourceTaskIndex*2, routeMetadata.getTarget());
} else {
EdgeManagerPluginOnDemand.EventRouteMetadata routeMetadata =
edgeManager.routeInputSourceTaskFailedEventToDestination(sourceTaskIndex, 0);
- Assert.assertEquals(2, routeMetadata.getNumEvents());
- Assert.assertArrayEquals(
+ assertEquals(2, routeMetadata.getNumEvents());
+ assertArrayEquals(
new int[]{0 + sourceTaskIndex * 2, 1 + sourceTaskIndex * 2},
routeMetadata.getTargetIndices());
}
@@ -147,7 +151,8 @@ public void testReduceSchedulingWithPartitionStats() throws Exception {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testFairSchedulingWithPartitionStats() throws Exception {
final int numScatherAndGatherSourceTasks = 300;
final Map newEdgeManagers =
@@ -165,7 +170,7 @@ public void testFairSchedulingWithPartitionStats() throws Exception {
// The first destination task fetches two partitions from all source tasks.
// Thus the # of inputs == # of source tasks * 2 merged partitions
- Assert.assertEquals(numScatherAndGatherSourceTasks * 2,
+ assertEquals(numScatherAndGatherSourceTasks * 2,
edgeManager.getNumDestinationTaskPhysicalInputs(0));
for (int sourceTaskIndex = 0; sourceTaskIndex < numScatherAndGatherSourceTasks;
sourceTaskIndex++) {
@@ -173,14 +178,14 @@ public void testFairSchedulingWithPartitionStats() throws Exception {
if (j == 0) {
EdgeManagerPluginOnDemand.CompositeEventRouteMetadata routeMetadata =
edgeManager.routeCompositeDataMovementEventToDestination(sourceTaskIndex, 0);
- Assert.assertEquals(2, routeMetadata.getCount());
- Assert.assertEquals(0, routeMetadata.getSource());
- Assert.assertEquals(sourceTaskIndex*2, routeMetadata.getTarget());
+ assertEquals(2, routeMetadata.getCount());
+ assertEquals(0, routeMetadata.getSource());
+ assertEquals(sourceTaskIndex*2, routeMetadata.getTarget());
} else {
EdgeManagerPluginOnDemand.EventRouteMetadata routeMetadata =
edgeManager.routeInputSourceTaskFailedEventToDestination(sourceTaskIndex, 0);
- Assert.assertEquals(2, routeMetadata.getNumEvents());
- Assert.assertArrayEquals(
+ assertEquals(2, routeMetadata.getNumEvents());
+ assertArrayEquals(
new int[]{0 + sourceTaskIndex * 2, 1 + sourceTaskIndex * 2},
routeMetadata.getTargetIndices());
}
@@ -189,26 +194,26 @@ public void testFairSchedulingWithPartitionStats() throws Exception {
// The 2nd destination task fetches one partition from the first half of
// source tasks.
- Assert.assertEquals(numScatherAndGatherSourceTasks / 2,
+ assertEquals(numScatherAndGatherSourceTasks / 2,
edgeManager.getNumDestinationTaskPhysicalInputs(1));
for (int j = 0; j < 2; j++) {
if (j == 0) {
EdgeManagerPluginOnDemand.CompositeEventRouteMetadata routeMetadata =
edgeManager.routeCompositeDataMovementEventToDestination(0, 1);
- Assert.assertEquals(1, routeMetadata.getCount());
- Assert.assertEquals(2, routeMetadata.getSource());
- Assert.assertEquals(0, routeMetadata.getTarget());
+ assertEquals(1, routeMetadata.getCount());
+ assertEquals(2, routeMetadata.getSource());
+ assertEquals(0, routeMetadata.getTarget());
} else {
EdgeManagerPluginOnDemand.EventRouteMetadata routeMetadata =
edgeManager.routeInputSourceTaskFailedEventToDestination(0, 1);
- Assert.assertEquals(1, routeMetadata.getNumEvents());
- Assert.assertEquals(0, routeMetadata.getTargetIndices()[0]);
+ assertEquals(1, routeMetadata.getNumEvents());
+ assertEquals(0, routeMetadata.getTargetIndices()[0]);
}
}
// The 3rd destination task fetches one partition from 2nd half of
// source tasks.
- Assert.assertEquals(numScatherAndGatherSourceTasks / 2,
+ assertEquals(numScatherAndGatherSourceTasks / 2,
edgeManager.getNumDestinationTaskPhysicalInputs(2));
for (int sourceTaskIndex = numScatherAndGatherSourceTasks / 2;
sourceTaskIndex < numScatherAndGatherSourceTasks; sourceTaskIndex++) {
@@ -216,23 +221,24 @@ public void testFairSchedulingWithPartitionStats() throws Exception {
if (j == 0) {
EdgeManagerPluginOnDemand.CompositeEventRouteMetadata routeMetadata =
edgeManager.routeCompositeDataMovementEventToDestination(sourceTaskIndex, 2);
- Assert.assertEquals(1, routeMetadata.getCount());
- Assert.assertEquals(2, routeMetadata.getSource());
- Assert.assertEquals(
+ assertEquals(1, routeMetadata.getCount());
+ assertEquals(2, routeMetadata.getSource());
+ assertEquals(
sourceTaskIndex - numScatherAndGatherSourceTasks / 2,
routeMetadata.getTarget());
} else {
EdgeManagerPluginOnDemand.EventRouteMetadata routeMetadata =
edgeManager.routeInputSourceTaskFailedEventToDestination(sourceTaskIndex, 2);
- Assert.assertEquals(1, routeMetadata.getNumEvents());
- Assert.assertEquals(sourceTaskIndex - numScatherAndGatherSourceTasks / 2,
+ assertEquals(1, routeMetadata.getNumEvents());
+ assertEquals(sourceTaskIndex - numScatherAndGatherSourceTasks / 2,
routeMetadata.getTargetIndices()[0]);
}
}
}
}
- @Test(timeout = 500000)
+ @Test
+ @Timeout(value = 500000, unit = TimeUnit.MILLISECONDS)
public void testOverflow() throws Exception {
final int numScatherAndGatherSourceTasks = 30000;
final Map newEdgeManagers =
@@ -317,21 +323,21 @@ private void testSchedulingWithPartitionStats(
manager = createFairShuffleVertexManager(conf, mockContext,
fairRoutingType, 1000 * MB, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.bipartiteSources == 1);
+ assertEquals(1, manager.bipartiteSources);
manager.onVertexStateUpdated(new VertexStateUpdate(r1,
VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m2,
VertexState.CONFIGURED));
- Assert.assertEquals(numOfTasksInDestination,
+ assertEquals(numOfTasksInDestination,
manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(numOfTasksInr1,
+ assertEquals(numOfTasksInr1,
manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
- Assert.assertTrue(manager.pendingTasks.size() == numOfTasksInDestination); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == numOfTasksInr1);
+ assertEquals(numOfTasksInDestination, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(manager.totalNumBipartiteSourceTasks, numOfTasksInr1);
for (int i = 0; i < numCompletedEvents; i++) {
@@ -343,28 +349,28 @@ private void testSchedulingWithPartitionStats(
//Send an event for m2.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == numOfTasksInDestination); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == numOfTasksInr1);
+ assertEquals(numOfTasksInDestination, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(manager.totalNumBipartiteSourceTasks, numOfTasksInr1);
//Send an event for m3.
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m3, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == expectedScheduledTasks);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(scheduledTasks.size(), expectedScheduledTasks);
- Assert.assertEquals(1, newEdgeManagers.size());
+ assertEquals(1, newEdgeManagers.size());
EdgeManagerPluginOnDemand edgeManager =
(EdgeManagerPluginOnDemand)newEdgeManagers.values().iterator().next();
// For each source task, there are 3 outputs,
// the same as original number of partitions.
for (int i = 0; i < numOfTasksInr1; i++) {
- Assert.assertEquals(numOfTasksInDestination,
+ assertEquals(numOfTasksInDestination,
edgeManager.getNumSourceTaskPhysicalOutputs(0));
}
for (int sourceTaskIndex = 0; sourceTaskIndex < numOfTasksInr1;
sourceTaskIndex++) {
- Assert.assertEquals(expectedNumDestinationConsumerTasks,
+ assertEquals(expectedNumDestinationConsumerTasks,
edgeManager.getNumDestinationConsumerTasks(sourceTaskIndex));
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestInputReadyVertexManager.java b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestInputReadyVertexManager.java
index 0d56d6fcea..37c392259e 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestInputReadyVertexManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestInputReadyVertexManager.java
@@ -18,11 +18,13 @@
*/
package org.apache.tez.dag.library.vertexmanager;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -39,9 +41,7 @@
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
@@ -52,12 +52,13 @@ public class TestInputReadyVertexManager {
@Captor
ArgumentCaptor> requestCaptor;
- @Before
+ @BeforeEach
public void init() {
MockitoAnnotations.initMocks(this);
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicScatterGather() throws Exception {
HashMap mockInputVertices =
new HashMap();
@@ -94,10 +95,11 @@ public void testBasicScatterGather() throws Exception {
manager.onSourceTaskCompleted(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 2));
verify(mockContext, times(1)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(2, requestCaptor.getValue().size());
+ assertEquals(2, requestCaptor.getValue().size());
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicOneToOne() throws Exception {
HashMap mockInputVertices =
new HashMap();
@@ -128,33 +130,34 @@ public void testBasicOneToOne() throws Exception {
manager.onVertexStarted(Collections.singletonList(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 0)));
verify(mockContext, times(1)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(1, requestCaptor.getValue().size());
- Assert.assertEquals(0, requestCaptor.getValue().get(0).getTaskIndex());
- Assert.assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().size());
+ assertEquals(0, requestCaptor.getValue().get(0).getTaskIndex());
+ assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getVertexName());
- Assert.assertEquals(0, requestCaptor.getValue().get(0)
+ assertEquals(0, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getTaskIndex());
manager.onSourceTaskCompleted(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 1));
verify(mockContext, times(2)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(1, requestCaptor.getValue().size());
- Assert.assertEquals(1, requestCaptor.getValue().get(0).getTaskIndex());
- Assert.assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().size());
+ assertEquals(1, requestCaptor.getValue().get(0).getTaskIndex());
+ assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getVertexName());
- Assert.assertEquals(1, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getTaskIndex());
manager.onSourceTaskCompleted(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 2));
verify(mockContext, times(3)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(1, requestCaptor.getValue().size());
- Assert.assertEquals(2, requestCaptor.getValue().get(0).getTaskIndex());
- Assert.assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().size());
+ assertEquals(2, requestCaptor.getValue().get(0).getTaskIndex());
+ assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getVertexName());
- Assert.assertEquals(2, requestCaptor.getValue().get(0)
+ assertEquals(2, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getTaskIndex());
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDelayedConfigureOneToOne() throws Exception {
HashMap mockInputVertices =
new HashMap();
@@ -195,15 +198,16 @@ public void testDelayedConfigureOneToOne() throws Exception {
manager.onSourceTaskCompleted(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 2));
verify(mockContext, times(3)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(1, requestCaptor.getValue().size());
- Assert.assertEquals(2, requestCaptor.getValue().get(0).getTaskIndex());
- Assert.assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().size());
+ assertEquals(2, requestCaptor.getValue().get(0).getTaskIndex());
+ assertEquals(mockSrcVertexId1, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getVertexName());
- Assert.assertEquals(2, requestCaptor.getValue().get(0)
+ assertEquals(2, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getTaskIndex());
}
- @Test (timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testComplex() throws Exception {
HashMap mockInputVertices =
new HashMap();
@@ -271,7 +275,7 @@ public void testComplex() throws Exception {
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
try {
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue("Should have exception", false);
+ fail("Should have exception");
} catch (TezUncheckedException e) {
e.getMessage().contains("1-1 source vertices must have identical concurrency");
}
@@ -303,21 +307,21 @@ public void testComplex() throws Exception {
manager.onSourceTaskCompleted(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 2)); // v1 done
verify(mockContext, times(1)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(1, requestCaptor.getValue().size());
- Assert.assertEquals(0, requestCaptor.getValue().get(0).getTaskIndex());
- Assert.assertEquals(mockSrcVertexId3, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().size());
+ assertEquals(0, requestCaptor.getValue().get(0).getTaskIndex());
+ assertEquals(mockSrcVertexId3, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getVertexName());
- Assert.assertEquals(0, requestCaptor.getValue().get(0)
+ assertEquals(0, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getTaskIndex()); // affinity to last completion
// 1-1 completion triggers since other 1-1 is done
manager.onSourceTaskCompleted(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId3, 1));
verify(mockContext, times(2)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(1, requestCaptor.getValue().size());
- Assert.assertEquals(1, requestCaptor.getValue().get(0).getTaskIndex());
- Assert.assertEquals(mockSrcVertexId3, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().size());
+ assertEquals(1, requestCaptor.getValue().get(0).getTaskIndex());
+ assertEquals(mockSrcVertexId3, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getVertexName());
- Assert.assertEquals(1, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getTaskIndex()); // affinity to last completion
// 1-1 completion does not trigger since other 1-1 is not done
manager.onSourceTaskCompleted(
@@ -327,11 +331,11 @@ public void testComplex() throws Exception {
manager.onSourceTaskCompleted(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId2, 2));
verify(mockContext, times(3)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(1, requestCaptor.getValue().size());
- Assert.assertEquals(2, requestCaptor.getValue().get(0).getTaskIndex());
- Assert.assertEquals(mockSrcVertexId2, requestCaptor.getValue().get(0)
+ assertEquals(1, requestCaptor.getValue().size());
+ assertEquals(2, requestCaptor.getValue().get(0).getTaskIndex());
+ assertEquals(mockSrcVertexId2, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getVertexName());
- Assert.assertEquals(2, requestCaptor.getValue().get(0)
+ assertEquals(2, requestCaptor.getValue().get(0)
.getTaskLocationHint().getAffinitizedTask().getTaskIndex()); // affinity to last completion
// no more starts
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManager.java b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManager.java
index 63ab5daed4..bba47c4ff0 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManager.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.dag.library.vertexmanager;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyList;
@@ -33,6 +34,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.common.ReflectionUtils;
@@ -45,15 +47,15 @@
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class TestShuffleVertexManager extends TestShuffleVertexManagerUtils {
List emptyCompletions = null;
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLargeDataSize() throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -75,7 +77,7 @@ public void testLargeDataSize() throws IOException {
manager = createManager(conf, mockContext, 0.1f, 0.1f);
verify(mockContext, times(1)).vertexReconfigurationPlanned(); // Tez notified of reconfig
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.pendingTasks.size() == 4); // no tasks scheduled
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
manager.onVertexManagerEventReceived(vmEvent);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
@@ -87,15 +89,15 @@ public void testLargeDataSize() throws IOException {
verify(mockContext, times(0)).doneReconfiguringVertex();
// trigger scheduling
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
verify(mockContext, times(0)).reconfigureVertex(anyInt(), any
(VertexLocationHint.class), anyMap());
verify(mockContext, times(1)).doneReconfiguringVertex(); // reconfig done
- Assert.assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
- Assert.assertEquals(4, scheduledTasks.size());
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(4, scheduledTasks.size());
// TODO TEZ-1714 locking verify(mockContext, times(2)).vertexManagerDone(); // notified after scheduling all tasks
- Assert.assertEquals(2, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(5000L, manager.completedSourceTasksOutputSize);
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(5000L, manager.completedSourceTasksOutputSize);
scheduledTasks.clear();
// Ensure long overflow doesn't reduce mistakenly
@@ -106,38 +108,38 @@ public void testLargeDataSize() throws IOException {
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
// task completion from non-bipartite stage does nothing
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId3, 0));
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(4, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
// First source 1 task completes
vmEvent = getVertexManagerEvent(null, 0L, mockSrcVertexId1);
manager.onVertexManagerEventReceived(vmEvent);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertEquals(4, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
- Assert.assertEquals(1, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(0L, manager.completedSourceTasksOutputSize);
+ assertEquals(4, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(0L, manager.completedSourceTasksOutputSize);
// Second source 1 task completes
vmEvent = getVertexManagerEvent(null, 0L, mockSrcVertexId1);
manager.onVertexManagerEventReceived(vmEvent);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 1));
- Assert.assertEquals(4, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
- Assert.assertEquals(2, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(0L, manager.completedSourceTasksOutputSize);
+ assertEquals(4, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(0L, manager.completedSourceTasksOutputSize);
// First source 2 task completes
vmEvent = getVertexManagerEvent(null, Long.MAX_VALUE >> 1 , mockSrcVertexId2);
manager.onVertexManagerEventReceived(vmEvent);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertEquals(4, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
- Assert.assertEquals(3, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(Long.MAX_VALUE >> 1, manager.completedSourceTasksOutputSize);
+ assertEquals(4, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(Long.MAX_VALUE >> 1, manager.completedSourceTasksOutputSize);
// Second source 2 task completes
vmEvent = getVertexManagerEvent(null, Long.MAX_VALUE >> 1 , mockSrcVertexId2);
manager.onVertexManagerEventReceived(vmEvent);
@@ -145,14 +147,14 @@ public void testLargeDataSize() throws IOException {
// Auto-reduce is triggered
verify(mockContext, times(1)).reconfigureVertex(anyInt(), any(), anyMap());
verify(mockContext, times(1)).reconfigureVertex(eq(2), any(), anyMap());
- Assert.assertEquals(2, newEdgeManagers.size());
- Assert.assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
- Assert.assertEquals(2, scheduledTasks.size());
- Assert.assertTrue(scheduledTasks.contains(new Integer(0)));
- Assert.assertTrue(scheduledTasks.contains(new Integer(1)));
- Assert.assertEquals(4, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(4, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(Long.MAX_VALUE >> 1 << 1, manager.completedSourceTasksOutputSize);
+ assertEquals(2, newEdgeManagers.size());
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(2, scheduledTasks.size());
+ assertTrue(scheduledTasks.contains(new Integer(0)));
+ assertTrue(scheduledTasks.contains(new Integer(1)));
+ assertEquals(4, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(4, manager.numVertexManagerEventsReceived);
+ assertEquals(Long.MAX_VALUE >> 1 << 1, manager.completedSourceTasksOutputSize);
//reset context for next test
when(mockContext.getVertexNumTasks(mockSrcVertexId1)).thenReturn(2);
@@ -163,7 +165,8 @@ public void testLargeDataSize() throws IOException {
scheduledTasks.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAutoParallelismConfig() throws Exception {
ShuffleVertexManager manager;
@@ -187,11 +190,11 @@ public void testAutoParallelismConfig() throws Exception {
manager.initialize();
verify(mockContext, times(1)).vertexReconfigurationPlanned(); // Tez notified of reconfig
- Assert.assertTrue(manager.config.isAutoParallelismEnabled());
- Assert.assertTrue(manager.config.getDesiredTaskInputDataSize() == 1000l);
- Assert.assertTrue(manager.mgrConfig.getMinTaskParallelism() == 10);
- Assert.assertTrue(manager.config.getMinFraction() == 0.25f);
- Assert.assertTrue(manager.config.getMaxFraction() == 0.5f);
+ assertTrue(manager.config.isAutoParallelismEnabled());
+ assertEquals(1000l, manager.config.getDesiredTaskInputDataSize());
+ assertEquals(10, manager.mgrConfig.getMinTaskParallelism());
+ assertEquals(0.25f, manager.config.getMinFraction());
+ assertEquals(0.5f, manager.config.getMaxFraction());
configurer = ShuffleVertexManager.createConfigBuilder(null);
pluginDesc = configurer.setAutoReduceParallelism(false).build();
@@ -202,17 +205,18 @@ public void testAutoParallelismConfig() throws Exception {
manager.initialize();
verify(mockContext, times(1)).vertexReconfigurationPlanned(); // Tez not notified of reconfig
- Assert.assertTrue(!manager.config.isAutoParallelismEnabled());
- Assert.assertTrue(manager.config.getDesiredTaskInputDataSize() ==
+ assertFalse(manager.config.isAutoParallelismEnabled());
+ assertEquals(manager.config.getDesiredTaskInputDataSize(),
ShuffleVertexManager.TEZ_SHUFFLE_VERTEX_MANAGER_DESIRED_TASK_INPUT_SIZE_DEFAULT);
- Assert.assertTrue(manager.mgrConfig.getMinTaskParallelism() == 1);
- Assert.assertTrue(manager.config.getMinFraction() ==
- ShuffleVertexManager.TEZ_SHUFFLE_VERTEX_MANAGER_MIN_SRC_FRACTION_DEFAULT);
- Assert.assertTrue(manager.config.getMaxFraction() ==
- ShuffleVertexManager.TEZ_SHUFFLE_VERTEX_MANAGER_MAX_SRC_FRACTION_DEFAULT);
+ assertEquals(1, manager.mgrConfig.getMinTaskParallelism());
+ assertEquals(ShuffleVertexManager.TEZ_SHUFFLE_VERTEX_MANAGER_MIN_SRC_FRACTION_DEFAULT,
+ manager.config.getMinFraction());
+ assertEquals(ShuffleVertexManager.TEZ_SHUFFLE_VERTEX_MANAGER_MAX_SRC_FRACTION_DEFAULT,
+ manager.config.getMaxFraction());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSchedulingWithPartitionStats() throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -261,19 +265,19 @@ public void testSchedulingWithPartitionStats() throws IOException {
// check initialization
manager = createManager(conf, mockContext, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.bipartiteSources == 1);
+ assertEquals(1, manager.bipartiteSources);
manager.onVertexStateUpdated(new VertexStateUpdate(r1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m2, VertexState.CONFIGURED));
- Assert.assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(3, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
//Send an event for r1.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 3);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
//Tasks should be scheduled in task 2, 0, 1 order
long[] sizes = new long[]{(100 * 1000l * 1000l), (0l), (5000 * 1000l * 1000l)};
@@ -287,19 +291,19 @@ public void testSchedulingWithPartitionStats() throws IOException {
//Send an event for m2.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 3);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
//Send an event for m3.
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m3, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 3);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(3, scheduledTasks.size());
//Order of scheduling should be 2,0,1 based on the available partition statistics
- Assert.assertTrue(scheduledTasks.get(0) == 2);
- Assert.assertTrue(scheduledTasks.get(1) == 0);
- Assert.assertTrue(scheduledTasks.get(2) == 1);
+ assertEquals(2, (int) scheduledTasks.get(0));
+ assertEquals(0, (int) scheduledTasks.get(1));
+ assertEquals(1, (int) scheduledTasks.get(2));
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerBase.java b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerBase.java
index 686320242e..d1b6e5935a 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerBase.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerBase.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.dag.library.vertexmanager;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyList;
@@ -30,12 +31,12 @@
import static org.mockito.Mockito.when;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.EdgeManagerPlugin;
@@ -56,36 +57,29 @@
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.params.*;
+import org.junit.jupiter.params.provider.*;
@SuppressWarnings({ "unchecked", "rawtypes" })
-@RunWith(Parameterized.class)
public class TestShuffleVertexManagerBase extends TestShuffleVertexManagerUtils {
List emptyCompletions = null;
- Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass;
@SuppressWarnings("deprecation")
- @Parameterized.Parameters(name = "test[{0}]")
- public static Collection data() {
- Object[][] data = new Object[][]{
- {ShuffleVertexManager.class},
- {FairShuffleVertexManager.class}};
- return Arrays.asList(data);
- }
-
- public TestShuffleVertexManagerBase(
- Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) {
- this.shuffleVertexManagerClass = shuffleVertexManagerClass;
+ public static Stream data() {
+ return Stream.of(
+ Arguments.of(ShuffleVertexManager.class),
+ Arguments.of(FairShuffleVertexManager.class)
+ );
}
// Test zero source tasks and onVertexStarted is called
// before onVertexStateUpdated.
- @Test(timeout = 5000)
- public void testZeroSourceTasksWithVertexStartedFirst() {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testZeroSourceTasksWithVertexStartedFirst(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -100,32 +94,34 @@ public void testZeroSourceTasksWithVertexStartedFirst() {
mockSrcVertexId1, 0, mockSrcVertexId2, 0, mockSrcVertexId3, 1,
mockManagedVertexId, 4, scheduledTasks, null);
// check initialization
- manager = createManager(conf, mockContext, 0.1f, 0.1f); // Tez notified of reconfig
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.1f, 0.1f); // Tez notified of reconfig
manager.onVertexStarted(emptyCompletions);
verify(mockContext, times(1)).vertexReconfigurationPlanned();
// The edge between destination and source vertex mockSrcVertexId3 is
// broadcast type. Thus mockSrcVertexId3 isn't counted as bipartiteSource.
- Assert.assertTrue(manager.bipartiteSources == 2);
+ assertEquals(2, manager.bipartiteSources);
// check waiting for notification before scheduling
- Assert.assertFalse(manager.pendingTasks.isEmpty());
+ assertFalse(manager.pendingTasks.isEmpty());
// source vertices have 0 tasks. triggers scheduling
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.isEmpty());
+ assertTrue(manager.pendingTasks.isEmpty());
verify(mockContext, times(1)).reconfigureVertex(eq(1), any(), anyMap());
verify(mockContext, times(1)).doneReconfiguringVertex(); // reconfig done
- Assert.assertTrue(scheduledTasks.size() == 1); // all tasks scheduled and parallelism changed
+ assertEquals(1, scheduledTasks.size()); // all tasks scheduled and parallelism changed
scheduledTasks.clear();
// TODO TEZ-1714 locking verify(mockContext, times(1)).vertexManagerDone(); // notified after scheduling all tasks
}
// Test zero source tasks and onVertexStateUpdated is called
// before onVertexStarted.
- @Test(timeout = 5000)
- public void testZeroSourceTasksWithVertexStateUpdatedFirst() {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testZeroSourceTasksWithVertexStateUpdatedFirst(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -140,7 +136,7 @@ public void testZeroSourceTasksWithVertexStateUpdatedFirst() {
mockSrcVertexId1, 0, mockSrcVertexId2, 0, mockSrcVertexId3, 1,
mockManagedVertexId, 4, scheduledTasks, null);
// check initialization
- manager = createManager(conf, mockContext, 0.1f, 0.1f); // Tez notified of reconfig
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.1f, 0.1f); // Tez notified of reconfig
verify(mockContext, times(1)).vertexReconfigurationPlanned();
// source vertices have 0 tasks. so only 1 notification needed. does not trigger scheduling
@@ -149,19 +145,21 @@ public void testZeroSourceTasksWithVertexStateUpdatedFirst() {
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
verify(mockContext, times(0)).doneReconfiguringVertex(); // no change. will trigger after start
- Assert.assertTrue(scheduledTasks.size() == 0); // no tasks scheduled
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
// trigger start and processing of pending notification events
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.bipartiteSources == 2);
+ assertEquals(2, manager.bipartiteSources);
verify(mockContext, times(1)).reconfigureVertex(eq(1), any(), anyMap());
verify(mockContext, times(1)).doneReconfiguringVertex(); // reconfig done
- Assert.assertTrue(manager.pendingTasks.isEmpty());
- Assert.assertTrue(scheduledTasks.size() == 1); // all tasks scheduled and parallelism changed
+ assertTrue(manager.pendingTasks.isEmpty());
+ assertEquals(1, scheduledTasks.size()); // all tasks scheduled and parallelism changed
}
// Test vmEvent and vertexStatusUpdate before started.
- @Test(timeout = 5000)
- public void testVMEventFirst() throws IOException {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testVMEventFirst(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -177,22 +175,24 @@ public void testVMEventFirst() throws IOException {
mockManagedVertexId, 4, scheduledTasks, null);
VertexManagerEvent vmEvent = getVertexManagerEvent(null, 1L, "Vertex");
- manager = createManager(conf, mockContext, 0.01f, 0.75f);
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.01f, 0.75f);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
TezTaskAttemptID taId1 = TezTaskAttemptID.fromString("attempt_1436907267600_195589_1_00_000000_0");
vmEvent.setProducerAttemptIdentifier(new TaskAttemptIdentifierImpl("dag", mockSrcVertexId1, taId1));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexManagerEventReceived(vmEvent);
- Assert.assertEquals(0, manager.numVertexManagerEventsReceived); // nothing happens
+ assertEquals(0, manager.numVertexManagerEventsReceived); // nothing happens
manager.onVertexStarted(emptyCompletions); // now the processing happens
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
}
// Test partition stats.
- @Test(timeout = 5000)
- public void testPartitionStats() throws IOException {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testPartitionStats(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -211,65 +211,67 @@ public void testPartitionStats() throws IOException {
long[] sizes = new long[]{(0l), (1 * MB), (964 * MB), (48 * MB)};
VertexManagerEvent vmEvent = getVertexManagerEvent(sizes, 0, "Vertex", false);
- manager = createManager(conf, mockContext, 0.01f, 0.75f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.01f, 0.75f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
TezTaskAttemptID taId1 = TezTaskAttemptID.fromString("attempt_1436907267600_195589_1_00_000000_0");
vmEvent.setProducerAttemptIdentifier(new TaskAttemptIdentifierImpl("dag", mockSrcVertexId1, taId1));
manager.onVertexManagerEventReceived(vmEvent);
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0)); //0 MB bucket
- Assert.assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1)); //1 MB bucket
- Assert.assertEquals(100, manager.getCurrentlyKnownStatsAtIndex(2)); //100 MB bucket
- Assert.assertEquals(10, manager.getCurrentlyKnownStatsAtIndex(3)); //10 MB bucket
+ assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0)); //0 MB bucket
+ assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1)); //1 MB bucket
+ assertEquals(100, manager.getCurrentlyKnownStatsAtIndex(2)); //100 MB bucket
+ assertEquals(10, manager.getCurrentlyKnownStatsAtIndex(3)); //10 MB bucket
// sending again from a different version of the same task has not impact
TezTaskAttemptID taId2 = TezTaskAttemptID.fromString("attempt_1436907267600_195589_1_00_000000_1");
vmEvent.setProducerAttemptIdentifier(new TaskAttemptIdentifierImpl("dag", mockSrcVertexId1, taId2));
manager.onVertexManagerEventReceived(vmEvent);
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0)); //0 MB bucket
- Assert.assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1)); //1 MB bucket
- Assert.assertEquals(100, manager.getCurrentlyKnownStatsAtIndex(2)); //100 MB bucket
- Assert.assertEquals(10, manager.getCurrentlyKnownStatsAtIndex(3)); //10 MB bucket
+ assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0)); //0 MB bucket
+ assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1)); //1 MB bucket
+ assertEquals(100, manager.getCurrentlyKnownStatsAtIndex(2)); //100 MB bucket
+ assertEquals(10, manager.getCurrentlyKnownStatsAtIndex(3)); //10 MB bucket
// Testing for detailed partition stats
vmEvent = getVertexManagerEvent(sizes, 0, "Vertex", true);
- manager = createManager(conf, mockContext, 0.01f, 0.75f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.01f, 0.75f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
taId1 = TezTaskAttemptID.fromString("attempt_1436907267600_195589_1_00_000000_0");
vmEvent.setProducerAttemptIdentifier(new TaskAttemptIdentifierImpl("dag", mockSrcVertexId1, taId1));
manager.onVertexManagerEventReceived(vmEvent);
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0));
- Assert.assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1));
- Assert.assertEquals(964, manager.getCurrentlyKnownStatsAtIndex(2));
- Assert.assertEquals(48, manager.getCurrentlyKnownStatsAtIndex(3));
+ assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0));
+ assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1));
+ assertEquals(964, manager.getCurrentlyKnownStatsAtIndex(2));
+ assertEquals(48, manager.getCurrentlyKnownStatsAtIndex(3));
// sending again from a different version of the same task has not impact
taId2 = TezTaskAttemptID.fromString("attempt_1436907267600_195589_1_00_000000_1");
vmEvent.setProducerAttemptIdentifier(new TaskAttemptIdentifierImpl("dag", mockSrcVertexId1, taId2));
manager.onVertexManagerEventReceived(vmEvent);
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0));
- Assert.assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1));
- Assert.assertEquals(964, manager.getCurrentlyKnownStatsAtIndex(2));
- Assert.assertEquals(48, manager.getCurrentlyKnownStatsAtIndex(3));
+ assertEquals(0, manager.getCurrentlyKnownStatsAtIndex(0));
+ assertEquals(1, manager.getCurrentlyKnownStatsAtIndex(1));
+ assertEquals(964, manager.getCurrentlyKnownStatsAtIndex(2));
+ assertEquals(48, manager.getCurrentlyKnownStatsAtIndex(3));
}
// Delay determining parallelism until enough data has been received.
- @Test(timeout = 5000)
- public void testTez978() throws IOException {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testTez978(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -285,50 +287,50 @@ public void testTez978() throws IOException {
mockManagedVertexId, 4, scheduledTasks, null);
//min/max fraction of 0.01/0.75 would ensure that we hit determineParallelism code path on receiving first event itself.
- manager = createManager(conf, mockContext, 0.01f, 0.75f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.01f, 0.75f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(4, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
//First task in src1 completed with small payload
VertexManagerEvent vmEvent = getVertexManagerEvent(null, 1L, mockSrcVertexId1);
manager.onVertexManagerEventReceived(vmEvent); //small payload
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertTrue(manager.determineParallelismAndApply(0f) == false);
- Assert.assertEquals(4, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
- Assert.assertEquals(1, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(1L, manager.completedSourceTasksOutputSize);
+ assertFalse(manager.determineParallelismAndApply(0f));
+ assertEquals(4, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(1L, manager.completedSourceTasksOutputSize);
//First task in src2 completed with small payload
vmEvent = getVertexManagerEvent(null, 1L, mockSrcVertexId2);
manager.onVertexManagerEventReceived(vmEvent); //small payload
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
//Still overall data gathered has not reached threshold; So, ensure parallelism can be determined later
- Assert.assertTrue(manager.determineParallelismAndApply(0.25f) == false);
- Assert.assertEquals(4, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
- Assert.assertEquals(2, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(2, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(2L, manager.completedSourceTasksOutputSize);
+ assertFalse(manager.determineParallelismAndApply(0.25f));
+ assertEquals(4, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(2, manager.numVertexManagerEventsReceived);
+ assertEquals(2L, manager.completedSourceTasksOutputSize);
//First task in src2 completed (with larger payload) to trigger determining parallelism
vmEvent = getVertexManagerEvent(null, 160 * MB, mockSrcVertexId2);
manager.onVertexManagerEventReceived(vmEvent);
- Assert.assertTrue(manager.determineParallelismAndApply(0.25f)); //ensure parallelism is determined
+ assertTrue(manager.determineParallelismAndApply(0.25f)); //ensure parallelism is determined
verify(mockContext, times(1)).reconfigureVertex(anyInt(), any(), anyMap());
verify(mockContext, times(1)).reconfigureVertex(eq(2), any(), anyMap());
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertEquals(0, manager.pendingTasks.size());
- Assert.assertEquals(2, scheduledTasks.size());
- Assert.assertEquals(2, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(3, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(160 * MB + 2, manager.completedSourceTasksOutputSize);
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(2, scheduledTasks.size());
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(3, manager.numVertexManagerEventsReceived);
+ assertEquals(160 * MB + 2, manager.completedSourceTasksOutputSize);
//Test for max fraction. Min fraction is just instruction to framework, but honor max fraction
when(mockContext.getVertexNumTasks(mockSrcVertexId1)).thenReturn(20);
@@ -337,16 +339,16 @@ public void testTez978() throws IOException {
scheduledTasks.clear();
//min/max fraction of 0.0/0.2
- manager = createManager(conf, mockContext, 0.0f, 0.2f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.0f, 0.2f);
// initial invocation count == 3
verify(mockContext, times(1)).reconfigureVertex(anyInt(), any(), anyMap());
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertEquals(40, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(40, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(40, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(40, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
//send 8 events with payload size as 10MB
for(int i=0;i<8;i++) {
//small payload - create new event each time or it will be ignored (from same task)
@@ -367,8 +369,10 @@ public void testTez978() throws IOException {
verify(mockContext, times(2)).reconfigureVertex(eq(2), any(), anyMap());
}
- @Test(timeout = 5000)
- public void testAutoParallelism() throws Exception {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testAutoParallelism(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) throws Exception {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -386,32 +390,32 @@ public void testAutoParallelism() throws Exception {
mockManagedVertexId, 4, scheduledTasks, newEdgeManagers);
// parallelism changed due to small data size
- manager = createManager(conf, mockContext, 0.5f, 0.5f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.5f, 0.5f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
// task completion from non-bipartite stage does nothing
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId3, 0));
- Assert.assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(4, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(4, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
VertexManagerEvent vmEvent = getVertexManagerEvent(null, 50 * MB, mockSrcVertexId1);
manager.onVertexManagerEventReceived(vmEvent);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertEquals(4, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
- Assert.assertEquals(1, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(1, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(50 * MB, manager.completedSourceTasksOutputSize);
+ assertEquals(4, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(1, manager.numVertexManagerEventsReceived);
+ assertEquals(50 * MB, manager.completedSourceTasksOutputSize);
// ignore duplicate completion
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertEquals(4, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
- Assert.assertEquals(1, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(50 * MB, manager.completedSourceTasksOutputSize);
+ assertEquals(4, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(50 * MB, manager.completedSourceTasksOutputSize);
vmEvent = getVertexManagerEvent(null, 50 * MB, mockSrcVertexId2);
manager.onVertexManagerEventReceived(vmEvent);
@@ -419,50 +423,52 @@ public void testAutoParallelism() throws Exception {
// managedVertex tasks reduced
verify(mockContext, times(1)).reconfigureVertex(anyInt(), any(), anyMap());
verify(mockContext, times(1)).reconfigureVertex(eq(2), any(), anyMap());
- Assert.assertEquals(2, newEdgeManagers.size());
+ assertEquals(2, newEdgeManagers.size());
// TODO improve tests for parallelism
- Assert.assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
- Assert.assertEquals(2, scheduledTasks.size());
- Assert.assertTrue(scheduledTasks.contains(new Integer(0)));
- Assert.assertTrue(scheduledTasks.contains(new Integer(1)));
- Assert.assertEquals(2, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(2, manager.numVertexManagerEventsReceived);
- Assert.assertEquals(100 * MB, manager.completedSourceTasksOutputSize);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(2, scheduledTasks.size());
+ assertTrue(scheduledTasks.contains(new Integer(0)));
+ assertTrue(scheduledTasks.contains(new Integer(1)));
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(2, manager.numVertexManagerEventsReceived);
+ assertEquals(100 * MB, manager.completedSourceTasksOutputSize);
// more completions dont cause recalculation of parallelism
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
verify(mockContext, times(1)).reconfigureVertex(anyInt(), any(), anyMap());
- Assert.assertEquals(2, newEdgeManagers.size());
+ assertEquals(2, newEdgeManagers.size());
EdgeManagerPluginOnDemand edgeManager =
(EdgeManagerPluginOnDemand)newEdgeManagers.values().iterator().next();
// 4 source task outputs - same as original number of partitions
- Assert.assertEquals(4, edgeManager.getNumSourceTaskPhysicalOutputs(0));
+ assertEquals(4, edgeManager.getNumSourceTaskPhysicalOutputs(0));
// 4 destination task inputs - 2 source tasks * 2 merged partitions
- Assert.assertEquals(4, edgeManager.getNumDestinationTaskPhysicalInputs(0));
+ assertEquals(4, edgeManager.getNumDestinationTaskPhysicalInputs(0));
EdgeManagerPluginOnDemand.EventRouteMetadata routeMetadata =
edgeManager.routeDataMovementEventToDestination(1, 1, 0);
- Assert.assertEquals(1, routeMetadata.getNumEvents());
- Assert.assertEquals(3, routeMetadata.getTargetIndices()[0]);
+ assertEquals(1, routeMetadata.getNumEvents());
+ assertEquals(3, routeMetadata.getTargetIndices()[0]);
routeMetadata = edgeManager.routeDataMovementEventToDestination(0, 2, 1);
- Assert.assertEquals(1, routeMetadata.getNumEvents());
- Assert.assertEquals(0, routeMetadata.getTargetIndices()[0]);
+ assertEquals(1, routeMetadata.getNumEvents());
+ assertEquals(0, routeMetadata.getTargetIndices()[0]);
routeMetadata = edgeManager.routeInputSourceTaskFailedEventToDestination(1, 0);
- Assert.assertEquals(2, routeMetadata.getNumEvents());
- Assert.assertEquals(2, routeMetadata.getTargetIndices()[0]);
- Assert.assertEquals(3, routeMetadata.getTargetIndices()[1]);
+ assertEquals(2, routeMetadata.getNumEvents());
+ assertEquals(2, routeMetadata.getTargetIndices()[0]);
+ assertEquals(3, routeMetadata.getTargetIndices()[1]);
routeMetadata = edgeManager.routeInputSourceTaskFailedEventToDestination(1, 1);
- Assert.assertEquals(2, routeMetadata.getNumEvents());
- Assert.assertEquals(2, routeMetadata.getTargetIndices()[0]);
- Assert.assertEquals(3, routeMetadata.getTargetIndices()[1]);
+ assertEquals(2, routeMetadata.getNumEvents());
+ assertEquals(2, routeMetadata.getTargetIndices()[0]);
+ assertEquals(3, routeMetadata.getTargetIndices()[1]);
}
- @Test(timeout = 5000)
- public void testShuffleVertexManagerSlowStart() {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testShuffleVertexManagerSlowStart(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager = null;
HashMap mockInputVertices =
@@ -501,11 +507,11 @@ public void testShuffleVertexManagerSlowStart() {
// fail if there is no bipartite src vertex
mockInputVertices.put(mockSrcVertexId3, eProp3);
try {
- manager = createManager(conf, mockContext, 0.1f, 0.1f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.1f, 0.1f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertFalse(true);
+ fail();
} catch (TezUncheckedException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"At least 1 bipartite source should exist"));
}
@@ -513,9 +519,9 @@ public void testShuffleVertexManagerSlowStart() {
mockInputVertices.put(mockSrcVertexId2, eProp2);
// check initialization
- manager = createManager(conf, mockContext, 0.1f, 0.1f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.1f, 0.1f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.bipartiteSources == 2);
+ assertEquals(2, manager.bipartiteSources);
final List scheduledTasks = Lists.newLinkedList();
doAnswer(new ScheduledTasksAnswer(scheduledTasks)).when(
@@ -528,36 +534,36 @@ public void testShuffleVertexManagerSlowStart() {
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.pendingTasks.isEmpty());
- Assert.assertTrue(scheduledTasks.size() == 3); // all tasks scheduled
+ assertTrue(manager.pendingTasks.isEmpty());
+ assertEquals(3, scheduledTasks.size()); // all tasks scheduled
when(mockContext.getVertexNumTasks(mockSrcVertexId1)).thenReturn(2);
when(mockContext.getVertexNumTasks(mockSrcVertexId2)).thenReturn(2);
try {
// source vertex have some tasks. min < 0.
- manager = createManager(conf, mockContext, -0.1f, 0.0f);
- Assert.assertTrue(false); // should not come here
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, -0.1f, 0.0f);
+ fail(); // should not come here
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"Invalid values for slowStartMinFraction"));
}
try {
// source vertex have some tasks. max > 1.
- manager = createManager(conf, mockContext, 0.0f, 95.0f);
- Assert.assertTrue(false); // should not come here
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.0f, 95.0f);
+ fail(); // should not come here
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"Invalid values for slowStartMinFraction"));
}
try {
// source vertex have some tasks. min > max
- manager = createManager(conf, mockContext, 0.5f, 0.3f);
- Assert.assertTrue(false); // should not come here
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.5f, 0.3f);
+ fail(); // should not come here
} catch (IllegalArgumentException e) {
- Assert.assertTrue(e.getMessage().contains(
+ assertTrue(e.getMessage().contains(
"Invalid values for slowStartMinFraction"));
}
@@ -567,15 +573,15 @@ public void testShuffleVertexManagerSlowStart() {
when(mockContext.getVertexNumTasks(mockSrcVertexId2)).thenReturn(numTasks);
scheduledTasks.clear();
- manager = createManager(conf, mockContext, 0.8f, null);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.8f, null);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertEquals(3, manager.pendingTasks.size());
- Assert.assertEquals(numTasks*2, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(numTasks*2, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
float completedTasksThreshold = 0.8f * numTasks;
// Finish all tasks before exceeding the threshold
for (String mockSrcVertex : new String[] { mockSrcVertexId1, mockSrcVertexId2 }) {
@@ -589,213 +595,215 @@ public void testShuffleVertexManagerSlowStart() {
}
}
// Since we haven't exceeded the threshold, all tasks are still pending
- Assert.assertEquals(manager.totalTasksToSchedule, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size()); // no tasks scheduled
+ assertEquals(manager.totalTasksToSchedule, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no tasks scheduled
// Cross the threshold min/max threshold to schedule all tasks
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertEquals(3, manager.pendingTasks.size());
- Assert.assertEquals(0, scheduledTasks.size());
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size());
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertEquals(0, manager.pendingTasks.size());
- Assert.assertEquals(manager.totalTasksToSchedule, scheduledTasks.size()); // all tasks scheduled
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(manager.totalTasksToSchedule, scheduledTasks.size()); // all tasks scheduled
// reset vertices for next test
when(mockContext.getVertexNumTasks(mockSrcVertexId1)).thenReturn(2);
when(mockContext.getVertexNumTasks(mockSrcVertexId2)).thenReturn(2);
// source vertex have some tasks. min, max == 0
- manager = createManager(conf, mockContext, 0.0f, 0.0f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.0f, 0.0f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.totalTasksToSchedule == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 0);
+ assertEquals(3, manager.totalTasksToSchedule);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
// all source vertices need to be configured
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
- Assert.assertTrue(manager.pendingTasks.isEmpty());
- Assert.assertTrue(scheduledTasks.size() == 3); // all tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertTrue(manager.pendingTasks.isEmpty());
+ assertEquals(3, scheduledTasks.size()); // all tasks scheduled
// min, max > 0 and min == max
- manager = createManager(conf, mockContext, 0.25f, 0.25f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.25f, 0.25f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
// task completion from non-bipartite stage does nothing
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId3, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 0);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
// task completion on only 1 SG edge does nothing
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 1);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertTrue(manager.pendingTasks.isEmpty());
- Assert.assertTrue(scheduledTasks.size() == 3); // all tasks scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 2);
+ assertTrue(manager.pendingTasks.isEmpty());
+ assertEquals(3, scheduledTasks.size()); // all tasks scheduled
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
// min, max > 0 and min == max == absolute max 1.0
- manager = createManager(conf, mockContext, 1.0f, 1.0f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 1.0f, 1.0f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
// task completion from non-bipartite stage does nothing
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId3, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 0);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 1);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 2);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 3);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(3, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 1));
- Assert.assertTrue(manager.pendingTasks.isEmpty());
- Assert.assertTrue(scheduledTasks.size() == 3); // all tasks scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 4);
+ assertTrue(manager.pendingTasks.isEmpty());
+ assertEquals(3, scheduledTasks.size()); // all tasks scheduled
+ assertEquals(4, manager.numBipartiteSourceTasksCompleted);
// min, max > 0 and min == max
- manager = createManager(conf, mockContext, 1.0f, 1.0f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 1.0f, 1.0f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
// task completion from non-bipartite stage does nothing
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId3, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 4);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 0);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(4, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 1);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 2);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 3);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(3, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 1));
- Assert.assertTrue(manager.pendingTasks.isEmpty());
- Assert.assertTrue(scheduledTasks.size() == 3); // all tasks scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 4);
+ assertTrue(manager.pendingTasks.isEmpty());
+ assertEquals(3, scheduledTasks.size()); // all tasks scheduled
+ assertEquals(4, manager.numBipartiteSourceTasksCompleted);
// reset vertices for next test
when(mockContext.getVertexNumTasks(mockSrcVertexId1)).thenReturn(4);
when(mockContext.getVertexNumTasks(mockSrcVertexId2)).thenReturn(4);
// min, max > and min < max
- manager = createManager(conf, mockContext, 0.25f, 0.75f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.25f, 0.75f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 8);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(8, manager.totalNumBipartiteSourceTasks);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 2);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
// completion of same task again should not get counted
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 3);
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 2);
+ assertEquals(3, manager.pendingTasks.size());
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 1));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 1);
- Assert.assertTrue(scheduledTasks.size() == 2); // 2 task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 4);
+ assertEquals(1, manager.pendingTasks.size());
+ assertEquals(2, scheduledTasks.size()); // 2 task scheduled
+ assertEquals(4, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 2));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 2));
- Assert.assertTrue(manager.pendingTasks.size() == 0);
- Assert.assertTrue(scheduledTasks.size() == 1); // 1 tasks scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 6);
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(1, scheduledTasks.size()); // 1 tasks scheduled
+ assertEquals(6, manager.numBipartiteSourceTasksCompleted);
scheduledTasks.clear();
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 3)); // we are done. no action
- Assert.assertTrue(manager.pendingTasks.size() == 0);
- Assert.assertTrue(scheduledTasks.size() == 0); // no task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 7);
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no task scheduled
+ assertEquals(7, manager.numBipartiteSourceTasksCompleted);
// min, max > and min < max
- manager = createManager(conf, mockContext, 0.25f, 1.0f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.25f, 1.0f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 8);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(8, manager.totalNumBipartiteSourceTasks);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 1));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 1));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 2);
- Assert.assertTrue(scheduledTasks.size() == 1); // 1 task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 4);
+ assertEquals(2, manager.pendingTasks.size());
+ assertEquals(1, scheduledTasks.size()); // 1 task scheduled
+ assertEquals(4, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 2));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 2));
- Assert.assertTrue(manager.pendingTasks.size() == 1);
- Assert.assertTrue(scheduledTasks.size() == 1); // 1 task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 6);
+ assertEquals(1, manager.pendingTasks.size());
+ assertEquals(1, scheduledTasks.size()); // 1 task scheduled
+ assertEquals(6, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 3));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 3));
- Assert.assertTrue(manager.pendingTasks.size() == 0);
- Assert.assertTrue(scheduledTasks.size() == 1); // no task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 8);
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(1, scheduledTasks.size()); // no task scheduled
+ assertEquals(8, manager.numBipartiteSourceTasksCompleted);
// if there is single task to schedule, it should be schedule when src completed
// fraction is more than min slow start fraction
scheduledTasks.clear();
when(mockContext.getVertexNumTasks(mockManagedVertexId)).thenReturn(1);
- manager = createManager(conf, mockContext, 0.25f, 0.75f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.25f, 0.75f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(mockSrcVertexId3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 1); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 8);
+ assertEquals(1, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(8, manager.totalNumBipartiteSourceTasks);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 1);
- Assert.assertTrue(scheduledTasks.size() == 0); // no task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 2);
+ assertEquals(1, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no task scheduled
+ assertEquals(2, manager.numBipartiteSourceTasksCompleted);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 1));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 0);
- Assert.assertTrue(scheduledTasks.size() == 1); // 1 task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 4);
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(1, scheduledTasks.size()); // 1 task scheduled
+ assertEquals(4, manager.numBipartiteSourceTasksCompleted);
scheduledTasks.clear();
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 2));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId2, 2));
- Assert.assertTrue(manager.pendingTasks.size() == 0);
- Assert.assertTrue(scheduledTasks.size() == 0); // no task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 6);
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no task scheduled
+ assertEquals(6, manager.numBipartiteSourceTasksCompleted);
scheduledTasks.clear();
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(mockSrcVertexId1, 3)); // we are done. no action
- Assert.assertTrue(manager.pendingTasks.size() == 0);
- Assert.assertTrue(scheduledTasks.size() == 0); // no task scheduled
- Assert.assertTrue(manager.numBipartiteSourceTasksCompleted == 7);
+ assertEquals(0, manager.pendingTasks.size());
+ assertEquals(0, scheduledTasks.size()); // no task scheduled
+ assertEquals(7, manager.numBipartiteSourceTasksCompleted);
}
/**
* Tasks should be scheduled only when all source vertices are configured completely
* @throws IOException
*/
- @Test(timeout = 5000)
- public void test_Tez1649_with_scatter_gather_edges() throws IOException {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void test_Tez1649_with_scatter_gather_edges(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager = null;
@@ -837,43 +845,43 @@ public void test_Tez1649_with_scatter_gather_edges() throws IOException {
VertexManagerEvent vmEvent = getVertexManagerEvent(null, 50L, r1);
// check initialization
- manager = createManager(conf, mockContext_R2, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext_R2, 0.001f, 0.001f);
final List scheduledTasks = Lists.newLinkedList();
doAnswer(new ScheduledTasksAnswer(scheduledTasks)).when(
mockContext_R2).scheduleTasks(anyList());
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.bipartiteSources == 3);
+ assertEquals(3, manager.bipartiteSources);
manager.onVertexStateUpdated(new VertexStateUpdate(m2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
manager.onVertexManagerEventReceived(vmEvent);
- Assert.assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(6, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(6, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 6);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(6, manager.totalNumBipartiteSourceTasks);
//Send events for all tasks of m3.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m3, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m3, 1));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m3, 2));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 6);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(6, manager.totalNumBipartiteSourceTasks);
//Send events for m2. But still we need to wait for at least 1 event from r1.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m2, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m2, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 6);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(6, manager.totalNumBipartiteSourceTasks);
// we need to wait for at least 1 event from r1 to make sure all vertices cross min threshold
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 6);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(6, manager.totalNumBipartiteSourceTasks);
//Ensure that setVertexParallelism is not called for R2.
verify(mockContext_R2, times(0)).reconfigureVertex(anyInt(), any(), anyMap());
@@ -883,11 +891,11 @@ public void test_Tez1649_with_scatter_gather_edges() throws IOException {
// complete configuration of r1 triggers the scheduling
manager.onVertexStateUpdated(new VertexStateUpdate(r1, VertexState.CONFIGURED));
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 9);
+ assertEquals(9, manager.totalNumBipartiteSourceTasks);
verify(mockContext_R2, times(1)).reconfigureVertex(eq(1), any(), anyMap());
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 1);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(1, scheduledTasks.size());
//try with zero task vertices
scheduledTasks.clear();
@@ -898,23 +906,25 @@ public void test_Tez1649_with_scatter_gather_edges() throws IOException {
when(mockContext_R2.getVertexNumTasks(m2)).thenReturn(0);
when(mockContext_R2.getVertexNumTasks(m3)).thenReturn(3);
- manager = createManager(conf, mockContext_R2, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext_R2, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
// Only need completed configuration notification from m3
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(r1, VertexState.CONFIGURED));
- Assert.assertEquals(3, manager.totalNumBipartiteSourceTasks);
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m3, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 3);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(3, scheduledTasks.size());
}
- @Test(timeout = 5000)
- public void test_Tez1649_with_mixed_edges() {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void test_Tez1649_with_mixed_edges(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager = null;
@@ -960,37 +970,37 @@ public void test_Tez1649_with_mixed_edges() {
doAnswer(new ScheduledTasksAnswer(scheduledTasks)).when(
mockContext).scheduleTasks(anyList());
// check initialization
- manager = createManager(conf, mockContext, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
- Assert.assertTrue(manager.bipartiteSources == 1);
+ assertEquals(1, manager.bipartiteSources);
manager.onVertexStateUpdated(new VertexStateUpdate(r1, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m2, VertexState.CONFIGURED));
- Assert.assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(3, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
//Send events for 2 tasks of r1.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 3);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
//Send an event for m2.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(m2, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 3);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
//Send an event for m3.
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 3);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(3, scheduledTasks.size());
//Scenario when numBipartiteSourceTasksCompleted == totalNumBipartiteSourceTasks.
//Still, wait for a configuration to be completed from other edges
scheduledTasks.clear();
- manager = createManager(conf, mockContext, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(r1, VertexState.CONFIGURED));
@@ -1000,24 +1010,24 @@ public void test_Tez1649_with_mixed_edges() {
when(mockContext.getVertexNumTasks(r1)).thenReturn(3);
when(mockContext.getVertexNumTasks(m2)).thenReturn(3);
when(mockContext.getVertexNumTasks(m3)).thenReturn(3);
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(manager.totalNumBipartiteSourceTasks == 3);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 1));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 2));
//Tasks from non-scatter edges of m2 and m3 are not complete.
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
manager.onVertexStateUpdated(new VertexStateUpdate(m2, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
//Got an event from other edges. Schedule all
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 3);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(3, scheduledTasks.size());
//try with a zero task vertex (with non-scatter-gather edges)
scheduledTasks.clear();
- manager = createManager(conf, mockContext, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
when(mockContext.getInputVertexEdgeProperties()).thenReturn(mockInputVertices);
when(mockContext.getVertexName()).thenReturn(mockManagedVertexId);
@@ -1026,29 +1036,29 @@ public void test_Tez1649_with_mixed_edges() {
when(mockContext.getVertexNumTasks(m2)).thenReturn(0); //broadcast
when(mockContext.getVertexNumTasks(m3)).thenReturn(3); //broadcast
- manager = createManager(conf, mockContext, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(r1, VertexState.CONFIGURED));
- Assert.assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(3, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(3, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
//Send 2 events for tasks of r1.
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 0));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 1));
- Assert.assertTrue(manager.pendingTasks.size() == 3); // no tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 0);
+ assertEquals(3, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(0, scheduledTasks.size());
// event from m3 triggers scheduling
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m2, VertexState.CONFIGURED));
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 3);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(3, scheduledTasks.size());
//try with all zero task vertices in non-SG edges
scheduledTasks.clear();
- manager = createManager(conf, mockContext, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.001f, 0.001f);
manager.onVertexStarted(emptyCompletions);
when(mockContext.getInputVertexEdgeProperties()).thenReturn(mockInputVertices);
when(mockContext.getVertexName()).thenReturn(mockManagedVertexId);
@@ -1062,12 +1072,13 @@ public void test_Tez1649_with_mixed_edges() {
manager.onVertexStateUpdated(new VertexStateUpdate(m3, VertexState.CONFIGURED));
manager.onVertexStateUpdated(new VertexStateUpdate(m2, VertexState.CONFIGURED));
manager.onSourceTaskCompleted(createTaskAttemptIdentifier(r1, 0));
- Assert.assertTrue(manager.pendingTasks.size() == 0); // all tasks scheduled
- Assert.assertTrue(scheduledTasks.size() == 3);
+ assertEquals(0, manager.pendingTasks.size()); // all tasks scheduled
+ assertEquals(3, scheduledTasks.size());
}
- @Test
- public void testZeroTasksSendsConfigured() throws IOException {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ public void testZeroTasksSendsConfigured(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager = null;
@@ -1089,7 +1100,7 @@ public void testZeroTasksSendsConfigured() throws IOException {
when(mockContext.getVertexNumTasks(mockManagedVertexId)).thenReturn(0);
// check initialization
- manager = createManager(conf, mockContext, 0.001f, 0.001f);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.001f, 0.001f);
final List scheduledTasks = Lists.newLinkedList();
doAnswer(new ScheduledTasksAnswer(scheduledTasks)).when(
@@ -1097,17 +1108,19 @@ public void testZeroTasksSendsConfigured() throws IOException {
manager.onVertexStarted(emptyCompletions);
manager.onVertexStateUpdated(new VertexStateUpdate(r1, VertexState.CONFIGURED));
- Assert.assertEquals(1, manager.bipartiteSources);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
- Assert.assertEquals(0, manager.totalNumBipartiteSourceTasks);
- Assert.assertEquals(0, manager.pendingTasks.size()); // no tasks scheduled
- Assert.assertEquals(0, scheduledTasks.size());
+ assertEquals(1, manager.bipartiteSources);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(0, manager.totalNumBipartiteSourceTasks);
+ assertEquals(0, manager.pendingTasks.size()); // no tasks scheduled
+ assertEquals(0, scheduledTasks.size());
verify(mockContext).doneReconfiguringVertex();
}
- @Test(timeout=5000)
- public void testTezDrainCompletionsOnVertexStart() throws IOException {
+ @ParameterizedTest(name = "test[{0}]")
+ @MethodSource("data")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testTezDrainCompletionsOnVertexStart(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass) throws IOException {
Configuration conf = new Configuration();
ShuffleVertexManagerBase manager;
@@ -1123,17 +1136,17 @@ public void testTezDrainCompletionsOnVertexStart() throws IOException {
mockManagedVertexId, 4, scheduledTasks, null);
//min/max fraction of 0.01/0.75 would ensure that we hit determineParallelism code path on receiving first event itself.
- manager = createManager(conf, mockContext, 0.01f, 0.75f);
- Assert.assertEquals(0, manager.numBipartiteSourceTasksCompleted);
+ manager = createManager(shuffleVertexManagerClass, conf, mockContext, 0.01f, 0.75f);
+ assertEquals(0, manager.numBipartiteSourceTasksCompleted);
manager.onVertexStarted(Collections.singletonList(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 0)));
- Assert.assertEquals(1, manager.numBipartiteSourceTasksCompleted);
+ assertEquals(1, manager.numBipartiteSourceTasksCompleted);
}
- private ShuffleVertexManagerBase createManager(Configuration conf,
+ private ShuffleVertexManagerBase createManager(Class extends ShuffleVertexManagerBase> shuffleVertexManagerClass, Configuration conf,
VertexManagerPluginContext context, Float min, Float max) {
- return createManager(this.shuffleVertexManagerClass, conf, context, true,
+ return createManager(shuffleVertexManagerClass, conf, context, true,
null, min, max);
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerUtils.java b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerUtils.java
index 89c22dd8b6..d760b6b0da 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerUtils.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestShuffleVertexManagerUtils.java
@@ -18,7 +18,6 @@
*/
package org.apache.tez.dag.library.vertexmanager;
-
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyList;
@@ -62,6 +61,7 @@
import com.google.protobuf.ByteString;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.roaringbitmap.RoaringBitmap;
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestVertexManagerWithConcurrentInput.java b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestVertexManagerWithConcurrentInput.java
index 08891d80c7..886d5b5530 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestVertexManagerWithConcurrentInput.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/dag/library/vertexmanager/TestVertexManagerWithConcurrentInput.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.dag.library.vertexmanager;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -26,6 +27,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.dag.api.EdgeManagerPluginDescriptor;
import org.apache.tez.dag.api.EdgeProperty;
@@ -37,9 +39,7 @@
import org.apache.tez.dag.api.event.VertexStateUpdate;
import org.apache.tez.dag.library.edgemanager.SilentEdgeManager;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
@@ -49,12 +49,13 @@ public class TestVertexManagerWithConcurrentInput {
@Captor
ArgumentCaptor> requestCaptor;
- @Before
+ @BeforeEach
public void init() {
MockitoAnnotations.initMocks(this);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testBasicVertexWithConcurrentInput() throws Exception {
HashMap mockInputVertices =
new HashMap();
@@ -110,6 +111,6 @@ public void testBasicVertexWithConcurrentInput() throws Exception {
manager.onVertexStarted(Collections.singletonList(
TestShuffleVertexManager.createTaskAttemptIdentifier(mockSrcVertexId1, 0)));
verify(mockContext, times(1)).scheduleTasks(requestCaptor.capture());
- Assert.assertEquals(0, manager.completedUpstreamTasks);
+ assertEquals(0, manager.completedUpstreamTasks);
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/http/TestHttpConnection.java b/tez-runtime-library/src/test/java/org/apache/tez/http/TestHttpConnection.java
index b41e2c81c3..77d3a3910c 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/http/TestHttpConnection.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/http/TestHttpConnection.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.http;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -37,15 +36,14 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.common.security.JobTokenSecretManager;
import org.apache.tez.http.async.netty.AsyncHttpConnection;
import com.google.common.base.Throwables;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestHttpConnection {
@@ -66,7 +64,7 @@ public class TestHttpConnection {
private Thread currentThread;
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException, URISyntaxException {
executorService = Executors.newFixedThreadPool(1,
new ThreadFactory() {
@@ -81,7 +79,7 @@ public Thread newThread(Runnable r) {
when(tokenSecretManager.computeHash(any())).thenReturn("1234".getBytes());
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
executorService.shutdownNow();
}
@@ -93,16 +91,16 @@ public void baseTest(Callable worker, CountDownLatch latch, String message
Future future = executorService.submit(worker);
future.get();
} catch (ExecutionException e) {
- assertTrue(e.getCause().getCause() instanceof IOException);
- assertTrue(e.getMessage(), e.getMessage().contains(message));
+ assertInstanceOf(IOException.class, e.getCause().getCause());
+ assertTrue(e.getMessage().contains(message), e.getMessage());
long elapsedTime = System.currentTimeMillis() - startTime;
- assertTrue("elapasedTime=" + elapsedTime + " should be greater than " + connTimeout,
- elapsedTime > connTimeout);
+ assertTrue(elapsedTime > connTimeout, "elapasedTime=" + elapsedTime + " should be greater than " + connTimeout);
}
- assertTrue(latch.getCount() == 0);
+ assertEquals(0, latch.getCount());
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testConnectionTimeout() throws IOException, InterruptedException {
HttpConnectionParams params = getConnectionParams();
@@ -117,7 +115,8 @@ public void testConnectionTimeout() throws IOException, InterruptedException {
baseTest(new Worker(latch, asyncHttpConn, false), latch, "connection timed out");
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
//Should be interruptible
public void testAsyncHttpConnectionInterrupt()
throws IOException, InterruptedException, ExecutionException {
@@ -131,14 +130,14 @@ public void testAsyncHttpConnectionInterrupt()
wait(100);
}
}
- assertTrue("currentThread is still null", currentThread != null);
+ assertNotNull(currentThread, "currentThread is still null");
Thread.sleep(1000); //To avoid race to interrupt the thread before connect()
//Try interrupting the thread (exception verification happens in the worker itself)
currentThread.interrupt();
future.get();
- assertTrue(latch.getCount() == 0);
+ assertEquals(0, latch.getCount());
}
HttpConnectionParams getConnectionParams() {
@@ -185,12 +184,12 @@ public Void call() throws Exception {
if (expectingInterrupt) {
if (t instanceof ConnectException) {
//ClosedByInterruptException via NettyConnectListener.operationComplete()
- assertTrue("Expected ClosedByInterruptException, received "
- + Throwables.getStackTraceAsString(t.getCause()),
- t.getCause() instanceof ClosedByInterruptException);
+ assertInstanceOf(ClosedByInterruptException.class, t.getCause(),
+ "Expected ClosedByInterruptException, received "
+ + Throwables.getStackTraceAsString(t.getCause()));
} else {
// InterruptedException if TezBodyDeferringAsyncHandler quits
- assertTrue(t instanceof InterruptedException);
+ assertInstanceOf(InterruptedException.class, t);
}
}
} finally {
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/common/resources/TestWeightedScalingMemoryDistributor.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/common/resources/TestWeightedScalingMemoryDistributor.java
index 9a43d000fa..d443201a22 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/common/resources/TestWeightedScalingMemoryDistributor.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/common/resources/TestWeightedScalingMemoryDistributor.java
@@ -18,10 +18,12 @@
*/
package org.apache.tez.runtime.common.resources;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import java.util.concurrent.TimeUnit;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.InputDescriptor;
import org.apache.tez.dag.api.OutputDescriptor;
@@ -41,10 +43,11 @@
import com.google.common.base.Joiner;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestWeightedScalingMemoryDistributor extends TestMemoryDistributor {
+ @BeforeEach
@Override
public void setup() {
conf.setBoolean(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ENABLED, true);
@@ -54,7 +57,8 @@ public void setup() {
conf.setDouble(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ADDITIONAL_RESERVATION_FRACTION_PER_IO, 0.0d);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSimpleWeightedScaling() throws TezException {
Configuration conf = new Configuration(this.conf);
conf.setStrings(TezConfiguration.TEZ_TASK_SCALE_MEMORY_WEIGHTED_RATIOS,
@@ -101,7 +105,8 @@ public void testSimpleWeightedScaling() throws TezException {
assertEquals(2000, e4Callback.assigned);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAdditionalReserveFractionWeightedScaling() throws TezException {
Configuration conf = new Configuration(this.conf);
conf.setStrings(TezConfiguration.TEZ_TASK_SCALE_MEMORY_WEIGHTED_RATIOS,
@@ -148,7 +153,8 @@ public void testAdditionalReserveFractionWeightedScaling() throws TezException {
assertEquals(1500, e4Callback.assigned);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWeightedScalingNonConcurrent() throws TezException {
Configuration conf = new Configuration(this.conf);
conf.setBoolean(TezConfiguration.TEZ_TASK_SCALE_MEMORY_INPUT_OUTPUT_CONCURRENT, false);
@@ -205,7 +211,8 @@ public void testWeightedScalingNonConcurrent() throws TezException {
assertEquals(1000, e5Callback.assigned);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAdditionalReserveFractionWeightedScalingNonConcurrent() throws TezException {
Configuration conf = new Configuration(this.conf);
conf.setBoolean(TezConfiguration.TEZ_TASK_SCALE_MEMORY_INPUT_OUTPUT_CONCURRENT, false);
@@ -254,7 +261,8 @@ public void testAdditionalReserveFractionWeightedScalingNonConcurrent() throws T
assertEquals(4500, e4Callback.assigned);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWeightedScalingNonConcurrentInputsDisabled() throws TezException {
Configuration conf = new Configuration(this.conf);
conf.setBoolean(TezConfiguration.TEZ_TASK_SCALE_MEMORY_INPUT_OUTPUT_CONCURRENT, false);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/api/TestTezRuntimeConfiguration.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/api/TestTezRuntimeConfiguration.java
index 190e1e4def..e80e58d90c 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/api/TestTezRuntimeConfiguration.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/api/TestTezRuntimeConfiguration.java
@@ -18,20 +18,20 @@
*/
package org.apache.tez.runtime.library.api;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestTezRuntimeConfiguration {
-
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testKeySet() throws IllegalAccessException {
Class> c = TezRuntimeConfiguration.class;
Set expectedKeys = new HashSet();
@@ -47,7 +47,6 @@ public void testKeySet() throws IllegalAccessException {
fail("Found unexpected key: " + key + " in key set");
}
}
- assertTrue("Missing keys in key set: " + expectedKeys, expectedKeys.size() == 0);
+ assertEquals(0, expectedKeys.size(), "Missing keys in key set: " + expectedKeys);
}
-
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductCombination.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductCombination.java
index d0c73a6264..92d0bd2fdd 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductCombination.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductCombination.java
@@ -18,16 +18,14 @@
*/
package org.apache.tez.runtime.library.cartesianproduct;
-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.*;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import com.google.common.primitives.Ints;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestCartesianProductCombination {
private void verifyCombination(CartesianProductCombination combination, int[] result, int taskId) {
@@ -72,7 +70,8 @@ private void testCombinationThreeWay() {
assertFalse(combination.nextTaskWithFixedChunk());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCombinationWithFixedPartition() {
// two way cartesian product
testCombinationTwoWayVertex0();
@@ -82,7 +81,8 @@ public void testCombinationWithFixedPartition() {
testCombinationThreeWay();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCombination() {
CartesianProductCombination combination = new CartesianProductCombination(new int[]{2,3});
List list = combination.getCombination();
@@ -93,29 +93,31 @@ public void testCombination() {
} else {
assertTrue(combination.nextTask());
}
- assertTrue(list.get(0) == i);
- assertTrue(list.get(1) == j);
+ assertEquals((int) list.get(0), i);
+ assertEquals((int) list.get(1), j);
}
}
assertFalse(combination.nextTask());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testFromTaskId() {
for (int i = 0; i < 6; i++) {
List list = CartesianProductCombination.fromTaskId(new int[]{2,3}, i)
.getCombination();
- assertTrue(list.get(0) == i/3);
- assertTrue(list.get(1) == i%3);
+ assertEquals((int) list.get(0), i / 3);
+ assertEquals((int) list.get(1), i % 3);
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRejectZero() {
int[] numChunk = new int[] {0 ,1};
try {
new CartesianProductCombination(numChunk);
- assertTrue(false);
+ fail();
} catch (Exception ignored) {}
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductConfig.java
index eef23ba564..0790785135 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductConfig.java
@@ -18,10 +18,7 @@
*/
package org.apache.tez.runtime.library.cartesianproduct;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -30,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.UserPayload;
@@ -37,18 +35,18 @@
import com.google.common.primitives.Ints;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestCartesianProductConfig {
private TezConfiguration conf;
- @Before
+ @BeforeEach
public void setup() {
conf = new TezConfiguration();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSerializationPartitioned() throws IOException {
Map vertexPartitionMap = new HashMap<>();
vertexPartitionMap.put("v1", 2);
@@ -67,7 +65,8 @@ public void testSerializationPartitioned() throws IOException {
assertConfigEquals(config, parsedConfig);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSerializationFair() throws Exception {
List sourceVertices = new ArrayList<>();
sourceVertices.add("v1");
@@ -114,7 +113,8 @@ private void assertConfigEquals(CartesianProductConfig config1, CartesianProduct
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testFairCartesianProductConfig() {
List sourceVertices = new ArrayList<>();
sourceVertices.add("v0");
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManager.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManager.java
index a2bda18986..abec029a30 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManager.java
@@ -19,22 +19,24 @@
package org.apache.tez.runtime.library.cartesianproduct;
import static org.apache.tez.runtime.library.cartesianproduct.CartesianProductUserPayload.*;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.nio.ByteBuffer;
import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.dag.api.EdgeManagerPluginContext;
import org.apache.tez.dag.api.UserPayload;
import com.google.common.primitives.Ints;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestCartesianProductEdgeManager {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInitialize() throws Exception {
EdgeManagerPluginContext context = mock(EdgeManagerPluginContext.class);
when(context.getSourceVertexName()).thenReturn("v0");
@@ -49,8 +51,8 @@ public void testInitialize() throws Exception {
UserPayload payload = UserPayload.create(ByteBuffer.wrap(builder.build().toByteArray()));
when(context.getUserPayload()).thenReturn(payload);
edgeManager.initialize();
- assertTrue(edgeManager.getEdgeManagerReal()
- instanceof CartesianProductEdgeManagerPartitioned);
+ assertInstanceOf(CartesianProductEdgeManagerPartitioned.class,
+ edgeManager.getEdgeManagerReal());
// unpartitioned case
builder.clear();
@@ -62,7 +64,6 @@ public void testInitialize() throws Exception {
when(context.getUserPayload()).thenReturn(payload);
when(context.getSourceVertexNumTasks()).thenReturn(2);
edgeManager.initialize();
- assertTrue(edgeManager.getEdgeManagerReal()
- instanceof FairCartesianProductEdgeManager);
+ assertInstanceOf(FairCartesianProductEdgeManager.class, edgeManager.getEdgeManagerReal());
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManagerPartitioned.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManagerPartitioned.java
index eb746a8b4e..f0a0984444 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManagerPartitioned.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductEdgeManagerPartitioned.java
@@ -19,15 +19,13 @@
package org.apache.tez.runtime.library.cartesianproduct;
import static org.apache.tez.runtime.library.cartesianproduct.CartesianProductUserPayload.*;
-import static org.junit.Assert.assertArrayEquals;
-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.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.nio.ByteBuffer;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.dag.api.EdgeManagerPluginContext;
import org.apache.tez.dag.api.EdgeManagerPluginOnDemand.CompositeEventRouteMetadata;
@@ -36,14 +34,13 @@
import com.google.protobuf.ByteString;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestCartesianProductEdgeManagerPartitioned {
private EdgeManagerPluginContext mockContext;
private CartesianProductEdgeManagerPartitioned edgeManager;
- @Before
+ @BeforeEach
public void setup() {
mockContext = mock(EdgeManagerPluginContext.class);
edgeManager = new CartesianProductEdgeManagerPartitioned(mockContext);
@@ -53,7 +50,8 @@ public void setup() {
* Vertex v0 has 2 tasks which generate 3 partitions
* Vertex v1 has 3 tasks which generate 4 partitions
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTwoWay() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(true).addSources("v0").addSources("v1")
@@ -145,7 +143,8 @@ public boolean isValidCombination(Map vertexPartitionMap) {
* Vertex v0 has 2 tasks which generate 3 partitions
* Vertex v1 has 3 tasks which generate 4 partitions
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTwoWayWithFilter() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
ByteBuffer buffer = ByteBuffer.allocate(2).putChar('>');
@@ -212,7 +211,8 @@ private void testTwoWayV1WithFilter(CartesianProductConfigProto config) throws E
* Vertex v1 has 3 tasks which generate 3 partitions
* Vertex v2 has 4 tasks which generate 2 partitions
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testThreeWay() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(true).addSources("v0").addSources("v1").addSources("v2")
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManager.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManager.java
index 5f3c65da7b..bc876aa4b7 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManager.java
@@ -20,7 +20,7 @@
import static org.apache.tez.dag.api.EdgeProperty.DataMovementType.BROADCAST;
import static org.apache.tez.dag.api.EdgeProperty.DataMovementType.CUSTOM;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.dag.api.EdgeManagerPluginDescriptor;
import org.apache.tez.dag.api.EdgeProperty;
@@ -37,8 +38,7 @@
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.api.VertexManagerPluginContext;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -56,7 +56,7 @@ public class TestCartesianProductVertexManager {
private EdgeProperty broadcastEdge =
EdgeProperty.create(DataMovementType.BROADCAST, null, null, null, null);
- @Before
+ @BeforeEach
public void setup() {
context = mock(VertexManagerPluginContext.class);
conf = new TezConfiguration();
@@ -75,22 +75,24 @@ public UserPayload answer(InvocationOnMock invocation) throws Throwable {
vertexManager = new CartesianProductVertexManager(context);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testRejectPredefinedParallelism() throws Exception {
when(context.getVertexNumTasks(vertexName)).thenReturn(10);
try {
vertexManager = new CartesianProductVertexManager(context);
- assertTrue(false);
+ fail();
} catch (Exception ignored){}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testChooseRealVertexManager() throws Exception {
// partitioned case
config = new CartesianProductConfig(new int[]{2, 3}, new String[]{"v0", "v1"}, null);
vertexManager.initialize();
- assertTrue(vertexManager.getVertexManagerReal()
- instanceof CartesianProductVertexManagerPartitioned);
+ assertInstanceOf(CartesianProductVertexManagerPartitioned.class,
+ vertexManager.getVertexManagerReal());
// unpartitioned case
List sourceVertices = new ArrayList<>();
@@ -98,11 +100,11 @@ public void testChooseRealVertexManager() throws Exception {
sourceVertices.add("v1");
config = new CartesianProductConfig(sourceVertices);
vertexManager.initialize();
- assertTrue(vertexManager.getVertexManagerReal()
- instanceof FairCartesianProductVertexManager);
+ assertInstanceOf(FairCartesianProductVertexManager.class, vertexManager.getVertexManagerReal());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCheckDAGConfigConsistent() throws Exception {
// positive case
edgePropertyMap.put("v2", broadcastEdge);
@@ -113,7 +115,7 @@ public void testCheckDAGConfigConsistent() throws Exception {
edgePropertyMap.put("v2", cpEdge);
try {
vertexManager.initialize();
- assertTrue(false);
+ fail();
} catch (Exception ignored) {}
// non-cartesian-product edge in dag but in config
@@ -121,24 +123,25 @@ public void testCheckDAGConfigConsistent() throws Exception {
config = new CartesianProductConfig(new int[]{2, 3, 4}, new String[]{"v0", "v1", "v2"}, null);
try {
vertexManager.initialize();
- assertTrue(false);
+ fail();
} catch (Exception ignored) {}
edgePropertyMap.put("v2", customEdge);
try {
vertexManager.initialize();
- assertTrue(false);
+ fail();
} catch (Exception ignored) {}
// edge in config but not in dag
edgePropertyMap.remove("v2");
try {
vertexManager.initialize();
- assertTrue(false);
+ fail();
} catch (Exception ignored) {}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCheckDAGConfigConsistentWithVertexGroup() throws Exception {
// positive case
edgePropertyMap.put("v2", cpEdge);
@@ -152,18 +155,19 @@ public void testCheckDAGConfigConsistentWithVertexGroup() throws Exception {
edgePropertyMap.put("v2", broadcastEdge);
try {
vertexManager.initialize();
- assertTrue(false);
+ fail();
} catch (Exception ignored) {}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOtherEdgeType() throws Exception {
// forbid other custom edge
edgePropertyMap.put("v2", customEdge);
config = new CartesianProductConfig(new int[]{2, 3}, new String[]{"v0", "v1"}, null);
try {
vertexManager.initialize();
- assertTrue(false);
+ fail();
} catch (Exception ignored) {}
// broadcast edge should be allowed and other non-custom edge shouldn't be allowed
@@ -174,9 +178,9 @@ public void testOtherEdgeType() throws Exception {
edgePropertyMap.put("v2", EdgeProperty.create(type, null, null, null, null));
try {
vertexManager.initialize();
- assertTrue(type == BROADCAST);
+ assertSame(type, BROADCAST);
} catch (Exception e) {
- assertTrue(type != BROADCAST);
+ assertNotSame(type, BROADCAST);
}
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManagerPartitioned.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManagerPartitioned.java
index 39e28844af..314c647d8e 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManagerPartitioned.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestCartesianProductVertexManagerPartitioned.java
@@ -19,8 +19,7 @@
package org.apache.tez.runtime.library.cartesianproduct;
import static org.apache.tez.dag.api.EdgeProperty.DataMovementType.BROADCAST;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.isNull;
@@ -34,6 +33,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.dag.api.EdgeManagerPluginDescriptor;
import org.apache.tez.dag.api.EdgeProperty;
@@ -51,8 +51,7 @@
import org.apache.tez.runtime.api.TaskAttemptIdentifier;
import org.apache.tez.runtime.library.cartesianproduct.CartesianProductUserPayload.CartesianProductConfigProto;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
@@ -66,7 +65,7 @@ public class TestCartesianProductVertexManagerPartitioned {
private VertexManagerPluginContext context;
private List allCompletions;
- @Before
+ @BeforeEach
public void setup() throws TezReflectionException {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(true).addSources("v0").addSources("v1")
@@ -116,7 +115,8 @@ private void testReconfigureVertexHelper(CartesianProductConfigProto config,
assertNull(edgePropertiesCaptor.getValue());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testReconfigureVertex() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(true).addSources("v0").addSources("v1")
@@ -126,7 +126,8 @@ public void testReconfigureVertex() throws Exception {
testReconfigureVertexHelper(builder.build(), 25);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testScheduling() throws Exception {
vertexManager.onVertexStarted(null);
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
@@ -166,12 +167,14 @@ public void testScheduling() throws Exception {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOnVertexStartWithBroadcastRunning() throws Exception {
testOnVertexStartHelper(true);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOnVertexStartWithoutBroadcastRunning() throws Exception {
testOnVertexStartHelper(false);
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductEdgeManager.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductEdgeManager.java
index 6fec6256e7..ee7474b476 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductEdgeManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductEdgeManager.java
@@ -19,25 +19,23 @@
package org.apache.tez.runtime.library.cartesianproduct;
import static org.apache.tez.runtime.library.cartesianproduct.CartesianProductUserPayload.*;
-import static org.junit.Assert.assertArrayEquals;
-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.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.util.concurrent.TimeUnit;
+
import org.apache.tez.dag.api.EdgeManagerPluginContext;
import org.apache.tez.dag.api.EdgeManagerPluginOnDemand.CompositeEventRouteMetadata;
import org.apache.tez.dag.api.EdgeManagerPluginOnDemand.EventRouteMetadata;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestFairCartesianProductEdgeManager {
private EdgeManagerPluginContext mockContext;
private FairCartesianProductEdgeManager edgeManager;
- @Before
+ @BeforeEach
public void setup() {
mockContext = mock(EdgeManagerPluginContext.class);
edgeManager = new FairCartesianProductEdgeManager(mockContext);
@@ -127,7 +125,8 @@ private void testEdgeManager(CartesianProductConfigProto conf, String vName, int
* Vertex v0 has 2 tasks, 2 chunks
* Vertex v1 has 30 tasks, 3 chunks
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTwoWayAllVertex() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(false).addSources("v0").addSources("v1")
@@ -150,7 +149,8 @@ public void testTwoWayAllVertex() throws Exception {
* Vertex v1 has 30 tasks, 3 chunks
* Vertex v2 has 1 tasks, 4 chunks
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testThreeWayAllVertex() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(false).addSources("v0").addSources("v1").addSources("v2")
@@ -181,7 +181,8 @@ null, dataForRouting(0, 13, EventRouteMetadata.create(3, new int[]{0,1,2})),
* Vertex v2 has 20 tasks
* Group g0 has 3 chunks
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTwoWayVertexWithVertexGroup() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(false).addSources("v0").addSources("g0")
@@ -208,7 +209,8 @@ public void testTwoWayVertexWithVertexGroup() throws Exception {
* Group g0 has 2 chunks
* Group g1 has 3 chunks
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testTwoWayAllVertexGroup() throws Exception {
CartesianProductConfigProto.Builder builder = CartesianProductConfigProto.newBuilder();
builder.setIsPartitioned(false).addSources("g0").addSources("g1")
@@ -227,7 +229,8 @@ public void testTwoWayAllVertexGroup() throws Exception {
dataForInputError(1, 15, 0), dataForDest(1, 25), dataForSrc(1, 10), dataForSrc(1, 3));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNumPartition() throws Exception {
when(mockContext.getSourceVertexName()).thenReturn("source");
when(mockContext.getSourceVertexNumTasks()).thenReturn(10);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductVertexManager.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductVertexManager.java
index ca7448ef0f..c7e355f493 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductVertexManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestFairCartesianProductVertexManager.java
@@ -19,9 +19,7 @@
package org.apache.tez.runtime.library.cartesianproduct;
import static org.apache.tez.dag.api.EdgeProperty.DataMovementType.BROADCAST;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyMap;
@@ -37,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.dag.api.EdgeManagerPluginDescriptor;
import org.apache.tez.dag.api.EdgeProperty;
@@ -58,8 +57,7 @@
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
@@ -72,7 +70,7 @@ public class TestFairCartesianProductVertexManager {
private FairCartesianProductVertexManager vertexManager;
private VertexManagerPluginContext ctx;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.openMocks(this);
ctx = mock(VertexManagerPluginContext.class);
@@ -218,7 +216,8 @@ private void verifyScheduleRequest(int expectedTimes, int... expectedTid) {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGVertexOnlyGroupByMaxParallelism() throws Exception {
setupDAGVertexOnly(30, 1, 30, 1);
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
@@ -246,7 +245,8 @@ public void testDAGVertexOnlyGroupByMaxParallelism() throws Exception {
verifyScheduleRequest(2, 12, 13, 18, 19, 24, 25);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGVertexOnlyGroupByMinOpsPerWorker() throws Exception {
setupDAGVertexOnly(100, 10000, 10, 10);
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
@@ -278,7 +278,8 @@ public void testDAGVertexOnlyGroupByMinOpsPerWorker() throws Exception {
verifyScheduleRequest(1, 1);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGVertexGroup() throws Exception {
setupDAGVertexGroup(100, 1, 1);
@@ -310,7 +311,8 @@ public void testDAGVertexGroup() throws Exception {
verifyScheduleRequest(2, 1, 6, 11, 16, 21, 26, 31, 36, 41, 46);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDAGVertexGroupOnly() throws Exception {
setupDAGVertexGroupOnly(100, 1, 1);
@@ -345,7 +347,8 @@ public void testDAGVertexGroupOnly() throws Exception {
verifyScheduleRequest(1, 3, 13, 23);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSchedulingVertexOnlyWithBroadcast() throws Exception {
setupDAGVertexOnlyWithBroadcast(30, 1, 1);
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
@@ -366,7 +369,8 @@ public void testSchedulingVertexOnlyWithBroadcast() throws Exception {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOnVertexStart() throws Exception {
setupDAGVertexOnly(6, 1, 6, 1);
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
@@ -380,7 +384,8 @@ public void testOnVertexStart() throws Exception {
verifyScheduleRequest(1, 0);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testZeroSrcTask() throws Exception {
ctx = mock(VertexManagerPluginContext.class);
vertexManager = new FairCartesianProductVertexManager(ctx);
@@ -420,7 +425,8 @@ private void setupGroupingFractionTest() throws Exception {
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v1", VertexState.CONFIGURED));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGroupingFraction() throws Exception {
setupGroupingFractionTest();
vertexManager.onVertexManagerEventReceived(getVMEvent(10000, "v0", 0));
@@ -439,7 +445,8 @@ public void testGroupingFraction() throws Exception {
eq(24), any(), edgePropertiesCaptor.capture());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGroupFractionWithZeroStats() throws Exception {
setupGroupingFractionTest();
@@ -453,7 +460,8 @@ public void testGroupFractionWithZeroStats() throws Exception {
anyInt(), any(), anyMap());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGroupingFractionWithZeroOutput() throws Exception {
setupGroupingFractionTest();
@@ -467,7 +475,8 @@ public void testGroupingFractionWithZeroOutput() throws Exception {
eq(0), any(), edgePropertiesCaptor.capture());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testZeroSrcOutput() throws Exception {
setupDAGVertexOnly(10, 1, 10, 1);
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
@@ -481,7 +490,8 @@ public void testZeroSrcOutput() throws Exception {
eq(0), any(), edgePropertiesCaptor.capture());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDisableGrouping() throws Exception {
when(ctx.getInputVertexEdgeProperties()).thenReturn(getEdgePropertyMap(2));
setSrcParallelism(ctx, 1, 2, 3);
@@ -500,7 +510,8 @@ public void testDisableGrouping() throws Exception {
eq(6), any(), edgePropertiesCaptor.capture());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testParallelismTwoSkewedSource() throws Exception {
setupDAGVertexOnly(100, 10000, 10, 10);
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
@@ -519,7 +530,8 @@ public void testParallelismTwoSkewedSource() throws Exception {
new int[]{99, 1}, 100);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testParallelismThreeSkewedSource() throws Exception {
when(ctx.getInputVertexEdgeProperties()).thenReturn(getEdgePropertyMap(3));
setSrcParallelism(ctx, 10, 2, 3, 4);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestGrouper.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestGrouper.java
index bb87d37999..7b57a9b460 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestGrouper.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/cartesianproduct/TestGrouper.java
@@ -18,18 +18,19 @@
*/
package org.apache.tez.runtime.library.cartesianproduct;
-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.*;
+
+import java.util.concurrent.TimeUnit;
import org.apache.tez.runtime.library.utils.Grouper;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestGrouper {
private Grouper grouper = new Grouper();
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEvenlyGrouping() {
grouper.init(4, 2);
assertEquals(0, grouper.getFirstItemInGroup(0));
@@ -44,7 +45,8 @@ public void testEvenlyGrouping() {
assertFalse(grouper.isInGroup(2, 0));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testUnevenlyGrouping() {
grouper.init(5, 2);
assertEquals(0, grouper.getFirstItemInGroup(0));
@@ -59,7 +61,8 @@ public void testUnevenlyGrouping() {
assertFalse(grouper.isInGroup(3, 0));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSingleGroup() {
grouper.init(4, 1);
assertEquals(0, grouper.getFirstItemInGroup(0));
@@ -70,7 +73,8 @@ public void testSingleGroup() {
assertTrue(grouper.isInGroup(3, 0));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNoGrouping() {
grouper.init(2, 2);
assertEquals(0, grouper.getFirstItemInGroup(0));
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestConfigUtils.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestConfigUtils.java
index b3a8884530..01daa5f225 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestConfigUtils.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestConfigUtils.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.runtime.library.common;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.DataInput;
import java.io.DataOutput;
@@ -29,7 +29,8 @@
import org.apache.hadoop.io.WritableComparator;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestConfigUtils {
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestInputIdentifiers.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestInputIdentifiers.java
index 8456299e23..b147b5ae76 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestInputIdentifiers.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestInputIdentifiers.java
@@ -18,15 +18,18 @@
*/
package org.apache.tez.runtime.library.common;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestInputIdentifiers {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAttemptIdentifier() {
Set set = new HashSet();
InputAttemptIdentifier i1 = new InputAttemptIdentifier(1, 1, InputAttemptIdentifier.PATH_PREFIX);
@@ -34,14 +37,15 @@ public void testInputAttemptIdentifier() {
InputAttemptIdentifier i3 = new InputAttemptIdentifier(1, 0, null);
InputAttemptIdentifier i4 = new InputAttemptIdentifier(0, 1, null);
- Assert.assertTrue(set.add(i1));
- Assert.assertFalse(set.add(i1));
- Assert.assertFalse(set.add(i2));
- Assert.assertTrue(set.add(i3));
- Assert.assertTrue(set.add(i4));
+ assertTrue(set.add(i1));
+ assertFalse(set.add(i1));
+ assertFalse(set.add(i2));
+ assertTrue(set.add(i3));
+ assertTrue(set.add(i4));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAttemptIdentifierIncludes() {
InputAttemptIdentifier inputData0Attempt0 = new InputAttemptIdentifier(0, 0);
InputAttemptIdentifier inputData1Attempt0 = new InputAttemptIdentifier(1, 0);
@@ -50,14 +54,14 @@ public void testInputAttemptIdentifierIncludes() {
InputAttemptIdentifier inputData1Attempt1 = new InputAttemptIdentifier(1, 1);
CompositeInputAttemptIdentifier inputData12Attempt0 = new CompositeInputAttemptIdentifier(1, 0, null, 2);
- Assert.assertTrue(inputData1Attempt0.includes(inputData1Attempt0));
- Assert.assertFalse(inputData1Attempt0.includes(inputData2Attempt0));
- Assert.assertFalse(inputData1Attempt0.includes(inputData1Attempt1));
+ assertTrue(inputData1Attempt0.includes(inputData1Attempt0));
+ assertFalse(inputData1Attempt0.includes(inputData2Attempt0));
+ assertFalse(inputData1Attempt0.includes(inputData1Attempt1));
- Assert.assertFalse(inputData12Attempt0.includes(inputData0Attempt0));
- Assert.assertTrue(inputData12Attempt0.includes(inputData1Attempt0));
- Assert.assertTrue(inputData12Attempt0.includes(inputData2Attempt0));
- Assert.assertFalse(inputData12Attempt0.includes(inputData3Attempt0));
- Assert.assertFalse(inputData12Attempt0.includes(inputData1Attempt1));
+ assertFalse(inputData12Attempt0.includes(inputData0Attempt0));
+ assertTrue(inputData12Attempt0.includes(inputData1Attempt0));
+ assertTrue(inputData12Attempt0.includes(inputData2Attempt0));
+ assertFalse(inputData12Attempt0.includes(inputData3Attempt0));
+ assertFalse(inputData12Attempt0.includes(inputData1Attempt1));
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestValuesIterator.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestValuesIterator.java
index ac4d387eb5..fe1c199791 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestValuesIterator.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/TestValuesIterator.java
@@ -18,10 +18,7 @@
*/
package org.apache.tez.runtime.library.common;
-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.*;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -37,6 +34,7 @@
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -80,11 +78,9 @@
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.params.*;
+import org.junit.jupiter.params.provider.*;
import org.mockito.internal.util.collections.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -107,7 +103,6 @@
* limitations under the License.
*/
-@RunWith(Parameterized.class)
public class TestValuesIterator {
private static final Logger LOG = LoggerFactory.getLogger(TestValuesIterator.class);
@@ -123,13 +118,13 @@ enum TestWithComparator {
static final Random rnd = new Random();
private SerializationContext serializationContext;
- final RawComparator comparator;
- final RawComparator correctComparator;
- final boolean expectedTestResult;
+ RawComparator comparator;
+ RawComparator correctComparator;
+ boolean expectedTestResult;
int mergeFactor;
//For storing original data
- final ListMultimap originalData;
+ ListMultimap originalData;
TezRawKeyValueIterator rawKeyValueIterator;
@@ -137,26 +132,17 @@ enum TestWithComparator {
Path tmpDir;
Path[] streamPaths; //merge stream paths
- /**
- * Constructor
- *
- * @param serializationClassName serialization class to be used
- * @param key key class name
- * @param val value class name
- * @param comparator to be used
- * @param correctComparator (real comparator to be used for correct results)
- * @param testResult expected result
- * @throws IOException
- */
- public TestValuesIterator(String serializationClassName, Class> key, Class> val,
+ public void setupInit(String serializationClassName, Class> key, Class> val,
TestWithComparator comparator, TestWithComparator correctComparator, boolean testResult)
- throws IOException {
+ throws Exception {
this.comparator = getComparator(comparator);
this.correctComparator =
(correctComparator == null) ? this.comparator : getComparator(correctComparator);
this.expectedTestResult = testResult;
originalData = LinkedListMultimap.create();
setupConf(key, val, serializationClassName);
+ fs.mkdirs(baseDir);
+ tmpDir = new Path(baseDir, "tmp");
}
private void setupConf(Class> key, Class> val, String serializationClassName) throws IOException {
@@ -178,37 +164,43 @@ private void setupConf(Class> key, Class> val, String serializationClassName
serializationContext.applyToConf(conf);
}
- @Before
- public void setup() throws Exception {
- fs.mkdirs(baseDir);
- tmpDir = new Path(baseDir, "tmp");
- }
-
- @After
+ @AfterEach
public void cleanup() throws Exception {
fs.delete(baseDir, true);
originalData.clear();
}
- @Test(timeout = 20000)
- public void testIteratorWithInMemoryReader() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}, {5}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
+ public void testIteratorWithInMemoryReader(String serializationClassName, Class> key, Class> val, TestWithComparator comparator, TestWithComparator correctComparator, boolean testResult) throws Exception {
+ setupInit(serializationClassName, key, val, comparator, correctComparator, testResult);
ValuesIterator iterator = createIterator(true);
verifyIteratorData(iterator);
}
- @Test(timeout = 20000)
- public void testIteratorWithIFileReader() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}, {5}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
+ public void testIteratorWithIFileReader(String serializationClassName, Class> key, Class> val, TestWithComparator comparator, TestWithComparator correctComparator, boolean testResult) throws Exception {
+ setupInit(serializationClassName, key, val, comparator, correctComparator, testResult);
ValuesIterator iterator = createIterator(false);
verifyIteratorData(iterator);
}
- @Test(timeout = 20000)
- public void testCountedIteratorWithInmemoryReader() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}, {5}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
+ public void testCountedIteratorWithInmemoryReader(String serializationClassName, Class> key, Class> val, TestWithComparator comparator, TestWithComparator correctComparator, boolean testResult) throws Exception {
+ setupInit(serializationClassName, key, val, comparator, correctComparator, testResult);
verifyCountedIteratorReader(true);
}
- @Test(timeout = 20000)
- public void testCountedIteratorWithIFileReader() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}, {5}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
+ public void testCountedIteratorWithIFileReader(String serializationClassName, Class> key, Class> val, TestWithComparator comparator, TestWithComparator correctComparator, boolean testResult) throws Exception {
+ setupInit(serializationClassName, key, val, comparator, correctComparator, testResult);
verifyCountedIteratorReader(false);
}
@@ -228,13 +220,16 @@ private void verifyCountedIteratorReader(boolean inMemory) throws IOException, I
}
}
- @Test(timeout = 20000)
- public void testIteratorWithIFileReaderEmptyPartitions() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}, {5}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
+ public void testIteratorWithIFileReaderEmptyPartitions(String serializationClassName, Class> key, Class> val, TestWithComparator comparator, TestWithComparator correctComparator, boolean testResult) throws Exception {
+ setupInit(serializationClassName, key, val, comparator, correctComparator, testResult);
ValuesIterator iterator = createEmptyIterator(false);
- assertTrue(iterator.moveToNext() == false);
+ assertFalse(iterator.moveToNext());
iterator = createEmptyIterator(true);
- assertTrue(iterator.moveToNext() == false);
+ assertFalse(iterator.moveToNext());
}
private void getNextFromFinishedIterator(ValuesIterator iterator) {
@@ -324,7 +319,7 @@ private List verifyIteratorData(
valueCount++;
}
sequence.add(valueCount);
- assertTrue("At least 1 value per key", valueCount > 0);
+ assertTrue(valueCount > 0, "At least 1 value per key");
}
if (expectedTestResult) {
assertTrue(result);
@@ -403,7 +398,7 @@ comparator, new ProgressReporter(), new GenericCounter("readsCounter", "y"),
serializationContext.getValueClass(), conf, keyCounter, tupleCounter);
}
- @Parameterized.Parameters(name = "test[{0}, {1}, {2}, {3} {4} {5} {6}]")
+
public static Collection getParameters() {
Collection parameters = new ArrayList();
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/comparator/TestProxyComparator.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/comparator/TestProxyComparator.java
index 96aac692f5..3a0b3d5d46 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/comparator/TestProxyComparator.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/comparator/TestProxyComparator.java
@@ -18,15 +18,14 @@
*/
package org.apache.tez.runtime.library.common.comparator;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.nio.charset.Charset;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.io.BytesWritable;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,16 +48,17 @@ private static final void set(BytesWritable bw, String s) {
bw.set(b, 0, b.length);
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
}
@SuppressWarnings("unchecked")
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testProxyComparator() {
final ProxyComparator comparator = new TezBytesComparator();
BytesWritable lhs = new BytesWritable();
@@ -70,12 +70,10 @@ public void testProxyComparator() {
final int lproxy = comparator.getProxy(lhs);
final int rproxy = comparator.getProxy(rhs);
if (lproxy < rproxy) {
- assertTrue(String.format("(%s) %d < (%s) %d", l, lproxy, r, rproxy),
- comparator.compare(lhs, rhs) < 0);
+ assertTrue(comparator.compare(lhs, rhs) < 0, String.format("(%s) %d < (%s) %d", l, lproxy, r, rproxy));
}
if (lproxy > rproxy) {
- assertTrue(String.format("(%s) %d > (%s) %d", l, lproxy, r, rproxy),
- comparator.compare(lhs, rhs) > 0);
+ assertTrue(comparator.compare(lhs, rhs) > 0, String.format("(%s) %d > (%s) %d", l, lproxy, r, rproxy));
}
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/readers/TestUnorderedKVReader.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/readers/TestUnorderedKVReader.java
index 75b3af9232..42569172fe 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/readers/TestUnorderedKVReader.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/readers/TestUnorderedKVReader.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.runtime.library.common.readers;
-import static junit.framework.TestCase.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
@@ -27,6 +27,7 @@
import java.io.IOException;
import java.util.LinkedList;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -47,10 +48,7 @@
import org.apache.tez.runtime.library.common.shuffle.impl.ShuffleManager;
import org.apache.tez.runtime.library.common.sort.impl.IFile;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
@@ -85,7 +83,7 @@ public class TestUnorderedKVReader {
}
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
outputPath = new Path(workDir, outputFileName);
setupReader();
@@ -145,13 +143,13 @@ private void createIFile(Path path, int recordCount) throws IOException {
out.close();
}
- @Before
- @After
+ @AfterEach
public void cleanup() throws Exception {
localFs.delete(workDir, true);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testReadingMultipleTimes() throws Exception {
int counter = 0;
while (unorderedKVReader.next()) {
@@ -159,18 +157,19 @@ public void testReadingMultipleTimes() throws Exception {
unorderedKVReader.getCurrentKey();
counter++;
}
- Assert.assertEquals(1, counter);
+ assertEquals(1, counter);
//Check the reader again. This shouldn't throw EOF exception in IFile
try {
boolean next = unorderedKVReader.next();
fail();
} catch(IOException ioe) {
- Assert.assertTrue(ioe.getMessage().contains("For usage, please refer to"));
+ assertTrue(ioe.getMessage().contains("For usage, please refer to"));
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInterruptOnNext() throws IOException, InterruptedException {
ShuffleManager shuffleManager = mock(ShuffleManager.class);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java
index 5fe155a3d6..f3d3ecd6fb 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestFetcher.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyLong;
@@ -39,6 +40,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -50,6 +52,9 @@
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.shuffle.FetchedInput.Type;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.FetcherBuilder;
+import org.apache.tez.runtime.library.common.shuffle.Fetcher.PathPartition;
import org.apache.tez.runtime.library.common.shuffle.api.ShuffleHandlerError;
import org.apache.tez.runtime.library.common.shuffle.impl.ShuffleManager;
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.ShuffleHeader;
@@ -58,8 +63,7 @@
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -69,7 +73,8 @@ public class TestFetcher {
private static String HOST = "localhost";
private static int PORT = 41;
- @Test(timeout = 3000)
+ @Test
+ @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
public void testLocalFetchModeSetting() throws Exception {
TezConfiguration conf = new TezConfiguration();
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, true);
@@ -148,7 +153,8 @@ public void testLocalFetchModeSetting() throws Exception {
verify(fetcher).doHttpFetch();
}
- @Test(timeout = 3000)
+ @Test
+ @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
public void testSetupLocalDiskFetch() throws Exception {
CompositeInputAttemptIdentifier[] srcAttempts = {
@@ -166,7 +172,7 @@ public void testSetupLocalDiskFetch() throws Exception {
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, "true");
int partition = 42;
FetcherCallback callback = mock(FetcherCallback.class);
- Fetcher.FetcherBuilder builder = new Fetcher.FetcherBuilder(callback, null, null,
+ FetcherBuilder builder = new FetcherBuilder(callback, null, null,
createMockInputContext(), null, conf, true, HOST, PORT,
false, true, true);
ArrayList inputAttemptIdentifiers = new ArrayList<>();
@@ -182,8 +188,8 @@ public void testSetupLocalDiskFetch() throws Exception {
for(CompositeInputAttemptIdentifier compositeInputAttemptIdentifier : srcAttempts) {
for(int i=0;i pendingInputs = Lists.newArrayList(fetchResult.getPendingInputs());
- Assert.assertEquals("fetchResult pendingInput size", pendingInputs.size(), 2);
- Assert.assertEquals("fetchResult failed attempt", pendingInputs.get(0),
- srcAttempts[FIRST_FAILED_ATTEMPT_IDX]);
- Assert.assertEquals("fetchResult failed attempt", pendingInputs.get(1),
- srcAttempts[SECOND_FAILED_ATTEMPT_IDX]);
+ assertEquals(pendingInputs.size(), 2, "fetchResult pendingInput size");
+ assertEquals(pendingInputs.get(0), srcAttempts[FIRST_FAILED_ATTEMPT_IDX], "fetchResult failed attempt");
+ assertEquals(pendingInputs.get(1), srcAttempts[SECOND_FAILED_ATTEMPT_IDX], "fetchResult failed attempt");
}
protected void verifyFetchSucceeded(FetcherCallback callback, CompositeInputAttemptIdentifier srcAttempId, Configuration conf) throws IOException {
@@ -257,16 +261,16 @@ protected void verifyFetchSucceeded(FetcherCallback callback, CompositeInputAtte
.fetchSucceeded(eq(HOST), eq(srcAttempId.expand(0)), capturedFetchedInput.capture(), eq(p * 100),
eq(p * 1000), anyLong());
LocalDiskFetchedInput f = capturedFetchedInput.getValue();
- Assert.assertEquals("success callback filename", f.getInputFile().toString(),
- SHUFFLE_INPUT_FILE_PREFIX + pathComponent);
- Assert.assertTrue("success callback fs", f.getLocalFS() instanceof RawLocalFileSystem);
- Assert.assertEquals("success callback filesystem", f.getStartOffset(), p * 10);
- Assert.assertEquals("success callback compressed size", f.getSize(), p * 100);
- Assert.assertEquals("success callback input id", f.getInputAttemptIdentifier(), srcAttempId.expand(0));
- Assert.assertEquals("success callback type", f.getType(), FetchedInput.Type.DISK_DIRECT);
+ assertEquals(f.getInputFile().toString(), SHUFFLE_INPUT_FILE_PREFIX + pathComponent, "success callback filename");
+ assertInstanceOf(RawLocalFileSystem.class, f.getLocalFS(), "success callback fs");
+ assertEquals(f.getStartOffset(), p * 10, "success callback filesystem");
+ assertEquals(f.getSize(), p * 100, "success callback compressed size");
+ assertEquals(f.getInputAttemptIdentifier(), srcAttempId.expand(0), "success callback input id");
+ assertEquals(f.getType(), Type.DISK_DIRECT, "success callback type");
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAttemptIdentifierMap() {
InputAttemptIdentifier[] srcAttempts = {
new InputAttemptIdentifier(0, 1, InputAttemptIdentifier.PATH_PREFIX + "pathComponent_0",
@@ -311,12 +315,12 @@ public void testInputAttemptIdentifierMap() {
builder.assignWork(HOST, PORT, partition, 1, Arrays.asList(srcAttempts));
Fetcher fetcher = spy(builder.build());
fetcher.populateRemainingMap(new LinkedList(Arrays.asList(srcAttempts)));
- Assert.assertTrue(expectedSrcAttempts.length == fetcher.srcAttemptsRemaining.size());
+ assertEquals(expectedSrcAttempts.length, fetcher.srcAttemptsRemaining.size());
Iterator> iterator = fetcher.srcAttemptsRemaining.entrySet().iterator();
int count = 0;
while(iterator.hasNext()) {
String key = iterator.next().getKey();
- Assert.assertTrue(expectedSrcAttempts[count++].toString().compareTo(key) == 0);
+ assertEquals(0, expectedSrcAttempts[count++].toString().compareTo(key));
}
}
@@ -341,9 +345,9 @@ null, createMockInputContext(), null, conf, true, HOST, PORT,
InputAttemptFetchFailure[] failures =
fetcher.fetchInputs(input, null, new InputAttemptIdentifier(0, 0));
- Assert.assertEquals(1, failures.length);
- Assert.assertTrue(failures[0].isDiskErrorAtSource());
- Assert.assertFalse(failures[0].isLocalFetch());
+ assertEquals(1, failures.length);
+ assertTrue(failures[0].isDiskErrorAtSource());
+ assertFalse(failures[0].isLocalFetch());
}
private InputContext createMockInputContext() {
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestShuffleUtils.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestShuffleUtils.java
index 20d2dda6b5..6a1675b33c 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestShuffleUtils.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/TestShuffleUtils.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
@@ -73,29 +74,10 @@
import com.google.common.collect.Lists;
import com.google.protobuf.ByteString;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentMatchers;
import org.slf4j.Logger;
-/**
- * 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.
- */
public class TestShuffleUtils {
private OutputContext outputContext;
@@ -138,7 +120,7 @@ private OutputContext createTezOutputContext() throws IOException {
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
conf = new Configuration();
outputContext = createTezOutputContext();
@@ -192,24 +174,25 @@ public void testGenerateOnSpillEvent() throws Exception {
outputContext, spillId, new TezSpillRecord(indexFile, conf),
physicalOutputs, true, pathComponent, null, false, auxiliaryService, TezCommonUtils.newBestCompressionDeflater());
- Assert.assertTrue(events.size() == 1);
- Assert.assertTrue(events.get(0) instanceof CompositeDataMovementEvent);
+ assertEquals(1, events.size());
+ assertInstanceOf(CompositeDataMovementEvent.class, events.get(0));
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(0);
- Assert.assertTrue(cdme.getCount() == physicalOutputs);
- Assert.assertTrue(cdme.getSourceIndexStart() == 0);
+ assertEquals(physicalOutputs, cdme.getCount());
+ assertEquals(0, cdme.getSourceIndexStart());
ByteBuffer payload = cdme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto dmeProto =
ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(payload));
- Assert.assertTrue(dmeProto.getSpillId() == 0);
- Assert.assertTrue(dmeProto.hasLastEvent() && !dmeProto.getLastEvent());
+ assertEquals(0, dmeProto.getSpillId());
+ assertTrue(dmeProto.hasLastEvent() && !dmeProto.getLastEvent());
byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(dmeProto.getEmptyPartitions());
BitSet emptyPartitionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
- Assert.assertTrue("emptyPartitionBitSet cardinality (expecting 5) = " + emptyPartitionsBitSet
- .cardinality(), emptyPartitionsBitSet.cardinality() == 5);
+ assertEquals(5, emptyPartitionsBitSet.cardinality(),
+ "emptyPartitionBitSet cardinality (expecting 5) = " + emptyPartitionsBitSet
+ .cardinality());
events.clear();
@@ -233,26 +216,27 @@ public void testGenerateOnSpillEvent_With_FinalMerge() throws Exception {
outputContext, spillId, new TezSpillRecord(indexFile, conf),
physicalOutputs, true, pathComponent, null, false, auxiliaryService, TezCommonUtils.newBestCompressionDeflater());
- Assert.assertTrue(events.size() == 2); //one for VM
- Assert.assertTrue(events.get(0) instanceof VertexManagerEvent);
- Assert.assertTrue(events.get(1) instanceof CompositeDataMovementEvent);
+ assertEquals(2, events.size()); //one for VM
+ assertInstanceOf(VertexManagerEvent.class, events.get(0));
+ assertInstanceOf(CompositeDataMovementEvent.class, events.get(1));
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(1);
- Assert.assertTrue(cdme.getCount() == physicalOutputs);
- Assert.assertTrue(cdme.getSourceIndexStart() == 0);
+ assertEquals(physicalOutputs, cdme.getCount());
+ assertEquals(0, cdme.getSourceIndexStart());
ShuffleUserPayloads.DataMovementEventPayloadProto dmeProto =
ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom( cdme.getUserPayload()));
//With final merge, spill details should not be present
- Assert.assertFalse(dmeProto.hasSpillId());
- Assert.assertFalse(dmeProto.hasLastEvent() || dmeProto.getLastEvent());
+ assertFalse(dmeProto.hasSpillId());
+ assertFalse(dmeProto.hasLastEvent() || dmeProto.getLastEvent());
byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(dmeProto
.getEmptyPartitions());
BitSet emptyPartitionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
- Assert.assertTrue("emptyPartitionBitSet cardinality (expecting 5) = " + emptyPartitionsBitSet
- .cardinality(), emptyPartitionsBitSet.cardinality() == 5);
+ assertEquals(5, emptyPartitionsBitSet.cardinality(),
+ "emptyPartitionBitSet cardinality (expecting 5) = " + emptyPartitionsBitSet
+ .cardinality());
}
@@ -260,7 +244,7 @@ outputContext, spillId, new TezSpillRecord(indexFile, conf),
public void testGenerateOnSpillEvent_With_All_EmptyPartitions() throws Exception {
List events = Lists.newLinkedList();
- //Create an index file with all empty partitions
+ // Create an index file with all empty partitions
Path indexFile = createIndexFile(10, true);
boolean finalMergeDisabled = false;
@@ -268,37 +252,52 @@ public void testGenerateOnSpillEvent_With_All_EmptyPartitions() throws Exception
int spillId = 0;
int physicalOutputs = 10;
String pathComponent = "/attempt_x_y_0/file.out";
- String auxiliaryService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
- TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
-
- //normal code path where we do final merge all the time
- ShuffleUtils.generateEventOnSpill(events, finalMergeDisabled, isLastEvent,
- outputContext, spillId, new TezSpillRecord(indexFile, conf),
- physicalOutputs, true, pathComponent, null, false, auxiliaryService, TezCommonUtils.newBestCompressionDeflater());
-
- Assert.assertEquals(2, events.size()); //one for VM
- Assert.assertTrue(events.get(0) instanceof VertexManagerEvent);
- Assert.assertTrue(events.get(1) instanceof CompositeDataMovementEvent);
+ String auxiliaryService =
+ conf.get(
+ TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
+ TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
+
+ // normal code path where we do final merge all the time
+ ShuffleUtils.generateEventOnSpill(
+ events,
+ finalMergeDisabled,
+ isLastEvent,
+ outputContext,
+ spillId,
+ new TezSpillRecord(indexFile, conf),
+ physicalOutputs,
+ true,
+ pathComponent,
+ null,
+ false,
+ auxiliaryService,
+ TezCommonUtils.newBestCompressionDeflater());
+
+ assertEquals(2, events.size()); // one for VM
+ assertInstanceOf(VertexManagerEvent.class, events.get(0));
+ assertInstanceOf(CompositeDataMovementEvent.class, events.get(1));
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(1);
- Assert.assertEquals(cdme.getCount(), physicalOutputs);
- Assert.assertEquals(0, cdme.getSourceIndexStart());
+ assertEquals(cdme.getCount(), physicalOutputs);
+ assertEquals(0, cdme.getSourceIndexStart());
ShuffleUserPayloads.DataMovementEventPayloadProto dmeProto =
- ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom( cdme.getUserPayload()));
+ ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(
+ ByteString.copyFrom(cdme.getUserPayload()));
- //spill details should be present
- Assert.assertEquals(0, dmeProto.getSpillId());
- Assert.assertTrue(dmeProto.hasLastEvent() && dmeProto.getLastEvent());
+ // spill details should be present
+ assertEquals(0, dmeProto.getSpillId());
+ assertTrue(dmeProto.hasLastEvent() && dmeProto.getLastEvent());
- Assert.assertEquals("", dmeProto.getPathComponent());
-
- byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(dmeProto
- .getEmptyPartitions());
- BitSet emptyPartitionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
- Assert.assertEquals("emptyPartitionBitSet cardinality (expecting 10) = " + emptyPartitionsBitSet
- .cardinality(), 10, emptyPartitionsBitSet.cardinality());
+ assertEquals("", dmeProto.getPathComponent());
+ byte[] emptyPartitions =
+ TezCommonUtils.decompressByteStringToByteArray(dmeProto.getEmptyPartitions());
+ BitSet emptyPartitionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
+ assertEquals(
+ 10,
+ emptyPartitionsBitSet.cardinality(),
+ "emptyPartitionBitSet cardinality (expecting 10) = " + emptyPartitionsBitSet.cardinality());
}
@Test
@@ -317,10 +316,10 @@ public void testInternalErrorTranslation() throws Exception {
try {
ShuffleUtils.shuffleToMemory(new byte[1024], new ByteArrayInputStream(header),
1024, 128, mockCodec, false, 0, mock(Logger.class), null);
- Assert.fail("shuffle was supposed to throw!");
+ fail("shuffle was supposed to throw!");
} catch (IOException e) {
- Assert.assertTrue(e.getCause() instanceof InternalError);
- Assert.assertTrue(e.getMessage().contains(codecErrorMsg));
+ assertInstanceOf(InternalError.class, e.getCause());
+ assertTrue(e.getMessage().contains(codecErrorMsg));
}
}
@@ -340,10 +339,10 @@ public void testExceptionTranslation() throws Exception {
try {
ShuffleUtils.shuffleToMemory(new byte[1024], new ByteArrayInputStream(header),
1024, 128, mockCodec, false, 0, mock(Logger.class), null);
- Assert.fail("shuffle was supposed to throw!");
+ fail("shuffle was supposed to throw!");
} catch (IOException e) {
- Assert.assertTrue(e.getCause() instanceof IllegalArgumentException);
- Assert.assertTrue(e.getMessage().contains(codecErrorMsg));
+ assertInstanceOf(IllegalArgumentException.class, e.getCause());
+ assertTrue(e.getMessage().contains(codecErrorMsg));
}
CompressionInputStream mockCodecStream1 = mock(CompressionInputStream.class);
when(mockCodecStream1.read(any(byte[].class), anyInt(), anyInt()))
@@ -356,10 +355,10 @@ public void testExceptionTranslation() throws Exception {
try {
ShuffleUtils.shuffleToMemory(new byte[1024], new ByteArrayInputStream(header),
1024, 128, mockCodec1, false, 0, mock(Logger.class), null);
- Assert.fail("shuffle was supposed to throw!");
+ fail("shuffle was supposed to throw!");
} catch (IOException e) {
- Assert.assertTrue(e instanceof SocketTimeoutException);
- Assert.assertTrue(e.getMessage().contains(codecErrorMsg));
+ assertInstanceOf(SocketTimeoutException.class, e);
+ assertTrue(e.getMessage().contains(codecErrorMsg));
}
CompressionInputStream mockCodecStream2 = mock(CompressionInputStream.class);
when(mockCodecStream2.read(any(byte[].class), anyInt(), anyInt()))
@@ -372,10 +371,10 @@ public void testExceptionTranslation() throws Exception {
try {
ShuffleUtils.shuffleToMemory(new byte[1024], new ByteArrayInputStream(header),
1024, 128, mockCodec2, false, 0, mock(Logger.class), null);
- Assert.fail("shuffle was supposed to throw!");
+ fail("shuffle was supposed to throw!");
} catch (IOException e) {
- Assert.assertTrue(e.getCause() instanceof InternalError);
- Assert.assertTrue(e.getMessage().contains(codecErrorMsg));
+ assertInstanceOf(InternalError.class, e.getCause());
+ assertTrue(e.getMessage().contains(codecErrorMsg));
}
}
@@ -389,14 +388,14 @@ public void testShuffleToDiskChecksum() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ShuffleUtils.shuffleToDisk(baos, "somehost", in,
bogusData.length, 2000, mock(Logger.class), null, false, 0, false);
- Assert.assertArrayEquals(bogusData, baos.toByteArray());
+ assertArrayEquals(bogusData, baos.toByteArray());
// verify sending same stream of zeroes with validation generates an exception
in.reset();
try {
ShuffleUtils.shuffleToDisk(mock(OutputStream.class), "somehost", in,
bogusData.length, 2000, mock(Logger.class), null, false, 0, true);
- Assert.fail("shuffle was supposed to throw!");
+ fail("shuffle was supposed to throw!");
} catch (IOException e) {
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleInputEventHandlerImpl.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleInputEventHandlerImpl.java
index 33a3b25679..9affd98fc3 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleInputEventHandlerImpl.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleInputEventHandlerImpl.java
@@ -40,6 +40,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -71,9 +72,7 @@
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.MockedStatic;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -87,17 +86,18 @@ public class TestShuffleInputEventHandlerImpl {
private TezExecutors sharedExecutor;
- @Before
+ @BeforeEach
public void setup() {
sharedExecutor = new TezSharedExecutor(conf);
}
- @After
+ @AfterEach
public void cleanup() {
sharedExecutor.shutdownNow();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSimple() throws IOException {
InputContext inputContext = mock(InputContext.class);
ShuffleManager shuffleManager = mock(ShuffleManager.class);
@@ -119,7 +119,8 @@ public void testSimple() throws IOException {
verify(shuffleManager).addKnownInput(eq(HOST), eq(PORT), eq(expectedIdentifier), eq(0));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCurrentPartitionEmpty() throws IOException {
InputContext inputContext = mock(InputContext.class);
ShuffleManager shuffleManager = mock(ShuffleManager.class);
@@ -140,7 +141,8 @@ public void testCurrentPartitionEmpty() throws IOException {
verify(shuffleManager).addCompletedInputWithNoData(eq(expectedIdentifier));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOtherPartitionEmpty() throws IOException {
InputContext inputContext = mock(InputContext.class);
ShuffleManager shuffleManager = mock(ShuffleManager.class);
@@ -160,7 +162,8 @@ public void testOtherPartitionEmpty() throws IOException {
verify(shuffleManager).addKnownInput(eq(HOST), eq(PORT), eq(expectedIdentifier), eq(0));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testMultipleEvents1() throws IOException {
InputContext inputContext = mock(InputContext.class);
ShuffleManager shuffleManager = mock(ShuffleManager.class);
@@ -243,7 +246,8 @@ private ShuffleManager createShuffleManager(InputContext inputContext) throws IO
*
* @throws IOException
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPipelinedShuffleEvents() throws IOException {
InputContext inputContext = createInputContext();
@@ -284,7 +288,8 @@ public void testPipelinedShuffleEvents() throws IOException {
*
* @throws IOException
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPipelinedShuffleEvents_WithOutOfOrderAttempts() throws IOException {
InputContext inputContext = createInputContext();
ShuffleManager shuffleManager = createShuffleManager(inputContext);
@@ -316,7 +321,8 @@ public void testPipelinedShuffleEvents_WithOutOfOrderAttempts() throws IOExcepti
*
* @throws IOException
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPipelinedShuffleEvents_WithEmptyPartitions() throws IOException {
InputContext inputContext = createInputContext();
ShuffleManager shuffleManager = createShuffleManager(inputContext);
@@ -356,7 +362,8 @@ public void testPipelinedShuffleEvents_WithEmptyPartitions() throws IOException
*
* @throws IOException
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDataMovementEventsWithShuffleData() throws IOException {
InputContext inputContext = mock(InputContext.class);
ShuffleManager shuffleManager = mock(ShuffleManager.class);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleManager.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleManager.java
index 9d5179addd..e7444e2d38 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestShuffleManager.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
@@ -39,6 +38,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -69,10 +69,7 @@
import com.google.common.annotations.VisibleForTesting;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -86,12 +83,12 @@ public class TestShuffleManager {
private final Configuration conf = new Configuration();
private TezExecutors sharedExecutor;
- @Before
+ @BeforeEach
public void setup() {
sharedExecutor = new TezSharedExecutor(conf);
}
- @After
+ @AfterEach
public void cleanup() {
sharedExecutor.shutdownNow();
}
@@ -103,7 +100,8 @@ public void cleanup() {
* rest of the partitions. Then do the same thing for the next mapper.
* Verify ShuffleManager is able to get all the events.
*/
- @Test(timeout = 50000)
+ @Test
+ @Timeout(value = 50000, unit = TimeUnit.MILLISECONDS)
public void testMultiplePartitions() throws Exception {
final int numOfMappers = 3;
final int numOfPartitions = 5;
@@ -188,7 +186,8 @@ public ExecutorService answer(InvocationOnMock invocation) throws Throwable {
return inputContext;
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testUseSharedExecutor() throws Exception {
InputContext inputContext = createInputContext();
createShuffleManager(inputContext, 2);
@@ -200,7 +199,8 @@ public void testUseSharedExecutor() throws Exception {
verify(inputContext).createTezFrameworkExecutorService(anyInt(), anyString());
}
- @Test (timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testProgressWithEmptyPendingHosts() throws Exception {
InputContext inputContext = createInputContext();
final ShuffleManager shuffleManager = spy(createShuffleManager(inputContext, 1));
@@ -220,20 +220,23 @@ public void run() {
verify(inputContext, atLeast(3)).notifyProgress();
}
- @Test (timeout = 200000)
+ @Test
+ @Timeout(value = 200000, unit = TimeUnit.MILLISECONDS)
public void testFetchFailed() throws Exception {
InputContext inputContext = createInputContext();
final ShuffleManager shuffleManager = spy(createShuffleManager(inputContext, 1));
- Thread schedulerGetHostThread = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- shuffleManager.run();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
+ Thread schedulerGetHostThread =
+ new Thread(
+ new Runnable() {
+ @Override
+ public void run() {
+ try {
+ shuffleManager.run();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
InputAttemptFetchFailure inputAttemptFetchFailure =
new InputAttemptFetchFailure(new InputAttemptIdentifier(1, 1));
@@ -243,16 +246,13 @@ public void run() {
Thread.sleep(1000);
ArgumentCaptor captor = ArgumentCaptor.forClass(List.class);
- verify(inputContext, times(1))
- .sendEvents(captor.capture());
- Assert.assertEquals("Size was: " + captor.getAllValues().size(),
- captor.getAllValues().size(), 1);
+ verify(inputContext, times(1)).sendEvents(captor.capture());
+ assertEquals(captor.getAllValues().size(), 1, "Size was: " + captor.getAllValues().size());
List capturedList = captor.getAllValues().get(0);
- Assert.assertEquals("Size was: " + capturedList.size(),
- capturedList.size(), 1);
- InputReadErrorEvent inputEvent = (InputReadErrorEvent)capturedList.get(0);
- Assert.assertEquals("Number of failures was: " + inputEvent.getNumFailures(),
- inputEvent.getNumFailures(), 1);
+ assertEquals(capturedList.size(), 1, "Size was: " + capturedList.size());
+ InputReadErrorEvent inputEvent = (InputReadErrorEvent) capturedList.get(0);
+ assertEquals(
+ inputEvent.getNumFailures(), 1, "Number of failures was: " + inputEvent.getNumFailures());
shuffleManager.fetchFailed("host1", inputAttemptFetchFailure, false);
shuffleManager.fetchFailed("host1", inputAttemptFetchFailure, false);
@@ -263,17 +263,13 @@ public void run() {
// Wait more than five seconds for the batch to go out
Thread.sleep(5000);
captor = ArgumentCaptor.forClass(List.class);
- verify(inputContext, times(2))
- .sendEvents(captor.capture());
- Assert.assertEquals("Size was: " + captor.getAllValues().size(),
- captor.getAllValues().size(), 2);
+ verify(inputContext, times(2)).sendEvents(captor.capture());
+ assertEquals(captor.getAllValues().size(), 2, "Size was: " + captor.getAllValues().size());
capturedList = captor.getAllValues().get(1);
- Assert.assertEquals("Size was: " + capturedList.size(),
- capturedList.size(), 1);
- inputEvent = (InputReadErrorEvent)capturedList.get(0);
- Assert.assertEquals("Number of failures was: " + inputEvent.getNumFailures(),
- inputEvent.getNumFailures(), 2);
-
+ assertEquals(capturedList.size(), 1, "Size was: " + capturedList.size());
+ inputEvent = (InputReadErrorEvent) capturedList.get(0);
+ assertEquals(
+ inputEvent.getNumFailures(), 2, "Number of failures was: " + inputEvent.getNumFailures());
schedulerGetHostThread.interrupt();
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestSimpleFetchedInputAllocator.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestSimpleFetchedInputAllocator.java
index ff24aee3fc..0bff2cf1fc 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestSimpleFetchedInputAllocator.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/impl/TestSimpleFetchedInputAllocator.java
@@ -18,12 +18,12 @@
*/
package org.apache.tez.runtime.library.common.shuffle.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.common.TezRuntimeFrameworkConfigs;
@@ -31,7 +31,7 @@
import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
import org.apache.tez.runtime.library.common.shuffle.FetchedInput;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +39,8 @@ public class TestSimpleFetchedInputAllocator {
private static final Logger LOG = LoggerFactory.getLogger(TestSimpleFetchedInputAllocator.class);
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInMemAllocation() throws IOException {
File localDirs = new File(System.getProperty("test.build.data", "/tmp"), this.getClass().getName());
Configuration conf = new Configuration();
@@ -91,7 +92,8 @@ public void testInMemAllocation() throws IOException {
* a high `maxMemory` is reported by the Runtime.The allocation results in a
* DISK input because the `requestSize` exceeds the `maxSingleShuffleLimit`.
*/
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInMemAllocationWithJvmMaxMemory() throws IOException {
File localDirs = new File(System.getProperty("test.build.data", "/tmp"), this.getClass().getName());
Configuration conf = new Configuration();
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/DummyCompressionCodec.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/DummyCompressionCodec.java
index 50581fa50f..01e2cc3752 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/DummyCompressionCodec.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/DummyCompressionCodec.java
@@ -34,6 +34,8 @@
import com.google.common.annotations.VisibleForTesting;
+import org.junit.jupiter.api.*;
+
/**
* A dummy codec. It passes everything to underlying stream
*/
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java
index fa89fad08b..9b8c07f0c1 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestFetcher.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle.orderedgrouped;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
@@ -50,6 +50,7 @@
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -76,8 +77,7 @@
import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -114,7 +114,8 @@ public class TestFetcher {
static final Logger LOG = LoggerFactory.getLogger(TestFetcher.class);
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputsReturnedOnConnectionException() throws Exception {
Configuration conf = new TezConfiguration();
ShuffleScheduler scheduler = mock(ShuffleScheduler.class);
@@ -141,7 +142,8 @@ public void testInputsReturnedOnConnectionException() throws Exception {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLocalFetchModeSetting1() throws Exception {
Configuration conf = new TezConfiguration();
ShuffleScheduler scheduler = mock(ShuffleScheduler.class);
@@ -211,7 +213,8 @@ conf, getRawFs(conf), DISABLE_LOCAL_FETCH, HOST, PORT, mapHost, ioErrsCounter,
verify(spyFetcher, times(1)).copyFromHost(mapHost);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetupLocalDiskFetch() throws Exception {
Configuration conf = new TezConfiguration();
ShuffleScheduler scheduler = mock(ShuffleScheduler.class);
@@ -322,7 +325,8 @@ public TezIndexRecord answer(InvocationOnMock invocation) throws Throwable {
verify(scheduler).putBackKnownMapOutput(host, srcAttempts.get(SECOND_FAILED_ATTEMPT_IDX));
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetupLocalDiskFetchEmptyPartitions() throws Exception {
Configuration conf = new TezConfiguration();
ShuffleScheduler scheduler = mock(ShuffleScheduler.class);
@@ -394,7 +398,8 @@ public TezIndexRecord answer(InvocationOnMock invocation) throws Throwable {
verify(spyFetcher).putBackRemainingMapOutputs(host);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetupLocalDiskFetchAutoReduce() throws Exception {
Configuration conf = new TezConfiguration();
ShuffleScheduler scheduler = mock(ShuffleScheduler.class);
@@ -532,7 +537,7 @@ private void verifyCopySucceeded(ShuffleScheduler scheduler, MapHost host,
// cannot use the equals of MapOutput as it compares id which is private. so doing it manually
MapOutput m = captureMapOutput.getAllValues().get(0);
- Assert.assertTrue(m.getType().equals(MapOutput.Type.DISK_DIRECT) &&
+ assertTrue(m.getType().equals(MapOutput.Type.DISK_DIRECT) &&
m.getAttemptIdentifier().equals(srcAttemptToMatch));
}
@@ -567,7 +572,8 @@ public void cleanup(boolean disconnect) throws IOException {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
@SuppressWarnings("unchecked")
public void testWithRetry() throws Exception {
Configuration conf = new TezConfiguration();
@@ -677,15 +683,16 @@ public void testAsyncWithException() throws Exception {
try {
long currentIOErrors = ioErrsCounter.getValue();
boolean connected = fetcher.setupConnection(host, srcAttempts);
- Assert.assertTrue(connected == false);
+ assertFalse(connected);
//Ensure that counters are incremented (i.e it followed the exception codepath)
- Assert.assertTrue(ioErrsCounter.getValue() > currentIOErrors);
+ assertTrue(ioErrsCounter.getValue() > currentIOErrors);
} catch (IOException e) {
fail();
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInputAttemptIdentifierMap() {
InputAttemptIdentifier[] srcAttempts = {
new InputAttemptIdentifier(0, 1, InputAttemptIdentifier.PATH_PREFIX + "pathComponent_0",
@@ -731,12 +738,12 @@ public void testInputAttemptIdentifierMap() {
ioErrsCounter, wrongLengthErrsCounter, badIdErrsCounter, wrongMapErrsCounter,
connectionErrsCounter, wrongReduceErrsCounter, false, false, true, false, createMockInputContext());
fetcher.populateRemainingMap(new LinkedList(Arrays.asList(srcAttempts)));
- Assert.assertEquals(expectedSrcAttempts.length, fetcher.remaining.size());
+ assertEquals(expectedSrcAttempts.length, fetcher.remaining.size());
Iterator> iterator = fetcher.remaining.entrySet().iterator();
int count = 0;
while(iterator.hasNext()) {
String key = iterator.next().getKey();
- Assert.assertTrue(expectedSrcAttempts[count++].toString().compareTo(key) == 0);
+ assertEquals(0, expectedSrcAttempts[count++].toString().compareTo(key));
}
}
@@ -761,9 +768,9 @@ public void testShuffleHandlerDiskErrorOrdered()
InputAttemptFetchFailure[] failures =
fetcher.copyMapOutput(mapHost, input, inputAttemptIdentifier);
- Assert.assertEquals(1, failures.length);
- Assert.assertTrue(failures[0].isDiskErrorAtSource());
- Assert.assertFalse(failures[0].isLocalFetch());
+ assertEquals(1, failures.length);
+ assertTrue(failures[0].isDiskErrorAtSource());
+ assertFalse(failures[0].isLocalFetch());
}
private RawLocalFileSystem getRawFs(Configuration conf) {
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestMergeManager.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestMergeManager.java
index 048699de2e..1d0fa8d5f9 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestMergeManager.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestMergeManager.java
@@ -18,9 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle.orderedgrouped;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -33,6 +31,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -54,10 +53,7 @@
import com.google.common.collect.Sets;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -85,13 +81,14 @@ public class TestMergeManager {
}
}
- @Before
- @After
+ @BeforeEach
+ @AfterEach
public void cleanup() throws IOException {
localFs.delete(workDir, true);
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testConfigs() throws IOException {
long maxTaskMem = 8192 * 1024 * 1024l;
@@ -99,59 +96,59 @@ public void testConfigs() throws IOException {
Configuration conf = new TezConfiguration(defaultConf);
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, 0.8f);
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_INPUT_POST_MERGE_BUFFER_PERCENT, 0.5f);
- Assert.assertTrue(MergeManager.getInitialMemoryRequirement(conf, maxTaskMem) == 6871947776l);
+ assertEquals(6871947776l, MergeManager.getInitialMemoryRequirement(conf, maxTaskMem));
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, 0.5f);
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_INPUT_POST_MERGE_BUFFER_PERCENT, 0.5f);
- Assert.assertTrue(MergeManager.getInitialMemoryRequirement(conf, maxTaskMem) > Integer.MAX_VALUE);
+ assertTrue(MergeManager.getInitialMemoryRequirement(conf, maxTaskMem) > Integer.MAX_VALUE);
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, 0.4f);
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_INPUT_POST_MERGE_BUFFER_PERCENT, 0.9f);
- Assert.assertTrue(MergeManager.getInitialMemoryRequirement(conf, maxTaskMem) > Integer.MAX_VALUE);
+ assertTrue(MergeManager.getInitialMemoryRequirement(conf, maxTaskMem) > Integer.MAX_VALUE);
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, 0.1f);
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_INPUT_POST_MERGE_BUFFER_PERCENT, 0.1f);
- Assert.assertTrue(MergeManager.getInitialMemoryRequirement(conf, maxTaskMem) < Integer.MAX_VALUE);
+ assertTrue(MergeManager.getInitialMemoryRequirement(conf, maxTaskMem) < Integer.MAX_VALUE);
try {
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, 2.4f);
MergeManager.getInitialMemoryRequirement(conf, maxTaskMem);
- Assert.fail("Should have thrown wrong buffer percent configuration exception");
+ fail("Should have thrown wrong buffer percent configuration exception");
} catch(IllegalArgumentException ie) {
}
try {
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, -2.4f);
MergeManager.getInitialMemoryRequirement(conf, maxTaskMem);
- Assert.fail("Should have thrown wrong buffer percent configuration exception");
+ fail("Should have thrown wrong buffer percent configuration exception");
} catch(IllegalArgumentException ie) {
}
try {
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_INPUT_POST_MERGE_BUFFER_PERCENT, 1.4f);
MergeManager.getInitialMemoryRequirement(conf, maxTaskMem);
- Assert.fail("Should have thrown wrong post merge buffer percent configuration exception");
+ fail("Should have thrown wrong post merge buffer percent configuration exception");
} catch(IllegalArgumentException ie) {
}
try {
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_INPUT_POST_MERGE_BUFFER_PERCENT, -1.4f);
MergeManager.getInitialMemoryRequirement(conf, maxTaskMem);
- Assert.fail("Should have thrown wrong post merge buffer percent configuration exception");
+ fail("Should have thrown wrong post merge buffer percent configuration exception");
} catch(IllegalArgumentException ie) {
}
try {
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, 1.4f);
MergeManager.getInitialMemoryRequirement(conf, maxTaskMem);
- Assert.fail("Should have thrown wrong shuffle fetch buffer percent configuration exception");
+ fail("Should have thrown wrong shuffle fetch buffer percent configuration exception");
} catch(IllegalArgumentException ie) {
}
try {
conf.setFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, -1.4f);
MergeManager.getInitialMemoryRequirement(conf, maxTaskMem);
- Assert.fail("Should have thrown wrong shuffle fetch buffer percent configuration exception");
+ fail("Should have thrown wrong shuffle fetch buffer percent configuration exception");
} catch(IllegalArgumentException ie) {
}
@@ -167,16 +164,17 @@ public void testConfigs() throws IOException {
MergeManager mergeManager =
new MergeManager(conf, localFs, localDirAllocator, t0inputContext, null, null, null, null,
t0exceptionReporter, initialMemoryAvailable, null, false, -1);
- Assert.assertTrue(mergeManager.postMergeMemLimit > Integer.MAX_VALUE);
+ assertTrue(mergeManager.postMergeMemLimit > Integer.MAX_VALUE);
initialMemoryAvailable = 200 * 1024 * 1024l; //initial mem < memlimit
mergeManager =
new MergeManager(conf, localFs, localDirAllocator, t0inputContext, null, null, null, null,
t0exceptionReporter, initialMemoryAvailable, null, false, -1);
- Assert.assertTrue(mergeManager.postMergeMemLimit == initialMemoryAvailable);
+ assertEquals(mergeManager.postMergeMemLimit, initialMemoryAvailable);
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testReservationAccounting() throws IOException {
Configuration conf = new TezConfiguration(defaultConf);
FileSystem localFs = FileSystem.getLocal(conf);
@@ -202,7 +200,8 @@ public void testReservationAccounting() throws IOException {
assertEquals(0, mergeManager.getCommitMemory());
}
- @Test(timeout=20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testIntermediateMemoryMergeAccounting() throws Exception {
Configuration conf = new TezConfiguration(defaultConf);
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS, false);
@@ -312,10 +311,11 @@ public void testDiskMergeWithCodec() throws Throwable {
mo4.commit();
mergeManager.close(true);
- Assert.assertTrue(dummyCodec.createInputStreamCalled > 0);
+ assertTrue(dummyCodec.createInputStreamCalled > 0);
}
- @Test(timeout = 60000l)
+ @Test
+ @org.junit.jupiter.api.Timeout(value = 60000, unit = java.util.concurrent.TimeUnit.MILLISECONDS)
public void testIntermediateMemoryMerge() throws Throwable {
Configuration conf = new TezConfiguration(defaultConf);
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS, false);
@@ -624,8 +624,8 @@ public void testIntermediateMemoryMerge() throws Throwable {
//Check if inMemorySegment has got the MapOutput back for merging later
assertEquals(numberOfMapOutputs, mergeManager.inMemoryMapOutputs.size());
- Assert.assertNull(mergeManager.close(false));
- Assert.assertFalse(mergeManager.isMergeComplete());
+ assertNull(mergeManager.close(false));
+ assertFalse(mergeManager.isMergeComplete());
}
private byte[] generateDataBySize(Configuration conf, int rawLen, InputAttemptIdentifier inputAttemptIdentifier) throws IOException {
@@ -708,13 +708,15 @@ public InterruptingThread(MergeManager.OnDiskMerger mergeThread) {
}
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testLocalDiskMergeMultipleTasks() throws IOException, InterruptedException {
testLocalDiskMergeMultipleTasks(false);
testLocalDiskMergeMultipleTasks(true);
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testOnDiskMergerFilenames() throws IOException, InterruptedException {
Configuration conf = new TezConfiguration(defaultConf);
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS, false);
@@ -772,7 +774,7 @@ public void testOnDiskMergerFilenames() throws IOException, InterruptedException
mergeManager.onDiskMapOutputs.clear();
mergeManager.onDiskMerger.merge(mergeFiles);
- Assert.assertEquals(1, mergeManager.onDiskMapOutputs.size());
+ assertEquals(1, mergeManager.onDiskMapOutputs.size());
FileChunk fcMerged1 = mergeManager.onDiskMapOutputs.iterator().next();
Path m1Path = fcMerged1.getPath();
@@ -796,7 +798,7 @@ public void testOnDiskMergerFilenames() throws IOException, InterruptedException
mergeManager.onDiskMapOutputs.clear();
mergeManager.onDiskMerger.merge(mergeFiles);
- Assert.assertEquals(1, mergeManager.onDiskMapOutputs.size());
+ assertEquals(1, mergeManager.onDiskMapOutputs.size());
FileChunk fcMerged2 = mergeManager.onDiskMapOutputs.iterator().next();
Path m2Path = fcMerged2.getPath();
@@ -826,7 +828,7 @@ public void testOnDiskMergerFilenames() throws IOException, InterruptedException
mergeManager.onDiskMapOutputs.clear();
mergeManager.onDiskMerger.merge(mergeFiles);
- Assert.assertEquals(1, mergeManager.onDiskMapOutputs.size());
+ assertEquals(1, mergeManager.onDiskMapOutputs.size());
FileChunk fcMerged3 = mergeManager.onDiskMapOutputs.iterator().next();
Path m3Path = fcMerged3.getPath();
@@ -952,7 +954,7 @@ public synchronized void closeOnDiskFile(FileChunk file) {
if (!interruptInMiddle) {
t0mergeManager.onDiskMerger.merge(t0MergeFiles);
- Assert.assertEquals(1, t0mergeManager.onDiskMapOutputs.size());
+ assertEquals(1, t0mergeManager.onDiskMapOutputs.size());
} else {
//Start Interrupting thread
@@ -967,7 +969,7 @@ public synchronized void closeOnDiskFile(FileChunk file) {
//Will be interrupted in the middle by interruptingThread.
t0mergeManager.onDiskMerger.startMerge(Sets.newHashSet(t0MergeFiles));
t0mergeManager.onDiskMerger.waitForMerge();
- Assert.assertNotEquals(1, t0mergeManager.onDiskMapOutputs.size());
+ assertNotEquals(1, t0mergeManager.onDiskMapOutputs.size());
}
if (!interruptInMiddle) {
@@ -981,14 +983,14 @@ public synchronized void closeOnDiskFile(FileChunk file) {
t1MergeFiles.addAll(t1mergeManager.onDiskMapOutputs);
t1mergeManager.onDiskMapOutputs.clear();
t1mergeManager.onDiskMerger.merge(t1MergeFiles);
- Assert.assertEquals(1, t1mergeManager.onDiskMapOutputs.size());
+ assertEquals(1, t1mergeManager.onDiskMapOutputs.size());
- Assert.assertNotEquals(t0mergeManager.onDiskMapOutputs.iterator().next().getPath(),
+ assertNotEquals(t0mergeManager.onDiskMapOutputs.iterator().next().getPath(),
t1mergeManager.onDiskMapOutputs.iterator().next().getPath());
- Assert.assertTrue(t0mergeManager.onDiskMapOutputs.iterator().next().getPath().toString()
+ assertTrue(t0mergeManager.onDiskMapOutputs.iterator().next().getPath().toString()
.contains(t0inputContext.getUniqueIdentifier()));
- Assert.assertTrue(t1mergeManager.onDiskMapOutputs.iterator().next().getPath().toString()
+ assertTrue(t1mergeManager.onDiskMapOutputs.iterator().next().getPath().toString()
.contains(t1inputContext.getUniqueIdentifier()));
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffle.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffle.java
index 8ddc0948b6..409e806e42 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffle.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffle.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle.orderedgrouped;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doReturn;
@@ -32,6 +31,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
@@ -50,9 +50,7 @@
import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.library.common.Constants;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -61,17 +59,18 @@ public class TestShuffle {
private TezExecutors sharedExecutor;
- @Before
+ @BeforeEach
public void setup() {
sharedExecutor = new TezSharedExecutor(new Configuration());
}
- @After
+ @AfterEach
public void cleanup() {
sharedExecutor.shutdownNow();
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testSchedulerTerminatesOnException() throws IOException, InterruptedException {
InputContext inputContext = createTezInputContext();
@@ -113,7 +112,8 @@ public void testSchedulerTerminatesOnException() throws IOException, Interrupted
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testKillSelf() throws IOException, InterruptedException {
InputContext inputContext = createTezInputContext();
TezConfiguration conf = new TezConfiguration();
@@ -122,14 +122,14 @@ public void testKillSelf() throws IOException, InterruptedException {
try {
shuffle.run();
ShuffleScheduler scheduler = shuffle.scheduler;
- assertFalse("scheduler.isShutdown should be false", scheduler.isShutdown());
+ assertFalse(scheduler.isShutdown(), "scheduler.isShutdown should be false");
// killSelf() would invoke close(). Internally Shuffle --> merge.close() --> finalMerge()
// gets called. In MergeManager::finalMerge(), it would throw illegal argument exception as
// uniqueIdentifier is not present in inputContext. This is used as means of simulating
// exception.
scheduler.killSelf(new Exception(), "due to internal error");
- assertTrue("scheduler.isShutdown should be true", scheduler.isShutdown());
+ assertTrue(scheduler.isShutdown(), "scheduler.isShutdown should be true");
//killSelf() should not result in reporting failure to AM
ArgumentCaptor throwableArgumentCaptor = ArgumentCaptor.forClass(Throwable.class);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleInputEventHandlerOrderedGrouped.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleInputEventHandlerOrderedGrouped.java
index aca8d57bd1..e0985e8a89 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleInputEventHandlerOrderedGrouped.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleInputEventHandlerOrderedGrouped.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle.orderedgrouped;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
@@ -37,6 +37,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
@@ -58,14 +59,13 @@
import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
+import org.apache.tez.runtime.library.common.InputAttemptIdentifier.SPILL_INFO;
import org.apache.tez.runtime.library.common.shuffle.ShuffleUtils;
import org.apache.tez.runtime.library.shuffle.impl.ShuffleUserPayloads;
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -173,13 +173,13 @@ private Event createDataMovementEvent(int srcIndex, int targetIndex,
.create(srcIndex, targetIndex, attemptNum, builder.build().toByteString().asReadOnlyByteBuffer());
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
sharedExecutor = new TezSharedExecutor(new Configuration());
setupScheduler(2);
}
- @After
+ @AfterEach
public void cleanup() {
sharedExecutor.shutdownNow();
}
@@ -204,7 +204,8 @@ private void setupScheduler(int numInputs) throws Exception {
mergeManager = mock(MergeManager.class);
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testPiplinedShuffleEvents() throws IOException, InterruptedException {
//test with 2 events per input (2 inputs)
int attemptNum = 0;
@@ -230,16 +231,16 @@ public void testPiplinedShuffleEvents() throws IOException, InterruptedException
assertTrue(scheduler.pipelinedShuffleInfoEventsMap.containsKey(id2.getInputIdentifier()));
MapHost host = scheduler.getHost();
- assertTrue(host != null);
+ assertNotNull(host);
List list = scheduler.getMapsForHost(host);
- assertTrue(!list.isEmpty());
+ assertFalse(list.isEmpty());
//Let the final_update event pass
MapOutput output = MapOutput.createMemoryMapOutput(id2, mergeManager, 1000, true);
scheduler.copySucceeded(id2, host, 1000, 10000, 10000, output, false);
- assertTrue(!scheduler.isDone()); //we haven't downloaded id1 yet
+ assertFalse(scheduler.isDone()); //we haven't downloaded id1 yet
output = MapOutput.createMemoryMapOutput(id1, mergeManager, 1000, true);
scheduler.copySucceeded(id1, host, 1000, 10000, 10000, output, false);
- assertTrue(!scheduler.isDone()); //we haven't downloaded another source yet
+ assertFalse(scheduler.isDone()); //we haven't downloaded another source yet
//Send events for source 2
attemptNum = 0;
@@ -253,16 +254,17 @@ public void testPiplinedShuffleEvents() throws IOException, InterruptedException
//Send final_update event (empty partition directly invoking copySucceeded).
InputAttemptIdentifier id4 = new InputAttemptIdentifier(inputIdx,
attemptNum, PATH_COMPONENT, false, InputAttemptIdentifier.SPILL_INFO.FINAL_UPDATE, 1);
- assertTrue(!scheduler.isInputFinished(id4.getInputIdentifier()));
+ assertFalse(scheduler.isInputFinished(id4.getInputIdentifier()));
scheduler.copySucceeded(id4, null, 0, 0, 0, null, false);
- assertTrue(!scheduler.isDone()); //we haven't downloaded another id yet
+ assertFalse(scheduler.isDone()); //we haven't downloaded another id yet
//Let the incremental event pass
output = MapOutput.createMemoryMapOutput(id3, mergeManager, 1000, true);
scheduler.copySucceeded(id3, host, 1000, 10000, 10000, output, false);
assertTrue(scheduler.isDone());
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPiplinedShuffleEvents_WithOutofOrderAttempts() throws IOException, InterruptedException {
//Process attempt #1 first
int attemptNum = 1;
@@ -273,15 +275,14 @@ public void testPiplinedShuffleEvents_WithOutofOrderAttempts() throws IOExceptio
CompositeInputAttemptIdentifier id1 =
new CompositeInputAttemptIdentifier(inputIdx, attemptNum,
- PATH_COMPONENT, false, InputAttemptIdentifier.SPILL_INFO.INCREMENTAL_UPDATE, 0, 1);
+ PATH_COMPONENT, false, SPILL_INFO.INCREMENTAL_UPDATE, 0, 1);
verify(scheduler, times(1)).addKnownMapOutput(eq(HOST), eq(PORT), eq(1), eq(id1));
- assertTrue("Shuffle info events should not be empty for pipelined shuffle",
- !scheduler.pipelinedShuffleInfoEventsMap.isEmpty());
+ assertFalse(scheduler.pipelinedShuffleInfoEventsMap.isEmpty(),
+ "Shuffle info events should not be empty for pipelined shuffle");
int valuesInMapLocations = scheduler.mapLocations.values().size();
- assertTrue("Maplocations should have values. current size: " + valuesInMapLocations,
- valuesInMapLocations > 0);
+ assertTrue(valuesInMapLocations > 0, "Maplocations should have values. current size: " + valuesInMapLocations);
// start scheduling for download
scheduler.getMapsForHost(scheduler.mapLocations.values().iterator().next());
@@ -296,7 +297,8 @@ public void testPiplinedShuffleEvents_WithOutofOrderAttempts() throws IOExceptio
verify(scheduler, times(1)).killSelf(any(), any());
}
- @Test (timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPipelinedShuffle_WithObsoleteEvents() throws IOException, InterruptedException {
//Process attempt #1 first
int attemptNum = 1;
@@ -307,15 +309,14 @@ public void testPipelinedShuffle_WithObsoleteEvents() throws IOException, Interr
CompositeInputAttemptIdentifier id1 =
new CompositeInputAttemptIdentifier(inputIdx, attemptNum,
- PATH_COMPONENT, false, InputAttemptIdentifier.SPILL_INFO.INCREMENTAL_UPDATE, 0, 1);
+ PATH_COMPONENT, false, SPILL_INFO.INCREMENTAL_UPDATE, 0, 1);
verify(scheduler, times(1)).addKnownMapOutput(eq(HOST), eq(PORT), eq(1), eq(id1));
- assertTrue("Shuffle info events should not be empty for pipelined shuffle",
- !scheduler.pipelinedShuffleInfoEventsMap.isEmpty());
+ assertFalse(scheduler.pipelinedShuffleInfoEventsMap.isEmpty(),
+ "Shuffle info events should not be empty for pipelined shuffle");
int valuesInMapLocations = scheduler.mapLocations.values().size();
- assertTrue("Maplocations should have values. current size: " + valuesInMapLocations,
- valuesInMapLocations > 0);
+ assertTrue(valuesInMapLocations > 0, "Maplocations should have values. current size: " + valuesInMapLocations);
// start scheduling for download. Sets up scheduledForDownload in eventInfo.
scheduler.getMapsForHost(scheduler.mapLocations.values().iterator().next());
@@ -331,7 +332,8 @@ public void testPipelinedShuffle_WithObsoleteEvents() throws IOException, Interr
verify(scheduler, times(1)).killSelf(any(), any());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void basicTest() throws IOException {
List events = new LinkedList();
int srcIdx = 0;
@@ -344,11 +346,11 @@ public void basicTest() throws IOException {
int partitionId = srcIdx;
verify(scheduler).addKnownMapOutput(eq(HOST), eq(PORT), eq(partitionId),
eq(expectedIdentifier));
- assertTrue("Shuffle info events should be empty for regular shuffle codepath",
- scheduler.pipelinedShuffleInfoEventsMap.isEmpty());
+ assertTrue(scheduler.pipelinedShuffleInfoEventsMap.isEmpty(), "Shuffle info events should be empty for regular shuffle codepath");
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testFailedEvent() throws IOException {
List events = new LinkedList();
int targetIdx = 1;
@@ -359,7 +361,8 @@ public void testFailedEvent() throws IOException {
verify(scheduler).obsoleteInput(eq(expectedIdentifier));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAllPartitionsEmpty() throws IOException {
List events = new LinkedList();
int srcIdx = 0;
@@ -373,7 +376,8 @@ public void testAllPartitionsEmpty() throws IOException {
eq(0L), eq(0L), any(), eq(true));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCurrentPartitionEmpty() throws IOException {
List events = new LinkedList();
int srcIdx = 0;
@@ -387,7 +391,8 @@ public void testCurrentPartitionEmpty() throws IOException {
eq(0L), eq(0L), any(), eq(true));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOtherPartitionEmpty() throws IOException {
List events = new LinkedList();
int srcIdx = 0;
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleScheduler.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleScheduler.java
index a13c556215..a05ce69b81 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleScheduler.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/TestShuffleScheduler.java
@@ -18,9 +18,7 @@
*/
package org.apache.tez.runtime.library.common.shuffle.orderedgrouped;
-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.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
@@ -60,11 +58,9 @@
import org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier;
import org.apache.tez.runtime.library.common.InputAttemptIdentifier;
import org.apache.tez.runtime.library.common.shuffle.InputAttemptFetchFailure;
+import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.MapHost.State;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -72,17 +68,18 @@ public class TestShuffleScheduler {
private TezExecutors sharedExecutor;
- @Before
+ @BeforeEach
public void setup() {
sharedExecutor = new TezSharedExecutor(new Configuration());
}
- @After
+ @AfterEach
public void cleanup() {
sharedExecutor.shutdownNow();
}
- @Test (timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testNumParallelScheduledFetchers() throws IOException, InterruptedException {
InputContext inputContext = createTezInputContext();
Configuration conf = new TezConfiguration();
@@ -129,7 +126,8 @@ public Void call() throws Exception {
}
}
- @Test(timeout=5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testUseSharedExecutor() throws Exception {
InputContext inputContext = createTezInputContext();
Configuration conf = new TezConfiguration();
@@ -150,7 +148,8 @@ public void testUseSharedExecutor() throws Exception {
scheduler.close();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSimpleFlow() throws Exception {
InputContext inputContext = createTezInputContext();
Configuration conf = new TezConfiguration();
@@ -206,7 +205,8 @@ public Void call() throws Exception {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
/**
* Scenario
* - reducer has not progressed enough
@@ -279,7 +279,8 @@ public void _testReducerHealth_1(Configuration conf) throws IOException {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
/**
* Scenario
* - reducer has progressed enough
@@ -398,7 +399,8 @@ public void testReducerHealth_2() throws IOException, InterruptedException {
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
/**
* Scenario
* - reducer has progressed enough
@@ -460,7 +462,8 @@ public void testReducerHealth_3() throws IOException {
verify(shuffle, times(0)).reportException(any());
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
/**
* Scenario
* - reducer has progressed enough
@@ -553,7 +556,8 @@ public void testReducerHealth_4() throws IOException {
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
/**
* Scenario
* - Shuffle has progressed enough
@@ -616,7 +620,8 @@ public void testReducerHealth_5() throws IOException {
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
/**
* Scenario
* - Shuffle has NOT progressed enough
@@ -709,7 +714,8 @@ public void _testReducerHealth_6(Configuration conf) throws IOException {
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
/**
* Scenario
* - reducer has not progressed enough
@@ -781,7 +787,8 @@ private ShuffleSchedulerForTest createScheduler(long startTime, int numInputs, S
TezConfiguration());
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testPenalty() throws IOException, InterruptedException {
long startTime = System.currentTimeMillis();
Shuffle shuffle = mock(Shuffle.class);
@@ -791,8 +798,8 @@ public void testPenalty() throws IOException, InterruptedException {
new CompositeInputAttemptIdentifier(0, 0, "attempt_", 1);
scheduler.addKnownMapOutput("host0", 10000, 0, inputAttemptIdentifier);
- assertTrue(scheduler.pendingHosts.size() == 1);
- assertTrue(scheduler.pendingHosts.iterator().next().getState() == MapHost.State.PENDING);
+ assertEquals(1, scheduler.pendingHosts.size());
+ assertSame(scheduler.pendingHosts.iterator().next().getState(), State.PENDING);
MapHost mapHost = scheduler.pendingHosts.iterator().next();
//Fails to pull from host0. host0 should be added to penalties
@@ -801,16 +808,17 @@ public void testPenalty() throws IOException, InterruptedException {
//Should not get host, as it is added to penalty loop
MapHost host = scheduler.getHost();
- assertFalse("Host identifier mismatch", (host.getHost() + ":" + host.getPort() + ":" + host.getPartitionId()).equalsIgnoreCase("host0:10000"));
+ assertFalse((host.getHost() + ":" + host.getPort() + ":" + host.getPartitionId()).equalsIgnoreCase("host0:10000"), "Host identifier mismatch");
//Refree thread would release it after INITIAL_PENALTY timeout
Thread.sleep(ShuffleScheduler.INITIAL_PENALTY + 1000);
host = scheduler.getHost();
- assertFalse("Host identifier mismatch", (host.getHost() + ":" + host.getPort() + ":" + host.getPartitionId()).equalsIgnoreCase("host0:10000"));
+ assertFalse((host.getHost() + ":" + host.getPort() + ":" + host.getPartitionId()).equalsIgnoreCase("host0:10000"), "Host identifier mismatch");
}
- @Test (timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testProgressDuringGetHostWait() throws IOException, InterruptedException {
long startTime = System.currentTimeMillis();
Configuration conf = new TezConfiguration();
@@ -832,7 +840,8 @@ public void run() {
verify(scheduler.inputContext, atLeast(3)).notifyProgress();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testShutdown() throws Exception {
InputContext inputContext = createTezInputContext();
Configuration conf = new TezConfiguration();
@@ -888,7 +897,8 @@ public Void call() throws Exception {
}
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testShutdownWithInterrupt() throws Exception {
InputContext inputContext = createTezInputContext();
Configuration conf = new TezConfiguration();
@@ -945,13 +955,13 @@ public Void call() throws Exception {
thread.start();
thread.join();
} finally {
- assertTrue("Fetcher executor should be shutdown, but still running",
- scheduler.hasFetcherExecutorStopped());
+ assertTrue(scheduler.hasFetcherExecutorStopped(), "Fetcher executor should be shutdown, but still running");
executor.shutdownNow();
}
}
- @Test (timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testPenalties() throws Exception {
InputContext inputContext = createTezInputContext();
Configuration conf = new TezConfiguration();
@@ -997,7 +1007,7 @@ public Void call() throws Exception {
ShuffleScheduler.Penalty[] penaltyArray = new ShuffleScheduler.Penalty[scheduler.getPenalties().size()];
scheduler.getPenalties().toArray(penaltyArray);
for (int i = 0; i < penaltyArray.length; i++) {
- Assert.assertTrue(penaltyArray[i].getDelay(TimeUnit.MILLISECONDS) <= 20000);
+ assertTrue(penaltyArray[i].getDelay(TimeUnit.MILLISECONDS) <= 20000);
}
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestIFile.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestIFile.java
index 271cedb197..672bdb2599 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestIFile.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestIFile.java
@@ -18,12 +18,8 @@
*/
package org.apache.tez.runtime.library.common.sort.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -35,6 +31,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
@@ -69,11 +66,7 @@
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,7 +98,7 @@ public class TestIFile {
}
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
CompressionCodecFactory codecFactory = new CompressionCodecFactory(new
Configuration());
@@ -113,20 +106,22 @@ public void setUp() throws Exception {
outputPath = new Path(workDir, outputFileName);
}
- @Before
- @After
+ @BeforeEach
+ @AfterEach
public void cleanup() throws Exception {
localFs.delete(workDir, true);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//empty IFile
public void testWithEmptyIFile() throws IOException {
testWriterAndReader(new LinkedList());
testWithDataBuffer(new LinkedList());
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCompressedFlag() throws IOException {
byte[] HEADER = new byte[] { (byte) 'T', (byte) 'I', (byte) 'F' , (byte) 1};
ByteArrayInputStream bin = new ByteArrayInputStream(HEADER);
@@ -144,7 +139,8 @@ public void testCompressedFlag() throws IOException {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//Write empty key value pairs
public void testWritingEmptyKeyValues() throws IOException {
DataInputBuffer key = new DataInputBuffer();
@@ -167,11 +163,12 @@ public void testWritingEmptyKeyValues() throws IOException {
assert(keyIn.getLength() == 0);
assert(valIn.getLength() == 0);
}
- assertTrue("Number of records read does not match", (records == 4));
+ assertTrue((records == 4), "Number of records read does not match");
reader.close();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//test with unsorted data and repeat keys
public void testWithUnsortedData() throws IOException {
List unsortedData = KVDataGen.generateTestData(false, rnd.nextInt(100));
@@ -179,7 +176,8 @@ public void testWithUnsortedData() throws IOException {
testWithDataBuffer(unsortedData);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//test with sorted data and repeat keys
public void testWithSortedData() throws IOException {
List sortedData = KVDataGen.generateTestData(true, rnd.nextInt(100));
@@ -188,7 +186,8 @@ public void testWithSortedData() throws IOException {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//test overflow
public void testExceedMaxSize() throws IOException {
final int oldMaxBufferSize = IFile.Reader.MAX_BUFFER_SIZE;
@@ -223,7 +222,7 @@ public void testExceedMaxSize() throws IOException {
try {
reader.nextRawKey(keyIn);
- Assert.fail("Expected IllegalArgumentException to be thrown");
+ fail("Expected IllegalArgumentException to be thrown");
} catch (IllegalArgumentException e) {
// test passed
}
@@ -247,7 +246,7 @@ public void testExceedMaxSize() throws IOException {
try {
reader.nextRawKey(keyIn);
reader.nextRawValue(valIn);
- Assert.fail("Expected IllegalArgumentException to be thrown");
+ fail("Expected IllegalArgumentException to be thrown");
} catch (IllegalArgumentException e) {
// test passed
}
@@ -296,7 +295,8 @@ public void testExceedMaxSize() throws IOException {
IFile.Reader.MAX_BUFFER_SIZE = oldMaxBufferSize;
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//test with sorted data and repeat keys
public void testWithRLEMarker() throws IOException {
//Test with append(Object, Object)
@@ -373,7 +373,8 @@ public void testWithRLEMarker() throws IOException {
boundedOut.close();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//test with unique keys
public void testWithUniqueKeys() throws IOException {
//all keys are unique
@@ -386,7 +387,8 @@ public void testWithUniqueKeys() throws IOException {
//This specific input is valid but the decompressor can leave lingering
// bytes between segments. If the lingering bytes aren't handled correctly,
// the stream will get out-of-sync.
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConcatenatedZlibPadding()
throws IOException, URISyntaxException {
byte[] bytes;
@@ -401,14 +403,14 @@ public void testConcatenatedZlibPadding()
URL url = getClass().getClassLoader()
.getResource("TestIFile_concatenated_compressed.bin");
- assertNotEquals("IFileinput file must exist", null, url);
+ assertNotNull(url, "IFileinput file must exist");
Path p = new Path(url.toURI());
FSDataInputStream inStream = localFs.open(p);
for (int i = 0; i < 5; i++) {
bytes = new byte[(int) raws[i]];
- assertEquals("Compressed stream out-of-sync", inStream.getPos(), compTotal);
- IFile.Reader.readToMemory(bytes, inStream, (int) compressed[i], codec,
+ assertEquals(inStream.getPos(), compTotal, "Compressed stream out-of-sync");
+ Reader.readToMemory(bytes, inStream, (int) compressed[i], codec,
false, -1);
compTotal += compressed[i];
@@ -434,7 +436,8 @@ public void testConcatenatedZlibPadding()
inStream.close();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//Test InMemoryWriter
public void testInMemoryWriter() throws IOException {
InMemoryWriter writer = null;
@@ -466,7 +469,8 @@ public void testInMemoryWriter() throws IOException {
readUsingInMemoryReader(bout.getBuffer(), data);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//Test appendValue feature
public void testAppendValue() throws IOException {
List data = KVDataGen.generateTestData(false, rnd.nextInt(100));
@@ -488,7 +492,8 @@ public void testAppendValue() throws IOException {
readAndVerifyData(writer.getRawLength(), writer.getCompressedLength(), data, codec);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//Test appendValues feature
public void testAppendValues() throws IOException {
List data = new ArrayList();
@@ -516,7 +521,8 @@ public void testAppendValues() throws IOException {
readAndVerifyData(writer.getRawLength(), writer.getCompressedLength(), data, codec);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// Basic test
public void testFileBackedInMemIFileWriter() throws IOException {
List data = new ArrayList<>();
@@ -548,7 +554,8 @@ public void testFileBackedInMemIFileWriter() throws IOException {
readUsingInMemoryReader(bytes, data);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// Basic test
public void testFileBackedInMemIFileWriterWithSmallBuffer() throws IOException {
List data = new ArrayList<>();
@@ -563,7 +570,7 @@ public void testFileBackedInMemIFileWriterWithSmallBuffer() throws IOException {
// Buffer should have self adjusted. So for this empty file, it shouldn't
// hit disk.
- assertFalse("Data should have been flushed to disk", writer.isDataFlushedToDisk());
+ assertFalse(writer.isDataFlushedToDisk(), "Data should have been flushed to disk");
byte[] bytes = new byte[(int) writer.getRawLength()];
IFile.Reader.readToMemory(bytes,
@@ -573,7 +580,8 @@ public void testFileBackedInMemIFileWriterWithSmallBuffer() throws IOException {
readUsingInMemoryReader(bytes, data);
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
// Test file spill over scenario
public void testFileBackedInMemIFileWriter_withSpill() throws IOException {
List data = new ArrayList<>();
@@ -602,7 +610,7 @@ public void testFileBackedInMemIFileWriter_withSpill() throws IOException {
writer.append(lastKey, lastVal);
writer.close();
- assertTrue("Data should have been flushed to disk", writer.isDataFlushedToDisk());
+ assertTrue(writer.isDataFlushedToDisk(), "Data should have been flushed to disk");
// Read output content to memory
FSDataInputStream inStream = localFs.open(outputPath);
@@ -615,7 +623,8 @@ public void testFileBackedInMemIFileWriter_withSpill() throws IOException {
readUsingInMemoryReader(bytes, data);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
// Test empty file case
public void testEmptyFileBackedInMemIFileWriter() throws IOException {
List data = new ArrayList<>();
@@ -640,7 +649,8 @@ public void testEmptyFileBackedInMemIFileWriter() throws IOException {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//Test appendKeyValues feature
public void testAppendKeyValues() throws IOException {
List data = new ArrayList();
@@ -667,7 +677,8 @@ public void testAppendKeyValues() throws IOException {
readAndVerifyData(writer.getRawLength(), writer.getCompressedLength(), data, codec);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
//Test appendValue with DataInputBuffer
public void testAppendValueWithDataInputBuffer() throws IOException {
List data = KVDataGen.generateTestData(false, rnd.nextInt(100));
@@ -693,7 +704,8 @@ public void testAppendValueWithDataInputBuffer() throws IOException {
readAndVerifyData(writer.getRawLength(), writer.getCompressedLength(), data, codec);
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testReadToDisk() throws IOException {
// verify sending a stream of zeroes generates an error
byte[] zeroData = new byte[1000];
@@ -715,7 +727,7 @@ public void testReadToDisk() throws IOException {
new ByteArrayInputStream(baos.toByteArray()), zeroData.length, false, 0);
fail("Exception should have been thrown");
} catch (IOException e) {
- assertTrue(e instanceof ChecksumException);
+ assertInstanceOf(ChecksumException.class, e);
}
// verify valid data is copied properly
@@ -742,7 +754,7 @@ public void testInMemoryBufferSize() throws IOException {
Writer writer = writeTestFile(false, false, data, codec);
readAndVerifyData(writer.getRawLength(), writer.getCompressedLength(), data, codec);
- Assert.assertEquals(originalCodecBufferSize, // original size is repaired
+ assertEquals(originalCodecBufferSize, // original size is repaired
configurableCodec.getConf().getInt(CodecUtils.getBufferSizeProperty(codec), 0));
// buffer size cannot grow infinitely with compressed data size
@@ -750,16 +762,25 @@ public void testInMemoryBufferSize() throws IOException {
writer = writeTestFile(false, false, data, codec);
readAndVerifyData(writer.getRawLength(), writer.getCompressedLength(), data, codec);
- Assert.assertEquals(originalCodecBufferSize, // original size is repaired
+ assertEquals(originalCodecBufferSize, // original size is repaired
configurableCodec.getConf().getInt(CodecUtils.getBufferSizeProperty(codec), 0));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSmallDataCompression() throws IOException {
- Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
-
- tryWriteFileWithBufferSize(17, "org.apache.hadoop.io.compress.Lz4Codec");
- tryWriteFileWithBufferSize(32, "org.apache.hadoop.io.compress.Lz4Codec");
+ assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
+
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ tryWriteFileWithBufferSize(17, "org.apache.hadoop.io.compress.Lz4Codec");
+ });
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ tryWriteFileWithBufferSize(32, "org.apache.hadoop.io.compress.Lz4Codec");
+ });
}
private void tryWriteFileWithBufferSize(int bufferSize, String codecClassName)
@@ -775,9 +796,10 @@ private void tryWriteFileWithBufferSize(int bufferSize, String codecClassName)
writeTestFile(false, false, data, codecToTest);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testLz4CompressedDataIsLargerThanOriginal() throws IOException {
- Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
+ assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
// this one succeeds
byte[] buf = new byte[32];
@@ -934,8 +956,7 @@ private void readUsingIFileReader(List originalData,
* @param data
* @throws IOException
*/
- private void verifyData(Reader reader, List data)
- throws IOException {
+ private void verifyData(Reader reader, List data) throws IOException {
LOG.info("Data verification");
Text readKey = new Text();
IntWritable readValue = new IntWritable();
@@ -943,8 +964,7 @@ private void verifyData(Reader reader, List data)
DataInputBuffer valIn = new DataInputBuffer();
Deserializer keyDeserializer;
Deserializer valDeserializer;
- SerializationFactory serializationFactory = new SerializationFactory(
- defaultConf);
+ SerializationFactory serializationFactory = new SerializationFactory(defaultConf);
keyDeserializer = serializationFactory.getDeserializer(Text.class);
valDeserializer = serializationFactory.getDeserializer(IntWritable.class);
keyDeserializer.open(keyIn);
@@ -958,15 +978,21 @@ private void verifyData(Reader reader, List data)
readValue = valDeserializer.deserialize(readValue);
KVPair expected = data.get(numRecordsRead);
- assertEquals("Key does not match: Expected: " + expected.getKey()
- + ", Read: " + readKey, expected.getKey(), readKey);
- assertEquals("Value does not match: Expected: " + expected.getvalue()
- + ", Read: " + readValue, expected.getvalue(), readValue);
+ assertEquals(
+ expected.getKey(),
+ readKey,
+ "Key does not match: Expected: " + expected.getKey() + ", Read: " + readKey);
+ assertEquals(
+ expected.getvalue(),
+ readValue,
+ "Value does not match: Expected: " + expected.getvalue() + ", Read: " + readValue);
numRecordsRead++;
}
- assertEquals("Expected: " + data.size() + " records, but found: "
- + numRecordsRead, data.size(), numRecordsRead);
+ assertEquals(
+ data.size(),
+ numRecordsRead,
+ "Expected: " + data.size() + " records, but found: " + numRecordsRead);
LOG.info("Found: " + numRecordsRead + " records");
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestPipelinedSorter.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestPipelinedSorter.java
index 6be733072e..141e200dd4 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestPipelinedSorter.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestPipelinedSorter.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.runtime.library.common.sort.impl;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
@@ -69,11 +68,7 @@
import com.google.common.collect.Maps;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestPipelinedSorter {
private static Configuration conf;
@@ -102,12 +97,12 @@ public class TestPipelinedSorter {
}
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws IOException {
localFs.delete(workDir, true);
}
- @Before
+ @BeforeEach
public void setup() throws IOException {
conf = getConf();
ApplicationId appId = ApplicationId.newInstance(10000, 1);
@@ -139,7 +134,7 @@ public static Configuration getConf() {
return conf;
}
- @After
+ @AfterEach
public void reset() throws IOException {
cleanup();
localFs.mkdirs(workDir);
@@ -183,7 +178,7 @@ public void testEmptyDataWithPipelinedShuffle() throws IOException {
writeData(sorter, 0, 1<<20);
// final merge is disabled. Final output file would not be populated in this case.
- assertTrue(sorter.finalOutputFile == null);
+ assertNull(sorter.finalOutputFile);
TezCounter numShuffleChunks = outputContext.getCounters().findCounter(TaskCounter.SHUFFLE_CHUNK_COUNT);
// assertTrue(sorter.getNumSpills() == numShuffleChunks.getValue());
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, true);
@@ -223,9 +218,9 @@ public void testEmptyPartitionsHelper(int numKeys, boolean sendEmptyPartitionDet
writeData(sorter, numKeys, 1000000);
if (numKeys == 0) {
- assertTrue(sorter.getNumSpills() == 1);
+ assertEquals(1, sorter.getNumSpills());
} else {
- assertTrue(sorter.getNumSpills() == numKeys + 1);
+ assertEquals(sorter.getNumSpills(), numKeys + 1);
}
verifyCounters(sorter, outputContext);
verifyOutputPermissions(outputContext.getUniqueIdentifier());
@@ -237,9 +232,9 @@ public void testEmptyPartitionsHelper(int numKeys, boolean sendEmptyPartitionDet
continue;
}
if (sendEmptyPartitionDetails) {
- Assert.assertEquals("Unexpected raw length for " + i + "th partition", 0, tezIndexRecord.getRawLength());
+ assertEquals(0, tezIndexRecord.getRawLength(), "Unexpected raw length for " + i + "th partition");
} else {
- Assert.assertEquals("Unexpected raw length for " + i + "th partition", 6, tezIndexRecord.getRawLength());
+ assertEquals(6, tezIndexRecord.getRawLength(), "Unexpected raw length for " + i + "th partition");
}
}
}
@@ -297,9 +292,9 @@ public void testExceedsKVWithPipelinedShuffle() throws IOException {
writeData(sorter, 5, 1<<20);
// final merge is disabled. Final output file would not be populated in this case.
- assertTrue(sorter.finalOutputFile == null);
+ assertNull(sorter.finalOutputFile);
TezCounter numShuffleChunks = outputContext.getCounters().findCounter(TaskCounter.SHUFFLE_CHUNK_COUNT);
- assertTrue(sorter.getNumSpills() == numShuffleChunks.getValue());
+ assertEquals(sorter.getNumSpills(), numShuffleChunks.getValue());
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, true);
}
@@ -410,7 +405,7 @@ public void testWithPipelinedShuffle() throws IOException {
List events = sorter.close();
//final merge is disabled. Final output file would not be populated in this case.
- assertTrue(sorter.finalOutputFile == null);
+ assertNull(sorter.finalOutputFile);
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, true);
verify(outputContext, times(0)).sendEvents(any());
assertTrue(events.size() > 0);
@@ -442,7 +437,7 @@ public void testMultipleSpills() throws IOException {
initialAvailableMem);
writeData(sorter, 25000, 1000);
- assertFalse("Expecting needsRLE to be false", sorter.needsRLE());
+ assertFalse(sorter.needsRLE(), "Expecting needsRLE to be false");
verifyCounters(sorter, outputContext);
verifyOutputPermissions(outputContext.getUniqueIdentifier());
}
@@ -495,7 +490,7 @@ public void testMultipleSpills_WithRLE() throws IOException {
initialAvailableMem);
writeSimilarKeys(sorter, 25000, 1000, true);
- assertTrue("Expecting needsRLE to be true", sorter.needsRLE());
+ assertTrue(sorter.needsRLE(), "Expecting needsRLE to be true");
verifyCounters(sorter, outputContext);
verifyOutputPermissions(outputContext.getUniqueIdentifier());
}
@@ -509,7 +504,7 @@ public void basicTestForBufferUsage() throws IOException {
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, true);
PipelinedSorter sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, (100 << 20));
- Assert.assertTrue(sorter.maxNumberOfBlocks >= 2);
+ assertTrue(sorter.maxNumberOfBlocks >= 2);
// Start filling in with data 1MB Key, 1MB Val.
for (int i = 0; i < 200; i++) {
@@ -521,8 +516,8 @@ public void basicTestForBufferUsage() throws IOException {
for(int i = 0; i< sorter.bufferUsage.size(); i++) {
int usage = sorter.bufferUsage.get(i);
- Assert.assertTrue("Buffer index " + i + " is not used correctly. "
- + " usage: " + usage + ", avg: " + avg, usage >= avg);
+ assertTrue(usage >= avg, "Buffer index " + i + " is not used correctly. "
+ + " usage: " + usage + ", avg: " + avg);
}
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, false);
}
@@ -572,7 +567,7 @@ public void basicTest(int partitions, int numKeys, int keySize,
TezRuntimeConfiguration.TEZ_RUNTIME_REPORT_PARTITION_STATS,
TezRuntimeConfiguration.TEZ_RUNTIME_REPORT_PARTITION_STATS_DEFAULT));
if (partitionStats.isEnabled()) {
- assertTrue(sorter.getPartitionStats() != null);
+ assertNotNull(sorter.getPartitionStats());
}
verifyCounters(sorter, outputContext);
@@ -600,19 +595,19 @@ private void verifyCounters(PipelinedSorter sorter, OutputContext context) {
context.getCounters().findCounter(TaskCounter.ADDITIONAL_SPILLS_BYTES_READ);
if (sorter.isFinalMergeEnabled()) {
- assertTrue(additionalSpills.getValue() == (sorter.getNumSpills() - 1));
+ assertEquals(additionalSpills.getValue(), (sorter.getNumSpills() - 1));
//Number of files served by shuffle-handler
- assertTrue(1 == numShuffleChunks.getValue());
+ assertEquals(1, numShuffleChunks.getValue());
if (sorter.getNumSpills() > 1) {
assertTrue(additionalSpillBytesRead.getValue() > 0);
assertTrue(additionalSpillBytesWritten.getValue() > 0);
}
} else {
- assertTrue(0 == additionalSpills.getValue());
+ assertEquals(0, additionalSpills.getValue());
//Number of files served by shuffle-handler
- assertTrue(sorter.getNumSpills() == numShuffleChunks.getValue());
- assertTrue(additionalSpillBytesRead.getValue() == 0);
- assertTrue(additionalSpillBytesWritten.getValue() == 0);
+ assertEquals(sorter.getNumSpills(), numShuffleChunks.getValue());
+ assertEquals(0, additionalSpillBytesRead.getValue());
+ assertEquals(0, additionalSpillBytesWritten.getValue());
}
TezCounter finalOutputBytes =
@@ -632,7 +627,7 @@ public void memTest() throws IOException {
//Verify if > 2 GB can be set via config
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 3076);
long size = ExternalSorter.getInitialMemoryRequirement(conf, 4096 * 1024 * 1024l);
- Assert.assertTrue(size == (3076l << 20));
+ assertEquals((3076l << 20), size);
//Verify number of block buffers allocated
this.initialAvailableMem = 10 * 1024 * 1024;
@@ -640,39 +635,39 @@ public void memTest() throws IOException {
.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 1);
PipelinedSorter sorter = new PipelinedSorter(this.outputContext, conf, numOutputs,
initialAvailableMem);
- Assert.assertTrue(sorter.maxNumberOfBlocks == 10);
+ assertEquals(10, sorter.maxNumberOfBlocks);
//10 MB available, request for 3 MB chunk. Last 1 MB gets added to previous chunk.
conf.setInt(TezRuntimeConfiguration
.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 3);
sorter = new PipelinedSorter(this.outputContext, conf, numOutputs,
initialAvailableMem);
- Assert.assertTrue(sorter.maxNumberOfBlocks == 3);
+ assertEquals(3, sorter.maxNumberOfBlocks);
//10 MB available, request for 10 MB min chunk. Would get 1 block.
conf.setInt(TezRuntimeConfiguration
.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 10);
sorter = new PipelinedSorter(this.outputContext, conf, numOutputs,
initialAvailableMem);
- Assert.assertTrue(sorter.maxNumberOfBlocks == 1);
+ assertEquals(1, sorter.maxNumberOfBlocks);
//Verify block sizes (10 MB min chunk size), but available mem is zero.
conf.setInt(TezRuntimeConfiguration
.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 10);
sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, initialAvailableMem);
- Assert.assertTrue(sorter.maxNumberOfBlocks == 1);
+ assertEquals(1, sorter.maxNumberOfBlocks);
int blockSize = sorter.computeBlockSize(0, (10 << 20));
//available is zero. Can't allocate any more buffer.
- Assert.assertTrue(blockSize == 0);
+ assertEquals(0, blockSize);
//300 MB available. Request for 200 MB min block size. It would allocate a block with 200 MB,
// but last 100 would get clubbed. Hence, it would return 300 MB block.
conf.setInt(TezRuntimeConfiguration
.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 200);
sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, (300 << 20));
- Assert.assertTrue(sorter.maxNumberOfBlocks == 1);
+ assertEquals(1, sorter.maxNumberOfBlocks);
blockSize = sorter.computeBlockSize((300 << 20), (300 << 20));
- Assert.assertTrue(blockSize == (300 << 20));
+ assertEquals((300 << 20), blockSize);
//300 MB available. Request for 3500 MB min block size. throw exception
conf.setInt(TezRuntimeConfiguration
@@ -690,24 +685,24 @@ public void memTest() throws IOException {
conf.setInt(TezRuntimeConfiguration
.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 32);
sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, (64 << 20));
- Assert.assertTrue(sorter.maxNumberOfBlocks == 2);
+ assertEquals(2, sorter.maxNumberOfBlocks);
blockSize = sorter.computeBlockSize((64 << 20), (64 << 20));
- Assert.assertTrue(blockSize == (32 << 20));
+ assertEquals((32 << 20), blockSize);
blockSize = sorter.computeBlockSize((32 << 20), (64 << 20));
- Assert.assertTrue(blockSize == (32 << 20));
+ assertEquals((32 << 20), blockSize);
blockSize = sorter.computeBlockSize((48 << 20), (64 << 20));
- Assert.assertTrue(blockSize == (48 << 20));
+ assertEquals((48 << 20), blockSize);
//64 MB available. Request for 8 MB min block size.
conf.setInt(TezRuntimeConfiguration
.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 8);
sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, (64 << 20));
- Assert.assertTrue(sorter.maxNumberOfBlocks == 8);
+ assertEquals(8, sorter.maxNumberOfBlocks);
blockSize = sorter.computeBlockSize((64 << 20), (64 << 20));
//Should return 16 instead of 8 which is min block size.
- Assert.assertTrue(blockSize == (8 << 20));
+ assertEquals((8 << 20), blockSize);
}
@Test
@@ -724,8 +719,8 @@ public void test_without_lazyMemAllocation() throws IOException {
.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, false);
PipelinedSorter sorter = new PipelinedSorter(this.outputContext, conf,
numOutputs, (128l << 20));
- assertTrue("Expected 1 sort buffers. current len=" + sorter.buffers.size(),
- sorter.buffers.size() == 1);
+ assertEquals(1, sorter.buffers.size(),
+ "Expected 1 sort buffers. current len=" + sorter.buffers.size());
//128 MB. Pre-allocate. Get 2 buffer
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 128);
@@ -735,8 +730,8 @@ public void test_without_lazyMemAllocation() throws IOException {
.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, false);
sorter = new PipelinedSorter(this.outputContext, conf,
numOutputs, (128l << 20));
- assertTrue("Expected 2 sort buffers. current len=" + sorter.buffers.size(),
- sorter.buffers.size() == 2);
+ assertEquals(2, sorter.buffers.size(),
+ "Expected 2 sort buffers. current len=" + sorter.buffers.size());
//48 MB. Pre-allocate. But request for lesser block size (62). Get 2 buffer
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 48);
@@ -746,66 +741,65 @@ public void test_without_lazyMemAllocation() throws IOException {
.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, false);
sorter = new PipelinedSorter(this.outputContext, conf,
numOutputs, (48l << 20));
- assertTrue("Expected 1 sort buffers. current len=" + sorter.buffers.size(),
- sorter.buffers.size() == 1);
+ assertEquals(1, sorter.buffers.size(),
+ "Expected 1 sort buffers. current len=" + sorter.buffers.size());
}
@Test
- //Intentionally not having timeout
+ // Intentionally not having timeout
public void test_with_lazyMemAllocation() throws IOException {
this.numOutputs = 10;
- //128 MB. Do not pre-allocate.
+ // 128 MB. Do not pre-allocate.
// Get 32 MB buffer first and the another buffer with 96 on filling up
// the 32 MB buffer.
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 128);
- conf.setBoolean(TezRuntimeConfiguration
- .TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, true);
- PipelinedSorter sorter = new PipelinedSorter(this.outputContext, conf,
- numOutputs, (128l << 20));
- assertTrue("Expected 1 sort buffers. current len=" + sorter.buffers.size(),
- sorter.buffers.size() == 1);
- assertTrue(sorter.buffers.get(0).capacity() == 32 * 1024 * 1024 - 64);
- writeData(sorter, 100, 1024*1024, false); //100 1 MB KV. Will spill
-
- //Now it should have created 2 buffers, 32 & 96 MB buffers.
- assertTrue(sorter.buffers.size() == 2);
- assertTrue(sorter.buffers.get(0).capacity() == 32 * 1024 * 1024 - 64);
- assertTrue(sorter.buffers.get(1).capacity() == 96 * 1024 * 1024 + 64);
+ conf.setBoolean(
+ TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, true);
+ PipelinedSorter sorter =
+ new PipelinedSorter(this.outputContext, conf, numOutputs, (128l << 20));
+ assertEquals(1, sorter.buffers.size(),
+ "Expected 1 sort buffers. current len=" + sorter.buffers.size());
+ assertEquals(32 * 1024 * 1024 - 64, sorter.buffers.get(0).capacity());
+ writeData(sorter, 100, 1024 * 1024, false); // 100 1 MB KV. Will spill
+
+ // Now it should have created 2 buffers, 32 & 96 MB buffers.
+ assertEquals(2, sorter.buffers.size());
+ assertEquals(32 * 1024 * 1024 - 64, sorter.buffers.get(0).capacity());
+ assertEquals(96 * 1024 * 1024 + 64, sorter.buffers.get(1).capacity());
closeSorter(sorter);
verifyCounters(sorter, outputContext);
- //TODO: Not sure if this would fail in build machines due to mem
- //300 MB. Do not pre-allocate.
+ // TODO: Not sure if this would fail in build machines due to mem
+ // 300 MB. Do not pre-allocate.
// Get 1 buffer with 62 MB. But grow to 2 buffers as data is written
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 300);
- conf.setBoolean(TezRuntimeConfiguration
- .TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, true);
+ conf.setBoolean(
+ TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, true);
sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, (300l << 20));
- assertTrue(sorter.buffers.size() == 1);
- assertTrue(sorter.buffers.get(0).capacity() == 32 * 1024 * 1024 - 64);
+ assertEquals(1, sorter.buffers.size());
+ assertEquals(32 * 1024 * 1024 - 64, sorter.buffers.get(0).capacity());
- writeData(sorter, 50, 1024*1024, false); //50 1 MB KV to allocate 2nd buf
- assertTrue(sorter.buffers.size() == 2);
- assertTrue(sorter.buffers.get(0).capacity() == 32 * 1024 * 1024 - 64);
- assertTrue(sorter.buffers.get(1).capacity() == 268 * 1024 * 1024 + 64);
+ writeData(sorter, 50, 1024 * 1024, false); // 50 1 MB KV to allocate 2nd buf
+ assertEquals(2, sorter.buffers.size());
+ assertEquals(32 * 1024 * 1024 - 64, sorter.buffers.get(0).capacity());
+ assertEquals(268 * 1024 * 1024 + 64, sorter.buffers.get(1).capacity());
- //48 MB. Do not pre-allocate.
+ // 48 MB. Do not pre-allocate.
// Get 32 MB buffer first invariably and proceed with the rest.
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 48);
- conf.setBoolean(TezRuntimeConfiguration
- .TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, true);
- sorter = new PipelinedSorter(this.outputContext, conf,
- numOutputs, (48l << 20));
- assertTrue("Expected 1 sort buffers. current len=" + sorter.buffers.size(),
- sorter.buffers.size() == 1);
- assertTrue(sorter.buffers.get(0).capacity() == 32 * 1024 * 1024 - 64);
- writeData(sorter, 20, 1024*1024, false); //100 1 MB KV. Will spill
-
- //Now it should have created 2 buffers, 32 & 96 MB buffers.
- assertTrue(sorter.buffers.size() == 2);
- assertTrue(sorter.buffers.get(0).capacity() == 32 * 1024 * 1024 - 64);
- assertTrue(sorter.buffers.get(1).capacity() == 16 * 1024 * 1024 + 64);
+ conf.setBoolean(
+ TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SORTER_LAZY_ALLOCATE_MEMORY, true);
+ sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, (48l << 20));
+ assertEquals(1, sorter.buffers.size(),
+ "Expected 1 sort buffers. current len=" + sorter.buffers.size());
+ assertEquals(32 * 1024 * 1024 - 64, sorter.buffers.get(0).capacity());
+ writeData(sorter, 20, 1024 * 1024, false); // 100 1 MB KV. Will spill
+
+ // Now it should have created 2 buffers, 32 & 96 MB buffers.
+ assertEquals(2, sorter.buffers.size());
+ assertEquals(32 * 1024 * 1024 - 64, sorter.buffers.get(0).capacity());
+ assertEquals(16 * 1024 * 1024 + 64, sorter.buffers.get(1).capacity());
closeSorter(sorter);
}
@@ -887,14 +881,24 @@ public void testWithLargeRecordAndLowMemory() throws IOException {
}
private void verifyOutputPermissions(String spillId) throws IOException {
- String subpath = Constants.TEZ_RUNTIME_TASK_OUTPUT_DIR + "/" + spillId
- + "/" + Constants.TEZ_RUNTIME_TASK_OUTPUT_FILENAME_STRING;
+ String subpath =
+ Constants.TEZ_RUNTIME_TASK_OUTPUT_DIR
+ + "/"
+ + spillId
+ + "/"
+ + Constants.TEZ_RUNTIME_TASK_OUTPUT_FILENAME_STRING;
Path outputPath = dirAllocator.getLocalPathToRead(subpath, conf);
- Path indexPath = dirAllocator.getLocalPathToRead(subpath + Constants.TEZ_RUNTIME_TASK_OUTPUT_INDEX_SUFFIX_STRING, conf);
- Assert.assertEquals("Incorrect output permissions", (short)0640,
- localFs.getFileStatus(outputPath).getPermission().toShort());
- Assert.assertEquals("Incorrect index permissions", (short)0640,
- localFs.getFileStatus(indexPath).getPermission().toShort());
+ Path indexPath =
+ dirAllocator.getLocalPathToRead(
+ subpath + Constants.TEZ_RUNTIME_TASK_OUTPUT_INDEX_SUFFIX_STRING, conf);
+ assertEquals(
+ (short) 0640,
+ localFs.getFileStatus(outputPath).getPermission().toShort(),
+ "Incorrect output permissions");
+ assertEquals(
+ (short) 0640,
+ localFs.getFileStatus(indexPath).getPermission().toShort(),
+ "Incorrect index permissions");
}
private void writeData(ExternalSorter sorter, int numKeys, int keyLen) throws IOException {
@@ -974,12 +978,12 @@ private void verifyData(IFile.Reader reader)
reader.nextRawValue(valIn);
readKey = keyDeserializer.deserialize(readKey);
readValue = valDeserializer.deserialize(readValue);
- Assert.assertTrue(key.equals(readKey));
- Assert.assertTrue(val.equals(readValue));
+ assertEquals(key, readKey);
+ assertEquals(val, readValue);
numRecordsRead++;
}
}
- Assert.assertTrue(numRecordsRead == sortedDataMap.size());
+ assertEquals(numRecordsRead, sortedDataMap.size());
}
private static OutputContext createMockOutputContext(TezCounters counters, ApplicationId appId,
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestTezMerger.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestTezMerger.java
index a4663c68ec..002bf60664 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestTezMerger.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/TestTezMerger.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.runtime.library.common.sort.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import java.io.IOException;
@@ -27,7 +26,9 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -53,6 +54,7 @@
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.InMemoryWriter;
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.MergeManager;
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.TestMergeManager;
+import org.apache.tez.runtime.library.common.sort.impl.TezMerger.MergeQueue;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
@@ -60,8 +62,7 @@
import com.google.common.collect.Maps;
import com.google.common.collect.TreeMultimap;
-import org.junit.AfterClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -102,12 +103,13 @@ public class TestTezMerger {
comparator = ConfigUtils.getIntermediateInputKeyComparator(DEFAULT_CONF);
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
localFs.delete(workDir, true);
}
- @Test(timeout = 80000)
+ @Test
+ @Timeout(value = 80000, unit = TimeUnit.MILLISECONDS)
public void testMerge() throws Exception {
/*
* test with number of files, keys per file and mergefactor
@@ -171,10 +173,10 @@ private void verify(TezRawKeyValueIterator records, String[][] expectedResult)
String correctResult = expectedResult[i][1];
if (records.isSameKey()) {
- assertTrue("Expected " + correctResult, correctResult.equalsIgnoreCase(SAME_KEY));
+ assertTrue(correctResult.equalsIgnoreCase(SAME_KEY), "Expected " + correctResult);
LOG.info("\tSame Key : key=" + k + ", val=" + v);
} else {
- assertTrue("Expected " + correctResult, correctResult.equalsIgnoreCase(DIFF_KEY));
+ assertTrue(correctResult.equalsIgnoreCase(DIFF_KEY), "Expected " + correctResult);
LOG.info("key=" + k + ", val=" + v);
}
@@ -182,7 +184,8 @@ private void verify(TezRawKeyValueIterator records, String[][] expectedResult)
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_WithEmptyStrings() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -232,7 +235,8 @@ public void testWithCustomComparator_WithEmptyStrings() throws Exception {
data.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_No_RLE() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -281,7 +285,8 @@ public void testWithCustomComparator_No_RLE() throws Exception {
data.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_RLE_acrossFiles() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -320,7 +325,8 @@ public void testWithCustomComparator_RLE_acrossFiles() throws Exception {
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_mixedFiles() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -368,7 +374,8 @@ public void testWithCustomComparator_mixedFiles() throws Exception {
data.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_RLE() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -406,7 +413,8 @@ public void testWithCustomComparator_RLE() throws Exception {
data.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_RLE2() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -454,7 +462,8 @@ public void testWithCustomComparator_RLE2() throws Exception {
data.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -491,7 +500,8 @@ public void testWithCustomComparator() throws Exception {
data.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_RLE3() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -525,7 +535,8 @@ public void testWithCustomComparator_RLE3() throws Exception {
data.clear();
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testWithCustomComparator_allEmptyFiles() throws Exception {
List pathList = new LinkedList<>();
List data = Lists.newLinkedList();
@@ -619,7 +630,7 @@ private void verifyData(TezRawKeyValueIterator records) throws IOException {
//More than one key should be present in the source data
assertTrue(VERIFICATION_DATA_SET.get(k.get()).size() > 1);
//Ensure this is same as the previous key we saw
- assertEquals("previousKey=" + pk + ", current=" + k.get(), pk, k.get());
+ assertEquals(pk, k.get(), "previousKey=" + pk + ", current=" + k.get());
} else {
LOG.info("key=" + k.get() + ", val=" + v.get());
}
@@ -630,20 +641,19 @@ private void verifyData(TezRawKeyValueIterator records) throws IOException {
}
//Verify if the number of distinct entries is the same in source and the test
- assertEquals("dataMap=" + dataMap.keySet().size() + ", verificationSet=" +
- VERIFICATION_DATA_SET.keySet().size(), dataMap.keySet().size(), VERIFICATION_DATA_SET.keySet().size());
+ assertEquals(dataMap.keySet().size(), VERIFICATION_DATA_SET.keySet().size(), "dataMap=" + dataMap.keySet().size() + ", verificationSet=" +
+ VERIFICATION_DATA_SET.keySet().size());
//Verify with source data
for (Integer key : VERIFICATION_DATA_SET.keySet()) {
- assertEquals("Data size for " + key + " not matching with source; dataSize:" + dataMap
- .get(key) + ", source:" + VERIFICATION_DATA_SET.get(key).size(),
- (int) dataMap.get(key), VERIFICATION_DATA_SET.get(key).size());
+ assertEquals((int) dataMap.get(key), VERIFICATION_DATA_SET.get(key).size(), "Data size for " + key + " not matching with source; dataSize:" + dataMap
+ .get(key) + ", source:" + VERIFICATION_DATA_SET.get(key).size());
}
//Verify if every key has the same number of repeated items in the source dataset as well
- for (Map.Entry entry : dataMap.entrySet()) {
- assertEquals(entry.getKey() + "", VERIFICATION_DATA_SET.get(entry.getKey()).size(), (int) entry
- .getValue());
+ for (Entry entry : dataMap.entrySet()) {
+ assertEquals(VERIFICATION_DATA_SET.get(entry.getKey()).size(), (int) entry
+ .getValue(), entry.getKey() + "");
}
LOG.info("******************");
@@ -661,7 +671,8 @@ private List createIFiles(int fileCount, int keysPerFile)
return pathList;
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testMergeSegments() throws Exception {
List segments = Lists.newLinkedList();
segments.addAll(createInMemorySegments(10, 100));
@@ -685,7 +696,7 @@ public void testMergeSegments() throws Exception {
private void mergeSegments(List segmentList, int mergeFactor, boolean
hasDiskSegments) throws Exception {
//Merge datasets
- TezMerger.MergeQueue mergeQueue = new TezMerger.MergeQueue(DEFAULT_CONF, localFs, segmentList,
+ MergeQueue mergeQueue = new MergeQueue(DEFAULT_CONF, localFs, segmentList,
comparator, new Reporter(), false, false);
TezRawKeyValueIterator records = mergeQueue.merge(
@@ -698,7 +709,7 @@ private void mergeSegments(List segmentList, int mergeFactor,
//ensure disk buffers are used
int diskBufLen = mergeQueue.diskIFileValue.getLength();
- assertTrue(diskBufLen + " disk buf length should be > 0", (hasDiskSegments == diskBufLen > 0));
+ assertTrue((hasDiskSegments == diskBufLen > 0), diskBufLen + " disk buf length should be > 0");
VERIFICATION_DATA_SET.clear();
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/dflt/TestDefaultSorter.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/dflt/TestDefaultSorter.java
index 5ff3d28d1e..8079b71f66 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/dflt/TestDefaultSorter.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/sort/impl/dflt/TestDefaultSorter.java
@@ -18,9 +18,7 @@
*/
package org.apache.tez.runtime.library.common.sort.impl.dflt;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.atLeastOnce;
@@ -36,6 +34,7 @@
import java.util.BitSet;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@@ -78,12 +77,7 @@
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -99,7 +93,7 @@ public class TestDefaultSorter {
private Configuration conf;
private LocalDirAllocator dirAllocator;
- @Before
+ @BeforeEach
public void setup() throws IOException {
conf = new Configuration();
conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
@@ -120,18 +114,19 @@ public void setup() throws IOException {
dirAllocator = new LocalDirAllocator(TezRuntimeFrameworkConfigs.LOCAL_DIRS);
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws IOException {
localFs.delete(workingDir, true);
}
- @After
+ @AfterEach
public void reset() throws IOException {
cleanup();
localFs.mkdirs(workingDir);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSortSpillPercent() throws Exception {
OutputContext context = createTezOutputContext();
@@ -154,7 +149,7 @@ public void testSortSpillPercent() throws Exception {
@Test
- @Ignore
+ @Disabled
/**
* Disabling this, as this would need 2047 MB sort mb for testing.
* Set DefaultSorter.MAX_IO_SORT_MB = 20467 for running this.
@@ -193,7 +188,7 @@ public void testSortLimitsWithSmallRecord() throws IOException {
}
@Test
- @Ignore
+ @Disabled
/**
* Disabling this, as this would need 2047 MB io.sort.mb for testing.
* Provide > 2GB to JVM when running this test to avoid OOM in string generation.
@@ -229,30 +224,31 @@ public void testSortLimitsWithLargeRecords() throws IOException {
}
}
-
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSortMBLimits() throws Exception {
- assertTrue("Expected " + DefaultSorter.MAX_IO_SORT_MB,
- DefaultSorter.computeSortBufferSize(4096, "") == DefaultSorter.MAX_IO_SORT_MB);
- assertTrue("Expected " + DefaultSorter.MAX_IO_SORT_MB,
- DefaultSorter.computeSortBufferSize(2047, "") == DefaultSorter.MAX_IO_SORT_MB);
- assertTrue("Expected 1024", DefaultSorter.computeSortBufferSize(1024, "") == 1024);
+ assertEquals(DefaultSorter.MAX_IO_SORT_MB, DefaultSorter.computeSortBufferSize(4096, ""),
+ "Expected " + DefaultSorter.MAX_IO_SORT_MB);
+ assertEquals(DefaultSorter.MAX_IO_SORT_MB, DefaultSorter.computeSortBufferSize(2047, ""),
+ "Expected " + DefaultSorter.MAX_IO_SORT_MB);
+ assertEquals(1024, DefaultSorter.computeSortBufferSize(1024, ""), "Expected 1024");
try {
DefaultSorter.computeSortBufferSize(0, "");
fail("Should have thrown error for setting buffer size to 0");
- } catch(RuntimeException re) {
+ } catch (RuntimeException re) {
}
try {
DefaultSorter.computeSortBufferSize(-100, "");
fail("Should have thrown error for setting buffer size to negative value");
- } catch(RuntimeException re) {
+ } catch (RuntimeException re) {
}
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
//Test TEZ-1977
public void basicTest() throws IOException {
OutputContext context = createTezOutputContext();
@@ -292,7 +288,8 @@ public void basicTest() throws IOException {
verifyOutputPermissions(context.getUniqueIdentifier());
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testEmptyCaseFileLengths() throws IOException {
testEmptyCaseFileLengthsHelper(50, new String[] {"a", "b"}, new String[] {"1", "2"});
testEmptyCaseFileLengthsHelper(50, new String[] {"a", "a"}, new String[] {"1", "2"});
@@ -311,7 +308,7 @@ public void testEmptyCaseFileLengthsHelper(int numPartitions, String[] keys, Str
String auxService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID, TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
SorterWrapper sorterWrapper = new SorterWrapper(context, conf, numPartitions, handler.getMemoryAssigned());
DefaultSorter sorter = sorterWrapper.getSorter();
- assertEquals("Key and Values must have the same number of elements", keys.length, values.length);
+ assertEquals(keys.length, values.length, "Key and Values must have the same number of elements");
BitSet keyRLEs = new BitSet(keys.length);
for (int i = 0; i < keys.length; i++) {
boolean isRLE = sorterWrapper.writeKeyValue(new Text(keys[i]), new Text(values[i]));
@@ -336,10 +333,9 @@ public void testEmptyCaseFileLengthsHelper(int numPartitions, String[] keys, Str
TezCommonUtils.decompressByteStringToByteArray(
shufflePayload.getEmptyPartitions());
BitSet emptyPartitionBitSet = TezUtilsInternal.fromByteArray(emptyPartitionsBytesString);
- Assert.assertEquals("Number of empty partitions did not match!",
- emptyPartitionBitSet.cardinality(), sorterWrapper.getEmptyPartitionsCount());
+ assertEquals(emptyPartitionBitSet.cardinality(), sorterWrapper.getEmptyPartitionsCount(), "Number of empty partitions did not match!");
} else {
- Assert.assertEquals(sorterWrapper.getEmptyPartitionsCount(), 0);
+ assertEquals(sorterWrapper.getEmptyPartitionsCount(), 0);
}
// Each non-empty partition adds 4 bytes for header, 2 bytes for EOF_MARKER, 4 bytes for checksum
int expectedFileOutLength = sorterWrapper.getNonEmptyPartitionsCount() * 10;
@@ -349,7 +345,7 @@ public void testEmptyCaseFileLengthsHelper(int numPartitions, String[] keys, Str
// Each Record adds 1 byte for value length, 1 byte Text overhead (length), value.length bytes for value
expectedFileOutLength += values[i].length() + 2;
}
- assertEquals("Unexpected Output File Size!", localFs.getFileStatus(sorter.getFinalOutputFile()).getLen(), expectedFileOutLength);
+ assertEquals(localFs.getFileStatus(sorter.getFinalOutputFile()).getLen(), expectedFileOutLength, "Unexpected Output File Size!");
assertEquals(sorter.getNumSpills(), 1);
verifyCounters(sorter, context);
}
@@ -376,7 +372,8 @@ public void testWithEmptyData() throws IOException {
}
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testWithEmptyDataWithFinalMergeDisabled() throws IOException {
OutputContext context = createTezOutputContext();
@@ -427,9 +424,9 @@ public void testEmptyPartitionsHelper(int numKeys, boolean sendEmptyPartitionDet
}
sorterWrapper.close();
if (numKeys == 0) {
- assertTrue(sorter.getNumSpills() == 1);
+ assertEquals(1, sorter.getNumSpills());
} else {
- assertTrue(sorter.getNumSpills() == numKeys);
+ assertEquals(sorter.getNumSpills(), numKeys);
}
verifyCounters(sorter, context);
verifyOutputPermissions(context.getUniqueIdentifier());
@@ -442,9 +439,9 @@ public void testEmptyPartitionsHelper(int numKeys, boolean sendEmptyPartitionDet
continue;
}
if (sendEmptyPartitionDetails) {
- Assert.assertEquals("Unexpected raw length for " + i + "th partition", 0, tezIndexRecord.getRawLength());
+ assertEquals(0, tezIndexRecord.getRawLength(), "Unexpected raw length for " + i + "th partition");
} else {
- Assert.assertEquals("", tezIndexRecord.getRawLength(), 6);
+ assertEquals(tezIndexRecord.getRawLength(), 6, "");
}
}
}
@@ -457,9 +454,9 @@ public void testEmptyPartitionsHelper(int numKeys, boolean sendEmptyPartitionDet
continue;
}
if (sendEmptyPartitionDetails) {
- Assert.assertEquals("Unexpected raw length for " + i + "th partition", 0, tezIndexRecord.getRawLength());
+ assertEquals(0, tezIndexRecord.getRawLength(), "Unexpected raw length for " + i + "th partition");
} else {
- Assert.assertEquals("Unexpected raw length for " + i + "th partition", 6, tezIndexRecord.getRawLength());
+ assertEquals(6, tezIndexRecord.getRawLength(), "Unexpected raw length for " + i + "th partition");
}
}
}
@@ -482,27 +479,30 @@ void testPartitionStats(boolean withStats) throws IOException {
sorterWrapper.writeKeyValue(keys[i], values[i]);
}
sorterWrapper.close();
- assertTrue(sorter.getNumSpills() == 1);
+ assertEquals(1, sorter.getNumSpills());
verifyCounters(sorter, context);
if (withStats) {
- assertTrue(sorter.getPartitionStats() != null);
+ assertNotNull(sorter.getPartitionStats());
} else {
- assertTrue(sorter.getPartitionStats() == null);
+ assertNull(sorter.getPartitionStats());
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testWithPartitionStats() throws IOException {
testPartitionStats(true);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testWithoutPartitionStats() throws IOException {
testPartitionStats(false);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
@SuppressWarnings("unchecked")
public void testWithSingleSpillWithFinalMergeDisabled() throws IOException {
OutputContext context = createTezOutputContext();
@@ -522,7 +522,7 @@ public void testWithSingleSpillWithFinalMergeDisabled() throws IOException {
sorterWrapper.writeKeyValue(keys[i], values[i]);
}
sorterWrapper.close();
- assertTrue(sorter.getNumSpills() == 1);
+ assertEquals(1, sorter.getNumSpills());
ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(List.class);
verify(context, times(1)).sendEvents(eventCaptor.capture());
List events = eventCaptor.getValue();
@@ -539,7 +539,8 @@ public void testWithSingleSpillWithFinalMergeDisabled() throws IOException {
verifyCounters(sorter, context);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
@SuppressWarnings("unchecked")
public void testWithMultipleSpillsWithFinalMergeDisabled() throws IOException {
OutputContext context = createTezOutputContext();
@@ -575,7 +576,7 @@ public void testWithMultipleSpillsWithFinalMergeDisabled() throws IOException {
spillIndex++;
}
}
- assertTrue(spillIndex == spillCount);
+ assertEquals(spillIndex, spillCount);
verifyCounters(sorter, context);
}
@@ -584,10 +585,8 @@ private void verifyOutputPermissions(String spillId) throws IOException {
+ "/" + Constants.TEZ_RUNTIME_TASK_OUTPUT_FILENAME_STRING;
Path outputPath = dirAllocator.getLocalPathToRead(subpath, conf);
Path indexPath = dirAllocator.getLocalPathToRead(subpath + Constants.TEZ_RUNTIME_TASK_OUTPUT_INDEX_SUFFIX_STRING, conf);
- Assert.assertEquals("Incorrect output permissions", (short)0640,
- localFs.getFileStatus(outputPath).getPermission().toShort());
- Assert.assertEquals("Incorrect index permissions", (short)0640,
- localFs.getFileStatus(indexPath).getPermission().toShort());
+ assertEquals((short)0640, localFs.getFileStatus(outputPath).getPermission().toShort(), "Incorrect output permissions");
+ assertEquals((short)0640, localFs.getFileStatus(indexPath).getPermission().toShort(), "Incorrect index permissions");
}
private void verifyCounters(DefaultSorter sorter, OutputContext context) {
@@ -597,19 +596,19 @@ private void verifyCounters(DefaultSorter sorter, OutputContext context) {
TezCounter additionalSpillBytesRead = context.getCounters().findCounter(TaskCounter.ADDITIONAL_SPILLS_BYTES_READ);
if (sorter.isFinalMergeEnabled()) {
- assertTrue(additionalSpills.getValue() == (sorter.getNumSpills() - 1));
+ assertEquals(additionalSpills.getValue(), (sorter.getNumSpills() - 1));
//Number of files served by shuffle-handler
- assertTrue(1 == numShuffleChunks.getValue());
+ assertEquals(1, numShuffleChunks.getValue());
if (sorter.getNumSpills() > 1) {
assertTrue(additionalSpillBytesRead.getValue() > 0);
assertTrue(additionalSpillBytesWritten.getValue() > 0);
}
} else {
- assertTrue(0 == additionalSpills.getValue());
+ assertEquals(0, additionalSpills.getValue());
//Number of files served by shuffle-handler
- assertTrue(sorter.getNumSpills() == numShuffleChunks.getValue());
- assertTrue(additionalSpillBytesRead.getValue() == 0);
- assertTrue(additionalSpillBytesWritten.getValue() == 0);
+ assertEquals(sorter.getNumSpills(), numShuffleChunks.getValue());
+ assertEquals(0, additionalSpillBytesRead.getValue());
+ assertEquals(0, additionalSpillBytesWritten.getValue());
}
TezCounter finalOutputBytes = context.getCounters().findCounter(TaskCounter.OUTPUT_BYTES_PHYSICAL);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/writers/TestUnorderedPartitionedKVWriter.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/writers/TestUnorderedPartitionedKVWriter.java
index 3bb2441659..6929605e6e 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/writers/TestUnorderedPartitionedKVWriter.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/common/writers/TestUnorderedPartitionedKVWriter.java
@@ -18,10 +18,7 @@
*/
package org.apache.tez.runtime.library.common.writers;
-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.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.atLeast;
@@ -39,9 +36,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
-import java.util.Arrays;
import java.util.BitSet;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -49,8 +44,10 @@
import java.util.Random;
import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
@@ -83,6 +80,7 @@
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration.ReportPartitionStats;
import org.apache.tez.runtime.library.common.Constants;
import org.apache.tez.runtime.library.common.sort.impl.IFile;
+import org.apache.tez.runtime.library.common.sort.impl.IFile.Reader;
import org.apache.tez.runtime.library.common.sort.impl.TezIndexRecord;
import org.apache.tez.runtime.library.common.sort.impl.TezSpillRecord;
import org.apache.tez.runtime.library.common.task.local.output.TezTaskOutput;
@@ -99,11 +97,9 @@
import com.google.common.collect.Sets;
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.params.*;
+import org.junit.jupiter.params.provider.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -111,7 +107,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@RunWith(value = Parameterized.class)
public class TestUnorderedPartitionedKVWriter {
private static final Logger LOG = LoggerFactory.getLogger(TestUnorderedPartitionedKVWriter.class);
@@ -128,45 +123,46 @@ public class TestUnorderedPartitionedKVWriter {
private ReportPartitionStats reportPartitionStats;
private Configuration defaultConf = new Configuration();
- public TestUnorderedPartitionedKVWriter(boolean shouldCompress,
- ReportPartitionStats reportPartitionStats) {
+ public void setupInit(boolean shouldCompress, ReportPartitionStats reportPartitionStats) {
this.shouldCompress = shouldCompress;
this.reportPartitionStats = reportPartitionStats;
}
@SuppressWarnings("deprecation")
- @Parameterized.Parameters(name = "test[{0}, {1}]")
- public static Collection data() {
- Object[][] data = new Object[][] {
- { false, ReportPartitionStats.DISABLED },
- { false, ReportPartitionStats.ENABLED },
- { false, ReportPartitionStats.NONE },
- { false, ReportPartitionStats.MEMORY_OPTIMIZED },
- { false, ReportPartitionStats.PRECISE },
- { true, ReportPartitionStats.DISABLED },
- { true, ReportPartitionStats.ENABLED },
- { true, ReportPartitionStats.NONE },
- { true, ReportPartitionStats.MEMORY_OPTIMIZED },
- { true, ReportPartitionStats.PRECISE }};
- return Arrays.asList(data);
+ public static Stream data() {
+ return Stream.of(
+ Arguments.of(false, ReportPartitionStats.DISABLED),
+ Arguments.of(false, ReportPartitionStats.ENABLED),
+ Arguments.of(false, ReportPartitionStats.NONE),
+ Arguments.of(false, ReportPartitionStats.MEMORY_OPTIMIZED),
+ Arguments.of(false, ReportPartitionStats.PRECISE),
+ Arguments.of(true, ReportPartitionStats.DISABLED),
+ Arguments.of(true, ReportPartitionStats.ENABLED),
+ Arguments.of(true, ReportPartitionStats.NONE),
+ Arguments.of(true, ReportPartitionStats.MEMORY_OPTIMIZED),
+ Arguments.of(true, ReportPartitionStats.PRECISE)
+ );
}
- @Before
- public void setup() throws IOException {
+ @BeforeAll
+ public static void setup() throws IOException {
LOG.info("Setup. Using test dir: " + TEST_ROOT_DIR);
localFs = FileSystem.getLocal(new Configuration());
localFs.delete(TEST_ROOT_DIR, true);
localFs.mkdirs(TEST_ROOT_DIR);
}
- @After
+ @AfterEach
public void cleanup() throws IOException {
LOG.info("CleanUp");
localFs.delete(TEST_ROOT_DIR, true);
}
- @Test(timeout = 10000)
- public void testBufferSizing() throws IOException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testBufferSizing(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException {
+ setupInit(shouldCompress, reportPartitionStats);
ApplicationId appId = ApplicationId.newInstance(10000000, 1);
TezCounters counters = new TezCounters();
String uniqueId = UUID.randomUUID().toString();
@@ -250,107 +246,167 @@ public void testBufferSizing() throws IOException {
assertEquals(1, kvWriter.spillLimit);
}
- @Test(timeout = 10000)
- public void testNoSpill() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoSpill(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(10, 10, null, shouldCompress, -1, 0);
}
- @Test(timeout = 10000)
- public void testSingleSpill() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSingleSpill(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(50, 10, null, shouldCompress, -1, 0);
}
- @Test(timeout = 10000)
- public void testMultipleSpills() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testMultipleSpills(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(200, 10, null, shouldCompress, -1, 0);
}
- @Test(timeout = 10000)
- public void testMultipleSpillsWithSmallBuffer() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testMultipleSpillsWithSmallBuffer(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
// numBuffers is much higher than available threads.
baseTest(200, 10, null, shouldCompress, 512, 0, 9600, false);
}
- @Test(timeout = 10000)
- public void testMergeBuffersAndSpill() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testMergeBuffersAndSpill(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(200, 10, null, shouldCompress, 2048, 10);
}
- @Test(timeout = 10000)
- public void testNoRecords() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoRecords(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(0, 10, null, shouldCompress, -1, 0);
}
- @Test(timeout = 10000)
- public void testNoRecords_SinglePartition() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoRecords_SinglePartition(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
// skipBuffers
baseTest(0, 1, null, shouldCompress, -1, 0, 2048, false);
// Check with data via events
baseTest(0, 1, null, shouldCompress, -1, 0, 2048, true);
}
- @Test(timeout = 10000)
- public void testSkippedPartitions() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSkippedPartitions(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(200, 10, Sets.newHashSet(2, 5), shouldCompress, -1, 0);
}
- @Test(timeout = 10000)
- public void testNoSpill_SinglePartition() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoSpill_SinglePartition(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(10, 1, null, shouldCompress, -1, 0);
}
- @Test(timeout = 10000)
- public void testSpill_SinglePartition() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSpill_SinglePartition(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTest(1000, 1, null, shouldCompress, -1, 0, 2048, true);
}
- @Test(timeout = 10000)
- public void testRandomText() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testRandomText(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(100, 10, 2048, 0, 0, 0, false, true);
}
- @Test(timeout = 10000)
- public void testLargeKeys() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testLargeKeys(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(0, 10, 2048, 10, 0, 0, false, true);
}
- @Test(timeout = 10000)
- public void testLargevalues() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testLargevalues(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(0, 10, 2048, 0, 10, 0, false, true);
}
- @Test(timeout = 10000)
- public void testLargeKvPairs() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testLargeKvPairs(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(0, 10, 2048, 0, 0, 10, false, true);
}
- @Test(timeout = 10000)
- public void testTextMixedRecords() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testTextMixedRecords(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(100, 10, 2048, 10, 10, 10, false, true);
}
- @Test(timeout = 10000000)
- public void testRandomTextWithoutFinalMerge() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000000, unit = TimeUnit.MILLISECONDS)
+ public void testRandomTextWithoutFinalMerge(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(100, 10, 2048, 0, 0, 0, false, false);
}
- @Test(timeout = 10000)
- public void testLargeKeysWithoutFinalMerge() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testLargeKeysWithoutFinalMerge(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(0, 10, 2048, 10, 0, 0, false, false);
}
- @Test(timeout = 10000)
- public void testLargevaluesWithoutFinalMerge() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testLargevaluesWithoutFinalMerge(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(0, 10, 2048, 0, 10, 0, false, false);
}
- @Test(timeout = 10000)
- public void testLargeKvPairsWithoutFinalMerge() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testLargeKvPairsWithoutFinalMerge(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(0, 10, 2048, 0, 0, 10, false, false);
}
- @Test(timeout = 10000)
- public void testTextMixedRecordsWithoutFinalMerge() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testTextMixedRecordsWithoutFinalMerge(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(100, 10, 2048, 10, 10, 10, false, false);
}
@@ -488,11 +544,11 @@ public void textTest(int numRegularRecords, int numPartitions, long availableMem
// Validate the events
assertEquals(2, events.size());
- assertTrue(events.get(0) instanceof VertexManagerEvent);
+ assertInstanceOf(VertexManagerEvent.class, events.get(0));
VertexManagerEvent vme = (VertexManagerEvent) events.get(0);
verifyPartitionStats(vme, partitionsWithData);
- assertTrue(events.get(1) instanceof CompositeDataMovementEvent);
+ assertInstanceOf(CompositeDataMovementEvent.class, events.get(1));
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(1);
assertEquals(0, cdme.getSourceIndexStart());
assertEquals(numPartitions, cdme.getCount());
@@ -610,43 +666,64 @@ private void verifyPartitionStats(VertexManagerEvent vme,
for (int i = 0; i < stats.length; i++) {
// The stats should be greater than zero if and only if
// the partition has data
- assertTrue(expectedPartitionsWithData.get(i) == (stats[i] > 0));
+ assertEquals(expectedPartitionsWithData.get(i), (stats[i] > 0));
}
}
- @Test(timeout = 10000)
- public void testNoSpill_WithPipelinedShuffle() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoSpill_WithPipelinedShuffle(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithPipelinedTransfer(10, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testSingleSpill_WithPipelinedShuffle() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSingleSpill_WithPipelinedShuffle(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithPipelinedTransfer(50, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testMultipleSpills_WithPipelinedShuffle() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testMultipleSpills_WithPipelinedShuffle(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithPipelinedTransfer(200, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testNoRecords_WithPipelinedShuffle() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoRecords_WithPipelinedShuffle(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithPipelinedTransfer(0, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testNoRecords_SinglePartition_WithPipelinedShuffle() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoRecords_SinglePartition_WithPipelinedShuffle(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
// skipBuffers
baseTestWithPipelinedTransfer(0, 1, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testSkippedPartitions_WithPipelinedShuffle() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSkippedPartitions_WithPipelinedShuffle(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithPipelinedTransfer(200, 10, Sets.newHashSet(2, 5), shouldCompress);
}
- @Test(timeout = 10000)
- public void testLargeKvPairs_WithPipelinedShuffle() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testLargeKvPairs_WithPipelinedShuffle(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
textTest(0, 10, 2048, 10, 20, 50, true, false);
}
@@ -710,11 +787,11 @@ private void baseTestWithPipelinedTransfer(int numRecords, int numPartitions, Se
List lastEvents = kvWriter.close();
if (numPartitions == 1) {
- assertEquals(false, kvWriter.skipBuffers);
+ assertFalse(kvWriter.skipBuffers);
}
//no events are sent to kvWriter upon close with pipelining
- assertTrue(lastEvents.size() == 0);
+ assertEquals(0, lastEvents.size());
verify(outputContext, atLeast(numExpectedSpills)).sendEvents(eventCaptor.capture());
int numOfCapturedEvents = eventCaptor.getAllValues().size();
lastEvents = eventCaptor.getAllValues().get(numOfCapturedEvents - 1);
@@ -723,12 +800,12 @@ private void baseTestWithPipelinedTransfer(int numRecords, int numPartitions, Se
for (int i=0; i events = eventCaptor.getAllValues().get(i);
if (i < numOfCapturedEvents - 1) {
- assertTrue(events.size() == 1);
- assertTrue(events.get(0) instanceof CompositeDataMovementEvent);
+ assertEquals(1, events.size());
+ assertInstanceOf(CompositeDataMovementEvent.class, events.get(0));
} else {
- assertTrue(events.size() == 2);
- assertTrue(events.get(0) instanceof VertexManagerEvent);
- assertTrue(events.get(1) instanceof CompositeDataMovementEvent);
+ assertEquals(2, events.size());
+ assertInstanceOf(VertexManagerEvent.class, events.get(0));
+ assertInstanceOf(CompositeDataMovementEvent.class, events.get(1));
}
}
verifyPartitionStats(VMEvent, partitionsWithData);
@@ -780,7 +857,7 @@ private void baseTestWithPipelinedTransfer(int numRecords, int numPartitions, Se
assertEquals(additionalSpillBytesWritten, 0);
//No additional spills when final merge is disabled.
- assertTrue(additionalSpillBytesWritten == additionalSpillBytesRead);
+ assertEquals(additionalSpillBytesWritten, additionalSpillBytesRead);
//No additional spills when final merge is disabled.
assertEquals(numAdditionalSpillsCounter.getValue(), 0);
@@ -788,7 +865,7 @@ private void baseTestWithPipelinedTransfer(int numRecords, int numPartitions, Se
assertTrue(lastEvents.size() > 0);
//Get the last event
int index = lastEvents.size() - 1;
- assertTrue(lastEvents.get(index) instanceof CompositeDataMovementEvent);
+ assertInstanceOf(CompositeDataMovementEvent.class, lastEvents.get(index));
CompositeDataMovementEvent cdme =
(CompositeDataMovementEvent)lastEvents.get(index);
assertEquals(0, cdme.getSourceIndexStart());
@@ -820,14 +897,10 @@ private void baseTestWithPipelinedTransfer(int numRecords, int numPartitions, Se
}
private void checkPermissions(Path outputFile, Path indexFile) throws IOException {
- assertEquals("Incorrect output permissions (user)", FsAction.READ_WRITE,
- localFs.getFileStatus(outputFile).getPermission().getUserAction());
- assertEquals("Incorrect output permissions (group)", FsAction.READ,
- localFs.getFileStatus(outputFile).getPermission().getGroupAction());
- assertEquals("Incorrect index permissions (user)", FsAction.READ_WRITE,
- localFs.getFileStatus(indexFile).getPermission().getUserAction());
- assertEquals("Incorrect index permissions (group)", FsAction.READ,
- localFs.getFileStatus(indexFile).getPermission().getGroupAction());
+ assertEquals(FsAction.READ_WRITE, localFs.getFileStatus(outputFile).getPermission().getUserAction(), "Incorrect output permissions (user)");
+ assertEquals(FsAction.READ, localFs.getFileStatus(outputFile).getPermission().getGroupAction(), "Incorrect output permissions (group)");
+ assertEquals(FsAction.READ_WRITE, localFs.getFileStatus(indexFile).getPermission().getUserAction(), "Incorrect index permissions (user)");
+ assertEquals(FsAction.READ, localFs.getFileStatus(indexFile).getPermission().getGroupAction(), "Incorrect index permissions (group)");
}
private void verifyEmptyPartitions(DataMovementEventPayloadProto eventProto,
@@ -863,38 +936,59 @@ private void verifyEmptyPartitions(DataMovementEventPayloadProto eventProto,
}
}
- @Test(timeout = 10000)
- public void testNoSpill_WithFinalMergeDisabled() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoSpill_WithFinalMergeDisabled(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithFinalMergeDisabled(10, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testSingleSpill_WithFinalMergeDisabled() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSingleSpill_WithFinalMergeDisabled(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithFinalMergeDisabled(50, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testSinglePartition_WithFinalMergeDisabled() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSinglePartition_WithFinalMergeDisabled(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithFinalMergeDisabled(0, 1, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testMultipleSpills_WithFinalMergeDisabled() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testMultipleSpills_WithFinalMergeDisabled(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithFinalMergeDisabled(200, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testNoRecords_WithFinalMergeDisabled() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoRecords_WithFinalMergeDisabled(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithFinalMergeDisabled(0, 10, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testNoRecords_SinglePartition_WithFinalMergeDisabled() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testNoRecords_SinglePartition_WithFinalMergeDisabled(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithFinalMergeDisabled(0, 1, null, shouldCompress);
}
- @Test(timeout = 10000)
- public void testSkippedPartitions_WithFinalMergeDisabled() throws IOException, InterruptedException {
+ @ParameterizedTest(name = "test[{0}, {1}]")
+ @MethodSource("data")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testSkippedPartitions_WithFinalMergeDisabled(boolean shouldCompress, ReportPartitionStats reportPartitionStats) throws IOException, InterruptedException {
+ setupInit(shouldCompress, reportPartitionStats);
baseTestWithFinalMergeDisabled(200, 10, Sets.newHashSet(2, 5), shouldCompress);
}
@@ -957,7 +1051,7 @@ private void baseTestWithFinalMergeDisabled(int numRecords, int numPartitions,
List lastEvents = kvWriter.close();
if (numPartitions == 1) {
- assertEquals(true, kvWriter.skipBuffers);
+ assertTrue(kvWriter.skipBuffers);
}
// max events sent are spills + one VM event. If there are no spills, atleast empty
@@ -1013,9 +1107,8 @@ private void baseTestWithFinalMergeDisabled(int numRecords, int numPartitions,
if (numRecordsWritten > 0) {
assertTrue(fileOutputBytes > 0);
if (!shouldCompress) {
- assertTrue("fileOutputBytes=" + fileOutputBytes + ", outputRecordBytes="
- +outputRecordBytesCounter.getValue(),
- fileOutputBytes > outputRecordBytesCounter.getValue());
+ assertTrue(fileOutputBytes > outputRecordBytesCounter.getValue(), "fileOutputBytes=" + fileOutputBytes + ", outputRecordBytes="
+ +outputRecordBytesCounter.getValue());
}
} else {
assertEquals(0, fileOutputBytes);
@@ -1029,7 +1122,7 @@ private void baseTestWithFinalMergeDisabled(int numRecords, int numPartitions,
assertEquals(additionalSpillBytesWritten, 0);
//No additional spills when final merge is disabled.
- assertTrue(additionalSpillBytesWritten == additionalSpillBytesRead);
+ assertEquals(additionalSpillBytesWritten, additionalSpillBytesRead);
//No additional spills when final merge is disabled.
assertEquals(numAdditionalSpillsCounter.getValue(), 0);
@@ -1037,7 +1130,7 @@ private void baseTestWithFinalMergeDisabled(int numRecords, int numPartitions,
assertTrue(lastEvents.size() > 0);
//Get the last event
int index = lastEvents.size() - 1;
- assertTrue(lastEvents.get(index) instanceof CompositeDataMovementEvent);
+ assertInstanceOf(CompositeDataMovementEvent.class, lastEvents.get(index));
CompositeDataMovementEvent cdme =
(CompositeDataMovementEvent)lastEvents.get(index);
assertEquals(0, cdme.getSourceIndexStart());
@@ -1062,14 +1155,14 @@ private void baseTestWithFinalMergeDisabled(int numRecords, int numPartitions,
cdme = (CompositeDataMovementEvent)event;
eventProto = DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(cdme.getUserPayload()));
- assertEquals(false, eventProto.getPipelined());
+ assertFalse(eventProto.getPipelined());
if (eventProto.hasPathComponent()) {
//for final merge disabled cases, it should have _spillId
Matcher matcher = mergePathComponentPattern.matcher(eventProto.getPathComponent());
- assertTrue("spill id should be present in path component " + eventProto.getPathComponent(), matcher.matches());
+ assertTrue(matcher.matches(), "spill id should be present in path component " + eventProto.getPathComponent());
assertEquals(2, matcher.groupCount());
assertEquals(uniqueId, matcher.group(1));
- assertTrue("spill id should be present in path component", matcher.group(2) != null);
+ assertNotNull(matcher.group(2), "spill id should be present in path component");
Path outputPath = new Path(outputContext.getWorkDirs()[0],
"output/" + eventProto.getPathComponent() + "/" + Constants.TEZ_RUNTIME_TASK_OUTPUT_FILENAME_STRING);
Path indexPath = outputPath.suffix(Constants.TEZ_RUNTIME_TASK_OUTPUT_INDEX_SUFFIX_STRING);
@@ -1077,7 +1170,7 @@ private void baseTestWithFinalMergeDisabled(int numRecords, int numPartitions,
} else {
assertEquals(0, eventProto.getSpillId());
if (outputRecordsCounter.getValue() > 0) {
- assertEquals(true, eventProto.getLastEvent());
+ assertTrue(eventProto.getLastEvent());
} else {
byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(eventProto
.getEmptyPartitions());
@@ -1172,12 +1265,12 @@ private void baseTest(int numRecords, int numPartitions, Set skippedPar
List events = kvWriter.close();
if (numPartitions == 1) {
- assertEquals(true, kvWriter.skipBuffers);
+ assertTrue(kvWriter.skipBuffers);
// VM & DME events
assertEquals(2, events.size());
Event event1 = events.get(1);
- assertTrue(event1 instanceof CompositeDataMovementEvent);
+ assertInstanceOf(CompositeDataMovementEvent.class, event1);
CompositeDataMovementEvent dme = (CompositeDataMovementEvent) event1;
ByteBuffer bb = dme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload =
@@ -1256,10 +1349,10 @@ private void baseTest(int numRecords, int numPartitions, Set skippedPar
BitSet emptyPartitionBits = null;
// Verify the events returned
assertEquals(2, events.size());
- assertTrue(events.get(0) instanceof VertexManagerEvent);
+ assertInstanceOf(VertexManagerEvent.class, events.get(0));
VertexManagerEvent vme = (VertexManagerEvent) events.get(0);
verifyPartitionStats(vme, partitionsWithData);
- assertTrue(events.get(1) instanceof CompositeDataMovementEvent);
+ assertInstanceOf(CompositeDataMovementEvent.class, events.get(1));
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(1);
assertEquals(0, cdme.getSourceIndexStart());
assertEquals(numOutputs, cdme.getCount());
@@ -1304,22 +1397,17 @@ private void baseTest(int numRecords, int numPartitions, Set skippedPar
boolean isInMem= eventProto.getData().hasData();
assertTrue(localFs.exists(outputFilePath));
- assertEquals("Incorrect output permissions (user)", FsAction.READ_WRITE,
- localFs.getFileStatus(outputFilePath).getPermission().getUserAction());
- assertEquals("Incorrect output permissions (group)", FsAction.READ,
- localFs.getFileStatus(outputFilePath).getPermission().getGroupAction());
+ assertEquals(FsAction.READ_WRITE, localFs.getFileStatus(outputFilePath).getPermission().getUserAction(), "Incorrect output permissions (user)");
+ assertEquals(FsAction.READ, localFs.getFileStatus(outputFilePath).getPermission().getGroupAction(), "Incorrect output permissions (group)");
if( !isInMem ) {
assertTrue(localFs.exists(spillFilePath));
- assertEquals("Incorrect index permissions (user)", FsAction.READ_WRITE,
- localFs.getFileStatus(spillFilePath).getPermission().getUserAction());
- assertEquals("Incorrect index permissions (group)", FsAction.READ,
- localFs.getFileStatus(spillFilePath).getPermission().getGroupAction());
+ assertEquals(FsAction.READ_WRITE, localFs.getFileStatus(spillFilePath).getPermission().getUserAction(), "Incorrect index permissions (user)");
+ assertEquals(FsAction.READ, localFs.getFileStatus(spillFilePath).getPermission().getGroupAction(), "Incorrect index permissions (group)");
// verify no intermediate spill files have been left around
synchronized (kvWriter.spillInfoList) {
for (SpillInfo spill : kvWriter.spillInfoList) {
- assertFalse("lingering intermediate spill file " + spill.outPath,
- localFs.exists(spill.outPath));
+ assertFalse(localFs.exists(spill.outPath), "lingering intermediate spill file " + spill.outPath);
}
}
}
@@ -1330,26 +1418,26 @@ private void baseTest(int numRecords, int numPartitions, Set skippedPar
IntWritable keyDeser = new IntWritable();
LongWritable valDeser = new LongWritable();
for (int i = 0; i < numOutputs; i++) {
- IFile.Reader reader = null;
+ Reader reader = null;
InputStream inStream;
if (isInMem) {
// Read from in memory payload
int dataLoadSize = eventProto.getData().getData().size();
inStream = new ByteArrayInputStream(eventProto.getData().getData().toByteArray());
- reader = new IFile.Reader(inStream, dataLoadSize, codec, null,
+ reader = new Reader(inStream, dataLoadSize, codec, null,
null, false, 0, -1);
} else {
TezSpillRecord spillRecord = new TezSpillRecord(spillFilePath, conf);
TezIndexRecord indexRecord = spillRecord.getIndex(i);
if (skippedPartitions != null && skippedPartitions.contains(i)) {
- assertFalse("The Index Record for partition " + i + " should not have any data", indexRecord.hasData());
+ assertFalse(indexRecord.hasData(), "The Index Record for partition " + i + " should not have any data");
continue;
}
FSDataInputStream tmpStream = FileSystem.getLocal(conf).open(outputFilePath);
tmpStream.seek(indexRecord.getStartOffset());
inStream = tmpStream;
- reader = new IFile.Reader(tmpStream, indexRecord.getPartLength(), codec, null,
+ reader = new Reader(tmpStream, indexRecord.getPartLength(), codec, null,
null, false, 0, -1);
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedGroupedMergedKVInputConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedGroupedMergedKVInputConfig.java
index 1fdb195b67..4380f9fe28 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedGroupedMergedKVInputConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedGroupedMergedKVInputConfig.java
@@ -18,24 +18,23 @@
*/
package org.apache.tez.runtime.library.conf;
-import static org.junit.Assert.assertEquals;
-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.*;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
import com.google.common.collect.Maps;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestOrderedGroupedMergedKVInputConfig {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
OrderedGroupedKVInputConfig.newBuilder(null, "VALUE");
@@ -52,7 +51,8 @@ public void testNullParams() {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetters() {
Configuration fromConf = new Configuration(false);
fromConf.set("test.conf.key.1", "confkey1");
@@ -110,7 +110,7 @@ public void testSetters() {
assertEquals("VALUE", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, ""));
assertEquals("CustomCodec",
conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
false));
assertEquals(0.11f, conf.getFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_MEMORY_LIMIT_PERCENT, 0.0f), 0.001f);
assertEquals(0.22f, conf.getFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_MERGE_PERCENT, 0.0f), 0.001f);
@@ -127,11 +127,11 @@ public void testSetters() {
.TEZ_RUNTIME_SHUFFLE_MAX_ALLOWED_FAILED_FETCH_ATTEMPT_FRACTION, 0.00f), 0.001f);
assertEquals(0.6f, conf.getFloat(TezRuntimeConfiguration
.TEZ_RUNTIME_SHUFFLE_MIN_REQUIRED_PROGRESS_FRACTION, 0.6f), 0.001f);
- assertEquals(false, conf.getBoolean(TezRuntimeConfiguration
+ assertFalse(conf.getBoolean(TezRuntimeConfiguration
.TEZ_RUNTIME_SHUFFLE_FAILED_CHECK_SINCE_LAST_COMPLETION, true));
// Verify additional configs
- assertEquals(false, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertFalse(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals(1111, conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES_DEFAULT));
@@ -146,7 +146,8 @@ public void testSetters() {
assertEquals("unfiltered1", conf.get("test.conf.unfiltered.1"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
OrderedGroupedKVInputConfig.Builder builder =
OrderedGroupedKVInputConfig.newBuilder("KEY", "VALUE");
@@ -157,7 +158,7 @@ public void testDefaultConfigsUsed() {
Configuration conf = rebuilt.conf;
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
// Default property present.
@@ -169,7 +170,8 @@ public void testDefaultConfigsUsed() {
assertEquals("VALUE", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, ""));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCombinerConfigs() {
Map combinerConf = Maps.newHashMap();
combinerConf.put("combiner.test.key", "COMBINERKEY");
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVEdgeConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVEdgeConfig.java
index cd433de4d2..2d0fb8955c 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVEdgeConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVEdgeConfig.java
@@ -18,15 +18,12 @@
*/
package org.apache.tez.runtime.library.conf;
-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.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -37,11 +34,12 @@
import com.google.common.collect.Maps;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestOrderedPartitionedKVEdgeConfig {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
OrderedPartitionedKVEdgeConfig.newBuilder(null, "VALUE", "PARTITIONER");
@@ -65,7 +63,8 @@ public void testNullParams() {
}
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
OrderedPartitionedKVEdgeConfig.Builder builder = OrderedPartitionedKVEdgeConfig
.newBuilder("KEY", "VALUE", "PARTITIONER");
@@ -79,19 +78,20 @@ public void testDefaultConfigsUsed() {
rebuiltInput.fromUserPayload(configuration.getInputPayload());
Configuration outputConf = rebuiltOutput.conf;
- assertEquals(true, outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals("TestCodec",
outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
Configuration inputConf = rebuiltInput.conf;
- assertEquals(true, inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals("TestCodec",
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testSpecificIOConfs() {
// Ensures that Output and Input confs are not mixed.
OrderedPartitionedKVEdgeConfig.Builder builder = OrderedPartitionedKVEdgeConfig
@@ -114,7 +114,8 @@ public void testSpecificIOConfs() {
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, "DEFAULT"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void tetCommonConf() {
Configuration fromConf = new Configuration(false);
@@ -184,7 +185,7 @@ public void tetCommonConf() {
ReportPartitionStats.fromString(outputConf.get(
TezRuntimeConfiguration.TEZ_RUNTIME_REPORT_PARTITION_STATS,
TezRuntimeConfiguration.TEZ_RUNTIME_REPORT_PARTITION_STATS_DEFAULT));
- assertEquals(true, partitionStats.isEnabled());
+ assertTrue(partitionStats.isEnabled());
assertEquals(3, inputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_FACTOR, 0));
@@ -206,7 +207,8 @@ public void tetCommonConf() {
assertEquals("unfiltered1", inputConf.get("test.conf.unfiltered.1"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testSetters() {
Map comparatorConf = Maps.newHashMap();
comparatorConf.put("comparator.test.key", "comparatorValue");
@@ -236,9 +238,8 @@ public void testSetters() {
assertEquals(1111, outputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 0));
assertEquals("CustomCodec",
outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true,
- outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
- false));
+ assertTrue(outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ false));
assertEquals("KEY_COMPARATOR",
outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_COMPARATOR_CLASS));
assertEquals("comparatorValue", outputConf.get("comparator.test.key"));
@@ -255,9 +256,8 @@ public void testSetters() {
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, ""));
assertEquals("CustomCodec",
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true,
- inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
- false));
+ assertTrue(inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ false));
assertEquals(0.11f,
inputConf.getFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_MEMORY_LIMIT_PERCENT, 0.0f), 0.001f);
@@ -271,7 +271,8 @@ public void testSetters() {
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testSerialization() {
OrderedPartitionedKVEdgeConfig.Builder builder = OrderedPartitionedKVEdgeConfig
.newBuilder("KEY", "VALUE", "PARTITIONER")
@@ -296,9 +297,8 @@ public void testSerialization() {
assertEquals("PARTITIONER", outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_PARTITIONER_CLASS, ""));
assertEquals("CustomCodec",
outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true,
- outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
- false));
+ assertTrue(outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ false));
assertNull(outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT));
//verify comparator and serialization class
assertEquals("SomeComparator1",
@@ -317,9 +317,8 @@ public void testSerialization() {
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, ""));
assertEquals("CustomCodec",
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true,
- inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
- false));
+ assertTrue(inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ false));
}
private void checkHistoryText(String historyText) {
@@ -328,7 +327,8 @@ private void checkHistoryText(String historyText) {
TezRuntimeConfiguration.TEZ_RUNTIME_CONVERT_USER_PAYLOAD_TO_HISTORY_TEXT));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testHistoryText() {
OrderedPartitionedKVEdgeConfig.Builder builder =
OrderedPartitionedKVEdgeConfig.newBuilder("KEY", "VALUE", "PARTITIONER");
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVOutputConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVOutputConfig.java
index 64d8487a1d..b9af81f2d9 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVOutputConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestOrderedPartitionedKVOutputConfig.java
@@ -18,24 +18,23 @@
*/
package org.apache.tez.runtime.library.conf;
-import static org.junit.Assert.assertEquals;
-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.*;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
import com.google.common.collect.Maps;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestOrderedPartitionedKVOutputConfig {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
OrderedPartitionedKVOutputConfig.newBuilder(
@@ -62,7 +61,8 @@ public void testNullParams() {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetters() {
Configuration fromConf = new Configuration(false);
fromConf.set("test.conf.key.1", "confkey1");
@@ -101,12 +101,12 @@ public void testSetters() {
assertEquals("PARTITIONER", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_PARTITIONER_CLASS, ""));
assertEquals("CustomCodec",
conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
false));
assertEquals("KEY_COMPARATOR", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_COMPARATOR_CLASS));
// Verify additional configs
- assertEquals(false, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertFalse(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals(1111, conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES_DEFAULT));
@@ -122,7 +122,8 @@ public void testSetters() {
assertEquals("unfiltered1", conf.get("test.conf.unfiltered.1"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
OrderedPartitionedKVOutputConfig.Builder builder =
OrderedPartitionedKVOutputConfig.newBuilder("KEY", "VALUE", "PARTITIONER", null);
@@ -133,7 +134,7 @@ public void testDefaultConfigsUsed() {
Configuration conf = rebuilt.conf;
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
// Property present
@@ -146,7 +147,8 @@ public void testDefaultConfigsUsed() {
assertEquals("PARTITIONER", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_PARTITIONER_CLASS, ""));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPartitionerConfigs() {
Map partitionerConf = Maps.newHashMap();
partitionerConf.put("partitioner.test.key", "PARTITIONERKEY");
@@ -170,7 +172,8 @@ public void testPartitionerConfigs() {
assertEquals("PARTITIONERKEY", conf.get("partitioner.test.key"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testCombinerConfigs() {
Map combinerConf = Maps.newHashMap();
combinerConf.put("combiner.test.key", "COMBINERKEY");
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVEdgeConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVEdgeConfig.java
index e51484cb28..55b8710d91 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVEdgeConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVEdgeConfig.java
@@ -18,15 +18,12 @@
*/
package org.apache.tez.runtime.library.conf;
-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.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -34,11 +31,12 @@
import org.apache.tez.dag.api.EdgeProperty;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestUnorderedKVEdgeConfig {
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
UnorderedKVEdgeConfig.newBuilder(null, "VALUE");
@@ -55,7 +53,8 @@ public void testNullParams() {
}
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
UnorderedKVEdgeConfig.Builder builder =
UnorderedKVEdgeConfig.newBuilder("KEY", "VALUE");
@@ -72,7 +71,7 @@ public void testDefaultConfigsUsed() {
rebuiltInput.fromUserPayload(configuration.getInputPayload());
Configuration outputConf = rebuiltOutput.conf;
- assertEquals(true, outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals("TestCodec",
outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
@@ -80,7 +79,7 @@ public void testDefaultConfigsUsed() {
("SerClass2,SerClass1"));
Configuration inputConf = rebuiltInput.conf;
- assertEquals(true, inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals("TestCodec",
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
@@ -88,7 +87,8 @@ public void testDefaultConfigsUsed() {
("SerClass2,SerClass1"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testSpecificIOConfs() {
// Ensures that Output and Input confs are not mixed.
UnorderedKVEdgeConfig.Builder builder =
@@ -112,7 +112,8 @@ public void testSpecificIOConfs() {
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, "DEFAULT"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void tetCommonConf() {
Configuration fromConf = new Configuration(false);
@@ -151,7 +152,7 @@ public void tetCommonConf() {
Configuration outputConf = rebuiltOutput.conf;
Configuration inputConf = rebuiltInput.conf;
- assertEquals(false, outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
+ assertFalse(outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
assertEquals(1111, outputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES, 0));
assertEquals(3333, outputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_FILE_BUFFER_SIZE, 0));
assertNull(outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT));
@@ -163,7 +164,7 @@ public void tetCommonConf() {
assertEquals("unfiltered1", outputConf.get("test.conf.unfiltered.1"));
- assertEquals(false, inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
+ assertFalse(inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
assertEquals(1111, inputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES, 0));
assertEquals(3333, inputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_FILE_BUFFER_SIZE, 0));
assertEquals(0.11f,
@@ -185,7 +186,8 @@ private void checkHistoryText(String historyText) {
TezRuntimeConfiguration.TEZ_RUNTIME_CONVERT_USER_PAYLOAD_TO_HISTORY_TEXT));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testHistoryText() {
UnorderedKVEdgeConfig.Builder builder = UnorderedKVEdgeConfig.newBuilder("KEY", "VALUE");
Configuration fromConf = new Configuration(false);
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVInputConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVInputConfig.java
index b313655f16..90c3d5c2f5 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVInputConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVInputConfig.java
@@ -18,23 +18,22 @@
*/
package org.apache.tez.runtime.library.conf;
-import static org.junit.Assert.assertEquals;
-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.*;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestUnorderedKVInputConfig {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
UnorderedKVInputConfig.newBuilder(null, "VALUE");
@@ -51,7 +50,8 @@ public void testNullParams() {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetters() {
Configuration fromConf = new Configuration(false);
fromConf.set("test.conf.key.1", "confkey1");
@@ -90,14 +90,14 @@ public void testSetters() {
assertEquals("VALUE", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, ""));
assertEquals("CustomCodec",
conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
false));
assertEquals(0.11f, conf.getFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_MEMORY_LIMIT_PERCENT, 0.0f), 0.001f);
assertEquals(0.22f, conf.getFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_MERGE_PERCENT, 0.0f), 0.001f);
assertEquals(0.33f, conf.getFloat(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT, 0.00f), 0.001f);
// Verify additional configs
- assertEquals(false, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertFalse(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals(1111, conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES_DEFAULT));
@@ -113,7 +113,8 @@ public void testSetters() {
assertEquals("unfiltered1", conf.get("test.conf.unfiltered.1"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
UnorderedKVInputConfig.Builder builder =
UnorderedKVInputConfig.newBuilder("KEY", "VALUE");
@@ -124,7 +125,7 @@ public void testDefaultConfigsUsed() {
Configuration conf = rebuilt.conf;
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
// Default property present.
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVOutputConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVOutputConfig.java
index bfdc7f171e..47122939bf 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVOutputConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedKVOutputConfig.java
@@ -18,22 +18,21 @@
*/
package org.apache.tez.runtime.library.conf;
-import static org.junit.Assert.assertEquals;
-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.*;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestUnorderedKVOutputConfig {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
UnorderedKVOutputConfig.newBuilder(
@@ -52,7 +51,8 @@ public void testNullParams() {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetters() {
Configuration fromConf = new Configuration(false);
fromConf.set("test.conf.key.1", "confkey1");
@@ -88,11 +88,11 @@ public void testSetters() {
assertEquals("VALUE", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_VALUE_CLASS, ""));
assertEquals("CustomCodec",
conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
false));
// Verify additional configs
- assertEquals(false, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertFalse(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals(1111, conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES_DEFAULT));
@@ -106,7 +106,8 @@ public void testSetters() {
assertEquals("unfiltered1", conf.get("test.conf.unfiltered.1"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
UnorderedKVOutputConfig.Builder builder =
UnorderedKVOutputConfig
@@ -119,7 +120,7 @@ public void testDefaultConfigsUsed() {
Configuration conf = rebuilt.conf;
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
// Default property present.
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVEdgeConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVEdgeConfig.java
index b5e0e0065f..a500adf3da 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVEdgeConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVEdgeConfig.java
@@ -18,15 +18,12 @@
*/
package org.apache.tez.runtime.library.conf;
-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.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -34,11 +31,12 @@
import org.apache.tez.dag.api.EdgeProperty;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestUnorderedPartitionedKVEdgeConfig {
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
UnorderedPartitionedKVEdgeConfig.newBuilder(null, "VALUE", "PARTITIONER");
@@ -62,7 +60,8 @@ public void testNullParams() {
}
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
UnorderedPartitionedKVEdgeConfig.Builder builder =
UnorderedPartitionedKVEdgeConfig.newBuilder("KEY", "VALUE", "PARTITIONER");
@@ -79,7 +78,7 @@ public void testDefaultConfigsUsed() {
rebuiltInput.fromUserPayload(configuration.getInputPayload());
Configuration outputConf = rebuiltOutput.conf;
- assertEquals(true, outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals("TestCodec",
outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
@@ -87,7 +86,7 @@ public void testDefaultConfigsUsed() {
("SerClass2,SerClass1"));
Configuration inputConf = rebuiltInput.conf;
- assertEquals(true, inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals("TestCodec",
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
@@ -95,7 +94,8 @@ public void testDefaultConfigsUsed() {
("SerClass2,SerClass1"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testSpecificIOConfs() {
// Ensures that Output and Input confs are not mixed.
UnorderedPartitionedKVEdgeConfig.Builder builder =
@@ -119,7 +119,8 @@ public void testSpecificIOConfs() {
inputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, "DEFAULT"));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void tetCommonConf() {
Configuration fromConf = new Configuration(false);
@@ -160,7 +161,7 @@ public void tetCommonConf() {
Configuration outputConf = rebuiltOutput.conf;
Configuration inputConf = rebuiltInput.conf;
- assertEquals(false, outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
+ assertFalse(outputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
assertEquals(1111, outputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES, 0));
assertEquals(3333, outputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_FILE_BUFFER_SIZE, 0));
assertNull(outputConf.get(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_FETCH_BUFFER_PERCENT));
@@ -176,7 +177,7 @@ public void tetCommonConf() {
assertEquals("unfiltered1", outputConf.get("test.conf.unfiltered.1"));
- assertEquals(false, inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
+ assertFalse(inputConf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD, true));
assertEquals(1111, inputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES, 0));
assertEquals(3333, inputConf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_FILE_BUFFER_SIZE, 0));
assertEquals(0.11f,
@@ -200,7 +201,8 @@ private void checkHistoryText(String historyText) {
TezRuntimeConfiguration.TEZ_RUNTIME_CONVERT_USER_PAYLOAD_TO_HISTORY_TEXT));
}
- @Test (timeout=2000)
+ @Test
+ @Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testHistoryText() {
UnorderedPartitionedKVEdgeConfig.Builder builder =
UnorderedPartitionedKVEdgeConfig.newBuilder("KEY", "VALUE", "PARTITIONER");
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVOutputConfig.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVOutputConfig.java
index 31963cb875..b93317d93a 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVOutputConfig.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/conf/TestUnorderedPartitionedKVOutputConfig.java
@@ -18,13 +18,11 @@
*/
package org.apache.tez.runtime.library.conf;
-import static org.junit.Assert.assertEquals;
-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.*;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -32,11 +30,12 @@
import com.google.common.collect.Maps;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestUnorderedPartitionedKVOutputConfig {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNullParams() {
try {
UnorderedPartitionedKVOutputConfig.newBuilder(
@@ -63,7 +62,8 @@ public void testNullParams() {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSetters() {
Configuration fromConf = new Configuration(false);
fromConf.set("test.conf.key.1", "confkey1");
@@ -108,9 +108,9 @@ public void testSetters() {
Configuration conf = rebuilt.conf;
// Verify programmatic API usage
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration
.TEZ_RUNTIME_PIPELINED_SHUFFLE_ENABLED, false));
- assertEquals(false, conf.getBoolean(TezRuntimeConfiguration
+ assertFalse(conf.getBoolean(TezRuntimeConfiguration
.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, true));
assertEquals(1111, conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_UNORDERED_OUTPUT_BUFFER_SIZE_MB, 0));
assertEquals("KEY", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_CLASS, ""));
@@ -118,22 +118,23 @@ public void testSetters() {
assertEquals("PARTITIONER", conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_PARTITIONER_CLASS, ""));
assertEquals("CustomCodec",
conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS_CODEC, ""));
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_COMPRESS,
false));
// Verify additional configs
- assertEquals(false, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertFalse(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
assertEquals(1111, conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_BYTES_DEFAULT));
assertEquals(2222,
conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_UNORDERED_OUTPUT_MAX_PER_BUFFER_SIZE_BYTES, 0));
- assertEquals(true,
- conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_EMPTY_PARTITION_INFO_VIA_EVENTS_ENABLED, false));
+ assertTrue(
+ conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_EMPTY_PARTITION_INFO_VIA_EVENTS_ENABLED,
+ false));
assertEquals(5120,
conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_TRANSFER_DATA_VIA_EVENTS_MAX_SIZE, 512));
- assertEquals(false,
- conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_TRANSFER_DATA_VIA_EVENTS_SUPPORT_IN_MEM_FILE, true));
+ assertFalse(conf.getBoolean(
+ TezRuntimeConfiguration.TEZ_RUNTIME_TRANSFER_DATA_VIA_EVENTS_SUPPORT_IN_MEM_FILE, true));
assertEquals("io", conf.get("io.shouldExist"));
assertEquals("file", conf.get("file.shouldExist"));
assertEquals("fs", conf.get("fs.shouldExist"));
@@ -144,7 +145,8 @@ public void testSetters() {
assertEquals("unfiltered1", conf.get("test.conf.unfiltered.1"));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testDefaultConfigsUsed() {
UnorderedPartitionedKVOutputConfig.Builder builder =
UnorderedPartitionedKVOutputConfig
@@ -159,7 +161,7 @@ public void testDefaultConfigsUsed() {
Configuration conf = rebuilt.conf;
- assertEquals(true, conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
+ assertTrue(conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD,
TezRuntimeConfiguration.TEZ_RUNTIME_IFILE_READAHEAD_DEFAULT));
// Default property present.
@@ -176,7 +178,8 @@ public void testDefaultConfigsUsed() {
assertNull(conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_COMPARATOR_CLASS));
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPartitionerConfigs() {
Map partitionerConf = Maps.newHashMap();
partitionerConf.put("partitioner.test.key", "PARTITIONERKEY");
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestOrderedGroupedKVInput.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestOrderedGroupedKVInput.java
index 06f56712a0..7e83a4cdd4 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestOrderedGroupedKVInput.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestOrderedGroupedKVInput.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.runtime.library.input;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
@@ -26,6 +26,7 @@
import static org.mockito.Mockito.mock;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.tez.common.TezUtils;
@@ -38,14 +39,14 @@
import org.apache.tez.runtime.library.common.MemoryUpdateCallbackHandler;
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.Shuffle;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
public class TestOrderedGroupedKVInput {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testInterruptWhileAwaitingInput() throws IOException, TezException {
InputContext inputContext = createMockInputContext();
@@ -56,9 +57,9 @@ public void testInterruptWhileAwaitingInput() throws IOException, TezException {
try {
kvInput.getReader();
- Assert.fail("getReader should not return since underlying inputs are not ready");
+ fail("getReader should not return since underlying inputs are not ready");
} catch (IOException e) {
- Assert.assertTrue(e instanceof IOInterruptedException);
+ assertInstanceOf(IOInterruptedException.class, e);
}
}
@@ -116,7 +117,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
(MemoryUpdateCallbackHandler) args[1];
memUpdateCallbackHandler.memoryAssigned(200 * 1024 * 1024);
} else {
- Assert.fail();
+ fail();
}
return null;
}
@@ -137,9 +138,9 @@ Shuffle createShuffle() throws IOException {
try {
doThrow(new InterruptedException()).when(shuffle).waitForInput();
} catch (InterruptedException e) {
- Assert.fail();
+ fail();
} catch (TezException e) {
- Assert.fail();
+ fail();
}
return shuffle;
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestSortedGroupedMergedInput.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestSortedGroupedMergedInput.java
index 0f8d7ebc1c..a9d17b0ee8 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestSortedGroupedMergedInput.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/input/TestSortedGroupedMergedInput.java
@@ -18,9 +18,7 @@
*/
package org.apache.tez.runtime.library.input;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -29,6 +27,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.io.RawComparator;
import org.apache.tez.runtime.api.Event;
@@ -38,7 +37,7 @@
import org.apache.tez.runtime.library.api.KeyValueReader;
import org.apache.tez.runtime.library.api.KeyValuesReader;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestSortedGroupedMergedInput {
@@ -46,7 +45,8 @@ MergedInputContext createMergedInputContext() {
return mock(MergedInputContext.class);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSimple() throws Exception {
SortedTestKeyValuesReader kvsReader1 = new SortedTestKeyValuesReader(new int[] { 1, 2, 3 },
new int[][] { { 1, 1 }, { 2, 2 }, { 3, 3 } });
@@ -98,7 +98,8 @@ private void getNextFromFinishedReader(KeyValuesReader kvsReader) {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSkippedKey() throws Exception {
@@ -144,7 +145,8 @@ public void testSkippedKey() throws Exception {
getNextFromFinishedReader(kvsReader);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testPartialValuesSkip() throws Exception {
SortedTestKeyValuesReader kvsReader1 = new SortedTestKeyValuesReader(new int[] { 1, 2, 3 },
@@ -191,7 +193,8 @@ public void testPartialValuesSkip() throws Exception {
getNextFromFinishedReader(kvsReader);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testOrdering() throws Exception {
SortedTestKeyValuesReader kvsReader1 = new SortedTestKeyValuesReader(new int[] { 2, 4 },
@@ -243,7 +246,8 @@ public void testOrdering() throws Exception {
getNextFromFinishedReader(kvsReader);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSkippedKey2() throws Exception {
SortedTestKeyValuesReader kvsReader1 = new SortedTestKeyValuesReader(new int[] { 2, 4 },
@@ -299,7 +303,8 @@ public void testSkippedKey2() throws Exception {
}
// Reads all values for a key, but doesn't trigger the last hasNext() call.
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSkippedKey3() throws Exception {
SortedTestKeyValuesReader kvsReader1 = new SortedTestKeyValuesReader(new int[] { 1, 2, 3, 4 },
@@ -346,7 +351,8 @@ public void testSkippedKey3() throws Exception {
getNextFromFinishedReader(kvsReader);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEmptySources() throws Exception {
SortedTestKeyValuesReader kvsReader1 = new SortedTestKeyValuesReader(new int[] {},
@@ -370,11 +376,12 @@ public void testEmptySources() throws Exception {
OrderedGroupedMergedKVInput input = new OrderedGroupedMergedKVInput(createMergedInputContext(), sInputs);
KeyValuesReader kvsReader = input.getReader();
- assertTrue(kvsReader.next() == false);
+ assertFalse(kvsReader.next());
getNextFromFinishedReader(kvsReader);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSimpleConcatenatedMergedKeyValueInput() throws Exception {
DummyInput sInput1 = new DummyInput(10);
@@ -395,13 +402,14 @@ public void testSimpleConcatenatedMergedKeyValueInput() throws Exception {
Integer key = (Integer) kvReader.getCurrentKey();
Integer value = (Integer) kvReader.getCurrentValue();
}
- assertTrue(keyCount == 30);
+ assertEquals(30, keyCount);
verify(mockContext, times(4)).notifyProgress(); // one for each reader change and one to exit
getNextFromFinishedReader(kvReader);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testSimpleConcatenatedMergedKeyValuesInput() throws Exception {
SortedTestKeyValuesReader kvsReader1 = new SortedTestKeyValuesReader(new int[] { 1, 2, 3 },
new int[][] { { 1, 1 }, { 2, 2 }, { 3, 3 } });
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/OutputTestHelpers.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/OutputTestHelpers.java
index a7c9ea0ff6..4d317c9ec9 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/OutputTestHelpers.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/OutputTestHelpers.java
@@ -37,6 +37,7 @@
import org.apache.tez.runtime.api.impl.ExecutionContextImpl;
import org.apache.tez.runtime.library.common.MemoryUpdateCallbackHandler;
+import org.junit.jupiter.api.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileSortedOutput.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileSortedOutput.java
index 9412c06719..5dceb078ff 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileSortedOutput.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileSortedOutput.java
@@ -18,10 +18,7 @@
*/
package org.apache.tez.runtime.library.output;
-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.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.doAnswer;
@@ -31,12 +28,12 @@
import java.io.IOException;
import java.math.BigInteger;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -65,17 +62,13 @@
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.params.*;
+import org.junit.jupiter.params.provider.*;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@SuppressWarnings({ "rawtypes", "unchecked" })
-@RunWith(Parameterized.class)
public class TestOnFileSortedOutput {
private static final Random rnd = new Random();
private static final String UniqueID = "UUID";
@@ -101,17 +94,9 @@ public class TestOnFileSortedOutput {
private int emptyPartitionIdx;
private ReportPartitionStats reportPartitionStats;
- /**
- * Constructor
- *
- * @param sendEmptyPartitionViaEvent
- * @param sorterImpl Which sorter impl ( pipeline/legacy )
- * @param sorterThreads number of threads needed for sorter (required only for pipelined sorter)
- * @param emptyPartitionIdx for which data should not be generated
- */
- public TestOnFileSortedOutput(boolean sendEmptyPartitionViaEvent,
+ public void setupInit(boolean sendEmptyPartitionViaEvent,
SorterImpl sorterImpl, int sorterThreads, int emptyPartitionIdx,
- ReportPartitionStats reportPartitionStats) throws IOException {
+ ReportPartitionStats reportPartitionStats) throws Exception {
this.sendEmptyPartitionViaEvent = sendEmptyPartitionViaEvent;
this.emptyPartitionIdx = emptyPartitionIdx;
this.sorterImpl = sorterImpl;
@@ -123,10 +108,7 @@ public TestOnFileSortedOutput(boolean sendEmptyPartitionViaEvent,
String localDirs = workingDir.toString();
conf.setStrings(TezRuntimeFrameworkConfigs.LOCAL_DIRS, localDirs);
fs = FileSystem.getLocal(conf);
- }
- @Before
- public void setup() throws Exception {
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_SORTER_CLASS, sorterImpl.name());
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SORTER_SORT_THREADS, sorterThreads);
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 5);
@@ -146,40 +128,28 @@ public void setup() throws Exception {
this.partitions = Math.max(1, rnd.nextInt(10));
}
- @After
+ @AfterEach
public void cleanup() throws IOException {
fs.delete(workingDir, true);
}
@SuppressWarnings("deprecation")
- @Parameterized.Parameters(name = "test[{0}, {1}, {2}, {3}, {4}]")
- public static Collection getParameters() {
- Collection parameters = new ArrayList();
- //empty_partition_via_events_enabled, noOfSortThreads,
- // partitionToBeEmpty, reportPartitionStats
- parameters.add(new Object[] { false, SorterImpl.LEGACY, 1, -1,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { false, SorterImpl.LEGACY, 1, 0,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { true, SorterImpl.LEGACY, 1, -1,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { true, SorterImpl.LEGACY, 1, 0,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { true, SorterImpl.LEGACY, 1, 0,
- ReportPartitionStats.PRECISE });
-
- //Pipelined sorter
- parameters.add(new Object[] { false, SorterImpl.PIPELINED, 2, -1,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { false, SorterImpl.PIPELINED, 2, 0,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { true, SorterImpl.PIPELINED, 2, -1,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { true, SorterImpl.PIPELINED, 2, 0,
- ReportPartitionStats.ENABLED });
- parameters.add(new Object[] { true, SorterImpl.PIPELINED, 2, 0,
- ReportPartitionStats.PRECISE });
- return parameters;
+ public static Stream getParameters() {
+ return Stream.of(
+ //empty_partition_via_events_enabled, noOfSortThreads, partitionToBeEmpty, reportPartitionStats
+ Arguments.of(false, SorterImpl.LEGACY, 1, -1, ReportPartitionStats.ENABLED),
+ Arguments.of(false, SorterImpl.LEGACY, 1, 0, ReportPartitionStats.ENABLED),
+ Arguments.of(true, SorterImpl.LEGACY, 1, -1, ReportPartitionStats.ENABLED),
+ Arguments.of(true, SorterImpl.LEGACY, 1, 0, ReportPartitionStats.ENABLED),
+ Arguments.of(true, SorterImpl.LEGACY, 1, 0, ReportPartitionStats.PRECISE),
+
+ //Pipelined sorter
+ Arguments.of(false, SorterImpl.PIPELINED, 2, -1, ReportPartitionStats.ENABLED),
+ Arguments.of(false, SorterImpl.PIPELINED, 2, 0, ReportPartitionStats.ENABLED),
+ Arguments.of(true, SorterImpl.PIPELINED, 2, -1, ReportPartitionStats.ENABLED),
+ Arguments.of(true, SorterImpl.PIPELINED, 2, 0, ReportPartitionStats.ENABLED),
+ Arguments.of(true, SorterImpl.PIPELINED, 2, 0, ReportPartitionStats.PRECISE)
+ );
}
private void startSortedOutput(int partitions) throws Exception {
@@ -211,13 +181,19 @@ private void _testPipelinedShuffle(String sorterName) throws Exception {
assertTrue(sortedOutput.pipelinedShuffle);
}
- @Test (timeout = 5000)
- public void testPipelinedShuffle() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testPipelinedShuffle(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
_testPipelinedShuffle(SorterImpl.PIPELINED.name());
}
- @Test (timeout = 5000)
- public void testPipelinedShuffleWithFinalMerge() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testPipelinedShuffleWithFinalMerge(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 3);
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_SORTER_CLASS, SorterImpl.PIPELINED.name());
@@ -235,8 +211,10 @@ public void testPipelinedShuffleWithFinalMerge() throws Exception {
assertTrue(sortedOutput.pipelinedShuffle);
}
- @Test
- public void testPipelinedSettingsWithDefaultSorter() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ public void testPipelinedSettingsWithDefaultSorter(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 3);
//negative. with default sorter
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_SORTER_CLASS, SorterImpl.LEGACY.name());
@@ -259,8 +237,11 @@ public void testPipelinedSettingsWithDefaultSorter() throws Exception {
}
- @Test (timeout = 5000)
- public void testSortBufferSize() throws Exception{
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testSortBufferSize(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception{
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
OutputContext context = createTezOutputContext();
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 2048);
UserPayload payLoad = TezUtils.createUserPayloadFromConf(conf);
@@ -286,8 +267,11 @@ public void testSortBufferSize() throws Exception{
}
}
- @Test(timeout = 5000)
- public void baseTest() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void baseTest(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
startSortedOutput(partitions);
//Write random set of keys
@@ -325,8 +309,11 @@ public void baseTest() throws Exception {
assertEquals(UniqueID, payload.getPathComponent());
}
- @Test(timeout = 5000)
- public void testWithSomeEmptyPartition() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testWithSomeEmptyPartition(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
//ensure atleast 2 partitions are available
partitions = Math.max(2, partitions);
startSortedOutput(partitions);
@@ -353,8 +340,11 @@ public void testWithSomeEmptyPartition() throws Exception {
assertEquals(UniqueID, payload.getPathComponent());
}
- @Test(timeout = 5000)
- public void testAllEmptyPartition() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testAllEmptyPartition(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
startSortedOutput(partitions);
//Close output without writing any data to it.
@@ -428,18 +418,24 @@ private OutputContext createTezOutputContext() throws IOException {
return context;
}
- @Test(timeout=5000)
- public void testInvalidSorter() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testInvalidSorter(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
try {
_testPipelinedShuffle("Foo");
- Assert.fail("Expected start to fail due to invalid sorter");
+ fail("Expected start to fail due to invalid sorter");
} catch (IllegalArgumentException e) {
// Expected
}
}
- @Test(timeout=5000)
- public void testLowerCaseNamedSorter() throws Exception {
+ @ParameterizedTest(name = "test[{0}, {1}, {2}, {3}, {4}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+ public void testLowerCaseNamedSorter(boolean sendEmptyPartitionViaEvent, SorterImpl sorterImpl, int sorterThreads, int emptyPartitionId, ReportPartitionStats reportPartitionStats) throws Exception {
+ setupInit(sendEmptyPartitionViaEvent, sorterImpl, sorterThreads, emptyPartitionId, reportPartitionStats);
_testPipelinedShuffle("Pipelined");
}
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileUnorderedKVOutput.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileUnorderedKVOutput.java
index 8c0445daf1..20e506685f 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileUnorderedKVOutput.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOnFileUnorderedKVOutput.java
@@ -18,9 +18,7 @@
*/
package org.apache.tez.runtime.library.output;
-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.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.atLeast;
@@ -37,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.conf.Configuration;
@@ -75,10 +74,7 @@
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.*;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -110,17 +106,18 @@ public class TestOnFileUnorderedKVOutput {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
localFs.mkdirs(workDir);
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
localFs.delete(workDir, true);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testGeneratedDataMovementEvent() throws Exception {
Configuration conf = new Configuration();
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_KEY_CLASS, Text.class.getName());
@@ -148,7 +145,7 @@ public void testGeneratedDataMovementEvent() throws Exception {
assertTrue(events != null && events.size() == 2);
CompositeDataMovementEvent dmEvent = (CompositeDataMovementEvent)events.get(1);
- assertEquals("Invalid source index", 0, dmEvent.getSourceIndexStart());
+ assertEquals(0, dmEvent.getSourceIndexStart(), "Invalid source index");
DataMovementEventPayloadProto shufflePayload = DataMovementEventPayloadProto
.parseFrom(ByteString.copyFrom(dmEvent.getUserPayload()));
@@ -180,7 +177,8 @@ public void testMergeConfig() throws Exception {
assertEquals("base-value", mergedConf.get("base-key"));
}
- @Test(timeout = 30000)
+ @Test
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
@SuppressWarnings("unchecked")
public void testWithPipelinedShuffle() throws Exception {
Configuration conf = new Configuration();
@@ -217,7 +215,7 @@ public void testWithPipelinedShuffle() throws Exception {
CompositeDataMovementEvent dmEvent = (CompositeDataMovementEvent)events.get(1);
- assertEquals("Invalid source index", 0, dmEvent.getSourceIndexStart());
+ assertEquals(0, dmEvent.getSourceIndexStart(), "Invalid source index");
DataMovementEventPayloadProto shufflePayload = DataMovementEventPayloadProto
.parseFrom(ByteString.copyFrom(dmEvent.getUserPayload()));
@@ -271,7 +269,7 @@ null, auxEnv, new MemoryDistributor(1, 1, payloadConf), outputDescriptor, null,
verify(runtimeTask, times(1)).addAndGetTezCounter(destinationVertexName);
verify(runtimeTask, times(1)).getTaskStatistics();
// verify output stats object got created
- Assert.assertTrue(task.getTaskStatistics().getIOStatistics().containsKey(destinationVertexName));
+ assertTrue(task.getTaskStatistics().getIOStatistics().containsKey(destinationVertexName));
OutputContext outputContext = spy(realOutputContext);
doAnswer(new Answer() {
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOrderedPartitionedKVOutput2.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOrderedPartitionedKVOutput2.java
index 2b076bde85..cf9e2a72d7 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOrderedPartitionedKVOutput2.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestOrderedPartitionedKVOutput2.java
@@ -18,13 +18,13 @@
*/
package org.apache.tez.runtime.library.output;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.BitSet;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -43,9 +43,7 @@
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
// Tests which don't require parameterization
public class TestOrderedPartitionedKVOutput2 {
@@ -53,7 +51,7 @@ public class TestOrderedPartitionedKVOutput2 {
private FileSystem localFs;
private Path workingDir;
- @Before
+ @BeforeEach
public void setup() throws IOException {
conf = new Configuration();
localFs = FileSystem.getLocal(conf);
@@ -68,12 +66,13 @@ public void setup() throws IOException {
conf.setStrings(TezRuntimeFrameworkConfigs.LOCAL_DIRS, workingDir.toString());
}
- @After
+ @AfterEach
public void cleanup() throws IOException {
localFs.delete(workingDir, true);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNonStartedOutput() throws IOException {
OutputContext outputContext = OutputTestHelpers.createOutputContext(conf, conf, workingDir);
int numPartitions = 10;
@@ -82,9 +81,9 @@ public void testNonStartedOutput() throws IOException {
List events = output.close();
assertEquals(2, events.size());
Event event1 = events.get(0);
- assertTrue(event1 instanceof VertexManagerEvent);
+ assertInstanceOf(VertexManagerEvent.class, event1);
Event event2 = events.get(1);
- assertTrue(event2 instanceof CompositeDataMovementEvent);
+ assertInstanceOf(CompositeDataMovementEvent.class, event2);
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) event2;
ByteBuffer bb = cdme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload =
@@ -100,7 +99,8 @@ public void testNonStartedOutput() throws IOException {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfigMerge() throws IOException {
Configuration localConf = new Configuration(conf);
localConf.set("config-from-local", "config-from-local-value");
@@ -115,7 +115,8 @@ public void testConfigMerge() throws IOException {
assertEquals("config-from-payload-value", configAfterMerge.get("config-from-payload"));
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testClose() throws Exception {
OutputContext outputContext = OutputTestHelpers.createOutputContext(conf, conf, workingDir);
int numPartitions = 10;
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedKVOutput2.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedKVOutput2.java
index 8e33c0af60..6ecba9510c 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedKVOutput2.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedKVOutput2.java
@@ -18,15 +18,13 @@
*/
package org.apache.tez.runtime.library.output;
-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.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.BitSet;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -44,9 +42,7 @@
import com.google.protobuf.ByteString;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
// Tests which don't require parameterization
public class TestUnorderedKVOutput2 {
@@ -54,7 +50,7 @@ public class TestUnorderedKVOutput2 {
private FileSystem localFs;
private Path workingDir;
- @Before
+ @BeforeEach
public void setup() throws IOException {
conf = new Configuration();
localFs = FileSystem.getLocal(conf);
@@ -69,12 +65,13 @@ public void setup() throws IOException {
conf.setStrings(TezRuntimeFrameworkConfigs.LOCAL_DIRS, workingDir.toString());
}
- @After
+ @AfterEach
public void cleanup() throws IOException {
localFs.delete(workingDir, true);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNonStartedOutput() throws Exception {
OutputContext outputContext = OutputTestHelpers.createOutputContext();
int numPartitions = 1;
@@ -83,7 +80,7 @@ public void testNonStartedOutput() throws Exception {
List events = output.close();
assertEquals(1, events.size());
Event event1 = events.get(0);
- assertTrue(event1 instanceof DataMovementEvent);
+ assertInstanceOf(DataMovementEvent.class, event1);
DataMovementEvent dme = (DataMovementEvent) event1;
ByteBuffer bb = dme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload =
@@ -99,7 +96,8 @@ public void testNonStartedOutput() throws Exception {
}
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testConfigMerge() throws Exception {
Configuration localConf = new Configuration(conf);
localConf.set("config-from-local", "config-from-local-value");
@@ -114,7 +112,8 @@ public void testConfigMerge() throws Exception {
assertEquals("config-from-payload-value", configAfterMerge.get("config-from-payload"));
}
- @Test(timeout = 10000)
+ @Test
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testClose() throws Exception {
OutputContext outputContext = OutputTestHelpers.createOutputContext(conf, conf, workingDir);
int numPartitions = 1;
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedPartitionedKVOutput2.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedPartitionedKVOutput2.java
index e377a803cb..b2b1fbe965 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedPartitionedKVOutput2.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/output/TestUnorderedPartitionedKVOutput2.java
@@ -18,12 +18,12 @@
*/
package org.apache.tez.runtime.library.output;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.nio.ByteBuffer;
import java.util.BitSet;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -36,13 +36,14 @@
import com.google.protobuf.ByteString;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
// Tests which don't require parameterization
public class TestUnorderedPartitionedKVOutput2 {
- @Test(timeout = 5000)
+ @Test
+ @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testNonStartedOutput() throws Exception {
OutputContext outputContext = OutputTestHelpers.createOutputContext();
int numPartitions = 1;
@@ -52,7 +53,7 @@ public void testNonStartedOutput() throws Exception {
List events = output.close();
assertEquals(1, events.size());
Event event1 = events.get(0);
- assertTrue(event1 instanceof CompositeDataMovementEvent);
+ assertInstanceOf(CompositeDataMovementEvent.class, event1);
CompositeDataMovementEvent dme = (CompositeDataMovementEvent) event1;
ByteBuffer bb = dme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload =
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/KVDataGen.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/KVDataGen.java
index a68fa0c19d..ca276d3899 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/KVDataGen.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/KVDataGen.java
@@ -25,6 +25,8 @@
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
+import org.junit.jupiter.api.*;
+
public final class KVDataGen {
static Random rnd = new Random();
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RandomTextGenerator.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RandomTextGenerator.java
index 1e9f2c0db2..acaf933d8c 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RandomTextGenerator.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RandomTextGenerator.java
@@ -22,6 +22,8 @@
import org.apache.hadoop.io.Text;
+import org.junit.jupiter.api.*;
+
public final class RandomTextGenerator {
static int minWordsInKey = 10;
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RuntimeTestUtils.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RuntimeTestUtils.java
index 85215f4da8..380788c913 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RuntimeTestUtils.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/testutils/RuntimeTestUtils.java
@@ -27,6 +27,8 @@
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.ShuffleHeader;
+import org.junit.jupiter.api.*;
+
public final class RuntimeTestUtils {
private RuntimeTestUtils() {
diff --git a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/utils/TestCodecUtils.java b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/utils/TestCodecUtils.java
index 3ad5302fbe..b0d825d07c 100644
--- a/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/utils/TestCodecUtils.java
+++ b/tez-runtime-library/src/test/java/org/apache/tez/runtime/library/utils/TestCodecUtils.java
@@ -18,6 +18,7 @@
*/
package org.apache.tez.runtime.library.utils;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import java.io.IOException;
@@ -51,8 +52,8 @@
import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.DummyCompressionCodec;
import org.apache.tez.runtime.library.common.sort.impl.IFileInputStream;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestCodecUtils {
@@ -85,8 +86,7 @@ private void testConcurrentDecompressorCreationWithModifiedBuffersizeOnCodec(
(DecompressorStream) CodecUtils.getDecompressedInputStreamWithBufferSize(codec,
mock(IFileInputStream.class), decompressor, modifiedBufferSize);
- Assert.assertEquals("stream buffer size is incorrect", modifiedBufferSize,
- getBufferSize(stream));
+ assertEquals(modifiedBufferSize, getBufferSize(stream), "stream buffer size is incorrect");
CodecPool.returnDecompressor(decompressor);
} catch (IOException e) {
@@ -133,8 +133,7 @@ private void testConcurrentCompressorDecompressorCreationOnCodec(CompressionCode
(CompressionInputStream) CodecUtils.getDecompressedInputStreamWithBufferSize(codec,
mock(IFileInputStream.class), decompressor, modifiedBufferSize);
- Assert.assertEquals("stream buffer size is incorrect", modifiedBufferSize,
- getBufferSize(stream));
+ assertEquals(modifiedBufferSize, getBufferSize(stream), "stream buffer size is incorrect");
CodecPool.returnDecompressor(decompressor);
} catch (IOException e) {
@@ -151,8 +150,7 @@ private void testConcurrentCompressorDecompressorCreationOnCodec(CompressionCode
CompressionOutputStream stream =
CodecUtils.createOutputStream(codec, mock(OutputStream.class), compressor);
- Assert.assertEquals("stream buffer size is incorrect",
- CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT, getBufferSize(stream));
+ assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT, getBufferSize(stream), "stream buffer size is incorrect");
CodecPool.returnCompressor(compressor);
} catch (Exception e) {
@@ -169,8 +167,7 @@ private void testConcurrentCompressorDecompressorCreationOnCodec(CompressionCode
CompressionInputStream stream =
CodecUtils.createInputStream(codec, mock(InputStream.class), decompressor);
- Assert.assertEquals("stream buffer size is incorrect",
- CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT, getBufferSize(stream));
+ assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT, getBufferSize(stream), "stream buffer size is incorrect");
CodecPool.returnDecompressor(decompressor);
} catch (Exception e) {
@@ -190,19 +187,19 @@ private void testConcurrentCompressorDecompressorCreationOnCodec(CompressionCode
public void testDefaultBufferSize() {
Configuration conf = new Configuration(); // config with no buffersize set
- Assert.assertEquals(CodecUtils.DEFAULT_BUFFER_SIZE,
+ assertEquals(CodecUtils.DEFAULT_BUFFER_SIZE,
CodecUtils.getDefaultBufferSize(conf, new DummyCompressionCodec()));
- Assert.assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT,
+ assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT,
CodecUtils.getDefaultBufferSize(conf, new DefaultCodec()));
- Assert.assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT,
+ assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT,
CodecUtils.getDefaultBufferSize(conf, new BZip2Codec()));
- Assert.assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT,
+ assertEquals(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT,
CodecUtils.getDefaultBufferSize(conf, new GzipCodec()));
- Assert.assertEquals(CommonConfigurationKeys.IO_COMPRESSION_CODEC_SNAPPY_BUFFERSIZE_DEFAULT,
+ assertEquals(CommonConfigurationKeys.IO_COMPRESSION_CODEC_SNAPPY_BUFFERSIZE_DEFAULT,
CodecUtils.getDefaultBufferSize(conf, new SnappyCodec()));
- Assert.assertEquals(CommonConfigurationKeys.IO_COMPRESSION_CODEC_ZSTD_BUFFER_SIZE_DEFAULT,
+ assertEquals(CommonConfigurationKeys.IO_COMPRESSION_CODEC_ZSTD_BUFFER_SIZE_DEFAULT,
CodecUtils.getDefaultBufferSize(conf, new ZStandardCodec()));
- Assert.assertEquals(CommonConfigurationKeys.IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_DEFAULT,
+ assertEquals(CommonConfigurationKeys.IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_DEFAULT,
CodecUtils.getDefaultBufferSize(conf, new Lz4Codec()));
}
diff --git a/tez-tests/pom.xml b/tez-tests/pom.xml
index 833a9978fb..6ad309d350 100644
--- a/tez-tests/pom.xml
+++ b/tez-tests/pom.xml
@@ -119,11 +119,6 @@
org.slf4j
slf4j-api
-
- junit
- junit
- test
-
org.bouncycastle
bcprov-jdk18on
diff --git a/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobs.java b/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobs.java
index 260308a1a2..8742749673 100644
--- a/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobs.java
+++ b/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobs.java
@@ -18,8 +18,11 @@
*/
package org.apache.tez.mapreduce;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.File;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.RandomTextWriterJob;
import org.apache.hadoop.conf.Configuration;
@@ -32,6 +35,7 @@
import org.apache.hadoop.io.compress.DefaultCodec;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.JobStatus;
+import org.apache.hadoop.mapreduce.JobStatus.State;
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
@@ -40,10 +44,7 @@
import org.apache.tez.mapreduce.hadoop.MRJobConfig;
import org.apache.tez.test.MiniTezCluster;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,7 +64,7 @@ public class TestMRRJobs {
private static final String OUTPUT_ROOT_DIR = "/tmp" + Path.SEPARATOR +
TestMRRJobs.class.getSimpleName();
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException {
try {
conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 1);
@@ -95,7 +96,7 @@ public static void setup() throws IOException {
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
if (mrrTezCluster != null) {
mrrTezCluster.stop();
@@ -107,7 +108,8 @@ public static void tearDown() {
}
}
- @Test (timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMRRSleepJob() throws IOException, InterruptedException,
ClassNotFoundException {
LOG.info("\n\n\nStarting testMRRSleepJob().");
@@ -132,22 +134,22 @@ public void testMRRSleepJob() throws IOException, InterruptedException,
String trackingUrl = job.getTrackingURL();
String jobId = job.getJobID().toString();
boolean succeeded = job.waitForCompletion(true);
- Assert.assertTrue(succeeded);
- Assert.assertEquals(JobStatus.State.SUCCEEDED, job.getJobState());
+ assertTrue(succeeded);
+ assertEquals(State.SUCCEEDED, job.getJobState());
// There's one bug in YARN that there may be some suffix at the end of trackingURL (YARN-2246)
// After TEZ-1961, the tracking will change from http://localhost:53419/proxy/application_1430963524753_0005
// to http://localhost:53419/proxy/application_1430963524753_0005/ui/
// So here use String#contains to verify.
- Assert.assertTrue("Tracking URL was " + trackingUrl +
- " but didn't Match Job ID " + jobId ,
- trackingUrl.contains(jobId.substring(jobId.indexOf("_"))));
+ assertTrue(trackingUrl.contains(jobId.substring(jobId.indexOf("_"))), "Tracking URL was " + trackingUrl +
+ " but didn't Match Job ID " + jobId);
// FIXME once counters and task progress can be obtained properly
// TODO use dag client to test counters and task progress?
// what about completed jobs?
}
- @Test (timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testRandomWriter() throws IOException, InterruptedException,
ClassNotFoundException {
@@ -171,11 +173,10 @@ public void testRandomWriter() throws IOException, InterruptedException,
String trackingUrl = job.getTrackingURL();
String jobId = job.getJobID().toString();
boolean succeeded = job.waitForCompletion(true);
- Assert.assertTrue(succeeded);
- Assert.assertEquals(JobStatus.State.SUCCEEDED, job.getJobState());
- Assert.assertTrue("Tracking URL was " + trackingUrl +
- " but didn't Match Job ID " + jobId ,
- trackingUrl.contains(jobId.substring(jobId.indexOf("_"))));
+ assertTrue(succeeded);
+ assertEquals(State.SUCCEEDED, job.getJobState());
+ assertTrue(trackingUrl.contains(jobId.substring(jobId.indexOf("_"))), "Tracking URL was " + trackingUrl +
+ " but didn't Match Job ID " + jobId);
// Make sure there are three files in the output-dir
@@ -190,12 +191,13 @@ public void testRandomWriter() throws IOException, InterruptedException,
count++;
}
}
- Assert.assertEquals("Number of part files is wrong!", 3, count);
+ assertEquals(3, count, "Number of part files is wrong!");
}
- @Test (timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testFailingJob() throws IOException, InterruptedException,
ClassNotFoundException {
@@ -222,14 +224,15 @@ public void testFailingJob() throws IOException, InterruptedException,
job.submit();
boolean succeeded = job.waitForCompletion(true);
- Assert.assertFalse(succeeded);
- Assert.assertEquals(JobStatus.State.FAILED, job.getJobState());
+ assertFalse(succeeded);
+ assertEquals(JobStatus.State.FAILED, job.getJobState());
// FIXME once counters and task progress can be obtained properly
// TODO verify failed task diagnostics
}
- @Test (timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testFailingAttempt() throws IOException, InterruptedException,
ClassNotFoundException {
@@ -256,21 +259,21 @@ public void testFailingAttempt() throws IOException, InterruptedException,
job.submit();
boolean succeeded = job.waitForCompletion(true);
- Assert.assertTrue(succeeded);
- Assert.assertEquals(JobStatus.State.SUCCEEDED, job.getJobState());
+ assertTrue(succeeded);
+ assertEquals(JobStatus.State.SUCCEEDED, job.getJobState());
// FIXME once counters and task progress can be obtained properly
// TODO verify failed task diagnostics
}
- @Test (timeout = 60000)
- public void testMRRSleepJobWithCompression() throws IOException,
- InterruptedException, ClassNotFoundException {
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
+ public void testMRRSleepJobWithCompression()
+ throws IOException, InterruptedException, ClassNotFoundException {
LOG.info("\n\n\nStarting testMRRSleepJobWithCompression().");
if (!(new File(MiniTezCluster.APPJAR)).exists()) {
- LOG.info("MRAppJar " + MiniTezCluster.APPJAR
- + " not found. Not running test.");
+ LOG.info("MRAppJar " + MiniTezCluster.APPJAR + " not found. Not running test.");
return;
}
@@ -279,26 +282,24 @@ public void testMRRSleepJobWithCompression() throws IOException,
MRRSleepJob sleepJob = new MRRSleepJob();
sleepJob.setConf(sleepConf);
- Job job = sleepJob.createJob(1, 1, 2, 1, 1,
- 1, 1, 1, 1, 1);
+ Job job = sleepJob.createJob(1, 1, 2, 1, 1, 1, 1, 1, 1, 1);
job.setJarByClass(MRRSleepJob.class);
job.setMaxMapAttempts(1); // speed up failures
// enable compression
job.getConfiguration().setBoolean(MRJobConfig.MAP_OUTPUT_COMPRESS, true);
- job.getConfiguration().set(MRJobConfig.MAP_OUTPUT_COMPRESS_CODEC,
- DefaultCodec.class.getName());
+ job.getConfiguration().set(MRJobConfig.MAP_OUTPUT_COMPRESS_CODEC, DefaultCodec.class.getName());
job.submit();
String trackingUrl = job.getTrackingURL();
String jobId = job.getJobID().toString();
boolean succeeded = job.waitForCompletion(true);
- Assert.assertTrue(succeeded);
- Assert.assertEquals(JobStatus.State.SUCCEEDED, job.getJobState());
- Assert.assertTrue("Tracking URL was " + trackingUrl +
- " but didn't Match Job ID " + jobId ,
- trackingUrl.contains(jobId.substring(jobId.indexOf("_"))));
+ assertTrue(succeeded);
+ assertEquals(State.SUCCEEDED, job.getJobState());
+ assertTrue(
+ trackingUrl.contains(jobId.substring(jobId.indexOf("_"))),
+ "Tracking URL was " + trackingUrl + " but didn't Match Job ID " + jobId);
// FIXME once counters and task progress can be obtained properly
// TODO use dag client to test counters and task progress?
@@ -306,9 +307,9 @@ public void testMRRSleepJobWithCompression() throws IOException,
}
-
/*
- //@Test (timeout = 60000)
+ //@Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMRRSleepJobWithSecurityOn() throws IOException,
InterruptedException, ClassNotFoundException {
@@ -351,8 +352,8 @@ public Void run() throws Exception {
String trackingUrl = job.getTrackingURL();
String jobId = job.getJobID().toString();
job.waitForCompletion(true);
- Assert.assertEquals(JobStatus.State.SUCCEEDED, job.getJobState());
- Assert.assertTrue("Tracking URL was " + trackingUrl +
+ assertEquals(JobStatus.State.SUCCEEDED, job.getJobState());
+ assertTrue("Tracking URL was " + trackingUrl +
" but didn't Match Job ID " + jobId ,
trackingUrl.endsWith(jobId.substring(jobId.lastIndexOf("_")) + "/"));
return null;
diff --git a/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobsDAGApi.java b/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobsDAGApi.java
index 5f5ca3702b..3296e55f2e 100644
--- a/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobsDAGApi.java
+++ b/tez-tests/src/test/java/org/apache/tez/mapreduce/TestMRRJobsDAGApi.java
@@ -18,9 +18,7 @@
*/
package org.apache.tez.mapreduce;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.IOException;
@@ -34,6 +32,7 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
@@ -128,10 +127,7 @@
import com.google.common.collect.Sets;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -149,7 +145,7 @@ public class TestMRRJobsDAGApi {
private static String TEST_ROOT_DIR = "target" + Path.SEPARATOR
+ TestMRRJobsDAGApi.class.getName() + "-tmpDir";
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException {
try {
conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR);
@@ -173,7 +169,7 @@ public static void setup() throws IOException {
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
if (mrrTezCluster != null) {
mrrTezCluster.stop();
@@ -186,7 +182,8 @@ public static void tearDown() {
// TODO Add cleanup code.
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testSleepJob() throws TezException, IOException, InterruptedException {
SleepProcessorConfig spConf = new SleepProcessorConfig(1);
@@ -213,8 +210,10 @@ public void testSleepJob() throws TezException, IOException, InterruptedExceptio
+ dagStatus.getState());
Thread.sleep(500l);
dagStatus = dagClient.getDAGStatus(null);
- assertTrue("Memory used by AM is supposed to be 0 if not requested", dagStatus.getMemoryUsedByAM() == 0);
- assertTrue("Memory used by tasks is supposed to be 0 if not requested", dagStatus.getMemoryUsedByTasks() == 0);
+ assertEquals(0, dagStatus.getMemoryUsedByAM(),
+ "Memory used by AM is supposed to be 0 if not requested");
+ assertEquals(0, dagStatus.getMemoryUsedByTasks(),
+ "Memory used by tasks is supposed to be 0 if not requested");
}
dagStatus = dagClient.getDAGStatus(Sets.newHashSet(StatusGetOpts.GET_COUNTERS, StatusGetOpts.GET_MEMORY_USAGE));
@@ -222,14 +221,15 @@ public void testSleepJob() throws TezException, IOException, InterruptedExceptio
assertNotNull(dagStatus.getDAGCounters());
assertNotNull(dagStatus.getDAGCounters().getGroup(FileSystemCounter.class.getName()));
assertNotNull(dagStatus.getDAGCounters().findCounter(TaskCounter.GC_TIME_MILLIS));
- assertTrue("Memory used by AM is supposed to be >0", dagStatus.getMemoryUsedByAM() > 0);
- assertTrue("Memory used by tasks is supposed to be >0", dagStatus.getMemoryUsedByTasks() > 0);
+ assertTrue(dagStatus.getMemoryUsedByAM() > 0, "Memory used by AM is supposed to be >0");
+ assertTrue(dagStatus.getMemoryUsedByTasks() > 0, "Memory used by tasks is supposed to be >0");
ExampleDriver.printDAGStatus(dagClient, new String[] { "SleepVertex" }, true, true);
tezSession.stop();
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testNonDefaultFSStagingDir() throws Exception {
SleepProcessorConfig spConf = new SleepProcessorConfig(1);
@@ -270,7 +270,8 @@ public void testNonDefaultFSStagingDir() throws Exception {
}
// Submits a simple 5 stage sleep job using tez session. Then kills it.
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testHistoryLogging() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
SleepProcessorConfig spConf = new SleepProcessorConfig(1);
@@ -320,46 +321,50 @@ public void testHistoryLogging() throws IOException,
break;
}
}
- Assert.assertNotNull(historyLogFileStatus);
- Assert.assertTrue(historyLogFileStatus.getLen() > 0);
+ assertNotNull(historyLogFileStatus);
+ assertTrue(historyLogFileStatus.getLen() > 0);
tezSession.stop();
}
// Submits a simple 5 stage sleep job using the DAG submit API instead of job
// client.
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMRRSleepJobDagSubmit() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
State finalState = testMRRSleepJobDagSubmitCore(false, false, false, false);
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
+ assertEquals(DAGStatus.State.SUCCEEDED, finalState);
// TODO Add additional checks for tracking URL etc. - once it's exposed by
// the DAG API.
}
// Submits a simple 5 stage sleep job using the DAG submit API. Then kills it.
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMRRSleepJobDagSubmitAndKill() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
State finalState = testMRRSleepJobDagSubmitCore(false, true, false, false);
- Assert.assertEquals(DAGStatus.State.KILLED, finalState);
+ assertEquals(DAGStatus.State.KILLED, finalState);
// TODO Add additional checks for tracking URL etc. - once it's exposed by
// the DAG API.
}
// Submits a DAG to AM via RPC after AM has started
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMRRSleepJobViaSession() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
State finalState = testMRRSleepJobDagSubmitCore(true, false, false, false);
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
+ assertEquals(DAGStatus.State.SUCCEEDED, finalState);
}
// Submit 2 jobs via RPC using a custom initializer. The second job is submitted with an
// additional local resource, which is verified by the initializer.
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testAMRelocalization() throws Exception {
Path relocPath = new Path("/tmp/relocalizationfilefound");
if (remoteFs.exists(relocPath)) {
@@ -369,8 +374,8 @@ public void testAMRelocalization() throws Exception {
State finalState = testMRRSleepJobDagSubmitCore(true, false, false,
tezSession, true, MRInputAMSplitGeneratorRelocalizationTest.class, null);
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
- Assert.assertFalse(remoteFs.exists(new Path("/tmp/relocalizationfilefound")));
+ assertEquals(DAGStatus.State.SUCCEEDED, finalState);
+ assertFalse(remoteFs.exists(new Path("/tmp/relocalizationfilefound")));
// Start the second job with some additional resources.
@@ -390,14 +395,14 @@ public void testAMRelocalization() throws Exception {
additionalResources.put("test.jar", createLrObjFromPath(relocFilePath));
additionalResources.put("TezAppJar.jar", createLrObjFromPath(tezAppJarRemote));
- Assert.assertEquals(TezAppMasterStatus.READY,
+ assertEquals(TezAppMasterStatus.READY,
tezSession.getAppMasterStatus());
finalState = testMRRSleepJobDagSubmitCore(true, false, false,
tezSession, true, MRInputAMSplitGeneratorRelocalizationTest.class, additionalResources);
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
- Assert.assertEquals(TezAppMasterStatus.READY,
+ assertEquals(DAGStatus.State.SUCCEEDED, finalState);
+ assertEquals(TezAppMasterStatus.READY,
tezSession.getAppMasterStatus());
- Assert.assertTrue(remoteFs.exists(new Path("/tmp/relocalizationfilefound")));
+ assertTrue(remoteFs.exists(new Path("/tmp/relocalizationfilefound")));
stopAndVerifyYarnApp(tezSession);
}
@@ -406,7 +411,7 @@ private void stopAndVerifyYarnApp(TezClient tezSession) throws TezException,
IOException, YarnException {
ApplicationId appId = tezSession.getAppMasterApplicationId();
tezSession.stop();
- Assert.assertEquals(TezAppMasterStatus.SHUTDOWN,
+ assertEquals(TezAppMasterStatus.SHUTDOWN,
tezSession.getAppMasterStatus());
YarnClient yarnClient = YarnClient.createYarnClient();
@@ -426,14 +431,15 @@ private void stopAndVerifyYarnApp(TezClient tezSession) throws TezException,
}
ApplicationReport appReport = yarnClient.getApplicationReport(appId);
- Assert.assertEquals(YarnApplicationState.FINISHED,
+ assertEquals(YarnApplicationState.FINISHED,
appReport.getYarnApplicationState());
- Assert.assertEquals(FinalApplicationStatus.SUCCEEDED,
+ assertEquals(FinalApplicationStatus.SUCCEEDED,
appReport.getFinalApplicationStatus());
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testAMRelocalizationConflict() throws Exception {
Path relocPath = new Path("/tmp/relocalizationfilefound");
if (remoteFs.exists(relocPath)) {
@@ -444,8 +450,8 @@ public void testAMRelocalizationConflict() throws Exception {
TezClient tezSession = createTezSession();
State finalState = testMRRSleepJobDagSubmitCore(true, false, false,
tezSession, true, MRInputAMSplitGeneratorRelocalizationTest.class, null);
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
- Assert.assertFalse(remoteFs.exists(relocPath));
+ assertEquals(DAGStatus.State.SUCCEEDED, finalState);
+ assertFalse(remoteFs.exists(relocPath));
// Create a bogus TezAppJar directly to HDFS
LOG.info("Creating jar for relocalization test");
@@ -460,7 +466,7 @@ public void testAMRelocalizationConflict() throws Exception {
try {
testMRRSleepJobDagSubmitCore(true, false, false,
tezSession, true, MRInputAMSplitGeneratorRelocalizationTest.class, additionalResources);
- Assert.fail("should have failed");
+ fail("should have failed");
} catch (Exception ex) {
// expected
}
@@ -482,12 +488,13 @@ private TezClient createTezSession() throws IOException, TezException {
TezClient tezSession = TezClient.create("testrelocalizationsession", tezConf, true);
tezSession.start();
- Assert.assertEquals(TezAppMasterStatus.INITIALIZING, tezSession.getAppMasterStatus());
+ assertEquals(TezAppMasterStatus.INITIALIZING, tezSession.getAppMasterStatus());
return tezSession;
}
// Submits a DAG to AM via RPC after AM has started
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testMultipleMRRSleepJobViaSession() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String
@@ -500,42 +507,45 @@ public void testMultipleMRRSleepJobViaSession() throws IOException,
TezClient tezSession = TezClient.create("testsession", tezConf, true);
tezSession.start();
- Assert.assertEquals(TezAppMasterStatus.INITIALIZING,
+ assertEquals(TezAppMasterStatus.INITIALIZING,
tezSession.getAppMasterStatus());
State finalState = testMRRSleepJobDagSubmitCore(true, false, false,
tezSession, false, null, null);
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
- Assert.assertEquals(TezAppMasterStatus.READY,
+ assertEquals(DAGStatus.State.SUCCEEDED, finalState);
+ assertEquals(TezAppMasterStatus.READY,
tezSession.getAppMasterStatus());
finalState = testMRRSleepJobDagSubmitCore(true, false, false,
tezSession, false, null, null);
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
- Assert.assertEquals(TezAppMasterStatus.READY,
+ assertEquals(DAGStatus.State.SUCCEEDED, finalState);
+ assertEquals(TezAppMasterStatus.READY,
tezSession.getAppMasterStatus());
stopAndVerifyYarnApp(tezSession);
}
// Submits a simple 5 stage sleep job using tez session. Then kills it.
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMRRSleepJobDagSubmitAndKillViaRPC() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
State finalState = testMRRSleepJobDagSubmitCore(true, true, false, false);
- Assert.assertEquals(DAGStatus.State.KILLED, finalState);
+ assertEquals(DAGStatus.State.KILLED, finalState);
// TODO Add additional checks for tracking URL etc. - once it's exposed by
// the DAG API.
}
// Create and close a tez session without submitting a job
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testTezSessionShutdown() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
testMRRSleepJobDagSubmitCore(true, false, true, false);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testAMSplitGeneration() throws IOException, InterruptedException,
TezException, ClassNotFoundException, YarnException {
testMRRSleepJobDagSubmitCore(true, false, false, true);
@@ -655,7 +665,7 @@ public State testMRRSleepJobDagSubmitCore(
true);
DataSinkDescriptor dataSinkDescriptor =
MROutputLegacy.createConfigBuilder(stage3Conf, NullOutputFormat.class).build();
- Assert.assertFalse(dataSinkDescriptor.getOutputDescriptor().getHistoryText().isEmpty());
+ assertFalse(dataSinkDescriptor.getOutputDescriptor().getHistoryText().isEmpty());
stage3Vertex.addDataSink("MROutput", dataSinkDescriptor);
// TODO env, resources
@@ -733,9 +743,9 @@ public State testMRRSleepJobDagSubmitCore(
LOG.info("Application completed after sending session shutdown"
+ ", yarnApplicationState=" + appState
+ ", finalAppStatus=" + appReport.getFinalApplicationStatus());
- Assert.assertEquals(YarnApplicationState.FINISHED,
+ assertEquals(YarnApplicationState.FINISHED,
appState);
- Assert.assertEquals(FinalApplicationStatus.SUCCEEDED,
+ assertEquals(FinalApplicationStatus.SUCCEEDED,
appReport.getFinalApplicationStatus());
break;
}
@@ -752,7 +762,7 @@ public State testMRRSleepJobDagSubmitCore(
tezSession.addAppMasterLocalFiles(additionalLocalResources);
}
dagClient = tezSession.submitDAG(dag);
- Assert.assertEquals(TezAppMasterStatus.RUNNING,
+ assertEquals(TezAppMasterStatus.RUNNING,
tezSession.getAppMasterStatus());
}
DAGStatus dagStatus = dagClient.getDAGStatus(null);
@@ -790,7 +800,8 @@ private static LocalResource createLocalResource(FileSystem fc, Path file,
resourceSize, resourceModificationTime);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testVertexGroups() throws Exception {
LOG.info("Running Group Test");
Path inPath = new Path(TEST_ROOT_DIR, "in-groups");
@@ -812,7 +823,8 @@ public void testVertexGroups() throws Exception {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBroadcastAndOneToOne() throws Exception {
LOG.info("Running BroadcastAndOneToOne Test");
BroadcastAndOneToOneExample job = new BroadcastAndOneToOneExample();
diff --git a/tez-tests/src/test/java/org/apache/tez/test/FaultToleranceTestRunner.java b/tez-tests/src/test/java/org/apache/tez/test/FaultToleranceTestRunner.java
index 45ae9a622d..0cf96003f3 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/FaultToleranceTestRunner.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/FaultToleranceTestRunner.java
@@ -32,6 +32,8 @@
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.client.DAGClient;
import org.apache.tez.dag.api.client.DAGStatus;
+
+import org.junit.jupiter.api.*;
/**
* Run a DAG on a cluster with the given configuration. Starts a TezSession
* using default cluster configuration from installation. Then uses reflection
diff --git a/tez-tests/src/test/java/org/apache/tez/test/MiniTezCluster.java b/tez-tests/src/test/java/org/apache/tez/test/MiniTezCluster.java
index 5b6f736e96..c886287d89 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/MiniTezCluster.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/MiniTezCluster.java
@@ -58,6 +58,7 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/tez-tests/src/test/java/org/apache/tez/test/RecoveryServiceWithEventHandlingHook.java b/tez-tests/src/test/java/org/apache/tez/test/RecoveryServiceWithEventHandlingHook.java
index 61a88dc0a5..0b31117f17 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/RecoveryServiceWithEventHandlingHook.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/RecoveryServiceWithEventHandlingHook.java
@@ -49,6 +49,7 @@
import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG.java b/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG.java
index 8dd4ff889a..fe3c45b098 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG.java
@@ -30,6 +30,8 @@
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.api.Vertex;
+import org.junit.jupiter.api.*;
+
/**
* Simple Test DAG with 2 vertices using TestProcessor/TestInput/TestOutput.
*
diff --git a/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG3Vertices.java b/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG3Vertices.java
index 3dbb0fe0b4..8238e0a8a4 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG3Vertices.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/SimpleTestDAG3Vertices.java
@@ -30,6 +30,8 @@
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.api.Vertex;
+import org.junit.jupiter.api.*;
+
/**
* Simple Test DAG with 3 vertices using TestProcessor/TestInput/TestOutput.
*
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestAM.java b/tez-tests/src/test/java/org/apache/tez/test/TestAM.java
index 5ddf23adb0..d654e37f58 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestAM.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestAM.java
@@ -18,14 +18,13 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletResponse;
@@ -47,9 +46,7 @@
import org.apache.tez.runtime.library.processor.SleepProcessor;
import org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,7 +62,7 @@ public class TestAM {
private static final String TEST_ROOT_DIR = "target" + Path.SEPARATOR + TestAM.class.getName() + "-tmpDir";
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException {
try {
conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR);
@@ -92,7 +89,7 @@ public static void setup() throws IOException {
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
if (tezCluster != null) {
tezCluster.stop();
@@ -105,7 +102,8 @@ public static void tearDown() {
getProfiler().delete();
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testAMWebUIService() throws TezException, IOException, InterruptedException {
SleepProcessorConfig spConf = new SleepProcessorConfig(1);
@@ -128,7 +126,7 @@ public void testAMWebUIService() throws TezException, IOException, InterruptedEx
}
String webUIAddress = dagClient.getWebUIAddress();
- assertNotNull("getWebUIAddress should return TezAM's web UI address", webUIAddress);
+ assertNotNull(webUIAddress, "getWebUIAddress should return TezAM's web UI address");
LOG.info("TezAM webUI address: " + webUIAddress);
checkAddress(webUIAddress + "/jmx");
@@ -146,8 +144,7 @@ public void testAMWebUIService() throws TezException, IOException, InterruptedEx
URL url = new URL(webUIAddress);
IntegerRanges portRange = conf.getRange(TezConfiguration.TEZ_AM_WEBSERVICE_PORT_RANGE,
TezConfiguration.TEZ_AM_WEBSERVICE_PORT_RANGE_DEFAULT);
- assertTrue("WebUIService port should be in the defined range (got: " + url.getPort() + ")",
- portRange.getRangeStart() <= url.getPort());
+ assertTrue(portRange.getRangeStart() <= url.getPort(), "WebUIService port should be in the defined range (got: " + url.getPort() + ")");
tezSession.stop();
}
@@ -165,7 +162,7 @@ private void checkAddress(String url, int expectedCode) {
} catch (Exception e) {
LOG.error("Error while checking url: " + url, e);
}
- assertTrue(url + " should be available", success);
+ assertTrue(success, url + " should be available");
}
private static File getProfiler() {
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestAMRecovery.java b/tez-tests/src/test/java/org/apache/tez/test/TestAMRecovery.java
index 73a4053c31..251a691c48 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestAMRecovery.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestAMRecovery.java
@@ -18,13 +18,14 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
@@ -75,12 +76,7 @@
import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -100,7 +96,7 @@ public class TestAMRecovery {
private static String FAIL_ON_PARTIAL_FINISHED = "FAIL_ON_PARTIAL_COMPLETED";
private static String FAIL_ON_ATTEMPT = "FAIL_ON_ATTEMPT";
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
LOG.info("Starting mini clusters");
try {
@@ -124,7 +120,7 @@ public static void beforeClass() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (tezSession != null) {
try {
@@ -153,7 +149,7 @@ public static void afterClass() throws InterruptedException {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
LOG.info("Starting session");
Path remoteStagingDir =
@@ -184,7 +180,7 @@ public void setup() throws Exception {
tezSession.start();
}
- @After
+ @AfterEach
public void teardown() throws InterruptedException {
if (tezSession != null) {
try {
@@ -204,7 +200,8 @@ public void teardown() throws InterruptedException {
*
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testVertexPartiallyFinished_Broadcast() throws Exception {
DAG dag =
createDAG("VertexPartiallyFinished_Broadcast", ControlledImmediateStartVertexManager.class,
@@ -235,7 +232,8 @@ public void testVertexPartiallyFinished_Broadcast() throws Exception {
*
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testVertexCompletelyFinished_Broadcast() throws Exception {
DAG dag =
createDAG("VertexCompletelyFinished_Broadcast", ControlledImmediateStartVertexManager.class,
@@ -267,7 +265,8 @@ public void testVertexCompletelyFinished_Broadcast() throws Exception {
*
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testVertexPartialFinished_One2One() throws Exception {
DAG dag =
createDAG("VertexPartialFinished_One2One", ControlledInputReadyVertexManager.class,
@@ -299,7 +298,8 @@ public void testVertexPartialFinished_One2One() throws Exception {
*
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testVertexCompletelyFinished_One2One() throws Exception {
DAG dag =
createDAG("VertexCompletelyFinished_One2One", ControlledInputReadyVertexManager.class,
@@ -331,7 +331,8 @@ public void testVertexCompletelyFinished_One2One() throws Exception {
*
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testVertexPartiallyFinished_ScatterGather() throws Exception {
DAG dag =
createDAG("VertexPartiallyFinished_ScatterGather", ControlledShuffleVertexManager.class,
@@ -363,7 +364,8 @@ public void testVertexPartiallyFinished_ScatterGather() throws Exception {
*
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testVertexCompletelyFinished_ScatterGather() throws Exception {
DAG dag =
createDAG("VertexCompletelyFinished_ScatterGather", ControlledShuffleVertexManager.class,
@@ -374,8 +376,8 @@ public void testVertexCompletelyFinished_ScatterGather() throws Exception {
TezCounter outputCounter = counters.findCounter(TestOutput.COUNTER_NAME, TestOutput.COUNTER_NAME);
TezCounter inputCounter = counters.findCounter(TestInput.COUNTER_NAME, TestInput.COUNTER_NAME);
// verify that processor, input and output counters, are all being collected
- Assert.assertTrue(outputCounter.getValue() > 0);
- Assert.assertTrue(inputCounter.getValue() > 0);
+ assertTrue(outputCounter.getValue() > 0);
+ assertTrue(inputCounter.getValue() > 0);
List historyEvents1 = readRecoveryLog(1);
List historyEvents2 = readRecoveryLog(2);
@@ -398,7 +400,8 @@ public void testVertexCompletelyFinished_ScatterGather() throws Exception {
*
* @throws Exception
*/
- @Test(timeout = 600000)
+ @Test
+ @Timeout(value = 600000, unit = TimeUnit.MILLISECONDS)
public void testHighMaxAttempt() throws Exception {
Random rand = new Random();
tezConf.set(FAIL_ON_ATTEMPT, rand.nextInt(MAX_AM_ATTEMPT) + "");
@@ -416,7 +419,7 @@ TezCounters runDAGAndVerify(DAG dag, DAGStatus.State finalState) throws Exceptio
DAGStatus dagStatus =
dagClient.waitForCompletionWithStatusUpdates(EnumSet
.of(StatusGetOpts.GET_COUNTERS));
- Assert.assertEquals(finalState, dagStatus.getState());
+ assertEquals(finalState, dagStatus.getState());
return dagStatus.getDAGCounters();
}
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestAMRecoveryAggregationBroadcast.java b/tez-tests/src/test/java/org/apache/tez/test/TestAMRecoveryAggregationBroadcast.java
index 979b696cbd..c42ebb3704 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestAMRecoveryAggregationBroadcast.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestAMRecoveryAggregationBroadcast.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -85,12 +85,7 @@
import org.apache.tez.runtime.library.conf.UnorderedKVEdgeConfig;
import org.apache.tez.runtime.library.partitioner.HashPartitioner;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -120,7 +115,7 @@ public class TestAMRecoveryAggregationBroadcast {
private TezConfiguration tezConf;
private TezClient tezSession;
- @BeforeClass
+ @BeforeAll
public static void setupAll() {
try {
dfsConf = new Configuration();
@@ -156,7 +151,7 @@ private static void createSampleFile() throws IOException {
writer.close();
}
- @AfterClass
+ @AfterAll
public static void tearDownAll() {
if (tezCluster != null) {
tezCluster.stop();
@@ -168,7 +163,7 @@ public static void tearDownAll() {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
Path remoteStagingDir = remoteFs.makeQualified(new Path(TEST_ROOT_DIR, String
.valueOf(new Random().nextInt(100000))));
@@ -187,7 +182,7 @@ public void setup() throws Exception {
tezSession.start();
}
- @After
+ @AfterEach
public void teardown() throws InterruptedException {
if (tezSession != null) {
try {
@@ -200,7 +195,8 @@ public void teardown() throws InterruptedException {
tezSession = null;
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testSucceed() throws Exception {
DAG dag = createDAG("Succeed");
TezCounters counters = runDAGAndVerify(dag, false);
@@ -215,7 +211,8 @@ public void testSucceed() throws Exception {
assertEquals(Collections.emptyList(), readRecoveryLog(2));
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testTableScanTemporalFailure() throws Exception {
tezConf.setBoolean(TABLE_SCAN_SLEEP, true);
DAG dag = createDAG("TableScanTemporalFailure");
@@ -235,7 +232,8 @@ public void testTableScanTemporalFailure() throws Exception {
assertEquals(Collections.emptyList(), readRecoveryLog(3));
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testAggregationTemporalFailure() throws Exception {
tezConf.setBoolean(AGGREGATION_SLEEP, true);
DAG dag = createDAG("AggregationTemporalFailure");
@@ -255,7 +253,8 @@ public void testAggregationTemporalFailure() throws Exception {
assertEquals(Collections.emptyList(), readRecoveryLog(3));
}
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testMapJoinTemporalFailure() throws Exception {
tezConf.setBoolean(MAP_JOIN_SLEEP, true);
DAG dag = createDAG("MapJoinTemporalFailure");
@@ -350,13 +349,13 @@ TezCounters runDAGAndVerify(DAG dag, boolean killAM) throws Exception {
}
DAGStatus dagStatus = dagClient.waitForCompletionWithStatusUpdates(EnumSet.of(StatusGetOpts.GET_COUNTERS));
LOG.info("Diagnosis: " + dagStatus.getDiagnostics());
- Assert.assertEquals(State.SUCCEEDED, dagStatus.getState());
+ assertEquals(State.SUCCEEDED, dagStatus.getState());
FSDataInputStream in = remoteFs.open(new Path(OUT_PATH, "part-v002-o000-r-00000"));
ByteBuffer buf = ByteBuffer.allocate(100);
in.read(buf);
buf.flip();
- Assert.assertEquals(EXPECTED_OUTPUT, StandardCharsets.UTF_8.decode(buf).toString());
+ assertEquals(EXPECTED_OUTPUT, StandardCharsets.UTF_8.decode(buf).toString());
return dagStatus.getDAGCounters();
}
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery.java b/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery.java
index 6b7dac6083..6b39184e30 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery.java
@@ -18,8 +18,11 @@
*/
package org.apache.tez.test;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.IOException;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
@@ -43,12 +46,7 @@
import org.apache.tez.test.dag.MultiAttemptDAG.TestRootInputInitializer;
import org.apache.tez.test.dag.SimpleVTestDAG;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,7 +63,7 @@ public class TestDAGRecovery {
private static FileSystem remoteFs = null;
private static TezConfiguration tezConf = null;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
LOG.info("Starting mini clusters");
try {
@@ -88,7 +86,7 @@ public static void beforeClass() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (tezSession != null) {
try {
@@ -116,7 +114,7 @@ public static void afterClass() throws InterruptedException {
}
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
LOG.info("Starting session");
Path remoteStagingDir = remoteFs.makeQualified(new Path(TEST_ROOT_DIR, String
@@ -142,7 +140,7 @@ public void setup() throws Exception {
tezSession.start();
}
- @After
+ @AfterEach
public void teardown() throws InterruptedException {
if (tezSession != null) {
try {
@@ -168,10 +166,11 @@ void runDAGAndVerify(DAG dag, DAGStatus.State finalState) throws Exception {
dagStatus = dagClient.getDAGStatus(null);
}
- Assert.assertEquals(finalState, dagStatus.getState());
+ assertEquals(finalState, dagStatus.getState());
}
- @Test(timeout=120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testBasicRecovery() throws Exception {
DAG dag = MultiAttemptDAG.createDAG("TestBasicRecovery", null);
// add input to v1 to make sure that there will be init events for v1 (TEZ-1345)
@@ -183,7 +182,8 @@ public void testBasicRecovery() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test(timeout=120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testDelayedInit() throws Exception {
DAG dag = SimpleVTestDAG.createDAG("DelayedInitDAG", null);
dag.getVertex("v1").addDataSource(
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery2.java b/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery2.java
index 13349ceaeb..27e29bc1ff 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery2.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestDAGRecovery2.java
@@ -18,9 +18,12 @@
*/
package org.apache.tez.test;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -41,12 +44,7 @@
import org.apache.tez.test.dag.MultiAttemptDAG;
import org.apache.tez.test.dag.SimpleVTestDAG;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,7 +60,7 @@ public class TestDAGRecovery2 {
private static TezClient tezSession = null;
private static FileSystem remoteFs = null;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
LOG.info("Starting mini clusters");
try {
@@ -85,7 +83,7 @@ public static void beforeClass() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (tezSession != null) {
try {
@@ -127,7 +125,7 @@ private TezConfiguration createSessionConfig(Path remoteStagingDir) {
return tezConf;
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
Path remoteStagingDir = remoteFs.makeQualified(new Path(TEST_ROOT_DIR, String
.valueOf(new Random().nextInt(100000))));
@@ -139,7 +137,7 @@ public void setup() throws Exception {
tezSession.start();
}
- @After
+ @AfterEach
public void teardown() throws InterruptedException {
if (tezSession != null) {
try {
@@ -170,10 +168,11 @@ void runDAGAndVerify(DAG dag, DAGStatus.State finalState,
dagStatus = dagClient.getDAGStatus(null);
}
- Assert.assertEquals(finalState, dagStatus.getState());
+ assertEquals(finalState, dagStatus.getState());
}
- @Test(timeout=120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testFailingCommitter() throws Exception {
DAG dag = SimpleVTestDAG.createDAG("FailingCommitterDAG", null);
OutputDescriptor od =
@@ -187,7 +186,8 @@ public void testFailingCommitter() throws Exception {
runDAGAndVerify(dag, State.FAILED);
}
- @Test(timeout=120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testSessionDisableMultiAttempts() throws Exception {
tezSession.stop();
Path remoteStagingDir = remoteFs.makeQualified(new Path(TEST_ROOT_DIR, String
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestDriver.java b/tez-tests/src/test/java/org/apache/tez/test/TestDriver.java
index 0fcbdc0295..e63cde7984 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestDriver.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestDriver.java
@@ -20,6 +20,8 @@
import org.apache.hadoop.util.ProgramDriver;
+import org.junit.jupiter.api.*;
+
public final class TestDriver {
private TestDriver() {}
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestExceptionPropagation.java b/tez-tests/src/test/java/org/apache/tez/test/TestExceptionPropagation.java
index be5ebcd4fc..137aa091b9 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestExceptionPropagation.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestExceptionPropagation.java
@@ -18,7 +18,7 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
@@ -90,7 +91,7 @@
import com.google.common.collect.Lists;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -216,7 +217,8 @@ private void stopNonSessionClient() {
* @throws Exception
*
*/
- @Test(timeout = 600000)
+ @Test
+ @Timeout(value = 600000, unit = TimeUnit.MILLISECONDS)
public void testExceptionPropagationSession() throws Exception {
try {
startSessionClient();
@@ -245,7 +247,8 @@ public void testExceptionPropagationSession() throws Exception {
*
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testExceptionPropagationNonSession() throws Exception {
try {
startMiniTezCluster();
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestFaultTolerance.java b/tez-tests/src/test/java/org/apache/tez/test/TestFaultTolerance.java
index d3883945bc..0ff06da1d6 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestFaultTolerance.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestFaultTolerance.java
@@ -18,9 +18,12 @@
*/
package org.apache.tez.test;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -50,12 +53,7 @@
import com.google.common.base.Joiner;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,7 +69,7 @@ public class TestFaultTolerance {
private static TezClient tezSession = null;
private static TezConfiguration tezConf;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
LOG.info("Starting mini clusters");
FileSystem remoteFs = null;
@@ -109,7 +107,7 @@ public static void setup() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
LOG.info("Stopping mini clusters");
if (tezSession != null) {
@@ -125,7 +123,7 @@ public static void tearDown() throws Exception {
}
}
- @Before
+ @BeforeEach
public void checkSessionStatus() {
// TODO restart session if it crashed due to some test error
}
@@ -152,20 +150,21 @@ void runDAGAndVerify(DAG dag, DAGStatus.State finalState, int checkFailedAttempt
dagStatus = dagClient.getDAGStatus(null);
}
- Assert.assertEquals(finalState, dagStatus.getState());
+ assertEquals(finalState, dagStatus.getState());
if (checkFailedAttempts > 0) {
- Assert.assertEquals(checkFailedAttempts,
+ assertEquals(checkFailedAttempts,
dagStatus.getDAGProgress().getFailedTaskAttemptCount());
}
if (diagnostics != null) {
- Assert.assertNotNull(dagStatus.getDiagnostics());
- Assert.assertTrue(Joiner.on(":").join(dagStatus.getDiagnostics()).contains(diagnostics));
+ assertNotNull(dagStatus.getDiagnostics());
+ assertTrue(Joiner.on(":").join(dagStatus.getDiagnostics()).contains(diagnostics));
}
}
- @Test (timeout=600000)
+ @Test
+ @Timeout(value = 600000, unit = TimeUnit.MILLISECONDS)
public void testSessionStopped() throws Exception {
Configuration testConf = new Configuration(false);
@@ -198,13 +197,15 @@ public void testSessionStopped() throws Exception {
tezSession.start();
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicSuccessScatterGather() throws Exception {
DAG dag = SimpleTestDAG.createDAG("testBasicSuccessScatterGather", null);
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicSuccessBroadcast() throws Exception {
DAG dag = DAG.create("testBasicSuccessBroadcast");
Vertex v1 =
@@ -220,7 +221,8 @@ public void testBasicSuccessBroadcast() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicTaskFailure() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestProcessor.getVertexConfName(
@@ -245,7 +247,8 @@ public void testBasicTaskFailure() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED, 1);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testTaskMultipleFailures() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestProcessor.getVertexConfName(
@@ -266,7 +269,8 @@ public void testTaskMultipleFailures() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED, 4);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testTaskMultipleFailuresDAGFail() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestProcessor.getVertexConfName(
@@ -280,7 +284,8 @@ public void testTaskMultipleFailuresDAGFail() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.FAILED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicInputFailureWithExit() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.getVertexConfName(
@@ -308,7 +313,8 @@ public void testBasicInputFailureWithExit() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicInputFailureWithoutExit() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.getVertexConfName(
@@ -330,7 +336,8 @@ public void testBasicInputFailureWithoutExit() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testBasicInputFailureWithoutExitDeadline() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setInt(SimpleTestDAG.TEZ_SIMPLE_DAG_NUM_TASKS, 3); // 1 error < 0.4 fail fraction
@@ -348,7 +355,8 @@ public void testBasicInputFailureWithoutExitDeadline() throws Exception {
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMultipleInputFailureWithoutExit() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.getVertexConfName(
@@ -375,7 +383,8 @@ public void testMultipleInputFailureWithoutExit() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMultiVersionInputFailureWithoutExit() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.getVertexConfName(
@@ -404,7 +413,8 @@ public void testMultiVersionInputFailureWithoutExit() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testTwoLevelsFailingDAGSuccess() throws Exception {
Configuration testConf = new Configuration();
DAG dag = new FailingDagBuilder(FailingDagBuilder.Levels.TWO)
@@ -412,7 +422,8 @@ public void testTwoLevelsFailingDAGSuccess() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testThreeLevelsFailingDAGSuccess() throws Exception {
Configuration testConf = new Configuration();
DAG dag = new FailingDagBuilder(FailingDagBuilder.Levels.THREE)
@@ -420,7 +431,8 @@ public void testThreeLevelsFailingDAGSuccess() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testSixLevelsFailingDAGSuccess() throws Exception {
Configuration testConf = new Configuration();
DAG dag = new FailingDagBuilder(FailingDagBuilder.Levels.SIX)
@@ -428,7 +440,8 @@ public void testSixLevelsFailingDAGSuccess() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testThreeLevelsFailingDAG2VerticesHaveFailedAttemptsDAGSucceeds() throws Exception {
Configuration testConf = new Configuration();
//set maximum number of task attempts to 4
@@ -482,7 +495,8 @@ public void testThreeLevelsFailingDAG2VerticesHaveFailedAttemptsDAGSucceeds() th
* The input version is now 2. The attempt will now succeed.
* @throws Exception
*/
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testInputFailureCausesRerunAttemptWithinMaxAttemptSuccess() throws Exception {
Configuration testConf = new Configuration();
//at v1, task 1 has attempt 0 failing. Attempt 1 succeeds. 1 attempt fails so far.
@@ -578,7 +592,8 @@ private void setCascadingInputFailureConfig(Configuration testConf,
* AM vertex succeeded order is v1, v2, v1, v2, v3.
* @throws Exception
*/
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testCascadingInputFailureWithoutExitSuccess() throws Exception {
Configuration testConf = new Configuration(false);
setCascadingInputFailureConfig(testConf, false);
@@ -608,7 +623,8 @@ public void testCascadingInputFailureWithoutExitSuccess() throws Exception {
* AM vertex succeeded order is v1, v2, v3, v1, v2, v3.
* @throws Exception
*/
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testCascadingInputFailureWithExitSuccess() throws Exception {
Configuration testConf = new Configuration(false);
setCascadingInputFailureConfig(testConf, true);
@@ -635,7 +651,8 @@ public void testCascadingInputFailureWithExitSuccess() throws Exception {
*
* @throws Exception
*/
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testInputFailureCausesRerunOfTwoVerticesWithoutExit() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.getVertexConfName(
@@ -673,7 +690,8 @@ public void testInputFailureCausesRerunOfTwoVerticesWithoutExit() throws Excepti
*
* @throws Exception
*/
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testAttemptOfDownstreamVertexConnectedWithTwoUpstreamVerticesFailure() throws Exception {
Configuration testConf = new Configuration(false);
@@ -708,7 +726,8 @@ public void testAttemptOfDownstreamVertexConnectedWithTwoUpstreamVerticesFailure
* Also covers multiple consumer vertices report failure against same producer task.
* @throws Exception
*/
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testInputFailureRerunCanSendOutputToTwoDownstreamVertices() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.getVertexConfName(
@@ -765,7 +784,8 @@ public void testInputFailureRerunCanSendOutputToTwoDownstreamVertices() throws E
* DAG succeeds with v1 attempt2.
* @throws Exception
*/
- @Test (timeout=60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testTwoTasksHaveInputFailuresSuccess() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.getVertexConfName(
@@ -796,7 +816,8 @@ public void testTwoTasksHaveInputFailuresSuccess() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=240000)
+ @Test
+ @Timeout(value = 240000, unit = TimeUnit.MILLISECONDS)
public void testRandomFailingTasks() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestProcessor.TEZ_FAILING_PROCESSOR_DO_RANDOM_FAIL, true);
@@ -806,8 +827,9 @@ public void testRandomFailingTasks() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Ignore
- @Test (timeout=240000)
+ @Disabled
+ @Test
+ @Timeout(value = 240000, unit = TimeUnit.MILLISECONDS)
public void testRandomFailingInputs() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setBoolean(TestInput.TEZ_FAILING_INPUT_DO_RANDOM_FAIL, true);
@@ -817,7 +839,8 @@ public void testRandomFailingInputs() throws Exception {
runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
- @Test (timeout=240000)
+ @Test
+ @Timeout(value = 240000, unit = TimeUnit.MILLISECONDS)
public void testNoProgress() throws Exception {
Configuration testConf = new Configuration(false);
testConf.setInt(SimpleTestDAG.TEZ_SIMPLE_DAG_NUM_TASKS, 1);
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestInput.java b/tez-tests/src/test/java/org/apache/tez/test/TestInput.java
index 9a4532eaae..a5cc36ce74 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestInput.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestInput.java
@@ -40,6 +40,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestLocalMode.java b/tez-tests/src/test/java/org/apache/tez/test/TestLocalMode.java
index af65ff4e2f..e0ed3a3e08 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestLocalMode.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestLocalMode.java
@@ -18,14 +18,14 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -51,16 +51,13 @@
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
import org.apache.tez.runtime.library.processor.SleepProcessor;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.params.*;
+import org.junit.jupiter.params.provider.*;
/**
* Tests for running Tez in local execution mode (without YARN).
*/
-@RunWith(Parameterized.class)
public class TestLocalMode {
/**
@@ -75,20 +72,16 @@ public class TestLocalMode {
private static MiniDFSCluster dfsCluster;
private static FileSystem remoteFs;
- private final boolean useDfs;
- private final boolean useLocalModeWithoutNetwork;
-
- @Parameterized.Parameters(name = "useDFS:{0} useLocalModeWithoutNetwork:{1}")
- public static Collection params() {
- return Arrays.asList(new Object[][]{{false, false}, {true, false}, {false, true}, {true, true}});
- }
-
- public TestLocalMode(boolean useDfs, boolean useLocalModeWithoutNetwork) {
- this.useDfs = useDfs;
- this.useLocalModeWithoutNetwork = useLocalModeWithoutNetwork;
+ public static Stream params() {
+ return Stream.of(
+ Arguments.of(false, false),
+ Arguments.of(true, false),
+ Arguments.of(false, true),
+ Arguments.of(true, true)
+ );
}
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
try {
Configuration conf = new Configuration();
@@ -101,7 +94,7 @@ public static void beforeClass() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (dfsCluster != null) {
try {
@@ -112,7 +105,7 @@ public static void afterClass() throws InterruptedException {
}
}
- private TezConfiguration createConf() {
+ private TezConfiguration createConf(boolean useDfs, boolean useLocalModeWithoutNetwork) {
TezConfiguration conf = new TezConfiguration();
conf.setBoolean(TezConfiguration.TEZ_LOCAL_MODE, true);
conf.setBoolean(TezConfiguration.TEZ_LOCAL_MODE_WITHOUT_NETWORK, useLocalModeWithoutNetwork);
@@ -127,14 +120,16 @@ private TezConfiguration createConf() {
return conf;
}
- @Test(timeout = 30000)
- public void testMultipleClientsWithSession() throws TezException, InterruptedException,
+ @ParameterizedTest(name = "useDFS:{0} useLocalModeWithoutNetwork:{1}")
+ @MethodSource("params")
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ public void testMultipleClientsWithSession(boolean useDfs, boolean useLocalModeWithoutNetwork) throws TezException, InterruptedException,
IOException {
- TezConfiguration tezConf1 = createConf();
+ TezConfiguration tezConf1 = createConf(useDfs, useLocalModeWithoutNetwork);
TezClient tezClient1 = TezClient.create("commonName", tezConf1, true);
tezClient1.start();
- DAG dag1 = createSimpleDAG("testMultipleClientsWithSession", SleepProcessor.class.getName());
+ DAG dag1 = createSimpleDAG("testMultipleClientsWithSession", SleepProcessor.class.getName(), useDfs, useLocalModeWithoutNetwork);
DAGClient dagClient1 = tezClient1.submitDAG(dag1);
dagClient1.waitForCompletion();
@@ -145,8 +140,8 @@ public void testMultipleClientsWithSession() throws TezException, InterruptedExc
dagClient1.close();
tezClient1.stop();
- TezConfiguration tezConf2 = createConf();
- DAG dag2 = createSimpleDAG("testMultipleClientsWithSession_2", SleepProcessor.class.getName());
+ TezConfiguration tezConf2 = createConf(useDfs, useLocalModeWithoutNetwork);
+ DAG dag2 = createSimpleDAG("testMultipleClientsWithSession_2", SleepProcessor.class.getName(), useDfs, useLocalModeWithoutNetwork);
TezClient tezClient2 = TezClient.create("commonName", tezConf2, true);
tezClient2.start();
DAGClient dagClient2 = tezClient2.submitDAG(dag2);
@@ -154,19 +149,21 @@ public void testMultipleClientsWithSession() throws TezException, InterruptedExc
assertEquals(DAGStatus.State.SUCCEEDED, dagClient2.getDAGStatus(null).getState());
assertEquals(VertexStatus.State.SUCCEEDED,
dagClient2.getVertexStatus(SleepProcessor.SLEEP_VERTEX_NAME, null).getState());
- assertFalse(dagClient1.getExecutionContext().equals(dagClient2.getExecutionContext()));
+ assertNotEquals(dagClient1.getExecutionContext(), dagClient2.getExecutionContext());
dagClient2.close();
tezClient2.stop();
}
- @Test(timeout = 10000)
- public void testMultipleClientsWithoutSession() throws TezException, InterruptedException,
+ @ParameterizedTest(name = "useDFS:{0} useLocalModeWithoutNetwork:{1}")
+ @MethodSource("params")
+ @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
+ public void testMultipleClientsWithoutSession(boolean useDfs, boolean useLocalModeWithoutNetwork) throws TezException, InterruptedException,
IOException {
- TezConfiguration tezConf1 = createConf();
+ TezConfiguration tezConf1 = createConf(useDfs, useLocalModeWithoutNetwork);
TezClient tezClient1 = TezClient.create("commonName", tezConf1, false);
tezClient1.start();
- DAG dag1 = createSimpleDAG("testMultipleClientsWithoutSession", SleepProcessor.class.getName());
+ DAG dag1 = createSimpleDAG("testMultipleClientsWithoutSession", SleepProcessor.class.getName(), useDfs, useLocalModeWithoutNetwork);
DAGClient dagClient1 = tezClient1.submitDAG(dag1);
dagClient1.waitForCompletion();
@@ -177,8 +174,8 @@ public void testMultipleClientsWithoutSession() throws TezException, Interrupted
tezClient1.stop();
- TezConfiguration tezConf2 = createConf();
- DAG dag2 = createSimpleDAG("testMultipleClientsWithoutSession_2", SleepProcessor.class.getName());
+ TezConfiguration tezConf2 = createConf(useDfs, useLocalModeWithoutNetwork);
+ DAG dag2 = createSimpleDAG("testMultipleClientsWithoutSession_2", SleepProcessor.class.getName(), useDfs, useLocalModeWithoutNetwork);
TezClient tezClient2 = TezClient.create("commonName", tezConf2, false);
tezClient2.start();
DAGClient dagClient2 = tezClient2.submitDAG(dag2);
@@ -186,20 +183,22 @@ public void testMultipleClientsWithoutSession() throws TezException, Interrupted
assertEquals(DAGStatus.State.SUCCEEDED, dagClient2.getDAGStatus(null).getState());
assertEquals(VertexStatus.State.SUCCEEDED,
dagClient2.getVertexStatus(SleepProcessor.SLEEP_VERTEX_NAME, null).getState());
- assertFalse(dagClient1.getExecutionContext().equals(dagClient2.getExecutionContext()));
+ assertNotEquals(dagClient1.getExecutionContext(), dagClient2.getExecutionContext());
dagClient2.close();
tezClient2.stop();
}
- @Test(timeout = 20000)
- public void testNoSysExitOnSuccessfulDAG() throws TezException, InterruptedException,
+ @ParameterizedTest(name = "useDFS:{0} useLocalModeWithoutNetwork:{1}")
+ @MethodSource("params")
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
+ public void testNoSysExitOnSuccessfulDAG(boolean useDfs, boolean useLocalModeWithoutNetwork) throws TezException, InterruptedException,
IOException {
- TezConfiguration tezConf1 = createConf();
+ TezConfiguration tezConf1 = createConf(useDfs, useLocalModeWithoutNetwork);
// Run in non-session mode so that the AM terminates
TezClient tezClient1 = TezClient.create("commonName", tezConf1, false);
tezClient1.start();
- DAG dag1 = createSimpleDAG("testNoSysExitOnSuccessfulDAG", SleepProcessor.class.getName());
+ DAG dag1 = createSimpleDAG("testNoSysExitOnSuccessfulDAG", SleepProcessor.class.getName(), useDfs, useLocalModeWithoutNetwork);
DAGClient dagClient1 = tezClient1.submitDAG(dag1);
dagClient1.waitForCompletion();
@@ -213,15 +212,17 @@ public void testNoSysExitOnSuccessfulDAG() throws TezException, InterruptedExcep
tezClient1.stop();
}
- @Test(timeout = 20000)
- public void testNoSysExitOnFailingDAG() throws TezException, InterruptedException,
+ @ParameterizedTest(name = "useDFS:{0} useLocalModeWithoutNetwork:{1}")
+ @MethodSource("params")
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
+ public void testNoSysExitOnFailingDAG(boolean useDfs, boolean useLocalModeWithoutNetwork) throws TezException, InterruptedException,
IOException {
- TezConfiguration tezConf1 = createConf();
+ TezConfiguration tezConf1 = createConf(useDfs, useLocalModeWithoutNetwork);
// Run in non-session mode so that the AM terminates
TezClient tezClient1 = TezClient.create("commonName", tezConf1, false);
tezClient1.start();
- DAG dag1 = createSimpleDAG("testNoSysExitOnFailingDAG", FailingProcessor.class.getName());
+ DAG dag1 = createSimpleDAG("testNoSysExitOnFailingDAG", FailingProcessor.class.getName(), useDfs, useLocalModeWithoutNetwork);
DAGClient dagClient1 = tezClient1.submitDAG(dag1);
dagClient1.waitForCompletion();
@@ -261,24 +262,26 @@ public void run(Map inputs, Map out
}
}
- private DAG createSimpleDAG(String dagName, String processorName) {
- DAG dag = DAG.create(generateDagName("DAG-" + dagName)).addVertex(
+ private DAG createSimpleDAG(String dagName, String processorName, boolean useDfs, boolean useLocalModeWithoutNetwork) {
+ DAG dag = DAG.create(generateDagName("DAG-" + dagName, useDfs, useLocalModeWithoutNetwork)).addVertex(
Vertex.create(SleepProcessor.SLEEP_VERTEX_NAME, ProcessorDescriptor.create(processorName).setUserPayload(
new SleepProcessor.SleepProcessorConfig(SLEEP_PROCESSOR_TIME_TO_SLEEP_MS).toUserPayload()), 1));
return dag;
}
- private String generateDagName(String baseName) {
+ private String generateDagName(String baseName, boolean useDfs, boolean useLocalModeWithoutNetwork) {
return baseName + (useDfs ? "_useDfs" : "") + (useLocalModeWithoutNetwork ? "_useLocalModeWithoutNetwork" : "");
}
- @Test(timeout=30000)
- public void testMultiDAGsOnSession() throws IOException, TezException, InterruptedException {
+ @ParameterizedTest(name = "useDFS:{0} useLocalModeWithoutNetwork:{1}")
+ @MethodSource("params")
+ @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
+ public void testMultiDAGsOnSession(boolean useDfs, boolean useLocalModeWithoutNetwork) throws IOException, TezException, InterruptedException {
int dags = 2;//two dags will be submitted to session
String[] inputPaths = new String[dags];
String[] outputPaths = new String[dags];
DAGClient[] dagClients = new DAGClient[dags];
- TezConfiguration tezConf = createConf();
+ TezConfiguration tezConf = createConf(useDfs, useLocalModeWithoutNetwork);
TezClient tezClient = TezClient.create("testMultiDAGOnSession", tezConf, true);
tezClient.start();
@@ -308,7 +311,8 @@ public void testMultiDAGsOnSession() throws IOException, TezException, Interrupt
}
//verify all dags sharing the same execution context
if(i>0) {
- assertTrue(dagClients[i-1].getExecutionContext().equals(dagClients[i].getExecutionContext()));
+ assertEquals(dagClients[i - 1].getExecutionContext(),
+ dagClients[i].getExecutionContext());
}
}
} finally {
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestMiniTezCluster.java b/tez-tests/src/test/java/org/apache/tez/test/TestMiniTezCluster.java
index afb24277eb..edc960c33b 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestMiniTezCluster.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestMiniTezCluster.java
@@ -18,13 +18,15 @@
*/
package org.apache.tez.test;
+import static org.junit.jupiter.api.Assertions.*;
+
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
+
public class TestMiniTezCluster {
@@ -35,7 +37,7 @@ public void testOverrideYarnDiskHealthCheck() throws IOException {
tezMiniCluster.start();
// overrides if not set
- Assert.assertEquals(99.0, tezMiniCluster.getConfig()
+ assertEquals(99.0, tezMiniCluster.getConfig()
.getFloat(YarnConfiguration.NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE, -1), 0.00001);
tezMiniCluster.close();
@@ -47,7 +49,7 @@ public void testOverrideYarnDiskHealthCheck() throws IOException {
tezMiniCluster.start();
// respects provided non-default value
- Assert.assertEquals(50.0, tezMiniCluster.getConfig()
+ assertEquals(50.0, tezMiniCluster.getConfig()
.getFloat(YarnConfiguration.NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE, -1), 0.00001);
tezMiniCluster.close();
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestOutput.java b/tez-tests/src/test/java/org/apache/tez/test/TestOutput.java
index 9a0fa219b9..ddb6b4964b 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestOutput.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestOutput.java
@@ -34,6 +34,7 @@
import com.google.common.collect.Lists;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestPipelinedShuffle.java b/tez-tests/src/test/java/org/apache/tez/test/TestPipelinedShuffle.java
index c8549ca21a..90f2b79f2c 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestPipelinedShuffle.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestPipelinedShuffle.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.util.Set;
@@ -56,11 +55,7 @@
import com.google.common.collect.Sets;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
public class TestPipelinedShuffle {
@@ -75,7 +70,7 @@ public class TestPipelinedShuffle {
private static final int KEYS_PER_MAPPER = 5000;
- @BeforeClass
+ @BeforeAll
public static void setupDFSCluster() throws Exception {
conf = new Configuration();
conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_EDITS_NOEDITLOGCHANNELFLUSH, false);
@@ -88,7 +83,7 @@ public static void setupDFSCluster() throws Exception {
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, false);
}
- @AfterClass
+ @AfterAll
public static void shutdownDFSCluster() {
if (miniDFSCluster != null) {
//shutdown
@@ -97,8 +92,8 @@ public static void shutdownDFSCluster() {
}
//TODO: Add support for async http clients
- @Before
- public void setupTezCluster() throws Exception {
+ @BeforeAll
+ public static void setupTezCluster() {
//With 1 MB sort buffer and with good amount of dataset, it would spill records
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 1);
@@ -122,8 +117,8 @@ public void setupTezCluster() throws Exception {
miniTezCluster.start();
}
- @After
- public void shutdownTezCluster() throws IOException {
+ @AfterAll
+ public static void shutdownTezCluster() {
if (miniTezCluster != null) {
miniTezCluster.stop();
}
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestRecovery.java b/tez-tests/src/test/java/org/apache/tez/test/TestRecovery.java
index 6aa4b62d9d..31ec8ead9d 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestRecovery.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestRecovery.java
@@ -18,8 +18,7 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -31,6 +30,7 @@
import java.util.List;
import java.util.Random;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
@@ -81,10 +81,7 @@
import com.google.common.collect.Lists;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -99,7 +96,7 @@ public class TestRecovery {
private static MiniDFSCluster dfsCluster = null;
private static FileSystem remoteFs = null;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
LOG.info("Starting mini clusters");
try {
@@ -121,7 +118,7 @@ public static void beforeClass() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws InterruptedException {
if (miniTezCluster != null) {
try {
@@ -141,7 +138,8 @@ public static void afterClass() throws InterruptedException {
}
}
- @Test(timeout=1800000)
+ @Test
+ @Timeout(value = 1800000, unit = TimeUnit.MILLISECONDS)
public void testRecovery_OrderedWordCount() throws Exception {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(),
1);
@@ -285,13 +283,14 @@ private void testOrderedWordCount(SimpleShutdownCondition shutdownCondition,
tezConf.set(TezConfiguration.TEZ_AM_LOG_LEVEL, "INFO;org.apache.tez=DEBUG");
OrderedWordCount job = new OrderedWordCount();
if (generateSplitInClient) {
- Assert
- .assertTrue("OrderedWordCount failed", job.run(tezConf, new String[]{
- "-generateSplitInClient", inputDirStr, outputDirStr, "5"}, null) == 0);
+
+ assertEquals(0, job.run(tezConf, new String[]{
+ "-generateSplitInClient", inputDirStr, outputDirStr, "5"}, null),
+ "OrderedWordCount failed");
} else {
- Assert
- .assertTrue("OrderedWordCount failed", job.run(tezConf, new String[]{
- inputDirStr, outputDirStr, "5"}, null) == 0);
+
+ assertEquals(0, job.run(tezConf, new String[]{
+ inputDirStr, outputDirStr, "5"}, null), "OrderedWordCount failed");
}
TestTezJobs.verifyOutput(outputDir, remoteFs);
List historyEventsOfAttempt1 = RecoveryParser
@@ -343,18 +342,20 @@ private void testOrderedWordCountMultipleRoundRecoverying(
TezConfiguration.TEZ_AM_STAGING_SCRATCH_DATA_AUTO_DELETE, false);
OrderedWordCount job = new OrderedWordCount();
if (generateSplitInClient) {
- Assert
- .assertTrue("OrderedWordCount failed", job.run(tezConf, new String[]{
- "-generateSplitInClient", inputDirStr, outputDirStr, "5"}, null) == 0);
+
+ Assertions.assertEquals(0, job.run(tezConf, new String[]{
+ "-generateSplitInClient", inputDirStr, outputDirStr, "5"}, null),
+ "OrderedWordCount failed");
} else {
- Assert
- .assertTrue("OrderedWordCount failed", job.run(tezConf, new String[]{
- inputDirStr, outputDirStr, "5"}, null) == 0);
+
+ Assertions.assertEquals(0, job.run(tezConf, new String[]{
+ inputDirStr, outputDirStr, "5"}, null), "OrderedWordCount failed");
}
TestTezJobs.verifyOutput(outputDir, remoteFs);
}
- @Test(timeout = 1800000)
+ @Test
+ @Timeout(value = 1800000, unit = TimeUnit.MILLISECONDS)
public void testRecovery_HashJoin() throws Exception {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(),
1);
@@ -557,7 +558,8 @@ public boolean accept(Path p) {
assertTrue(shutdownCondition.match(lastEvent));
}
- @Test(timeout = 1800000)
+ @Test
+ @Timeout(value = 1800000, unit = TimeUnit.MILLISECONDS)
public void testTwoRoundsRecoverying() throws Exception {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(),
1);
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestSecureShuffle.java b/tez-tests/src/test/java/org/apache/tez/test/TestSecureShuffle.java
index 2e5b4a6284..c4851624c5 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestSecureShuffle.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestSecureShuffle.java
@@ -19,7 +19,7 @@
package org.apache.tez.test;
import static org.apache.hadoop.security.ssl.SSLFactory.SSL_CLIENT_CONF_KEY;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.BufferedWriter;
import java.io.File;
@@ -30,11 +30,11 @@
import java.security.KeyPair;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
import javax.security.auth.x500.X500Principal;
@@ -56,18 +56,16 @@
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.X509Extensions;
import org.bouncycastle.x509.X509V3CertificateGenerator;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.params.*;
+import org.junit.jupiter.params.provider.*;
+
+
/**
* Test to verify secure-shuffle (SSL mode) in Tez
*/
-@RunWith(Parameterized.class)
+
public class TestSecureShuffle {
private static MiniDFSCluster miniDFSCluster;
@@ -80,38 +78,19 @@ public class TestSecureShuffle {
+ TestSecureShuffle.class.getName() + "-tmpDir";
private static File keysStoresDir = new File(TEST_ROOT_DIR, "keystores");
- private boolean enableSSLInCluster; //To set ssl config in cluster
- private int resultWithTezSSL; //expected result with tez ssl setting
- private int resultWithoutTezSSL; //expected result without tez ssl setting
- private boolean asyncHttp;
-
- public TestSecureShuffle(boolean sslInCluster, int resultWithTezSSL, int resultWithoutTezSSL,
- boolean asyncHttp) {
- this.enableSSLInCluster = sslInCluster;
- this.resultWithTezSSL = resultWithTezSSL;
- this.resultWithoutTezSSL = resultWithoutTezSSL;
- this.asyncHttp = asyncHttp;
+ public static Stream getParameters() {
+ return Stream.of(
+ // enable ssl in cluster, succeed with tez-ssl enabled, fail with tez-ssl disabled
+ Arguments.of(true, 0, 1, false),
+ // With asyncHttp
+ Arguments.of(true, 0, 1, true),
+ Arguments.of(false, 1, 0, true),
+ // Negative testcase
+ // disable ssl in cluster, fail with tez-ssl enabled, succeed with tez-ssl disabled
+ Arguments.of(false, 1, 0, false));
}
- @Parameterized.Parameters(name = "test[sslInCluster:{0}, resultWithTezSSL:{1}, "
- + "resultWithoutTezSSL:{2}, asyncHttp:{3}]")
- public static Collection getParameters() {
- Collection parameters = new ArrayList();
- //enable ssl in cluster, succeed with tez-ssl enabled, fail with tez-ssl disabled
- parameters.add(new Object[] { true, 0, 1, false });
-
- //With asyncHttp
- parameters.add(new Object[] { true, 0, 1, true });
- parameters.add(new Object[] { false, 1, 0, true });
-
- //Negative testcase
- //disable ssl in cluster, fail with tez-ssl enabled, succeed with tez-ssl disabled
- parameters.add(new Object[] { false, 1, 0, false });
-
- return parameters;
- }
-
- @BeforeClass
+ @BeforeAll
public static void setupDFSCluster() throws Exception {
conf = new Configuration();
conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_EDITS_NOEDITLOGCHANNELFLUSH, false);
@@ -125,7 +104,7 @@ public static void setupDFSCluster() throws Exception {
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, false);
}
- @AfterClass
+ @AfterAll
public static void shutdownDFSCluster() {
if (miniDFSCluster != null) {
//shutdown
@@ -133,8 +112,7 @@ public static void shutdownDFSCluster() {
}
}
- @Before
- public void setupTezCluster() throws Exception {
+ public void setupTezCluster(boolean enableSSLInCluster, boolean asyncHttp) throws Exception {
if (enableSSLInCluster) {
// Enable SSL debugging
System.setProperty("javax.net.debug", "all");
@@ -163,10 +141,11 @@ public void setupTezCluster() throws Exception {
createSampleFile(inputLoc);
}
- @After
+ @AfterEach
public void shutdownTezCluster() throws IOException {
if (miniTezCluster != null) {
miniTezCluster.stop();
+ miniTezCluster = null;
}
}
@@ -180,22 +159,23 @@ private void baseTest(int expectedResult) throws Exception {
assertEquals(expectedResult, wordCount.run(args));
}
- /**
- * Verify whether shuffle works in mini cluster
- *
- * @throws Exception
- */
- @Test(timeout = 500000)
- public void testSecureShuffle() throws Exception {
+ @ParameterizedTest(name = "test[sslInCluster:{0}, resultWithTezSSL:{1}, "
+ + "resultWithoutTezSSL:{2}, asyncHttp:{3}]")
+ @MethodSource("getParameters")
+ @Timeout(value = 500000, unit = TimeUnit.MILLISECONDS)
+ public void testSecureShuffle(
+ boolean sslInCluster, int resultWithTezSSL, int resultWithoutTezSSL, boolean asyncHttp)
+ throws Exception {
+ setupTezCluster(sslInCluster, asyncHttp);
//With tez-ssl setting
miniTezCluster.getConfig().setBoolean(
TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_ENABLE_SSL, true);
- baseTest(this.resultWithTezSSL);
+ baseTest(resultWithTezSSL);
//Without tez-ssl setting
miniTezCluster.getConfig().setBoolean(
TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_ENABLE_SSL, false);
- baseTest(this.resultWithoutTezSSL);
+ baseTest(resultWithoutTezSSL);
}
/**
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestTaskErrorsUsingLocalMode.java b/tez-tests/src/test/java/org/apache/tez/test/TestTaskErrorsUsingLocalMode.java
index fcca4c1524..dfe18c5161 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestTaskErrorsUsingLocalMode.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestTaskErrorsUsingLocalMode.java
@@ -18,12 +18,13 @@
*/
package org.apache.tez.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.tez.client.TezClient;
import org.apache.tez.dag.api.DAG;
@@ -41,7 +42,7 @@
import org.apache.tez.runtime.api.TaskFailureType;
import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,7 +55,8 @@ public class TestTaskErrorsUsingLocalMode {
TestTaskErrorsUsingLocalMode.class.getName()).getAbsoluteFile();
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testFatalErrorReported() throws IOException, TezException, InterruptedException {
TezClient tezClient = getTezClient("testFatalErrorReported");
@@ -78,7 +80,8 @@ public void testFatalErrorReported() throws IOException, TezException, Interrupt
}
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testNonFatalErrorReported() throws IOException, TezException, InterruptedException {
TezClient tezClient = getTezClient("testNonFatalErrorReported");
@@ -102,7 +105,8 @@ public void testNonFatalErrorReported() throws IOException, TezException, Interr
}
}
- @Test(timeout = 20000)
+ @Test
+ @Timeout(value = 20000, unit = TimeUnit.MILLISECONDS)
public void testSelfKillReported() throws IOException, TezException, InterruptedException {
TezClient tezClient = getTezClient("testSelfKillReported");
diff --git a/tez-tests/src/test/java/org/apache/tez/test/TestTezJobs.java b/tez-tests/src/test/java/org/apache/tez/test/TestTezJobs.java
index 19e9ff0613..4e9abbc5c3 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/TestTezJobs.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/TestTezJobs.java
@@ -22,10 +22,7 @@
import static org.apache.tez.dag.api.TezConfiguration.TEZ_TASK_ATTEMPT_HOOKS;
import static org.apache.tez.dag.api.TezConfiguration.TEZ_THREAD_DUMP_INTERVAL;
import static org.apache.tez.dag.api.TezConstants.TEZ_CONTAINER_LOGGER_NAME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -41,6 +38,7 @@
import java.util.List;
import java.util.Random;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@@ -109,10 +107,7 @@
import com.google.common.collect.Lists;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -135,7 +130,7 @@ public class TestTezJobs {
private static String TEST_ROOT_DIR = "target" + Path.SEPARATOR + TestTezJobs.class.getName()
+ "-tmpDir";
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException {
localFs = FileSystem.getLocal(conf);
try {
@@ -157,7 +152,7 @@ public static void setup() throws IOException {
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
if (mrrTezCluster != null) {
mrrTezCluster.stop();
@@ -170,14 +165,16 @@ public static void tearDown() {
// TODO Add cleanup code.
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testHashJoinExample() throws Exception {
HashJoinExample hashJoinExample = new HashJoinExample();
hashJoinExample.setConf(new Configuration(mrrTezCluster.getConfig()));
runHashJoinExample(hashJoinExample);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testHashJoinExampleWithLogPattern() throws Exception {
HashJoinExample hashJoinExample = new HashJoinExample();
@@ -280,7 +277,8 @@ public boolean accept(Path p) {
* {@link JoinDataGen} -> {@link HashJoinExample} -> {@link JoinValidate}
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testHashJoinExampleWithDataViaEvent() throws Exception {
Path testDir = new Path("/tmp/testHashJoinExampleDataViaEvent");
@@ -329,7 +327,8 @@ public void testHashJoinExampleWithDataViaEvent() throws Exception {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testHashJoinExampleDisableSplitGrouping() throws Exception {
HashJoinExample hashJoinExample = new HashJoinExample();
hashJoinExample.setConf(new Configuration(mrrTezCluster.getConfig()));
@@ -387,7 +386,8 @@ public boolean accept(Path p) {
assertEquals(0, expectedResult.size());
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testSortMergeJoinExample() throws Exception {
SortMergeJoinExample sortMergeJoinExample = new SortMergeJoinExample();
sortMergeJoinExample.setConf(new Configuration(mrrTezCluster.getConfig()));
@@ -444,7 +444,8 @@ public boolean accept(Path p) {
assertEquals(0, expectedResult.size());
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testPerIOCounterAggregation() throws Exception {
String baseDir = "/tmp/perIOCounterAgg/";
Path inPath1 = new Path(baseDir + "inPath1");
@@ -483,9 +484,9 @@ public void testPerIOCounterAggregation() throws Exception {
TaskCounter.class.getSimpleName() + "_" + joinerVertexName + "_INPUT_" + input1Name);
final CounterGroup input2Group = joinerCounters.getGroup(
TaskCounter.class.getSimpleName() + "_" + joinerVertexName + "_INPUT_" + input2Name);
- assertTrue("aggregated counter group cannot be empty", aggregatedGroup.size() > 0);
- assertTrue("per io group for input1 cannot be empty", input1Group.size() > 0);
- assertTrue("per io group for input1 cannot be empty", input2Group.size() > 0);
+ assertTrue(aggregatedGroup.size() > 0, "aggregated counter group cannot be empty");
+ assertTrue(input1Group.size() > 0, "per io group for input1 cannot be empty");
+ assertTrue(input2Group.size() > 0, "per io group for input1 cannot be empty");
List countersToVerifyAgg = Arrays.asList(
TaskCounter.ADDITIONAL_SPILLS_BYTES_READ,
@@ -513,12 +514,11 @@ public void testPerIOCounterAggregation() throws Exception {
TezCounter aggregatedCounter = aggregatedGroup.findCounter(c.name(), false);
TezCounter input1Counter = input1Group.findCounter(c.name(), false);
TezCounter input2Counter = input2Group.findCounter(c.name(), false);
- assertNotNull("aggregated counter cannot be null " + c.name(), aggregatedCounter);
- assertNotNull("input1 counter cannot be null " + c.name(), input1Counter);
- assertNotNull("input2 counter cannot be null " + c.name(), input2Counter);
+ assertNotNull(aggregatedCounter, "aggregated counter cannot be null " + c.name());
+ assertNotNull(input1Counter, "input1 counter cannot be null " + c.name());
+ assertNotNull(input2Counter, "input2 counter cannot be null " + c.name());
- assertEquals("aggregated counter does not match sum of input counters " + c.name(),
- aggregatedCounter.getValue(), input1Counter.getValue() + input2Counter.getValue());
+ assertEquals(aggregatedCounter.getValue(), input1Counter.getValue() + input2Counter.getValue(), "aggregated counter does not match sum of input counters " + c.name());
if (aggregatedCounter.getValue() > 0) {
nonZeroCounters++;
@@ -526,22 +526,22 @@ public void testPerIOCounterAggregation() throws Exception {
}
// ensure that at least one of the counters tested above were non-zero.
- assertTrue("At least one of the counter should be non-zero. invalid test ", nonZeroCounters > 0);
+ assertTrue(nonZeroCounters > 0, "At least one of the counter should be non-zero. invalid test ");
CounterGroup joinerOutputGroup = joinerCounters.getGroup(
TaskCounter.class.getSimpleName() + "_" + joinerVertexName + "_OUTPUT_" + joinOutputName);
String outputCounterName = TaskCounter.OUTPUT_RECORDS.name();
TezCounter aggregateCounter = aggregatedGroup.findCounter(outputCounterName, false);
TezCounter joinerOutputCounter = joinerOutputGroup.findCounter(outputCounterName, false);
- assertNotNull("aggregated counter cannot be null " + outputCounterName, aggregateCounter);
- assertNotNull("output counter cannot be null " + outputCounterName, joinerOutputCounter);
- assertTrue("counter value is zero. test is invalid", aggregateCounter.getValue() > 0);
- assertEquals("aggregated counter does not match sum of output counters " + outputCounterName,
- aggregateCounter.getValue(), joinerOutputCounter.getValue());
+ assertNotNull(aggregateCounter, "aggregated counter cannot be null " + outputCounterName);
+ assertNotNull(joinerOutputCounter, "output counter cannot be null " + outputCounterName);
+ assertTrue(aggregateCounter.getValue() > 0, "counter value is zero. test is invalid");
+ assertEquals(aggregateCounter.getValue(), joinerOutputCounter.getValue(), "aggregated counter does not match sum of output counters " + outputCounterName);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testSortMergeJoinExampleDisableSplitGrouping() throws Exception {
testSortMergeJoinExampleDisableSplitGrouping(false);
}
@@ -653,7 +653,8 @@ private static void validateThreadDumpCaptured(Path jstackPath) throws IOExcepti
* {@link JoinDataGen} -> {@link HashJoinExample} -> {@link JoinValidate}
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testHashJoinExamplePipeline() throws Exception {
Path testDir = new Path("/tmp/testHashJoinExample");
@@ -702,7 +703,8 @@ public void testHashJoinExamplePipeline() throws Exception {
* {@link JoinDataGen} -> {@link SortMergeJoinExample} -> {@link JoinValidate}
* @throws Exception
*/
- @Test(timeout = 120000)
+ @Test
+ @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public void testSortMergeJoinExamplePipeline() throws Exception {
Path testDir = new Path("/tmp/testSortMergeExample");
@@ -794,13 +796,13 @@ public static void verifyOrderedWordCountOutput(Path resultFile, FileSystem fs)
LOG.info("Line: " + line + ", counter=" + currentCounter);
int pos = line.indexOf("\t");
String word = line.substring(0, pos-1);
- Assert.assertEquals(prefix + "_" + currentCounter, word);
+ assertEquals(prefix + "_" + currentCounter, word);
String val = line.substring(pos+1, line.length());
- Assert.assertEquals((long)(11 - currentCounter) * 2, (long)Long.valueOf(val));
+ assertEquals((long)(11 - currentCounter) * 2, (long)Long.valueOf(val));
currentCounter--;
}
- Assert.assertEquals(0, currentCounter);
+ assertEquals(0, currentCounter);
}
public static void verifyOutput(Path outputDir, FileSystem fs) throws IOException {
@@ -827,12 +829,13 @@ public static void verifyOutput(Path outputDir, FileSystem fs) throws IOExceptio
}
}
assertTrue(foundResult);
- assertTrue(resultFile != null);
+ assertNotNull(resultFile);
assertTrue(foundSuccessFile);
verifyOrderedWordCountOutput(resultFile, fs);
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testOrderedWordCount() throws Exception {
String inputDirStr = "/tmp/owc-input/";
Path inputDir = new Path(inputDirStr);
@@ -851,7 +854,9 @@ public void testOrderedWordCount() throws Exception {
try {
OrderedWordCount job = new OrderedWordCount();
- Assert.assertTrue("OrderedWordCount failed", job.run(tezConf, new String[]{"-counter", inputDirStr, outputDirStr, "2"}, null)==0);
+ assertEquals(0,
+ job.run(tezConf, new String[]{"-counter", inputDirStr, outputDirStr, "2"}, null),
+ "OrderedWordCount failed");
verifyOutput(outputDir, remoteFs);
} finally {
@@ -863,7 +868,8 @@ public void testOrderedWordCount() throws Exception {
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testOrderedWordCountDisableSplitGrouping() throws Exception {
String inputDirStr = TEST_ROOT_DIR + "/tmp/owc-input/";
Path inputDir = new Path(inputDirStr);
@@ -883,8 +889,8 @@ public void testOrderedWordCountDisableSplitGrouping() throws Exception {
try {
OrderedWordCount job = new OrderedWordCount();
- Assert.assertTrue("OrderedWordCount failed", job.run(tezConf, new String[]{"-counter", "-local", "-disableSplitGrouping",
- inputDirStr, outputDirStr, "2"}, null)==0);
+ assertEquals(0, job.run(tezConf, new String[]{"-counter", "-local", "-disableSplitGrouping",
+ inputDirStr, outputDirStr, "2"}, null), "OrderedWordCount failed");
verifyOutput(outputDir, localFs);
} finally {
@@ -896,7 +902,8 @@ public void testOrderedWordCountDisableSplitGrouping() throws Exception {
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testSimpleSessionExample() throws Exception {
Path stagingDirPath = new Path("/tmp/owc-staging-dir");
remoteFs.mkdirs(stagingDirPath);
@@ -932,10 +939,8 @@ public void testSimpleSessionExample() throws Exception {
SimpleSessionExample job = new SimpleSessionExample();
tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
- Assert.assertTrue(
- "SimpleSessionExample failed",
- job.run(tezConf, new String[] { StringUtils.join(",", inputPaths),
- StringUtils.join(",", outputPaths), "2" }, null) == 0);
+ assertEquals(0, job.run(tezConf, new String[]{StringUtils.join(",", inputPaths),
+ StringUtils.join(",", outputPaths), "2"}, null), "SimpleSessionExample failed");
for (int i=0; i resultVertices = dagStatus.getVertexProgress().keySet();
- Assert.assertEquals(6, resultVertices.size());
+ assertEquals(6, resultVertices.size());
int i = 0;
for (String vertexName : resultVertices){
if (i <= 1){
- Assert.assertTrue( vertexName.equals("v1") || vertexName.equals("v2"));
+ assertTrue( vertexName.equals("v1") || vertexName.equals("v2"));
} else if (i == 2){
- Assert.assertTrue( vertexName.equals("v3"));
+ assertEquals("v3", vertexName);
} else if (i <= 4){
- Assert.assertTrue( vertexName.equals("v4") || vertexName.equals("v5"));
+ assertTrue( vertexName.equals("v4") || vertexName.equals("v5"));
} else {
- Assert.assertTrue( vertexName.equals("v6"));
+ assertEquals("v6", vertexName);
}
i++;
}
@@ -1072,7 +1080,8 @@ public void testVertexOrder() throws Exception {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testInputInitializerEvents() throws TezException, InterruptedException, IOException {
TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
@@ -1096,13 +1105,14 @@ public void testInputInitializerEvents() throws TezException, InterruptedExcepti
DAGClient dagClient = tezClient.submitDAG(dag);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
} finally {
tezClient.stop();
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMultipleCommits_OnDAGSuccess() throws Exception {
Path stagingDirPath = new Path("/tmp/commit-staging-dir");
Random rand = new Random();
@@ -1120,9 +1130,10 @@ public void testMultipleCommits_OnDAGSuccess() throws Exception {
try {
MultipleCommitsExample job = new MultipleCommitsExample();
- Assert.assertTrue("MultipleCommitsExample failed", job.run(tezConf,
- new String[]{ v1OutputPathPrefix, v1OutputNum + "", v2OutputPathPrefix, v2OutputNum + "",
- uv12OutputPathPrefix, uv12OutputNum + "", v3OutputPathPrefix, v3OutputNum + ""}, null)==0);
+ assertEquals(0, job.run(tezConf,
+ new String[]{v1OutputPathPrefix, v1OutputNum + "", v2OutputPathPrefix, v2OutputNum + "",
+ uv12OutputPathPrefix, uv12OutputNum + "", v3OutputPathPrefix, v3OutputNum + ""},
+ null), "MultipleCommitsExample failed");
verifyCommits(v1OutputPathPrefix, v1OutputNum);
verifyCommits(v2OutputPathPrefix, v2OutputNum);
verifyCommits(uv12OutputPathPrefix, uv12OutputNum);
@@ -1135,7 +1146,8 @@ public void testMultipleCommits_OnDAGSuccess() throws Exception {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testMultipleCommits_OnVertexSuccess() throws Exception {
Path stagingDirPath = new Path("/tmp/commit-staging-dir");
Random rand = new Random();
@@ -1153,10 +1165,11 @@ public void testMultipleCommits_OnVertexSuccess() throws Exception {
try {
MultipleCommitsExample job = new MultipleCommitsExample();
- Assert.assertTrue("MultipleCommitsExample failed", job.run(tezConf,
- new String[]{ v1OutputPathPrefix, v1OutputNum + "", v2OutputPathPrefix, v2OutputNum + "",
- uv12OutputPathPrefix, uv12OutputNum + "", v3OutputPathPrefix, v3OutputNum + "",
- MultipleCommitsExample.CommitOnVertexSuccessOption}, null)==0);
+ assertEquals(0, job.run(tezConf,
+ new String[]{v1OutputPathPrefix, v1OutputNum + "", v2OutputPathPrefix, v2OutputNum + "",
+ uv12OutputPathPrefix, uv12OutputNum + "", v3OutputPathPrefix, v3OutputNum + "",
+ MultipleCommitsExample.CommitOnVertexSuccessOption}, null),
+ "MultipleCommitsExample failed");
verifyCommits(v1OutputPathPrefix, v1OutputNum);
verifyCommits(v2OutputPathPrefix, v2OutputNum);
verifyCommits(uv12OutputPathPrefix, uv12OutputNum);
@@ -1172,8 +1185,7 @@ public void testMultipleCommits_OnVertexSuccess() throws Exception {
private void verifyCommits(String outputPrefix, int outputNum) throws IllegalArgumentException, IOException {
for (int i=0; i< outputNum; ++i) {
String outputDir = outputPrefix + "_" + i;
- Assert.assertTrue("Output of " + outputDir + " is not succeeded",
- remoteFs.exists(new Path( outputDir + "/_SUCCESS")));
+ assertTrue(remoteFs.exists(new Path( outputDir + "/_SUCCESS")), "Output of " + outputDir + " is not succeeded");
}
}
@@ -1355,7 +1367,8 @@ public boolean accept(Path p) {
assertEquals(0, expectedResult.size());
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testAMClientHeartbeatTimeout() throws Exception {
Path stagingDirPath = new Path("/tmp/timeout-staging-dir");
remoteFs.mkdirs(stagingDirPath);
@@ -1383,7 +1396,7 @@ public void testAMClientHeartbeatTimeout() throws Exception {
int appsAfterCount = apps != null ? apps.size() : 0;
// Running in session mode. So should only create 1 more app.
- Assert.assertEquals(appsBeforeCount + 1, appsAfterCount);
+ assertEquals(appsBeforeCount + 1, appsAfterCount);
ApplicationReport report;
while (true) {
@@ -1400,8 +1413,7 @@ public void testAMClientHeartbeatTimeout() throws Exception {
report = yarnClient.getApplicationReport(appId);
LOG.info("App Report for appId=" + appId
+ ", report=" + report);
- Assert.assertTrue("Actual diagnostics: " + report.getDiagnostics(),
- report.getDiagnostics().contains("Client-to-AM Heartbeat timeout interval expired"));
+ assertTrue(report.getDiagnostics().contains("Client-to-AM Heartbeat timeout interval expired"), "Actual diagnostics: " + report.getDiagnostics());
} finally {
remoteFs.delete(stagingDirPath, true);
@@ -1411,7 +1423,8 @@ public void testAMClientHeartbeatTimeout() throws Exception {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testSessionTimeout() throws Exception {
Path stagingDirPath = new Path("/tmp/sessiontimeout-staging-dir");
remoteFs.mkdirs(stagingDirPath);
@@ -1438,7 +1451,7 @@ public void testSessionTimeout() throws Exception {
int appsAfterCount = apps != null ? apps.size() : 0;
// Running in session mode. So should only create 1 more app.
- Assert.assertEquals(appsBeforeCount + 1, appsAfterCount);
+ assertEquals(appsBeforeCount + 1, appsAfterCount);
ApplicationReport report;
while (true) {
@@ -1453,10 +1466,10 @@ public void testSessionTimeout() throws Exception {
// Add a sleep because YARN is not consistent in terms of reporting uptodate diagnostics
Thread.sleep(2000);
report = yarnClient.getApplicationReport(appId);
- LOG.info("App Report for appId=" + appId
- + ", report=" + report);
- Assert.assertTrue("Actual diagnostics: " + report.getDiagnostics(),
- report.getDiagnostics().contains("Session timed out"));
+ LOG.info("App Report for appId=" + appId + ", report=" + report);
+ assertTrue(
+ report.getDiagnostics().contains("Session timed out"),
+ "Actual diagnostics: " + report.getDiagnostics());
} finally {
remoteFs.delete(stagingDirPath, true);
@@ -1466,7 +1479,8 @@ public void testSessionTimeout() throws Exception {
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testVertexFailuresMaxPercent() throws TezException, InterruptedException, IOException {
TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
@@ -1492,13 +1506,14 @@ public void testVertexFailuresMaxPercent() throws TezException, InterruptedExcep
DAGClient dagClient = tezClient.submitDAG(dag);
dagClient.waitForCompletion();
- Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
+ assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
} finally {
tezClient.stop();
}
}
- @Test(timeout = 60000)
+ @Test
+ @Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
public void testCartesianProduct() throws Exception {
LOG.info("Running CartesianProduct Test");
CartesianProduct job = new CartesianProduct();
@@ -1506,6 +1521,6 @@ public void testCartesianProduct() throws Exception {
TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
tezConf.setInt(CartesianProductVertexManager.TEZ_CARTESIAN_PRODUCT_MAX_PARALLELISM, 10);
tezConf.setInt(CartesianProductVertexManager.TEZ_CARTESIAN_PRODUCT_MIN_OPS_PER_WORKER, 25);
- Assert.assertEquals("CartesianProduct failed", job.run(tezConf, null, null), 0);
+ assertEquals(job.run(tezConf, null, null), 0, "CartesianProduct failed");
}
}
diff --git a/tez-tests/src/test/java/org/apache/tez/test/dag/MultiAttemptDAG.java b/tez-tests/src/test/java/org/apache/tez/test/dag/MultiAttemptDAG.java
index f87655faca..c87a6aa45e 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/dag/MultiAttemptDAG.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/dag/MultiAttemptDAG.java
@@ -63,6 +63,7 @@
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleReverseVTestDAG.java b/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleReverseVTestDAG.java
index 5453e16bab..a972e75fdd 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleReverseVTestDAG.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleReverseVTestDAG.java
@@ -33,6 +33,8 @@
import org.apache.tez.test.TestOutput;
import org.apache.tez.test.TestProcessor;
+import org.junit.jupiter.api.*;
+
/**
* A DAG with 3 vertices of which their graph can be depicted easily with reverse V shape.
* v1
diff --git a/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleVTestDAG.java b/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleVTestDAG.java
index 5d4d876305..534b665e14 100644
--- a/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleVTestDAG.java
+++ b/tez-tests/src/test/java/org/apache/tez/test/dag/SimpleVTestDAG.java
@@ -33,6 +33,8 @@
import org.apache.tez.test.TestOutput;
import org.apache.tez.test.TestProcessor;
+import org.junit.jupiter.api.*;
+
/**
* A DAG with 3 vertices of which their graph can be depicted easily with V shape.
* v1 v2
diff --git a/tez-tests/src/test/java/org/junit/Assert.java b/tez-tests/src/test/java/org/junit/Assert.java
new file mode 100644
index 0000000000..f7d038a2a1
--- /dev/null
+++ b/tez-tests/src/test/java/org/junit/Assert.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.junit;
+
+import org.junit.jupiter.api.Assertions;
+
+/**
+ * A JUnit 4 polyfill for Hadoop test utilities (e.g. MiniYARNCluster)
+ * that are hardcoded to invoke org.junit.Assert.
+ * This class simply delegates the legacy calls to JUnit 5 (Jupiter).
+ */
+public class Assert {
+
+ public static void assertTrue(String message, boolean condition) {
+ Assertions.assertTrue(condition, message);
+ }
+
+ public static void assertTrue(boolean condition) {
+ Assertions.assertTrue(condition);
+ }
+
+ public static void assertFalse(String message, boolean condition) {
+ Assertions.assertFalse(condition, message);
+ }
+
+ public static void assertFalse(boolean condition) {
+ Assertions.assertFalse(condition);
+ }
+
+ public static void fail(String message) {
+ Assertions.fail(message);
+ }
+
+ public static void assertEquals(Object expected, Object actual) {
+ Assertions.assertEquals(expected, actual);
+ }
+
+ public static void assertEquals(String message, Object expected, Object actual) {
+ Assertions.assertEquals(expected, actual, message);
+ }
+
+ public static void assertNull(Object object) {
+ Assertions.assertNull(object);
+ }
+
+ public static void assertNull(String message, Object object) {
+ Assertions.assertNull(object, message);
+ }
+
+ public static void assertNotNull(Object object) {
+ Assertions.assertNotNull(object);
+ }
+
+ public static void assertNotNull(String message, Object object) {
+ Assertions.assertNotNull(object, message);
+ }
+}
diff --git a/tez-tools/analyzers/job-analyzer/pom.xml b/tez-tools/analyzers/job-analyzer/pom.xml
index 34f10b3757..3ac249f86e 100644
--- a/tez-tools/analyzers/job-analyzer/pom.xml
+++ b/tez-tools/analyzers/job-analyzer/pom.xml
@@ -151,11 +151,6 @@
mockito-core
test
-
- junit
- junit
- test
-
com.sun.jersey
jersey-json
diff --git a/tez-tools/analyzers/job-analyzer/src/test/java/org/apache/tez/analyzer/TestAnalyzer.java b/tez-tools/analyzers/job-analyzer/src/test/java/org/apache/tez/analyzer/TestAnalyzer.java
index 800e0b3837..a4fb9e0ad9 100644
--- a/tez-tools/analyzers/job-analyzer/src/test/java/org/apache/tez/analyzer/TestAnalyzer.java
+++ b/tez-tools/analyzers/job-analyzer/src/test/java/org/apache/tez/analyzer/TestAnalyzer.java
@@ -18,13 +18,14 @@
*/
package org.apache.tez.analyzer;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -64,10 +65,7 @@
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -92,7 +90,7 @@ public class TestAnalyzer {
private boolean downloadedSimpleHistoryFile = false;
private static String yarnTimelineAddress;
- @BeforeClass
+ @BeforeAll
public static void setupClass() throws Exception {
conf = new Configuration();
conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_EDITS_NOEDITLOGCHANNELFLUSH, false);
@@ -106,7 +104,7 @@ public static void setupClass() throws Exception {
setupTezCluster();
}
- @AfterClass
+ @AfterAll
public static void tearDownClass() throws Exception {
LOG.info("Stopping mini clusters");
if (miniTezCluster != null) {
@@ -245,7 +243,7 @@ private void runDAG(DAG dag, DAGStatus.State finalState) throws Exception {
dagStatus = dagClient.getDAGStatus(null);
}
- Assert.assertEquals(finalState, dagStatus.getState());
+ assertEquals(finalState, dagStatus.getState());
}
private void verify(ApplicationId appId, int dagNum, List steps) throws Exception {
@@ -263,7 +261,7 @@ private DagInfo getDagInfo(String dagId) throws Exception {
String[] args = { "--dagId=" + dagId, "--downloadDir=" + DOWNLOAD_DIR, "--yarnTimelineAddress=" + yarnTimelineAddress };
int result = ATSImportTool.process(args);
- assertTrue(result == 0);
+ assertEquals(0, result);
//Parse ATS data and verify results
//Parse downloaded contents
@@ -271,7 +269,7 @@ private DagInfo getDagInfo(String dagId) throws Exception {
+ Path.SEPARATOR + dagId + ".zip");
ATSFileParser parser = new ATSFileParser(Arrays.asList(downloadedFile));
dagInfo = parser.getDAGData(dagId);
- assertTrue(dagInfo.getDagId().equals(dagId));
+ assertEquals(dagInfo.getDagId(), dagId);
} else {
if (!downloadedSimpleHistoryFile) {
downloadedSimpleHistoryFile = true;
@@ -290,7 +288,7 @@ private DagInfo getDagInfo(String dagId) throws Exception {
File localFile = new File(DOWNLOAD_DIR, HISTORY_TXT);
SimpleHistoryParser parser = new SimpleHistoryParser(Arrays.asList(localFile));
dagInfo = parser.getDAGData(dagId);
- assertTrue(dagInfo.getDagId().equals(dagId));
+ assertEquals(dagInfo.getDagId(), dagId);
}
return dagInfo;
}
@@ -316,47 +314,48 @@ private void verifyCriticalPath(DagInfo dagInfo, List stepsOptions)
for (StepCheck[] steps : stepsOptions) {
if (steps.length + 2 == criticalPath.size()) {
foundMatchingLength = true;
- Assert.assertEquals(CriticalPathStep.EntityType.VERTEX_INIT, criticalPath.get(0).getType());
- Assert.assertEquals(criticalPath.get(1).getAttempt().getShortName(),
+ assertEquals(CriticalPathStep.EntityType.VERTEX_INIT, criticalPath.get(0).getType());
+ assertEquals(criticalPath.get(1).getAttempt().getShortName(),
criticalPath.get(0).getAttempt().getShortName());
for (int i=1; i new CSVResult(new String[] {"x"}).dumpToFile(null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testDumpToFileRejectsEmptyFileName() throws Exception {
- new CSVResult(new String[]{"x"}).dumpToFile("");
+ assertThrows(
+ IllegalArgumentException.class, () -> new CSVResult(new String[] {"x"}).dumpToFile(""));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testDumpToFileRejectsBlankFileName() throws Exception {
- new CSVResult(new String[]{"x"}).dumpToFile(" ");
+ assertThrows(
+ IllegalArgumentException.class, () -> new CSVResult(new String[] {"x"}).dumpToFile(" "));
}
@Test
@@ -118,7 +120,7 @@ public void testDumpToFileNestedDirectory() throws Exception {
result.addRecord(new String[]{"r"});
result.dumpToFile(out.toString());
- Assert.assertEquals("h\nr\n", Files.readString(out, StandardCharsets.UTF_8));
+ assertEquals("h\nr\n", Files.readString(out, StandardCharsets.UTF_8));
}
@Test
@@ -128,9 +130,9 @@ public void testDumpToFileNoWriteUpwardDirPath() throws Exception {
try {
result.dumpToFile(relativePath);
- Assert.fail("Expected IOException due to moving upwards from pwd");
+ fail("Expected IOException due to moving upwards from pwd");
} catch (IOException e) {
- Assert.assertTrue(e.getMessage().contains(Paths.get(relativePath).toAbsolutePath().normalize().toString()));
+ assertTrue(e.getMessage().contains(Paths.get(relativePath).toAbsolutePath().normalize().toString()));
}
}
}