You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by an...@apache.org on 2013/12/14 01:43:41 UTC

git commit: TWILL-25 prevent tests from stealing focus on MacOS

Updated Branches:
  refs/heads/master 4a1c943c2 -> 603ea385a


TWILL-25 prevent tests from stealing focus on MacOS


Project: http://git-wip-us.apache.org/repos/asf/incubator-twill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-twill/commit/603ea385
Tree: http://git-wip-us.apache.org/repos/asf/incubator-twill/tree/603ea385
Diff: http://git-wip-us.apache.org/repos/asf/incubator-twill/diff/603ea385

Branch: refs/heads/master
Commit: 603ea385aa4e3417db97f890c61dd0d6d9d5a636
Parents: 4a1c943
Author: anew <an...@continuuity.com>
Authored: Fri Dec 13 16:43:29 2013 -0800
Committer: anew <an...@continuuity.com>
Committed: Fri Dec 13 16:43:29 2013 -0800

----------------------------------------------------------------------
 pom.xml                                                      | 2 +-
 .../java/org/apache/twill/yarn/YarnTwillRunnerService.java   | 8 ++++++++
 .../test/java/org/apache/twill/yarn/LocalFileTestRun.java    | 7 +++++--
 .../src/test/java/org/apache/twill/yarn/YarnTestSuite.java   | 7 +++++--
 4 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/603ea385/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ea7bc90..dea488a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -260,7 +260,7 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>2.14.1</version>
                 <configuration>
-                    <argLine>-Xmx512m</argLine>
+                    <argLine>-Xmx512m -Djava.awt.headless=true</argLine>
                     <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}</redirectTestOutputToFile>
                     <systemPropertyVariables>
                         <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/603ea385/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillRunnerService.java
----------------------------------------------------------------------
diff --git a/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillRunnerService.java b/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillRunnerService.java
index 9335465..baa5740 100644
--- a/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillRunnerService.java
+++ b/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillRunnerService.java
@@ -161,6 +161,14 @@ public final class YarnTwillRunnerService extends AbstractIdleService implements
     this.jvmOptions = options;
   }
 
+  /**
+   * Returns any extra JVM options that have been set.
+   * @see #setJVMOptions(String)
+   */
+  public String getJVMOptions() {
+    return jvmOptions;
+  }
+
   @Override
   public Cancellable scheduleSecureStoreUpdate(final SecureStoreUpdater updater,
                                                long initialDelay, long delay, TimeUnit unit) {

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/603ea385/twill-yarn/src/test/java/org/apache/twill/yarn/LocalFileTestRun.java
----------------------------------------------------------------------
diff --git a/twill-yarn/src/test/java/org/apache/twill/yarn/LocalFileTestRun.java b/twill-yarn/src/test/java/org/apache/twill/yarn/LocalFileTestRun.java
index de2c74c..54020aa 100644
--- a/twill-yarn/src/test/java/org/apache/twill/yarn/LocalFileTestRun.java
+++ b/twill-yarn/src/test/java/org/apache/twill/yarn/LocalFileTestRun.java
@@ -62,8 +62,11 @@ public class LocalFileTestRun {
                                         Charsets.UTF_8);
 
     TwillRunner runner = YarnTestSuite.getTwillRunner();
+    String prevJVMOptions = "";
     if (runner instanceof YarnTwillRunnerService) {
-      ((YarnTwillRunnerService) runner).setJVMOptions("-verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails");
+      YarnTwillRunnerService yarnRunner = (YarnTwillRunnerService) runner;
+      prevJVMOptions = yarnRunner.getJVMOptions() != null ? yarnRunner.getJVMOptions() : "";
+      yarnRunner.setJVMOptions(prevJVMOptions + " -verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails");
     }
 
     TwillController controller = runner.prepare(new LocalFileApplication())
@@ -73,7 +76,7 @@ public class LocalFileTestRun {
       .start();
 
     if (runner instanceof YarnTwillRunnerService) {
-      ((YarnTwillRunnerService) runner).setJVMOptions("");
+      ((YarnTwillRunnerService) runner).setJVMOptions(prevJVMOptions);
     }
 
     Iterable<Discoverable> discoverables = controller.discoverService("local");

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/603ea385/twill-yarn/src/test/java/org/apache/twill/yarn/YarnTestSuite.java
----------------------------------------------------------------------
diff --git a/twill-yarn/src/test/java/org/apache/twill/yarn/YarnTestSuite.java b/twill-yarn/src/test/java/org/apache/twill/yarn/YarnTestSuite.java
index b55d620..6533cdd 100644
--- a/twill-yarn/src/test/java/org/apache/twill/yarn/YarnTestSuite.java
+++ b/twill-yarn/src/test/java/org/apache/twill/yarn/YarnTestSuite.java
@@ -109,8 +109,11 @@ public class YarnTestSuite {
    * Creates an unstarted instance of {@link org.apache.twill.api.TwillRunnerService}.
    */
   public static final TwillRunnerService createTwillRunnerService() throws IOException {
-    return new YarnTwillRunnerService(config, zkServer.getConnectionStr() + "/twill",
-                                      new LocalLocationFactory(tmpFolder.newFolder()));
+    YarnTwillRunnerService runner = new YarnTwillRunnerService(config, zkServer.getConnectionStr() + "/twill",
+                                                               new LocalLocationFactory(tmpFolder.newFolder()));
+    // disable tests stealing focus
+    runner.setJVMOptions("-Djava.awt.headless=true");
+    return runner;
   }
 
   public static final <T> boolean waitForSize(Iterable<T> iterable, int count, int limit) throws InterruptedException {