This is an automated email from the ASF dual-hosted git repository.

jeagles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tez.git


The following commit(s) were added to refs/heads/master by this push:
     new 41f6f3b  TEZ-4161. Speed up TestTezUtils
41f6f3b is described below

commit 41f6f3b587b00815c9abe016e617ef194326e58d
Author: Jonathan Eagles <[email protected]>
AuthorDate: Thu Apr 30 04:44:23 2020 -0500

    TEZ-4161. Speed up TestTezUtils
---
 .../src/test/java/org/apache/tez/common/TestTezUtils.java    | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java 
b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
index c0c3e5d..f9008b9 100644
--- a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
+++ b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
@@ -57,16 +57,20 @@ public class TestTezUtils {
   @Test (timeout=20000)
   public void testByteStringToAndFromLargeConf() throws IOException {
     Configuration conf = getConf();
-    int largeSize = 64 * 1024 * 1024;
+    int largeSizeMinimum = 64 * 1024 * 1024;
     final String alphaString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    int largeSize = (largeSizeMinimum + alphaString.length() - 1) / 
alphaString.length();
+
+    largeSize *= alphaString.length();
+    assertTrue(largeSize >= alphaString.length());
     StringBuilder sb = new StringBuilder(largeSize);
 
-    for (int i = 0; i < largeSize; i++) {
-      int index = (int)(alphaString.length() * Math.random());
-      sb.append(alphaString.charAt(index));
+    while (sb.length() < largeSize) {
+      sb.append(alphaString);
     }
 
     String largeValue = sb.toString();
+    Assert.assertEquals(largeSize, largeValue.length());
     conf.set("testLargeValue", largeValue);
     Assert.assertEquals(conf.size(), 7);
     ByteString bsConf = TezUtils.createByteStringFromConf(conf);

Reply via email to