Browse Source

AMBARI-3307. Fix Unit tests and create new test for step3 installer. (onechiporenko)

Oleg Nechiporenko 11 years ago
parent
commit
8bb6cdc2ae

+ 0 - 1
ambari-web/app/assets/test/tests.js

@@ -50,7 +50,6 @@ require('test/installer/step5_test');
 require('test/installer/step6_test');
 require('test/installer/step6_test');
 require('test/installer/step7_test');
 require('test/installer/step7_test');
 require('test/installer/step10_test');
 require('test/installer/step10_test');
-require('test/installer/step14_test');
 require('test/login_test');
 require('test/login_test');
 require('test/mappers/server_data_mapper_test');
 require('test/mappers/server_data_mapper_test');
 require('test/mappers/dataset_mapper_test');
 require('test/mappers/dataset_mapper_test');

+ 1 - 2
ambari-web/app/controllers/wizard/step3_controller.js

@@ -188,9 +188,8 @@ App.WizardStep3Controller = Em.Controller.extend({
 
 
   /* Returns the current set of visible hosts on view (All, Succeeded, Failed) */
   /* Returns the current set of visible hosts on view (All, Succeeded, Failed) */
   visibleHosts: function () {
   visibleHosts: function () {
-    var self = this;
     if (this.get('category.hostsBootStatus')) {
     if (this.get('category.hostsBootStatus')) {
-      return this.hosts.filterProperty('bootStatus', self.get('category.hostsBootStatus'));
+      return this.hosts.filterProperty('bootStatus', this.get('category.hostsBootStatus'));
     } else { // if (this.get('category') === 'All Hosts')
     } else { // if (this.get('category') === 'All Hosts')
       return this.hosts;
       return this.hosts;
     }
     }

+ 1 - 1
ambari-web/test/controllers/main/service/reassign_controller_test.js

@@ -27,7 +27,7 @@ describe('App.ReassignMasterController', function () {
 
 
   describe('#totalSteps', function () {
   describe('#totalSteps', function () {
     it('check', function () {
     it('check', function () {
-      expect(reassignMasterController.get('totalSteps')).to.equal(6);
+      expect(reassignMasterController.get('totalSteps')).to.equal(4);
     });
     });
   });
   });
 
 

+ 0 - 152
ambari-web/test/installer/step14_test.js

@@ -1,152 +0,0 @@
-/**
- * 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.
- */
-
-var App = require('app');
-require('utils/config');
-require('controllers/wizard/step14_controller');
-
-describe('App.WizardStep14Controller', function() {
-  var tasks = [
-    Em.Object.create({status:''}),
-    Em.Object.create({status:''}),
-    Em.Object.create({status:''}),
-    Em.Object.create({status:''}),
-    Em.Object.create({status:''}),
-    Em.Object.create({status:''}),
-    Em.Object.create({status:''}),
-    Em.Object.create({status:''})
-  ];
-
-  var tests = [
-    {
-      m: 'onStopServiceBeforeSend',
-      t: 0,
-      s: 'PENDING'
-    },
-    {
-      m: 'onStopServiceError',
-      t: 0,
-      s: 'FAILED'
-    },
-    {
-      m: 'onCreateMasterComponentBeforeSend',
-      t: 1,
-      s: 'PENDING'
-    },
-    {
-      m: 'onCreateMasterComponentSuccess',
-      t: 1,
-      s: 'COMPLETED'
-    },
-    {
-      m: 'onCreateMasterComponentError',
-      t: 1,
-      s: 'FAILED'
-    },
-    {
-      m: 'onCreateConfigsError',
-      t: 2,
-      s: 'FAILED'
-    },
-    {
-      m: 'onCheckConfigsError',
-      t: 3,
-      s: 'FAILED'
-    },
-    {
-      m: 'onApplyConfigsSuccess',
-      t: 3,
-      s: 'COMPLETED'
-    },
-    {
-      m: 'onApplyConfigsError',
-      t: 3,
-      s: 'FAILED'
-    },
-    {
-      m: 'onPutInMaintenanceModeBeforeSend',
-      t: 4,
-      s: 'PENDING'
-    },
-    {
-      m: 'onPutInMaintenanceModeSuccess',
-      t: 4,
-      s: 'COMPLETED'
-    },
-    {
-      m: 'onPutInMaintenanceModeError',
-      t: 4,
-      s: 'FAILED'
-    },
-    {
-      m: 'onInstallComponentBeforeSend',
-      t: 5,
-      s: 'PENDING'
-    },
-    {
-      m: 'onInstallComponentError',
-      t: 5,
-      s: 'FAILED'
-    },
-    {
-      m: 'onStartComponentsBeforeSend',
-      t: 6,
-      s: 'PENDING'
-    },
-    {
-      m: 'onStartComponentsError',
-      t: 6,
-      s: 'FAILED'
-    },
-    {
-      m: 'onRemoveComponentBeforeSend',
-      t: 7,
-      s: 'PENDING'
-    },
-    {
-      m: 'onRemoveComponentSuccess',
-      t: 7,
-      s: 'COMPLETED'
-    },
-    {
-      m: 'onRemoveComponentError',
-      t: 7,
-      s: 'FAILED'
-    }
-  ];
-
-  tests.forEach(function(test) {
-    describe('#' + test.m, function() {
-      it('Task #'+test.t+' should be '+test.s, function() {
-        var wizardStep14Controller = App.WizardStep14Controller.create();
-        wizardStep14Controller.set('tasks', tasks);
-        wizardStep14Controller[test.m]();
-        expect(wizardStep14Controller.get('tasks')[test.t].get('status')).to.equal(test.s);
-      });
-    });
-  });
-
-  describe('#onGetLogsByRequestError', function() {
-    it('', function() {
-      var wizardStep14Controller = App.WizardStep14Controller.create();
-      wizardStep14Controller.onGetLogsByRequestError();
-      expect(wizardStep14Controller.get('status')).to.equal('FAILED');
-    });
-  });
-
-});

+ 199 - 10
ambari-web/test/installer/step3_test.js

@@ -117,8 +117,8 @@ describe('App.WizardStep3Controller', function () {
   var tests = [
   var tests = [
     {
     {
       bootHosts: [
       bootHosts: [
-        Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERED'}),
-        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING'})
+        Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERED', isChecked: false}),
+        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
       ],
       ],
       m: 'One registered, one registering',
       m: 'One registered, one registering',
       allHostsComplete: {
       allHostsComplete: {
@@ -126,12 +126,29 @@ describe('App.WizardStep3Controller', function () {
       },
       },
       isInstallInProgress: {
       isInstallInProgress: {
         e: true
         e: true
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 1
+        },
+        REGISTERED: {
+          e: 1
+        },
+        FAILED: {
+          e: 0
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
       }
     },
     },
     {
     {
       bootHosts: [
       bootHosts: [
-        Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERED'}),
-        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED'})
+        Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERED', isChecked: false}),
+        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
       ],
       ],
       m: 'Two registered',
       m: 'Two registered',
       allHostsComplete: {
       allHostsComplete: {
@@ -139,12 +156,29 @@ describe('App.WizardStep3Controller', function () {
       },
       },
       isInstallInProgress: {
       isInstallInProgress: {
         e: false
         e: false
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 0
+        },
+        REGISTERED: {
+          e: 2
+        },
+        FAILED: {
+          e: 0
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
       }
     },
     },
     {
     {
       bootHosts: [
       bootHosts: [
-        Em.Object.create({name:'wst3_host1', bootStatus: 'FAILED'}),
-        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED'})
+        Em.Object.create({name:'wst3_host1', bootStatus: 'FAILED', isChecked: false}),
+        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
       ],
       ],
       m: 'One registered, one failed',
       m: 'One registered, one failed',
       allHostsComplete: {
       allHostsComplete: {
@@ -152,12 +186,29 @@ describe('App.WizardStep3Controller', function () {
       },
       },
       isInstallInProgress: {
       isInstallInProgress: {
         e: false
         e: false
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 0
+        },
+        REGISTERED: {
+          e: 1
+        },
+        FAILED: {
+          e: 1
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
       }
     },
     },
     {
     {
       bootHosts: [
       bootHosts: [
-        Em.Object.create({name:'wst3_host1', bootStatus: 'FAILED'}),
-        Em.Object.create({name:'wst3_host2', bootStatus: 'FAILED'})
+        Em.Object.create({name:'wst3_host1', bootStatus: 'FAILED', isChecked: false}),
+        Em.Object.create({name:'wst3_host2', bootStatus: 'FAILED', isChecked: false})
       ],
       ],
       m: 'Two failed',
       m: 'Two failed',
       allHostsComplete: {
       allHostsComplete: {
@@ -165,12 +216,29 @@ describe('App.WizardStep3Controller', function () {
       },
       },
       isInstallInProgress: {
       isInstallInProgress: {
         e: false
         e: false
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 0
+        },
+        REGISTERED: {
+          e: 0
+        },
+        FAILED: {
+          e: 2
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
       }
     },
     },
     {
     {
       bootHosts: [
       bootHosts: [
-        Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERING'}),
-        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING'})
+        Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERING', isChecked: false}),
+        Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
       ],
       ],
       m: 'Two registering',
       m: 'Two registering',
       allHostsComplete: {
       allHostsComplete: {
@@ -178,6 +246,23 @@ describe('App.WizardStep3Controller', function () {
       },
       },
       isInstallInProgress: {
       isInstallInProgress: {
         e: true
         e: true
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 2
+        },
+        REGISTERED: {
+          e: 0
+        },
+        FAILED: {
+          e: 0
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
       }
     }
     }
   ];
   ];
@@ -203,4 +288,108 @@ describe('App.WizardStep3Controller', function () {
       });
       });
     });
     });
   });
   });
+
+  describe('#registrationTimeoutSecs', function() {
+    it('Manual install', function() {
+      var controller = App.WizardStep3Controller.create({
+        content: {
+          installOptions: {
+            manualInstall: true
+          }
+        }
+      });
+      expect(controller.get('registrationTimeoutSecs')).to.equal(15);
+    });
+    it('Not manual install', function() {
+      var controller = App.WizardStep3Controller.create({
+        content: {
+          installOptions: {
+            manualInstall: false
+          }
+        }
+      });
+      expect(controller.get('registrationTimeoutSecs')).to.equal(120);
+    });
+  });
+
+  describe('#visibleHosts', function() {
+    var c = ['RUNNING', 'REGISTERING', 'REGISTERED', 'FAILED'];
+    tests.forEach(function(test) {
+      describe(test.m, function() {
+        c.forEach(function(_c) {
+          var controller = App.WizardStep3Controller.create({
+            hosts: test.bootHosts
+          });
+          controller.set('category', {hostsBootStatus: _c});
+          it(_c, function() {
+            expect(controller.get('visibleHosts').length).to.equal(test.visibleHosts[_c].e);
+          });
+        });
+        var controller = App.WizardStep3Controller.create({
+          hosts: test.bootHosts
+        });
+        controller.set('category', false);
+        it('ALL', function() {
+          expect(controller.get('visibleHosts').length).to.equal(test.bootHosts.length);
+        });
+      });
+    });
+  });
+
+  describe('#isHostHaveWarnings', function() {
+    var tests = [
+      {
+        warnings: [{},{}],
+        m: 'Warnings exist',
+        e: true
+      },
+      {
+        warnings: [],
+        m: 'Warnings don\'t exist',
+        e: false
+      }
+    ];
+    tests.forEach(function(test) {
+      var controller = App.WizardStep3Controller.create();
+      controller.set('warnings', test.warnings);
+      it(test.m, function() {
+        expect(controller.get('isHostHaveWarnings')).to.equal(test.e);
+      });
+    });
+  });
+
+  describe('#onAllChecked', function() {
+    tests.forEach(function(test) {
+      var controller = App.WizardStep3Controller.create({
+        hosts: test.bootHosts
+      });
+      controller.set('allChecked', true);
+      it(test.m, function() {
+        expect(controller.get('visibleHosts').getEach('isChecked')).to.eql(test.onAllChecked.e);
+      });
+    });
+  });
+
+  describe('#noHostsSelected', function() {
+    tests.forEach(function(test) {
+      it(test.m + ' - nothing checked', function() {
+        var controller = App.WizardStep3Controller.create({
+          hosts: test.bootHosts
+        });
+        controller.get('hosts').setEach('isChecked', false);
+        console.log(controller.hosts);
+        expect(controller.get('noHostsSelected')).to.equal(true);
+      });
+      it(test.m + ' - one checked', function() {
+        var controller = App.WizardStep3Controller.create({
+          hosts: test.bootHosts
+        });
+        controller.get('hosts').setEach('isChecked', true);
+        expect(controller.get('noHostsSelected')).to.equal(false);
+      });
+    });
+  });
+
+
+
 });
 });