incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject [2/2] git commit: AMBARI-3307. Fix Unit tests and create new test for step3 installer. (onechiporenko)
Date Mon, 23 Sep 2013 15:29:06 GMT
AMBARI-3307. Fix Unit tests and create new test for step3 installer. (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 8bb6cdc2aef9ecb2180813d6468c08e91d897846
Parents: 8f4ab52
Author: Oleg Nechiporenko <cv_github@yahoo.com>
Authored: Mon Sep 23 18:17:53 2013 +0300
Committer: Oleg Nechiporenko <cv_github@yahoo.com>
Committed: Mon Sep 23 18:28:55 2013 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 -
 .../app/controllers/wizard/step3_controller.js  |   3 +-
 .../main/service/reassign_controller_test.js    |   2 +-
 ambari-web/test/installer/step14_test.js        | 152 --------------
 ambari-web/test/installer/step3_test.js         | 209 ++++++++++++++++++-
 5 files changed, 201 insertions(+), 166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8bb6cdc2/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 62ca5c6..21fdfca 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -50,7 +50,6 @@ require('test/installer/step5_test');
 require('test/installer/step6_test');
 require('test/installer/step7_test');
 require('test/installer/step10_test');
-require('test/installer/step14_test');
 require('test/login_test');
 require('test/mappers/server_data_mapper_test');
 require('test/mappers/dataset_mapper_test');

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8bb6cdc2/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 5ac9937..4e4d80b 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/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) */
   visibleHosts: function () {
-    var self = this;
     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')
       return this.hosts;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8bb6cdc2/ambari-web/test/controllers/main/service/reassign_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign_controller_test.js b/ambari-web/test/controllers/main/service/reassign_controller_test.js
index 3d3401b..ce14c00 100644
--- a/ambari-web/test/controllers/main/service/reassign_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign_controller_test.js
@@ -27,7 +27,7 @@ describe('App.ReassignMasterController', function () {
 
   describe('#totalSteps', function () {
     it('check', function () {
-      expect(reassignMasterController.get('totalSteps')).to.equal(6);
+      expect(reassignMasterController.get('totalSteps')).to.equal(4);
     });
   });
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8bb6cdc2/ambari-web/test/installer/step14_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/installer/step14_test.js b/ambari-web/test/installer/step14_test.js
deleted file mode 100644
index 039ebb9..0000000
--- a/ambari-web/test/installer/step14_test.js
+++ /dev/null
@@ -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');
-    });
-  });
-
-});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8bb6cdc2/ambari-web/test/installer/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/installer/step3_test.js b/ambari-web/test/installer/step3_test.js
index 648756e..d351c9e 100644
--- a/ambari-web/test/installer/step3_test.js
+++ b/ambari-web/test/installer/step3_test.js
@@ -117,8 +117,8 @@ describe('App.WizardStep3Controller', function () {
   var tests = [
     {
       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',
       allHostsComplete: {
@@ -126,12 +126,29 @@ describe('App.WizardStep3Controller', function () {
       },
       isInstallInProgress: {
         e: true
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 1
+        },
+        REGISTERED: {
+          e: 1
+        },
+        FAILED: {
+          e: 0
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
     },
     {
       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',
       allHostsComplete: {
@@ -139,12 +156,29 @@ describe('App.WizardStep3Controller', function () {
       },
       isInstallInProgress: {
         e: false
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 0
+        },
+        REGISTERED: {
+          e: 2
+        },
+        FAILED: {
+          e: 0
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
     },
     {
       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',
       allHostsComplete: {
@@ -152,12 +186,29 @@ describe('App.WizardStep3Controller', function () {
       },
       isInstallInProgress: {
         e: false
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 0
+        },
+        REGISTERED: {
+          e: 1
+        },
+        FAILED: {
+          e: 1
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
     },
     {
       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',
       allHostsComplete: {
@@ -165,12 +216,29 @@ describe('App.WizardStep3Controller', function () {
       },
       isInstallInProgress: {
         e: false
+      },
+      visibleHosts: {
+        RUNNING: {
+          e: 0
+        },
+        REGISTERING: {
+          e: 0
+        },
+        REGISTERED: {
+          e: 0
+        },
+        FAILED: {
+          e: 2
+        }
+      },
+      onAllChecked: {
+        e: [true, true]
       }
     },
     {
       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',
       allHostsComplete: {
@@ -178,6 +246,23 @@ describe('App.WizardStep3Controller', function () {
       },
       isInstallInProgress: {
         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);
+      });
+    });
+  });
+
+
+
 });
\ No newline at end of file


Mime
View raw message