You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2014/03/03 02:24:27 UTC
git commit: AMBARI-2475. Ambari bootstrap actions report success even
if a failure happened. (Ximo Guanter via mahadev)
Repository: ambari
Updated Branches:
refs/heads/trunk 173a54efe -> b0740f535
AMBARI-2475. Ambari bootstrap actions report success even if a failure happened. (Ximo Guanter via mahadev)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b0740f53
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b0740f53
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b0740f53
Branch: refs/heads/trunk
Commit: b0740f535e4dee688468e29fc2b70a5572595d31
Parents: 173a54e
Author: Mahadev Konar <ma...@apache.org>
Authored: Sun Mar 2 17:24:16 2014 -0800
Committer: Mahadev Konar <ma...@apache.org>
Committed: Sun Mar 2 17:24:16 2014 -0800
----------------------------------------------------------------------
.../ambari/server/bootstrap/BSRunner.java | 6 +++
.../ambari/server/bootstrap/BootStrapTest.java | 52 ++++++++++++++++++++
2 files changed, 58 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0740f53/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
index 6ddcaf1..f4ccbca 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
@@ -302,6 +302,12 @@ class BSRunner extends Thread {
finally {
/* get the bstatus */
BootStrapStatus tmpStatus = bsImpl.getStatus(requestId);
+ for (BSHostStatus hostStatus : tmpStatus.getHostsStatus()) {
+ if ("FAILED".equals(hostStatus.getStatus())) {
+ stat = BSStat.ERROR;
+ break;
+ }
+ }
tmpStatus.setLog(scriptlog);
tmpStatus.setStatus(stat);
bsImpl.updateStatus(requestId, tmpStatus);
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0740f53/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
index c049d89..9116b9d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
@@ -103,6 +103,58 @@ public class BootStrapTest extends TestCase {
Assert.assertFalse(new File(bootdir + File.separator + "1" + File.separator + "host_pass").exists());
}
+ @Test
+ public void testHostFailure() throws Exception {
+ Properties properties = new Properties();
+ String bootdir = temp.newFolder("bootdir").toString();
+ String metadetadir = temp.newFolder("metadetadir").toString();
+ String serverVersionFilePath = temp.newFolder("serverVersionFilePath").toString();
+ LOG.info("Bootdir is " + bootdir);
+ LOG.info("Metadetadir is " + metadetadir);
+ LOG.info("ServerVersionFilePath is " + serverVersionFilePath);
+ properties.setProperty(Configuration.BOOTSTRAP_DIR,
+ bootdir);
+ properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, "echo");
+ properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, "target" + File.separator + "classes");
+ properties.setProperty(Configuration.METADETA_DIR_PATH, metadetadir);
+ properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);
+ Configuration conf = new Configuration(properties);
+ AmbariMetaInfo ambariMetaInfo = new AmbariMetaInfo(conf);
+ BootStrapImpl impl = new BootStrapImpl(conf, ambariMetaInfo);
+ impl.init();
+ SshHostInfo info = new SshHostInfo();
+ info.setSshKey("xyz");
+ ArrayList<String> hosts = new ArrayList<String>();
+ hosts.add("host1");
+ hosts.add("host2");
+ info.setHosts(hosts);
+ info.setUser("user");
+ info.setPassword("passwd");
+ BSResponse response = impl.runBootStrap(info);
+ long requestId = response.getRequestId();
+ LOG.info("Response id from bootstrap " + requestId);
+ /* create failed done file for host1 */
+ File requestDir = new File(bootdir, Long.toString(requestId));
+ FileUtils.writeStringToFile(new File(requestDir, "host1.done"), "0");
+ FileUtils.writeStringToFile(new File(requestDir, "host2.done"), "1");
+ /* do a query */
+ BootStrapStatus status = impl.getStatus(response.getRequestId());
+ LOG.info("Status " + status.getStatus());
+ int num = 0;
+ while ((status.getStatus() != BSStat.ERROR) && (num < 10000)) {
+ status = impl.getStatus(response.getRequestId());
+ Thread.sleep(100);
+ num++;
+ }
+ LOG.info("Status: log " + status.getLog() + " status=" + status.getStatus()
+ );
+ /* Note its an echo command so it should echo host1,host2 */
+ Assert.assertTrue(status.getLog().contains("host1,host2"));
+ Assert.assertEquals(BSStat.ERROR, status.getStatus());
+ Assert.assertEquals("DONE", status.getHostsStatus().get(0).getStatus());
+ Assert.assertEquals("FAILED", status.getHostsStatus().get(1).getStatus());
+ }
+
@Test
public void testPolling() throws Exception {