[jboss-svn-commits] JBL Code SVN: r37763 - in labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src: main and 9 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 1 06:55:26 EST 2011
Author: zhfeng
Date: 2011-12-01 06:55:26 -0500 (Thu, 01 Dec 2011)
New Revision: 37763
Added:
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/JBossAS7ServerKillProcessor.java
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/ServerExtension.java
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/resources/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/resources/META-INF/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/resources/META-INF/services/
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
Modified:
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/BaseCrashTest.java
labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/TestATCrashDuringOnePhaseCommit.java
Log:
JBTM-817 update to add custom ServerKillProcessor and use container.kill() to wait crashing by byteman scripts
Added: labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/JBossAS7ServerKillProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/JBossAS7ServerKillProcessor.java (rev 0)
+++ labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/JBossAS7ServerKillProcessor.java 2011-12-01 11:55:26 UTC (rev 37763)
@@ -0,0 +1,71 @@
+package com.arjuna.qa.extension;
+
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Logger;
+
+import org.jboss.arquillian.container.spi.Container;
+import org.jboss.arquillian.container.spi.ServerKillProcessor;
+
+public class JBossAS7ServerKillProcessor implements ServerKillProcessor {
+ private final Logger log = Logger.getLogger(
+ JBossAS7ServerKillProcessor.class.getName());
+ private static String killSequence = "[jbossHome]/bin/jboss-admin.[suffix] --connect quit";
+ private int checkDurableTime = 10;
+ private int numofCheck = 60;
+
+ @Override
+ public void kill(Container container) throws Exception {
+ log.info("waiting for byteman to kill server");
+ String jbossHome = System.getenv().get("JBOSS_HOME");
+ if(jbossHome == null) {
+ jbossHome = container.getContainerConfiguration().getContainerProperties().get("jbossHome");
+ }
+ killSequence = killSequence.replace("[jbossHome]", jbossHome);
+
+ String suffix;
+ String os = System.getProperty("os.name").toLowerCase();
+ if(os.indexOf("windows") > -1) {
+ suffix = "bat";
+ } else {
+ suffix = "sh";
+ }
+ killSequence = killSequence.replace("[suffix]", suffix);
+
+ int checkn = 0;
+ boolean killed = false;
+ do {
+ if(checkJBossAlive()) {
+ Thread.sleep(checkDurableTime * 1000);
+ log.info("jboss-as is alive");
+ } else {
+ killed = true;
+ break;
+ }
+ } while(checkn < numofCheck);
+
+ if(killed) {
+ log.info("jboss-as killed by byteman scirpt");
+ } else {
+ throw new RuntimeException("jboss-as not killed");
+ }
+ }
+
+ private boolean checkJBossAlive() throws Exception {
+ Process p = Runtime.getRuntime().exec(killSequence);
+
+ p.waitFor();
+
+ if (p.exitValue() != 0) {
+ throw new RuntimeException("Kill Sequence failed");
+ }
+
+ InputStream out = p.getInputStream();
+ BufferedReader in = new BufferedReader(new InputStreamReader(out));
+ String result= in.readLine();
+
+ return !(result != null && result.contains("The controller is not available"));
+ }
+}
\ No newline at end of file
Property changes on: labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/JBossAS7ServerKillProcessor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/ServerExtension.java
===================================================================
--- labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/ServerExtension.java (rev 0)
+++ labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/ServerExtension.java 2011-12-01 11:55:26 UTC (rev 37763)
@@ -0,0 +1,13 @@
+package com.arjuna.qa.extension;
+
+import org.jboss.arquillian.container.spi.ServerKillProcessor;
+import org.jboss.arquillian.core.spi.LoadableExtension;
+
+public class ServerExtension implements LoadableExtension {
+
+ @Override
+ public void register(ExtensionBuilder builder) {
+ builder.service(ServerKillProcessor.class, JBossAS7ServerKillProcessor.class);
+ }
+
+}
Property changes on: labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/java/com/arjuna/qa/extension/ServerExtension.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
===================================================================
--- labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension (rev 0)
+++ labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension 2011-12-01 11:55:26 UTC (rev 37763)
@@ -0,0 +1 @@
+com.arjuna.qa.extension.ServerExtension
\ No newline at end of file
Modified: labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/BaseCrashTest.java
===================================================================
--- labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/BaseCrashTest.java 2011-12-01 11:34:57 UTC (rev 37762)
+++ labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/BaseCrashTest.java 2011-12-01 11:55:26 UTC (rev 37763)
@@ -69,17 +69,18 @@
}
}
- protected void runTest(String testClass, long waitForCrash, long waitForRecovery) throws Exception {
+ protected void runTest(String testClass, long waitForRecovery) throws Exception {
Config config = new Config();
config.add("javaVmArguments", javaVmArguments + XTSServiceTest.replace("@TestName@", testClass));
controller.start("jboss-as", config.map());
+ deployer.undeploy("xtstest");
deployer.deploy("xtstest");
//Waiting for crashing
- Thread.sleep(waitForCrash * 60 * 1000);
+ controller.kill("jboss-as");
- //Boot jboss as after crashing
+ //Boot jboss-as after crashing
config.add("javaVmArguments", javaVmArguments);
controller.start("jboss-as", config.map());
Modified: labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/TestATCrashDuringOnePhaseCommit.java
===================================================================
--- labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/TestATCrashDuringOnePhaseCommit.java 2011-12-01 11:34:57 UTC (rev 37762)
+++ labs/jbosstm/trunk/XTS/localjunit/crash-recovery-tests/src/test/java/com/arjuna/qa/junit/TestATCrashDuringOnePhaseCommit.java 2011-12-01 11:55:26 UTC (rev 37763)
@@ -14,6 +14,6 @@
public void SingleParticipantPrepareAndCommit() throws Exception {
testName = "SingleParticipantPrepareAndCommit";
String testClass = "org.jboss.jbossts.xts.servicetests.test.at.SingleParticipantPrepareAndCommitTest";
- runTest(testClass, 3, 5);
+ runTest(testClass, 4);
}
}
More information about the jboss-svn-commits
mailing list