Browse Source

AMBARI-9810 Install wizard: request to start host check failed. (ababiichuk)

aBabiichuk 10 years ago
parent
commit
e413297025

+ 15 - 5
ambari-web/app/controllers/wizard/step3_controller.js

@@ -855,7 +855,7 @@ App.WizardStep3Controller = Em.Controller.extend({
       this.getHostCheckSuccess();
     } else {
       var data = this.getDataForCheckRequest("host_resolution_check", true);
-      this.requestToPerformHostCheck(data);
+      data ? this.requestToPerformHostCheck(data) : this.stopHostCheck();
     }
   },
 
@@ -864,10 +864,20 @@ App.WizardStep3Controller = Em.Controller.extend({
       this.getHostInfo();
     } else {
       var data = this.getDataForCheckRequest("last_agent_env_check", false);
-      this.requestToPerformHostCheck(data);
+      data ? this.requestToPerformHostCheck(data) : this.stopHostCheck();
     }
   },
 
+  /**
+   * set all fields from which depends runnig host check to true value
+   * which force finish checking;
+   */
+  stopHostCheck: function() {
+    this.set('stopChecking', true);
+    this.set('isJDKWarningsLoaded', true);
+    this.set('isHostsWarningsLoaded', true);
+  },
+
   getHostCheckSuccess: function(response) {
     if (!App.get('testMode')) {
       this.set("requestId", response.Requests.id);
@@ -881,12 +891,12 @@ App.WizardStep3Controller = Em.Controller.extend({
    *  <code>"last_agent_env_check"<code>
    *  <code>"host_resolution_check"<code>
    * @param {boolean} addHosts - true
+   * @return {object|null}
    * @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 hosts = this.get('bootHosts').filterProperty('bootStatus', 'REGISTERED').getEach('name').join(",");
+    if (hosts.length == 0) return null;
     var jdk_location = App.router.get('clusterController.ambariProperties.jdk_location');
     var RequestInfo = {
       "action": "check_host",

+ 73 - 0
ambari-web/test/controllers/wizard/step3_test.js

@@ -2532,4 +2532,77 @@ describe('App.WizardStep3Controller', function () {
     });
 
   });
+
+  describe('#getDataForCheckRequest', function() {
+    var tests = [
+      {
+        bootHosts: [
+          Em.Object.create({'bootStatus': 'REGISTERED', 'name': 'h1'}),
+          Em.Object.create({'bootStatus': 'FAILED', 'name': 'h2'})
+        ],
+        addHosts: true,
+        rez: {
+          RequestInfo: {
+            "action": "check_host",
+            "context": "Check host",
+            "parameters": {
+              "check_execute_list": 'checkExecuteList',
+              "jdk_location" : "jdk_location",
+              "threshold": "20",
+              "hosts": "h1"
+            }
+          },
+          resource_filters: {
+              "hosts": "h1"
+          }
+        },
+        m: 'with add host param'
+      },
+      {
+        bootHosts: [
+          Em.Object.create({'bootStatus': 'REGISTERED', 'name': 'h1'}),
+          Em.Object.create({'bootStatus': 'FAILED', 'name': 'h2'})
+        ],
+        addHosts: false,
+        rez: {
+          RequestInfo: {
+            "action": "check_host",
+            "context": "Check host",
+            "parameters": {
+              "check_execute_list": 'checkExecuteList',
+              "jdk_location" : "jdk_location",
+              "threshold": "20"
+            }
+          },
+          resource_filters: {
+            "hosts": "h1"
+          }
+        },
+        m: 'without add host param'
+      },
+      {
+        bootHosts: [
+          Em.Object.create({'bootStatus': 'FAILED', 'name': 'h1'}),
+          Em.Object.create({'bootStatus': 'FAILED', 'name': 'h2'})
+        ],
+        rez: null,
+        m: 'with all hosts failed'
+      }
+    ];
+
+    beforeEach(function() {
+      sinon.stub(App.get('router'), 'get' , function(p) {
+        return p === 'clusterController.ambariProperties.jdk_location' ? 'jdk_location' : Em.get(App.get('router'), p);
+      })
+    });
+    afterEach(function() {
+      App.get('router').get.restore();
+    });
+    tests.forEach(function(t) {
+      it(t.m, function() {
+        c.set('bootHosts', t.bootHosts);
+        expect(c.getDataForCheckRequest('checkExecuteList', t.addHosts)).to.be.eql(t.rez);
+      });
+    })
+  });
 });