You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by co...@apache.org on 2014/02/04 00:28:10 UTC

[1/2] git commit: BIGTOP-1097. introduce bigtop-groovy package

Updated Branches:
  refs/heads/master 525da0a32 -> 40b398553


BIGTOP-1097. introduce bigtop-groovy package


Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/553a6ca1
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/553a6ca1
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/553a6ca1

Branch: refs/heads/master
Commit: 553a6ca128dbb62862a0d456f765250dac7b8371
Parents: 525da0a
Author: Konstantin Boudnik <co...@apache.org>
Authored: Thu Jan 23 00:09:57 2014 -0800
Committer: Konstantin Boudnik <co...@apache.org>
Committed: Fri Jan 31 15:15:45 2014 -0800

----------------------------------------------------------------------
 .../src/common/bigtop-groovy/do-component-build |  19 ++++
 .../src/common/bigtop-groovy/install_groovy.sh  | 108 +++++++++++++++++++
 .../src/deb/bigtop-groovy/bigtop-groovy.install |   4 +
 .../deb/bigtop-groovy/bigtop-groovy.postinst    |  36 +++++++
 bigtop-packages/src/deb/bigtop-groovy/changelog |   1 +
 bigtop-packages/src/deb/bigtop-groovy/compat    |   1 +
 bigtop-packages/src/deb/bigtop-groovy/control   |  27 +++++
 bigtop-packages/src/deb/bigtop-groovy/copyright |  15 +++
 bigtop-packages/src/deb/bigtop-groovy/rules     |  39 +++++++
 .../src/deb/bigtop-groovy/source/format         |   1 +
 .../src/rpm/bigtop-groovy/SPECS/.gitignore      |   0
 .../rpm/bigtop-groovy/SPECS/bigtop-groovy.spec  |  60 +++++++++++
 .../package/src/main/resources/package_data.xml |  12 +++
 bigtop.mk                                       |  13 +++
 14 files changed, 336 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/common/bigtop-groovy/do-component-build
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/bigtop-groovy/do-component-build b/bigtop-packages/src/common/bigtop-groovy/do-component-build
new file mode 100644
index 0000000..def8791
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-groovy/do-component-build
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -ex
+
+. `dirname ${0}`/bigtop.bom

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/common/bigtop-groovy/install_groovy.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/bigtop-groovy/install_groovy.sh b/bigtop-packages/src/common/bigtop-groovy/install_groovy.sh
new file mode 100755
index 0000000..c5a819a
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-groovy/install_groovy.sh
@@ -0,0 +1,108 @@
+#!/bin/bash -x
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -ex
+
+usage() {
+  echo "
+usage: $0 <options>
+  Required not-so-options:
+     --build-dir=DIR             path to hive/build/dist
+     --prefix=PREFIX             path to install into
+  "
+  exit 1
+}
+
+OPTS=$(getopt \
+  -n $0 \
+  -o '' \
+  -l 'prefix:' \
+  -l 'version:' \
+  -l 'build-dir:' \
+  -l 'lib-dir:' \
+  -l 'bin-dir:' \
+  -l 'conf-dir:' \
+  -- "$@")
+
+if [ $? != 0 ] ; then
+    usage
+fi
+
+eval set -- "$OPTS"
+while true ; do
+    case "$1" in
+        --prefix)
+        PREFIX=$2 ; shift 2
+        ;;
+        --version)
+        VERSION=$2 ; shift 2
+        ;;
+        --build-dir)
+        BUILD_DIR=$2 ; shift 2
+        ;;
+        --bin-dir)
+        BIN_DIR=$2 ; shift 2
+        ;;
+        --lib-dir)
+        LIB_DIR=$2 ; shift 2
+        ;;
+        --conf-dir)
+        CONF_DIR=$2 ; shift 2
+        ;;
+        --doc-dir)
+        DOC_DIR=$2 ; shift 2
+        ;;
+        --)
+        shift ; break
+        ;;
+        *)
+        echo "Unknown option: $1"
+        usage
+        exit 1
+        ;;
+    esac
+done
+
+for var in PREFIX BUILD_DIR; do
+  if [ -z "$(eval "echo \$$var")" ]; then
+    echo Missing param: $var
+    usage
+  fi
+done
+
+. `dirname ${0}`/bigtop.bom
+
+BIN_DIR=${BIN_DIR:-/usr/lib/bigtop-groovy/bin}
+CONF_DIR=${CONF_DIR:-/usr/lib/bigtop-groovy/conf}
+LIB_DIR=${LIB_DIR:-/usr/lib/bigtop-groovy/lib}
+echo ${BIGTOP_GROOVY_BASE_VERSION}
+
+#bin
+install -d -m 0755 ${PREFIX}/${BIN_DIR}
+cp ${BUILD_DIR}/bin/startGroovy ${PREFIX}/${BIN_DIR}
+cp ${BUILD_DIR}/bin/groovy ${PREFIX}/${BIN_DIR}
+
+# lib
+install -d -m 0755 ${PREFIX}/${LIB_DIR}
+cp ${BUILD_DIR}/lib/groovy-${BIGTOP_GROOVY_VERSION}.jar ${PREFIX}/${LIB_DIR}
+cp ${BUILD_DIR}/embeddable/groovy-all-${BIGTOP_GROOVY_VERSION}.jar ${PREFIX}/${LIB_DIR}
+cp ${BUILD_DIR}/lib/commons-cli-1.2.jar ${PREFIX}/${LIB_DIR}
+cp ${BUILD_DIR}/lib/asm*.jar ${PREFIX}/${LIB_DIR}
+cp ${BUILD_DIR}/lib/antlr*.jar ${PREFIX}/${LIB_DIR}
+
+#conf
+install -d -m 0755 ${PREFIX}/${CONF_DIR}
+cp ${BUILD_DIR}/conf/groovy-starter.conf  ${PREFIX}/${CONF_DIR}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.install
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.install b/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.install
new file mode 100644
index 0000000..625ae2e
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.install
@@ -0,0 +1,4 @@
+/usr/lib/bigtop-groovy
+/usr/lib/bigtop-groovy/bin
+/usr/lib/bigtop-groovy/conf
+/usr/lib/bigtop-groovy/lib
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.postinst
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.postinst b/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.postinst
new file mode 100644
index 0000000..29db417
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/bigtop-groovy.postinst
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# postinst script for bigtop-groovy
+
+set -e
+
+case "$1" in
+    configure)
+	    chmod 0755 /usr/lib/bigtop-groovy/bin/*
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/changelog
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/changelog b/bigtop-packages/src/deb/bigtop-groovy/changelog
new file mode 100755
index 0000000..547ed02
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/changelog
@@ -0,0 +1 @@
+--- This is auto-generated 

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/compat
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/compat b/bigtop-packages/src/deb/bigtop-groovy/compat
new file mode 100755
index 0000000..7f8f011
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/compat
@@ -0,0 +1 @@
+7

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/control
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/control b/bigtop-packages/src/deb/bigtop-groovy/control
new file mode 100755
index 0000000..fe8469c
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/control
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+Source: bigtop-groovy
+Section: misc
+Priority: extra
+Maintainer: Bigtop <de...@bigtop.apache.org>
+Build-Depends: debhelper (>= 7.0.50~)
+Standards-Version: 3.8.0
+Homepage: http://groovy.codehaus.org/
+
+Package: bigtop-groovy
+Architecture: any
+Depends: bigtop-utils (>= 0.7)
+Description: Groovy provides a JVM based runtime environment
+ for function programming and scripting.Application to launch java daemon

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/copyright
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/copyright b/bigtop-packages/src/deb/bigtop-groovy/copyright
new file mode 100755
index 0000000..35ed5ff
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/copyright
@@ -0,0 +1,15 @@
+Format: http://dep.debian.net/deps/dep5
+Source: http://commons.apache.org/daemon/
+Upstream-Name: Apache Commons Daemon
+
+Files: *
+Copyright: 2008-2012, The Apache Software Foundation
+License: Apache-2.0
+
+Files debian/*
+Copyright: 2012, The Apache Software Foundation
+License: Apache-2.0
+
+License: Apache-2.0
+ On Debian systems, the complete text of the Apache 2.0 license
+ can be found in "/usr/share/common-licenses/Apache-2.0".

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/rules
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/rules b/bigtop-packages/src/deb/bigtop-groovy/rules
new file mode 100755
index 0000000..f4cd744
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/rules
@@ -0,0 +1,39 @@
+#!/usr/bin/make -f
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# 
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+# This has to be exported to make some magic below work.
+export DH_OPTIONS=-s
+
+%:
+	dh $@
+
+override_dh_auto_build:
+	bash debian/do-component-build
+
+override_dh_auto_install:
+	sh -x debian/install_groovy.sh \
+    --build-dir=. \
+    --prefix=debian/tmp \
+    --bin-dir=usr/lib/bigtop-groovy/bin \
+    --version=%{bigtop_groovy_version} \
+    --lib-dir=usr/lib/bigtop-groovy/lib \
+    --conf-dir=usr/lib/bigtop-groovy/conf

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/deb/bigtop-groovy/source/format
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/deb/bigtop-groovy/source/format b/bigtop-packages/src/deb/bigtop-groovy/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/bigtop-packages/src/deb/bigtop-groovy/source/format
@@ -0,0 +1 @@
+3.0 (quilt)

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/rpm/bigtop-groovy/SPECS/.gitignore
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/bigtop-groovy/SPECS/.gitignore b/bigtop-packages/src/rpm/bigtop-groovy/SPECS/.gitignore
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-packages/src/rpm/bigtop-groovy/SPECS/bigtop-groovy.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/bigtop-groovy/SPECS/bigtop-groovy.spec b/bigtop-packages/src/rpm/bigtop-groovy/SPECS/bigtop-groovy.spec
new file mode 100644
index 0000000..b686adb
--- /dev/null
+++ b/bigtop-packages/src/rpm/bigtop-groovy/SPECS/bigtop-groovy.spec
@@ -0,0 +1,60 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+%define bin_groovy /usr/lib/bigtop-groovy
+
+Name: bigtop-groovy
+Version: %{bigtop_groovy_version}
+Release: %{bigtop_groovy_release}
+Summary: An agile and dynamic language for the Java Virtual Machine
+URL: http://groovy.codehaus.org/
+Group: Development/Libraries
+Buildroot: %{_topdir}/INSTALL/%{name}-%{version}
+BuildArch:  noarch
+License: ASL 2.0
+Source0: groovy-binary-%{bigtop_groovy_base_version}.zip
+Source1: do-component-build
+Source2: install_groovy.sh
+Requires: bigtop-utils >= 0.7
+
+%description 
+Groovy provides a JVM based runtime environment for function programming and scripting.
+
+%prep
+%setup -n groovy-%{bigtop_groovy_base_version}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%build
+bash %{SOURCE1}
+
+%install
+%__rm -rf $RPM_BUILD_ROOT
+sh %{SOURCE2} \
+          --build-dir=.         \
+          --bin-dir=%{bin_groovy}/bin \
+          --version=%{bigtop_groovy_version} \
+          --lib-dir=%{bin_groovy}/lib \
+          --conf-dir=%{bin_groovy}/conf \
+          --prefix=$RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%{bin_groovy}
+%attr(0775,root,root) %{bin_groovy}/bin/*
+
+%changelog
+

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop-tests/test-artifacts/package/src/main/resources/package_data.xml
----------------------------------------------------------------------
diff --git a/bigtop-tests/test-artifacts/package/src/main/resources/package_data.xml b/bigtop-tests/test-artifacts/package/src/main/resources/package_data.xml
index 3eb24f7..9cbbbfe 100644
--- a/bigtop-tests/test-artifacts/package/src/main/resources/package_data.xml
+++ b/bigtop-tests/test-artifacts/package/src/main/resources/package_data.xml
@@ -30,6 +30,18 @@
       <url>http://commons.apache.org/daemon/</url>
     </metadata>
   </bigtop-jsvc>
+
+  <bigtop-jsvc>
+    <metadata>
+      <summary>An agile and dynamic language for the Java Virtual Machine</summary>
+      <description>Groovy provides a JVM based runtime environment for function programming and scripting.</description>
+      <url>http://groovy.codehaus.org/</url>
+    </metadata>
+    <deps>
+      <bigtop-utils/>
+    </deps>
+  </bigtop-jsvc>
+
   <bigtop-tomcat>
     <metadata>
       <summary>Apache Tomcat</summary>

http://git-wip-us.apache.org/repos/asf/bigtop/blob/553a6ca1/bigtop.mk
----------------------------------------------------------------------
diff --git a/bigtop.mk b/bigtop.mk
index 36bd415..5644a75 100644
--- a/bigtop.mk
+++ b/bigtop.mk
@@ -249,6 +249,19 @@ PHOENIX_SITE=https://github.com/forcedotcom/phoenix/archive
 PHOENIX_ARCHIVE=$(PHOENIX_SITE)
 $(eval $(call PACKAGE,phoenix,PHOENIX))
 
+# Groovy
+BIGTOP_GROOVY_NAME=bigtop-groovy
+BIGTOP_GROOVY_RELNOTES_NAME=Grovvy: a dynamic language for the Java platform
+BIGTOP_GROOVY_PKG_NAME=bigtop-groovy
+BIGTOP_GROOVY_BASE_VERSION=2.2.1
+BIGTOP_GROOVY_PKG_VERSION=2.2.1
+BIGTOP_GROOVY_RELEASE_VERSION=1
+BIGTOP_GROOVY_TARBALL_DST=groovy-binary-$(BIGTOP_GROOVY_BASE_VERSION).zip
+BIGTOP_GROOVY_TARBALL_SRC=$(BIGTOP_GROOVY_TARBALL_DST)
+BIGTOP_GROOVY_SITE=http://dist.groovy.codehaus.org/distributions/
+BIGTOP_GROOVY_ARCHIVE=$(BIGTOP_GROOVY_SITE)
+$(eval $(call PACKAGE,bigtop-groovy,BIGTOP_GROOVY))
+
 # Bigtop-utils
 BIGTOP_UTILS_NAME=bigtop-utils
 BIGTOP_UTILS__RELNOTES_NAME=Bigtop-utils


[2/2] git commit: BIGTOP-1192. Add utilities to facilitate cluster failure testing into bigtop-test-framework

Posted by co...@apache.org.
BIGTOP-1192.  Add utilities to facilitate cluster failure testing into bigtop-test-framework


Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/40b39855
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/40b39855
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/40b39855

Branch: refs/heads/master
Commit: 40b398553ff4e00b68548e219aa58c3a8fec2232
Parents: 553a6ca
Author: Mikhail Antonov <ol...@gmail.com>
Authored: Mon Feb 3 15:19:21 2014 -0800
Committer: Konstantin Boudnik <co...@apache.org>
Committed: Mon Feb 3 15:19:21 2014 -0800

----------------------------------------------------------------------
 bigtop-test-framework/README                    |  40 +++++
 .../itest/failures/AbstractFailure.groovy       | 179 +++++++++++++++++++
 .../itest/failures/FailureConstants.groovy      |  38 ++++
 .../failures/NetworkShutdownFailure.groovy      |  78 ++++++++
 .../itest/failures/ServiceKilledFailure.groovy  |  69 +++++++
 .../itest/failures/ServiceRestartFailure.groovy |  69 +++++++
 .../itest/failures/ClusterFailuresTest.groovy   | 153 ++++++++++++++++
 7 files changed, 626 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/40b39855/bigtop-test-framework/README
----------------------------------------------------------------------
diff --git a/bigtop-test-framework/README b/bigtop-test-framework/README
index 009972c..0980a6a 100644
--- a/bigtop-test-framework/README
+++ b/bigtop-test-framework/README
@@ -25,3 +25,43 @@ tasks via specific adapters:
 This project contains the experimental foundation of JarRunner and a
 meta-service utilizing it to perform tests execution. These two components
 might be joined together later.
+
+New cluster failures injection capabilities for smoke tests (see BIGTOP-1192 for details)
+imposed certain additional requirements. Smoke tests running cluster failures against real clusters
+expect the following preconditions to be satistied:
+  - For all hosts in the cluster being smoke-tested there's a dedicated user(like "jenkins" or "bigtop"),
+    which has password-less SSH access to those hosts and permissions to execute certain sudo commands
+    (see below) without password
+  - 2 new environment variable are set:
+      * BIGTOP_SMOKES_USER should contain username of user which will be used to run SSH commands
+      * BIGTOP_SMOKES_CLUSTER_IDENTITY_FILE should point to a file with private key for password-less SSH.
+
+To be able to run new itest framework internal test (see ClusterFailuresTest.groovy), the following change
+is needed on the machine with Bigtop workspace:
+ - if your current user doesn't have password-less sude, then run 'visudo' and:
+     * add line in /etc/sudoers at the end of file like: (for Redhat):
+       myusername  localhost = NOPASSWD:/usr/sbin/service,/usr/bin/pkill,/usr/sbin/iptables
+
+To be able to run real module smoke tests again real cluster, more complex setup is needed
+on the machine with Bigtop workspace:
+ - make sure sshd is all nodes in the cluster
+ - check the following in /etc/ssh/sshd_config:
+     * PubkeyAuthentication yes
+     * PasswordAuthentication yes
+ - add new user, for example, "bigtop", on local machine AND on each cluster node, set some password,
+   make sure default shell is set
+ - on local machine, su bigtop, do ssh-keygen with empty passphrase
+ - run 'ssh-copy-id bigtop@<each cluster node>'
+ - log back in on your local machine as your regular user which you use to work with your workspace, copy the generated private
+   key for bigtop user somewhere, do chown and make sure it has right permissions (like 600)
+ - export BIGTOP_SMOKES_CLUSTER_IDENTITY_FILE=/full/path/to/private/key
+ - export BIGTOP_SMOKES_USER=bigtop
+ - on each remote node, run 'visudo' and
+     * add line in /etc/sudoers at the end of file like: (for Redhat):
+       bigtop  localhost = NOPASSWD:/usr/sbin/service,/usr/bin/pkill,/usr/sbin/iptables
+     * Comment out line 'Defaults    requiretty', otherwise sudo may complain like
+       "Sorry, you must have a tty to run sudo"
+
+  - run following sample commands from your local machine to verify your setup:
+      * ssh -i /test_bigtop_ssh_key bigtop@<some cluster node> sudo service crond stop
+      * ssh -i /test_bigtop_ssh_key bigtop@<some cluster node> sudo service crond start

http://git-wip-us.apache.org/repos/asf/bigtop/blob/40b39855/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/AbstractFailure.groovy
----------------------------------------------------------------------
diff --git a/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/AbstractFailure.groovy b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/AbstractFailure.groovy
new file mode 100644
index 0000000..d4f117d
--- /dev/null
+++ b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/AbstractFailure.groovy
@@ -0,0 +1,179 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bigtop.itest.failures
+
+import org.apache.bigtop.itest.shell.Shell
+import static org.apache.bigtop.itest.LogErrorsUtils.logError
+import static org.apache.bigtop.itest.failures.FailureConstants.PRIVATE_KEY_PATH_ENV_VAR
+import static org.apache.bigtop.itest.failures.FailureConstants.BIGTOP_SMOKES_USER
+
+/**
+ * Abstract class to be subclassed by cluster failures classes of various types:
+ *  - service restart
+ *  - service being killed (kill -9)
+ *  - network shutdown (iptables-based drop).
+ *
+ * Provides means to:
+ *  - run set of "failure" commands against the specified list of hosts
+ *  - restore the correct state.
+ *
+ *  Please see examples of usage in test class ClusterFailuresTest.
+ *
+ *  WARNING:
+ *   - password-less (PKI-based) SSH for user specified in env variable BIGTOP_SMOKES_USER
+ *     to all nodes in cluster being tested is assumed
+ *   - for local tests, like ClusterFailuresTest, this SSH should be setup for localhost
+ *   - env variable BIGTOP_SMOKES_CLUSTER_IDENTITY_FILE should point to according private key file.
+ */
+public abstract class AbstractFailure implements Runnable {
+  protected static Shell rootShell = new Shell("/bin/bash", "root")
+
+  /**
+   * Used to wrap actual command to be executed over SSH, if running in distributed setup.
+   * First substitution param is path to SSH private key, second - remote server username,
+   * third - remote server host address, forth - actual command being wrapped.
+   */
+  protected static String SSH_COMMAND_WRAPPER = "ssh -i %s -o StrictHostKeyChecking=no %s@%s '%s'"
+
+  /**
+   * List of hosts to run fail/restore commands against.
+   */
+  protected List<String> hosts = []
+
+  /**
+   * List of failing commands, defined by a subclass, execute in given sequence.
+   */
+  protected List<String> failCommands = []
+
+  /**
+   * List of restore commands, defined by a subclass, execute in given sequence.
+   */
+  protected List<String> restoreCommands = []
+
+  /**
+   * How long (in milliseconds) shall we wait before executing first failure.
+   */
+  protected long startDelay = 0
+
+  /**
+   * How long failure thread waits before next check if failure is over and it should call restore commands.
+   */
+  private static final SLEEP_TIME = 100;
+
+  /**
+   * Simple constructor for failures, uses default values.
+   * @param hosts list of hosts this failure will be executed on.
+   */
+  public AbstractFailure(List<String> hosts) {
+    this.hosts = hosts
+  }
+
+  /**
+   * Constructor allowing to set all params.
+   *
+   * @param hosts list of hosts the failure will be running against
+   * @param startDelay how long (in millisecs) failure will wait before starting
+   */
+  public AbstractFailure(List<String> hosts, long startDelay) {
+    this.hosts = hosts
+    this.startDelay = startDelay
+  }
+
+  /**
+   * Runs failure/restore commands in a separate thread.
+   */
+  @Override
+  public void run() {
+    try {
+      if (startDelay > 0) {
+        try {
+          Thread.sleep(startDelay)
+        } catch (InterruptedException e) {
+          Thread.currentThread().interrupt()
+          return
+        }
+      }
+
+      runFailCommands()
+
+      while (!Thread.currentThread().isInterrupted()) {
+        try {
+          Thread.sleep(SLEEP_TIME)
+        } catch (InterruptedException e) {
+          return
+        }
+      }
+    } finally {
+      runRestoreCommands()
+    }
+  }
+
+  private void runRestoreCommands() {
+    restoreCommands.each {
+      rootShell.exec(it)
+      logError(rootShell)
+      assert rootShell.getRet() == 0, "Restore command $it has returned non-0 error code:"
+    }
+  }
+
+  private void runFailCommands() {
+    failCommands.each {
+      rootShell.exec(it)
+      logError(rootShell)
+
+      //some commands, like pkill over ssh, return 137. It's ok.
+      //assertTrue(rootShell.getRet() == 0)
+    }
+  }
+
+  /**
+   * Reads the full path to private key file from env. variable PRIVATE_KEY_PATH_ENV_VAR.
+   * @return full path to file with private key for SSH connections to cluster.
+   */
+  protected String getIdentityFile() {
+    String identityFile = System.getenv(PRIVATE_KEY_PATH_ENV_VAR)
+    assert identityFile, "Env variable $PRIVATE_KEY_PATH_ENV_VAR is not set:"
+    return identityFile
+  }
+
+  /**
+   * Reads the username used for ssh commands from env. variable BIGTOP_SMOKES_USER.
+   * @return user which will be used to run SSH command on target hosts
+   */
+  protected String getSshUser() {
+    String sshUser = System.getenv(BIGTOP_SMOKES_USER)
+    assert sshUser, "Env variable $BIGTOP_SMOKES_USER is not set:"
+    return sshUser
+  }
+
+  /**
+   * If tests are running in distributed mode, i.e. not itest framework tests,
+   * but real cluster smoke tests, wrapping failure command to go over SSH to node on the cluster.
+   *
+   * @param formattedCommand actual failure command to be executed on the remote node
+   * @param host remote node to run command on
+   * @return full command to be executed in the local shell
+   */
+  protected String getSshWrappedCommand(String formattedCommand, String host) {
+    def identityFile = getIdentityFile()
+    def sshUser = getSshUser()
+
+    return String.format(SSH_COMMAND_WRAPPER, identityFile, sshUser, host, formattedCommand);
+  }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/40b39855/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/FailureConstants.groovy
----------------------------------------------------------------------
diff --git a/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/FailureConstants.groovy b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/FailureConstants.groovy
new file mode 100644
index 0000000..0c24681
--- /dev/null
+++ b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/FailureConstants.groovy
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bigtop.itest.failures
+
+/**
+ * Constants for cluster failure smoke tests.
+ */
+public final class FailureConstants {
+
+  /**
+   * Env variable which should contain full local path to the file with SSH private key
+   * used to remotely login on cluster nodes without password.
+   */
+  public static final PRIVATE_KEY_PATH_ENV_VAR = "BIGTOP_SMOKES_CLUSTER_IDENTITY_FILE"
+
+  /**
+   * Env variable which should contain name of Linux user on the hosts where failures are running,
+   * this user should have password-less SSH enabled and privileges to run password-less sudo
+   * commands: service stop/start, pkill -9, iptables rules editing.
+   */
+  public static final BIGTOP_SMOKES_USER = "BIGTOP_SMOKES_USER"
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/40b39855/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/NetworkShutdownFailure.groovy
----------------------------------------------------------------------
diff --git a/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/NetworkShutdownFailure.groovy b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/NetworkShutdownFailure.groovy
new file mode 100644
index 0000000..15bf797
--- /dev/null
+++ b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/NetworkShutdownFailure.groovy
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bigtop.itest.failures
+
+/**
+ * Can shutdown network connections between specified hosts during tests execution.
+ */
+public class NetworkShutdownFailure extends AbstractFailure {
+
+  private static final String DROP_INPUT_CONNECTIONS = "sudo iptables -A INPUT -s %s -j DROP"
+  private static final String DROP_OUTPUT_CONNECTIONS = "sudo iptables -A OUTPUT -d %s -j DROP"
+  private static final String RESTORE_INPUT_CONNECTIONS = "sudo iptables -D INPUT -s %s -j DROP"
+  private static final String RESTORE_OUTPUT_CONNECTIONS = "sudo iptables -D OUTPUT -d %s -j DROP"
+
+  /**
+   * Creates list of network disruptions between specified hosts.
+   *
+   * @param srcHost host whose connections will but cut
+   * @param dstHosts destination hosts connections to which from srcHost will be shut down.
+   */
+  public NetworkShutdownFailure(String srcHost, List<String> dstHosts) {
+    super(new ArrayList<String>())
+    populateCommandsList(srcHost, dstHosts)
+  }
+
+  /**
+   * Creates list of network disruptions between specified hosts,
+   * allows to set all additional params.
+   *
+   * @param srcHost host whose connections will but cut
+   * @param dstHosts destination hosts connections to which from srcHost will be shut down
+   * @param startDelay time in milliseconds) the failures will wait before start
+   */
+  public NetworkShutdownFailure(String srcHost,
+                               List<String> dstHosts,
+                               long startDelay) {
+
+    super(new ArrayList<String>(), startDelay)
+    populateCommandsList(srcHost, dstHosts)
+  }
+
+  /*
+   * Populate commands list, making choice between local execution and remote one.
+   */
+  private void populateCommandsList(String host, List<String> dstHosts){
+    if ("localhost".equalsIgnoreCase(host)) {
+      dstHosts.each { dstHost ->
+        failCommands.add(String.format(DROP_INPUT_CONNECTIONS, dstHost))
+        failCommands.add(String.format(DROP_OUTPUT_CONNECTIONS, dstHost))
+        restoreCommands.add(String.format(RESTORE_INPUT_CONNECTIONS, dstHost))
+        restoreCommands.add(String.format(RESTORE_OUTPUT_CONNECTIONS, dstHost))
+      }
+    } else {
+      dstHosts.each { dstHost ->
+        failCommands.add(getSshWrappedCommand(String.format(DROP_INPUT_CONNECTIONS, dstHost), host))
+        failCommands.add(getSshWrappedCommand(String.format(DROP_OUTPUT_CONNECTIONS, dstHost), host))
+        restoreCommands.add(getSshWrappedCommand(String.format(RESTORE_INPUT_CONNECTIONS, dstHost), host))
+        restoreCommands.add(getSshWrappedCommand(String.format(RESTORE_OUTPUT_CONNECTIONS, dstHost), host))
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/40b39855/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceKilledFailure.groovy
----------------------------------------------------------------------
diff --git a/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceKilledFailure.groovy b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceKilledFailure.groovy
new file mode 100644
index 0000000..413f171
--- /dev/null
+++ b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceKilledFailure.groovy
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bigtop.itest.failures
+
+/**
+ * Can kill (with kill -9) specified service on specified hosts during tests run.
+ */
+public class ServiceKilledFailure extends AbstractFailure {
+
+  private static final String KILL_SERVICE_TEMPLATE = "sudo pkill -9 -f %s"
+  private static final String START_SERVICE_TEMPLATE = "sudo service %s start"
+
+  /**
+   * Can kill specified service on specified hosts during tests run.
+   *
+   * @param hosts list of hosts on which specified service will be killed
+   * @param serviceName name of service to be killed.
+   */
+  public ServiceKilledFailure(List<String> hosts, String serviceName) {
+    super(hosts)
+    populateCommandsList(hosts, serviceName)
+  }
+
+  /**
+   * Can kill specified service on specified hosts during tests run.
+   *
+   * @param hosts list of hosts on which specified service will be killed
+   * @param serviceName name of service to be killed
+   * @param startDelay time in milliseconds) the failures will wait before start
+   */
+  public ServiceKilledFailure(List<String> hosts,
+                              String serviceName,
+                              long startDelay) {
+
+    super(hosts, startDelay)
+    populateCommandsList(hosts, serviceName)
+  }
+
+  /*
+   * Populate commands list, making choice between local execution and remote one.
+   */
+  private void populateCommandsList(List<String> hosts, String serviceName){
+    if (hosts.size() == 1 && "localhost".equalsIgnoreCase(hosts[0])) {
+      failCommands.add(String.format(KILL_SERVICE_TEMPLATE, serviceName))
+      restoreCommands.add(String.format(START_SERVICE_TEMPLATE, serviceName))
+    } else {
+      hosts.each { host ->
+        failCommands.add(getSshWrappedCommand(String.format(KILL_SERVICE_TEMPLATE, serviceName), host))
+        restoreCommands.add(getSshWrappedCommand(String.format(START_SERVICE_TEMPLATE, serviceName), host))
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/40b39855/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceRestartFailure.groovy
----------------------------------------------------------------------
diff --git a/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceRestartFailure.groovy b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceRestartFailure.groovy
new file mode 100644
index 0000000..6dd1005
--- /dev/null
+++ b/bigtop-test-framework/src/main/groovy/org/apache/bigtop/itest/failures/ServiceRestartFailure.groovy
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bigtop.itest.failures
+
+/**
+ * Can restart specified services on specified hosts during tests execution.
+ */
+public class ServiceRestartFailure extends AbstractFailure {
+
+  private static final String STOP_SERVICE_TEMPLATE = "sudo service %s stop"
+  private static final String START_SERVICE_TEMPLATE = "sudo service %s start"
+
+  /**
+   * Can restart specified service on specified hosts during tests run.
+   *
+   * @param hosts list of hosts on which specified service will be restarted
+   * @param serviceName name of service to be restarted.
+   */
+  public ServiceRestartFailure(List<String> hosts, String serviceName) {
+    super(hosts)
+    populateCommandsList(hosts, serviceName)
+  }
+
+  /**
+   * Can gracefully restart specified service on specified hosts during tests run.
+   *
+   * @param hosts list of hosts on which specified service will be restarted
+   * @param serviceName name of service to be restarted
+   * @param startDelay time in milliseconds) the failures will wait before start
+   */
+  public ServiceRestartFailure(List<String> hosts,
+                               String serviceName,
+                               long startDelay) {
+
+    super(hosts, startDelay)
+    populateCommandsList(hosts, serviceName)
+  }
+
+  /*
+   * Populate commands list, making choice between local execution and remote one.
+   */
+  private void populateCommandsList(List<String> hosts, String serviceName){
+    if (hosts.size() == 1 && "localhost".equalsIgnoreCase(hosts[0])) {
+      failCommands.add(String.format(STOP_SERVICE_TEMPLATE, serviceName))
+      restoreCommands.add(String.format(START_SERVICE_TEMPLATE, serviceName))
+    } else {
+      hosts.each { host ->
+        failCommands.add(getSshWrappedCommand(String.format(STOP_SERVICE_TEMPLATE, serviceName), host))
+        restoreCommands.add(getSshWrappedCommand(String.format(START_SERVICE_TEMPLATE, serviceName), host))
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/40b39855/bigtop-test-framework/src/test/groovy/org/apache/bigtop/itest/failures/ClusterFailuresTest.groovy
----------------------------------------------------------------------
diff --git a/bigtop-test-framework/src/test/groovy/org/apache/bigtop/itest/failures/ClusterFailuresTest.groovy b/bigtop-test-framework/src/test/groovy/org/apache/bigtop/itest/failures/ClusterFailuresTest.groovy
new file mode 100644
index 0000000..af6b36b
--- /dev/null
+++ b/bigtop-test-framework/src/test/groovy/org/apache/bigtop/itest/failures/ClusterFailuresTest.groovy
@@ -0,0 +1,153 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bigtop.itest.failures
+
+import org.apache.bigtop.itest.shell.OS
+import org.junit.Test
+import org.apache.bigtop.itest.shell.Shell
+
+public class ClusterFailuresTest {
+  private Shell rootShell = new Shell("/bin/bash", "root")
+  private final int SLEEP_TIME = 100
+  private final String TEST_HOST = "localhost"
+  private final String TEST_REMOTE_HOST = "apache.org"
+  private final String CRON_SERVICE
+
+  {
+    switch (OS.linux_flavor) {
+      case ~/(?is).*(redhat|centos|rhel|fedora|enterpriseenterpriseserver).*/:
+        CRON_SERVICE = "crond"
+        break
+      default:
+        CRON_SERVICE = "cron"
+    }
+  }
+
+  @Test
+  void testServiceRestart() {
+    startCron()
+    assert isCronRunning(), "$CRON_SERVICE service isn't running before the test:"
+
+    def cronKilled = new ServiceRestartFailure([TEST_HOST], "$CRON_SERVICE")
+    Thread t = new Thread(cronKilled)
+    t.start()
+
+    while (isCronRunning()) {
+      println "$CRON_SERVICE it still running"
+      Thread.sleep(SLEEP_TIME)
+    }
+
+    try{
+      assert !isCronRunning(), "$CRON_SERVICE hasn't been stopped as expected:"
+      println "$CRON_SERVICE stopped. Good."
+    } finally {
+      t.interrupt()
+    }
+
+    while (!isCronRunning()) {
+      println "$CRON_SERVICE it still stopped.."
+      Thread.sleep(SLEEP_TIME)
+    }
+
+    assert isCronRunning(), "$CRON_SERVICE hasn't been restarted after the test:"
+    println "$CRON_SERVICE is up. Good"
+  }
+
+  @Test
+  void testServiceKilled() {
+    // On Ubuntu services like cron or ssh get restarted automatically if killed,
+    // so for now disabling this test for Ubuntu users.
+    if (OS.linux_flavor ==~ /(?is).*(ubuntu|debian).*/) {
+      println "As you're running on $OS.linux_flavor, testServiceKilled() doesn't run for you."
+      return
+    }
+
+    startCron()
+    assert isCronRunning(), "$CRON_SERVICE service isn't running before the test:"
+
+    def cronKilled = new ServiceKilledFailure([TEST_HOST], "$CRON_SERVICE")
+    Thread t = new Thread(cronKilled)
+    t.start()
+
+    while (isCronRunning()) {
+      println "$CRON_SERVICE it still running.."
+      Thread.sleep(SLEEP_TIME)
+    }
+
+    try{
+      assert !isCronRunning(), "$CRON_SERVICE hasn't been killed as expected:"
+      println "$CRON_SERVICE killed. Good."
+    } finally {
+      t.interrupt()
+    }
+
+    while (!isCronRunning()) {
+      println "$CRON_SERVICE it still killed..."
+      Thread.sleep(SLEEP_TIME)
+    }
+
+    assert isCronRunning(), "$CRON_SERVICE hasn't been restarted after the test:"
+    println "$CRON_SERVICE is up. Good."
+  }
+
+  @Test
+  void testNetworkShutdown() {
+    //make sure there are no blocking rules
+    rootShell.exec("iptables -D INPUT -s $TEST_REMOTE_HOST -j DROP")
+    rootShell.exec("iptables -D OUTPUT -d $TEST_REMOTE_HOST -j DROP")
+
+    assert isRemoteHostReachable(), "No ping to $TEST_REMOTE_HOST, which is used for network failures test:"
+
+    def networkShutdown = new NetworkShutdownFailure(TEST_HOST, [TEST_REMOTE_HOST])
+    Thread t = new Thread(networkShutdown)
+    t.start()
+
+    while (isRemoteHostReachable()) {
+      println "$TEST_REMOTE_HOST is still reachable..."
+      Thread.sleep(SLEEP_TIME)
+    }
+
+    try{
+      assert !isRemoteHostReachable(), "Connection to $TEST_REMOTE_HOST hasn't been killed as expected:"
+      println "$TEST_REMOTE_HOST isn't reachable. Good."
+    } finally {
+      t.interrupt()
+    }
+
+    while (!isRemoteHostReachable()) {
+      println "$TEST_REMOTE_HOST isn't reachable..."
+      Thread.sleep(SLEEP_TIME)
+    }
+
+    assert isRemoteHostReachable(), "Connection to $TEST_REMOTE_HOST hasn't been restored after the test:"
+    println "$TEST_REMOTE_HOST is reachable again. Good."
+  }
+
+  private boolean isCronRunning() {
+    return rootShell.exec("pgrep $CRON_SERVICE").ret == 0 ? true : false
+  }
+
+  private void startCron() {
+    rootShell.exec("service $CRON_SERVICE start")
+  }
+
+  private boolean isRemoteHostReachable() {
+    return rootShell.exec("ping -qc 1 $TEST_REMOTE_HOST").ret == 0 ? true : false
+  }
+}