ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-8908 hostname resolution host check is failing. (ababiichuk)
Date Wed, 24 Dec 2014 18:09:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f93c6031a -> 3eb7ebda1


AMBARI-8908 hostname resolution host check is failing. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3eb7ebda
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3eb7ebda
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3eb7ebda

Branch: refs/heads/trunk
Commit: 3eb7ebda189c627173e0e1e61d606847c5b588c2
Parents: f93c603
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Wed Dec 24 19:39:26 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Wed Dec 24 19:39:26 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step3_controller.js  | 171 +++++++++++++------
 ambari-web/app/utils/ajax/ajax.js               |   2 +-
 .../test/controllers/wizard/step3_test.js       |  54 ++++++
 3 files changed, 176 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3eb7ebda/ambari-web/app/controllers/wizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js
index b5283a4..a9e6be0 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -203,6 +203,7 @@ App.WizardStep3Controller = Em.Controller.extend({
     this.set('isLoaded', false);
     this.set('isSubmitDisabled', true);
     this.set('isRetryDisabled', true);
+    this.set('stopChecking', false);
   },
 
   /**
@@ -848,45 +849,95 @@ App.WizardStep3Controller = Em.Controller.extend({
   },
 
   getHostNameResolution: function () {
-    var hosts = (!this.get('content.installOptions.manualInstall')) ? this.get('bootHosts').filterProperty('bootStatus',
'REGISTERED').getEach('name').join(",") : this.get('bootHosts').getEach('name').join(",");
+    if (App.get('testMode')) {
+      this.getHostCheckSuccess();
+    } else {
+      var data = this.getDataForCheckRequest("host_resolution_check", true);
+      this.requestToPerformHostCheck(data);
+    }
+  },
+
+  getGeneralHostCheck: function () {
+    if (App.get('testMode')) {
+      this.getHostInfo();
+    } else {
+      var data = this.getDataForCheckRequest("last_agent_env_check", false);
+      this.requestToPerformHostCheck(data);
+    }
+  },
+
+  getHostCheckSuccess: function(response) {
+    if (!App.get('testMode')) {
+      this.set("requestId", response.Requests.id);
+    }
+    this.getHostCheckTasks();
+  },
+
+  /**
+   * generates data for reuest to perform check
+   * @param {string} checkExecuteList - for now supported:
+   *  <code>"last_agent_env_check"<code>
+   *  <code>"host_resolution_check"<code>
+   * @param {boolean} addHosts - true
+   * @method getDataForCheckRequest
+   */
+  getDataForCheckRequest: function (checkExecuteList, addHosts) {
+    var hosts = (!this.get('content.installOptions.manualInstall'))
+      ? this.get('bootHosts').filterProperty('bootStatus', 'REGISTERED').getEach('name').join(",")
+      : this.get('bootHosts').getEach('name').join(",");
     var jdk_location = App.router.get('clusterController.ambariProperties.jdk_location');
     var RequestInfo = {
       "action": "check_host",
       "context": "Check host",
       "parameters": {
-        "check_execute_list": "last_agent_env_check",
+        "check_execute_list": checkExecuteList,
         "jdk_location" : jdk_location,
         "threshold": "20"
       }
     };
+    if (addHosts) {
+      RequestInfo.parameters.hosts = hosts;
+    }
     var resource_filters = {
       "hosts": hosts
     };
-    if (App.get('testMode')) {
-      this.getHostNameResolutionSuccess();
-    } else {
-      return App.ajax.send({
-        name: 'preinstalled.checks',
-        sender: this,
-        data: {
-          RequestInfo: RequestInfo,
-          resource_filters: resource_filters
-        },
-        success: 'getHostNameResolutionSuccess',
-        error: 'getHostNameResolutionError'
-      });
+    return {
+      RequestInfo: RequestInfo,
+      resource_filters: resource_filters
     }
   },
 
-  getHostNameResolutionSuccess: function(response) {
-    if (!App.get('testMode')) {
-      this.set("requestId", response.Requests.id);
-    }
-    this.getHostCheckTasks();
-  },
-
-  getHostNameResolutionError: function() {
-    this.getHostInfo();
+  /**
+   * send request to ceate tasks for performing hosts checks
+   * @params {object} data
+   *    {
+   *       RequestInfo: {
+   *           "action": {string},
+   *           "context": {string},
+   *           "parameters": {
+   *             "check_execute_list": {string},
+   *             "jdk_location" : {string},
+   *             "threshold": {string}
+   *             "hosts": {string|undefined}
+   *       },
+   *       resource_filters: {
+   *         "hosts": {string}
+   *       }
+   *    }
+   * @returns {$.ajax}
+   * @method requestToPerformHostCheck
+   */
+  requestToPerformHostCheck: function(data) {
+    return App.ajax.send({
+      name: 'preinstalled.checks',
+      sender: this,
+      data: {
+        RequestInfo: data.RequestInfo,
+        resource_filters: data.resource_filters
+      },
+      success: "getHostCheckSuccess",
+      error: "getHostCheckError"
+    })
   },
 
   /**
@@ -899,7 +950,6 @@ App.WizardStep3Controller = Em.Controller.extend({
     var checker = setTimeout(function () {
       if (self.get('stopChecking') == true) {
         clearInterval(checker);
-        self.getHostInfo();
       } else {
         App.ajax.send({
           name: 'preinstalled.checks.tasks',
@@ -925,38 +975,59 @@ App.WizardStep3Controller = Em.Controller.extend({
       console.warn("Error: jsonData is null");
       return;
     }
-    this.set('stopChecking', true);
+    if (["FAILED", "COMPLETED", "TIMEDOUT"].contains(data.Requests.request_status)) {
+      if (data.Requests.inputs.indexOf("last_agent_env_check") != -1) {
+        this.set('stopChecking', true);
+         this.getHostInfo();
+      } else if (data.Requests.inputs.indexOf("host_resolution_check") != -1) {
+        this.parseHostNameResolution(data);
+        this.getGeneralHostCheck();
+       }
+    } else {
+      this.getHostCheckTasks();
+    }
+  },
+
+  /**
+   * parse warnings for host names resolution only
+   * @param {object} data
+   * @method parseHostNameResolution
+   */
+  parseHostNameResolution: function (data) {
+    if (!data) {
+      console.warn("Error: jsonData is null");
+      return;
+    }
     data.tasks.forEach(function (task) {
       var name = Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.error');
       var hostInfo = this.get("hostCheckWarnings").findProperty('name', name);
       if (["FAILED", "COMPLETED", "TIMEDOUT"].contains(task.Tasks.status)) {
-        if (task.Tasks.status == "COMPLETED") {
-          if (Em.get(task, "Tasks.structured_out.last_agent_env_check.failed_count") == 0)
{
-            return;
-          }
-        }
-        var targetHostName = Em.get(task, "Tasks.host_name");
-        var relatedHostNames = Em.get(task, "Tasks.structured_out.last_agent_env_check.failures")
? Em.get(task, "Tasks.structured_out.last_agent_env_check.failures").mapProperty('host') :
[];
-        var contextMessage = Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.context').format(targetHostName,
relatedHostNames.join(', '));
-        if (!hostInfo) {
-          hostInfo = {
-            name: name,
-            hosts: [contextMessage],
-            hostsNames: [targetHostName],
-            onSingleHost: true
-          };
-          this.get("hostCheckWarnings").push(hostInfo);
-        } else {
-          if (!hostInfo.hostsNames.contains(targetHostName)) {
-            hostInfo.hosts.push(contextMessage);
-            hostInfo.hostsNames.push(targetHostName);
+        if (!(task.Tasks.status == "COMPLETED" && Em.get(task, "Tasks.structured_out.host_resolution_check.failed_count")
== 0)) {
+          var targetHostName = Em.get(task, "Tasks.host_name");
+          var relatedHostNames = Em.get(task, "Tasks.structured_out.host_resolution_check.failures")
+            ? Em.get(task, "Tasks.structured_out.host_resolution_check.failures").mapProperty('host')
: [];
+          var contextMessage = Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.context').format(targetHostName,
relatedHostNames.join(', '));
+          if (!hostInfo) {
+            hostInfo = {
+              name: name,
+              hosts: [contextMessage],
+              hostsNames: [targetHostName],
+              onSingleHost: true
+            };
+            this.get("hostCheckWarnings").push(hostInfo);
+          } else {
+            if (!hostInfo.hostsNames.contains(targetHostName)) {
+              hostInfo.hosts.push(contextMessage);
+              hostInfo.hostsNames.push(targetHostName);
+            }
           }
         }
-      } else {
-        this.set('stopChecking', false);
       }
     }, this);
-    this.getHostCheckTasks();
+  },
+
+  getHostCheckError: function() {
+    this.getHostInfo();
   },
 
   stopChecking: false,
@@ -983,6 +1054,7 @@ App.WizardStep3Controller = Em.Controller.extend({
 
     // parse host checks warning
     this.parseWarnings(jsonData);
+    this.set('isHostsWarningsLoaded', true);
     hosts.forEach(function (_host) {
       var host = (App.get('testMode')) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name',
_host.name);
       if (App.get('skipBootstrap')) {
@@ -1562,7 +1634,6 @@ App.WizardStep3Controller = Em.Controller.extend({
     });
     this.set('warnings', warnings);
     this.set('warningsByHost', hosts);
-    this.set('isHostsWarningsLoaded', true);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/3eb7ebda/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 0b5ef6d..0afd4b3 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1652,7 +1652,7 @@ var urls = {
   },
 
   'preinstalled.checks.tasks': {
-    'real': '/requests/{requestId}?fields=tasks/Tasks',
+    'real': '/requests/{requestId}?fields=tasks/Tasks,Requests/inputs,Requests/request_status',
     'mock': '/data/requests/host_check/1.json'
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3eb7ebda/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index 43a9d5c..06887a4 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -2478,4 +2478,58 @@ describe('App.WizardStep3Controller', function () {
 
   });
 
+  describe('#getHostCheckTasksSuccess', function() {
+
+    beforeEach(function() {
+      sinon.stub($, 'ajax', Em.K);
+      sinon.stub(c, 'getHostInfo', Em.K);
+      sinon.stub(c, 'parseHostNameResolution', Em.K);
+      sinon.stub(c, 'getGeneralHostCheck', Em.K);
+      sinon.stub(c, 'getHostCheckTasks', Em.K);
+
+    });
+
+    afterEach(function() {
+      $.ajax.restore();
+      c.getHostInfo.restore();
+      c.parseHostNameResolution.restore();
+      c.getGeneralHostCheck.restore();
+      c.getHostCheckTasks.restore();
+    });
+
+    var dataInProgress = {
+      Requests: {
+        request_status: "IN_PROGRESS"
+      }
+    };
+    it('run getHostCheckTasks', function() {
+      c.getHostCheckTasksSuccess(dataInProgress);
+      expect(c.getHostCheckTasks.calledOnce).to.be.true;
+    });
+
+    var hostResolutionCheckComplete = {
+      Requests: {
+        request_status: "COMPLETED",
+        inputs: "host_resolution_check"
+      }
+    };
+    it('run parseHostNameResolution and getGeneralHostCheck', function() {
+      c.getHostCheckTasksSuccess(hostResolutionCheckComplete);
+      expect(c.parseHostNameResolution.calledWith(hostResolutionCheckComplete)).to.be.true;
+      expect(c.getGeneralHostCheck.calledOnce).to.be.true;
+    });
+
+    var lastAgentEnvCheckComplete = {
+      Requests: {
+        request_status: "COMPLETED",
+        inputs: "last_agent_env_check"
+      }
+    };
+    it('run getHostInfo', function() {
+      c.getHostCheckTasksSuccess(lastAgentEnvCheckComplete);
+      expect(c.get('stopChecking')).to.be.true;
+      expect(c.getHostInfo.calledOnce).to.be.true;
+    });
+
+  });
 });


Mime
View raw message