Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A4875C105 for ; Thu, 3 May 2012 00:37:40 +0000 (UTC) Received: (qmail 21684 invoked by uid 500); 3 May 2012 00:37:40 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 21649 invoked by uid 500); 3 May 2012 00:37:40 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 21641 invoked by uid 99); 3 May 2012 00:37:40 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2012 00:37:40 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1BB7F13929; Thu, 3 May 2012 00:37:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: xedin@apache.org To: commits@cassandra.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: stress tool to return appropriate exit code on failure patch by Tyler Patterson; reviewed by Pavel Yaskevich for CASSANDRA-4188 Message-Id: <20120503003740.1BB7F13929@tyr.zones.apache.org> Date: Thu, 3 May 2012 00:37:40 +0000 (UTC) Updated Branches: refs/heads/cassandra-1.0 48a22695f -> f20badb68 stress tool to return appropriate exit code on failure patch by Tyler Patterson; reviewed by Pavel Yaskevich for CASSANDRA-4188 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f20badb6 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f20badb6 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f20badb6 Branch: refs/heads/cassandra-1.0 Commit: f20badb685393e60f74b236edf623c7c9264f1eb Parents: 48a2269 Author: Pavel Yaskevich Authored: Thu May 3 03:29:34 2012 +0300 Committer: Pavel Yaskevich Committed: Thu May 3 03:34:58 2012 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../src/org/apache/cassandra/stress/Stress.java | 7 ++- .../org/apache/cassandra/stress/StressAction.java | 34 ++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/f20badb6/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index bd508c6..ad301db 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,7 @@ * Avoids possible deadlock during bootstrap (CASSANDRA-4159) * fix stress tool that hangs forever on timeout or error (CASSANDRA-4128) * Fix super columns bug where cache is not updated (CASSANDRA-4190) + * stress tool to return appropriate exit code on failure (CASSANDRA-4188) 1.0.9 http://git-wip-us.apache.org/repos/asf/cassandra/blob/f20badb6/tools/stress/src/org/apache/cassandra/stress/Stress.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/Stress.java b/tools/stress/src/org/apache/cassandra/stress/Stress.java index c5e65f8..b490d69 100644 --- a/tools/stress/src/org/apache/cassandra/stress/Stress.java +++ b/tools/stress/src/org/apache/cassandra/stress/Stress.java @@ -66,7 +66,7 @@ public final class Stress { while (!socket.isClosed() && (line = inp.readLine()) != null) { - if (line.equals("END")) + if (line.equals("END") || line.equals("FAILURE")) { out.writeInt(1); break; @@ -88,7 +88,10 @@ public final class Stress } else { - new StressAction(session, outStream).start(); + StressAction stressAction = new StressAction(session, outStream); + stressAction.start(); + stressAction.join(); + System.exit(stressAction.getReturnCode()); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/f20badb6/tools/stress/src/org/apache/cassandra/stress/StressAction.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/StressAction.java b/tools/stress/src/org/apache/cassandra/stress/StressAction.java index f0a9f49..d043b66 100644 --- a/tools/stress/src/org/apache/cassandra/stress/StressAction.java +++ b/tools/stress/src/org/apache/cassandra/stress/StressAction.java @@ -37,6 +37,11 @@ public class StressAction extends Thread private volatile boolean stop = false; + public static final int SUCCESS = 0; + public static final int FAILURE = 1; + + private volatile int returnCode = -1; + public StressAction(Session session, PrintStream out) { client = session; @@ -137,11 +142,28 @@ public class StressAction extends Thread } } + // if any consumer failed, set the return code to failure. + returnCode = SUCCESS; if (producer.isAlive()) + { producer.interrupt(); // if producer is still alive it means that we had errors in the consumers + returnCode = FAILURE; + } + for (Consumer consumer : consumers) + if (consumer.getReturnCode() == FAILURE) + returnCode = FAILURE; + + if (returnCode == SUCCESS) + // marking an end of the output to the client + output.println("END"); + else + output.println("FAILURE"); - // marking an end of the output to the client - output.println("END"); + } + + public int getReturnCode() + { + return returnCode; } /** @@ -184,6 +206,7 @@ public class StressAction extends Thread { private final int items; private volatile boolean stop = false; + private volatile int returnCode = StressAction.SUCCESS; public Consumer(int toConsume) { @@ -208,11 +231,13 @@ public class StressAction extends Thread if (output == null) { System.err.println(e.getMessage()); + returnCode = StressAction.FAILURE; System.exit(-1); } output.println(e.getMessage()); + returnCode = StressAction.FAILURE; break; } } @@ -222,6 +247,11 @@ public class StressAction extends Thread { stop = true; } + + public int getReturnCode() + { + return returnCode; + } } private Operation createOperation(int index)