You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2013/11/01 16:30:41 UTC
svn commit: r1537959 - in /hive/trunk/testutils/ptest2/src:
main/java/org/apache/hive/ptest/execution/JIRAService.java
test/java/org/apache/hive/ptest/execution/TestJIRAService.java
Author: brock
Date: Fri Nov 1 15:30:41 2013
New Revision: 1537959
URL: http://svn.apache.org/r1537959
Log:
HIVE-5708 - PTest2 should trim long logs when posting to jira
Modified:
hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java
hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java
Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java?rev=1537959&r1=1537958&r2=1537959&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java Fri Nov 1 15:30:41 2013
@@ -58,6 +58,8 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
class JIRAService {
+ static final int MAX_MESSAGES = 200;
+ static final String TRIMMED_MESSAGE = "**** This message was trimmed, see log for full details ****";
private final Logger mLogger;
private final String mName;
private final String mBuildTag;
@@ -120,7 +122,7 @@ class JIRAService {
if(!messages.isEmpty()) {
comments.add("Messages:");
comments.add("{noformat}");
- comments.addAll(messages);
+ comments.addAll(trimMessages(messages));
comments.add("{noformat}");
comments.add("");
}
@@ -156,7 +158,14 @@ class JIRAService {
httpClient.getConnectionManager().shutdown();
}
}
-
+ static List<String> trimMessages(List<String> messages) {
+ int size = messages.size();
+ if(size > MAX_MESSAGES) {
+ messages = messages.subList(size - MAX_MESSAGES, size);
+ messages.add(0, TRIMMED_MESSAGE);
+ }
+ return messages;
+ }
@SuppressWarnings("unused")
private static class Body {
private String body;
Modified: hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java?rev=1537959&r1=1537958&r2=1537959&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java (original)
+++ hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java Fri Nov 1 15:30:41 2013
@@ -18,9 +18,10 @@
*/
package org.apache.hive.ptest.execution;
+import java.util.List;
import junit.framework.Assert;
-
import org.junit.Test;
+import com.google.common.collect.Lists;
public class TestJIRAService {
@@ -41,4 +42,30 @@ public class TestJIRAService {
public void testFormatBuildTagNoDashNone() throws Throwable {
JIRAService.formatBuildTag("abc123");
}
+ @Test
+ public void testTrimMesssagesBoundry() {
+ List<String> messages = Lists.newArrayList();
+ Assert.assertEquals(messages, JIRAService.trimMessages(messages));
+ messages.clear();
+ for (int i = 0; i < JIRAService.MAX_MESSAGES; i++) {
+ messages.add(String.valueOf(i));
+ }
+ Assert.assertEquals(messages, JIRAService.trimMessages(messages));
+ }
+ @Test
+ public void testTrimMesssagesNotTrimmed() {
+ List<String> messages = Lists.newArrayList("a", "b", "c");
+ Assert.assertEquals(messages, JIRAService.trimMessages(messages));
+ }
+ @Test
+ public void testTrimMesssagesTrimmed() {
+ List<String> messages = Lists.newArrayList();
+ for (int i = 0; i < JIRAService.MAX_MESSAGES + 1; i++) {
+ messages.add(String.valueOf(i));
+ }
+ List<String> expected = Lists.newArrayList(messages);
+ expected.remove(0);
+ expected.add(0, JIRAService.TRIMMED_MESSAGE);
+ Assert.assertEquals(expected, JIRAService.trimMessages(messages));
+ }
}
\ No newline at end of file