Jelajahi Sumber

AMBARI-4171. Fix UI Unit tests. (onechiporenko)

Oleg Nechiporenko 11 tahun lalu
induk
melakukan
6f17e44c05

+ 1 - 0
ambari-web/test/controllers/main/admin/security/add/step4_test.js

@@ -18,6 +18,7 @@
 
 
 
 
 var App = require('app');
 var App = require('app');
+require('controllers/main/admin/security/security_progress_controller');
 require('controllers/main/admin/security/add/step4');
 require('controllers/main/admin/security/add/step4');
 require('utils/polling');
 require('utils/polling');
 require('models/cluster_states');
 require('models/cluster_states');

+ 0 - 88
ambari-web/test/installer/step3_test.js

@@ -121,12 +121,6 @@ describe('App.WizardStep3Controller', function () {
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
       ],
       ],
       m: 'One registered, one registering',
       m: 'One registered, one registering',
-      allHostsComplete: {
-        e: false
-      },
-      isInstallInProgress: {
-        e: true
-      },
       visibleHosts: {
       visibleHosts: {
         RUNNING: {
         RUNNING: {
           e: 0
           e: 0
@@ -151,12 +145,6 @@ describe('App.WizardStep3Controller', function () {
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
       ],
       ],
       m: 'Two registered',
       m: 'Two registered',
-      allHostsComplete: {
-        e: true
-      },
-      isInstallInProgress: {
-        e: false
-      },
       visibleHosts: {
       visibleHosts: {
         RUNNING: {
         RUNNING: {
           e: 0
           e: 0
@@ -181,12 +169,6 @@ describe('App.WizardStep3Controller', function () {
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
       ],
       ],
       m: 'One registered, one failed',
       m: 'One registered, one failed',
-      allHostsComplete: {
-        e: true
-      },
-      isInstallInProgress: {
-        e: false
-      },
       visibleHosts: {
       visibleHosts: {
         RUNNING: {
         RUNNING: {
           e: 0
           e: 0
@@ -211,12 +193,6 @@ describe('App.WizardStep3Controller', function () {
         Em.Object.create({name:'wst3_host2', bootStatus: 'FAILED', isChecked: false})
         Em.Object.create({name:'wst3_host2', bootStatus: 'FAILED', isChecked: false})
       ],
       ],
       m: 'Two failed',
       m: 'Two failed',
-      allHostsComplete: {
-        e: true
-      },
-      isInstallInProgress: {
-        e: false
-      },
       visibleHosts: {
       visibleHosts: {
         RUNNING: {
         RUNNING: {
           e: 0
           e: 0
@@ -241,12 +217,6 @@ describe('App.WizardStep3Controller', function () {
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
         Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
       ],
       ],
       m: 'Two registering',
       m: 'Two registering',
-      allHostsComplete: {
-        e: false
-      },
-      isInstallInProgress: {
-        e: true
-      },
       visibleHosts: {
       visibleHosts: {
         RUNNING: {
         RUNNING: {
           e: 0
           e: 0
@@ -267,28 +237,6 @@ describe('App.WizardStep3Controller', function () {
     }
     }
   ];
   ];
 
 
-  describe('#allHostsComplete', function() {
-    tests.forEach(function(test) {
-      var controller = App.WizardStep3Controller.create({
-        bootHosts: test.bootHosts
-      });
-      it(test.m, function() {
-        expect(controller.get('allHostsComplete')).to.equal(test.allHostsComplete.e);
-      });
-    });
-  });
-
-  describe('#isInstallInProgress', function() {
-    tests.forEach(function(test) {
-      var controller = App.WizardStep3Controller.create({
-        bootHosts: test.bootHosts
-      });
-      it(test.m, function() {
-        expect(controller.get('isInstallInProgress')).to.equal(test.isInstallInProgress.e);
-      });
-    });
-  });
-
   describe('#registrationTimeoutSecs', function() {
   describe('#registrationTimeoutSecs', function() {
     it('Manual install', function() {
     it('Manual install', function() {
       var controller = App.WizardStep3Controller.create({
       var controller = App.WizardStep3Controller.create({
@@ -312,30 +260,6 @@ describe('App.WizardStep3Controller', function () {
     });
     });
   });
   });
 
 
-  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() {
   describe('#isHostHaveWarnings', function() {
     var tests = [
     var tests = [
       {
       {
@@ -358,18 +282,6 @@ describe('App.WizardStep3Controller', function () {
     });
     });
   });
   });
 
 
-  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() {
   describe('#noHostsSelected', function() {
     tests.forEach(function(test) {
     tests.forEach(function(test) {
       it(test.m + ' - nothing checked', function() {
       it(test.m + ' - nothing checked', function() {

+ 11 - 6
ambari-web/test/installer/step4_test.js

@@ -68,13 +68,18 @@ describe('App.WizardStep4Controller', function () {
     });
     });
   });
   });
 
 
+  var ajax_send;
   describe('#checkDependencies()', function () {
   describe('#checkDependencies()', function () {
-    /*it('should set ZooKeeper isSelected property like in HBase', function () {
-      controller.setEach('isSelected', false);
-      controller.findProperty('serviceName', 'HBASE').set('isSelected', true);
-      controller.checkDependencies();
-      expect(controller.findProperty('serviceName', 'ZOOKEEPER').get('isSelected')).to.equal(true);
-    });*/
+
+    beforeEach(function() {
+      ajax_send = App.ajax.send;
+      App.ajax.send = function() {};
+    });
+
+    afterEach(function() {
+      App.ajax.send = ajax_send;
+    });
+
     it('should set ZooKeeper, HCatalog, WebHCatalog isSelected property like in Hive', function () {
     it('should set ZooKeeper, HCatalog, WebHCatalog isSelected property like in Hive', function () {
       controller.setEach('isSelected', false);
       controller.setEach('isSelected', false);
       controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
       controller.findProperty('serviceName', 'HIVE').set('isSelected', true);

+ 22 - 20
ambari-web/test/views/common/quick_link_view_test.js

@@ -25,35 +25,37 @@ describe('App.QuickViewLinks', function () {
 
 
   describe('#setPort', function () {
   describe('#setPort', function () {
     var testData = [
     var testData = [
-      {
-        'service_id': 'HDFS',
-        'protocol': 'https',
-        'version': '2.0.6',
-        'result': ''
-      },
-      {
+      Em.Object.create({
         'service_id': 'YARN',
         'service_id': 'YARN',
         'protocol': 'http',
         'protocol': 'http',
-        'version': '2.0.6',
-        'result': '8088'
-      },
-      {
+        'result': '8088',
+        'default_http_port': '8088',
+        'default_https_port': '8090',
+        'regex': '\\w*:(\\d+)'
+      }),
+      Em.Object.create({
         'service_id': 'YARN',
         'service_id': 'YARN',
         'protocol': 'https',
         'protocol': 'https',
-        'version': '2.0.5',
-        'result': '8088'
-      },
-      {
+        'https_config': 'https_config',
+        'result': '8090',
+        'default_http_port': '8088',
+        'default_https_port': '8090',
+        'regex': '\\w*:(\\d+)'
+      }),
+      Em.Object.create({
         'service_id': 'YARN',
         'service_id': 'YARN',
         'protocol': 'https',
         'protocol': 'https',
-        'version': '2.0.6',
-        'result': '8090'
-      },
+        'https_config': 'https_config',
+        'result': '8090',
+        'default_http_port': '8088',
+        'default_https_port': '8090',
+        'regex': '\\w*:(\\d+)'
+      })
     ];
     ];
 
 
     testData.forEach(function(item) {
     testData.forEach(function(item) {
-      it('should return empty string if service_id is not YARN, 8090 if protocol is https and stack version higher than 2.0.5, http otherwise', function () {
-        expect(quickViewLinks.setPort(item.service_id, item.protocol, item.version)).to.equal(item.result);
+      it(item.service_id + ' ' + item.protocol, function () {
+        expect(quickViewLinks.setPort(item, item.protocol, item.version)).to.equal(item.result);
       })
       })
     },this);
     },this);
   });
   });

+ 3 - 2
ambari-web/test/views/main/dashboard/widgets/node_managers_live_test.js

@@ -71,8 +71,9 @@ describe('App.NodeManagersLiveView', function() {
   ];
   ];
 
 
   tests.forEach(function(test) {
   tests.forEach(function(test) {
-    describe('nodeManagerNodes length - ' + test.model.nodeManagerNodes.length + ' | nodeManagerLiveNodes length' + test.model.nodeManagerLiveNodes.length, function() {
-      var nodeManagersLiveView = App.NodeManagersLiveView.create({model_type:null, model: test.model});
+    describe('nodeManagerNodes length - ' + test.model.nodeManagerNodes.length + ' | nodeManagerLiveNodes length - ' + test.model.nodeManagerLiveNodes.length, function() {
+      var AppNodeManagersLiveView = App.NodeManagersLiveView.extend({nodeManagersLive: test.model.nodeManagerLiveNodes});
+      var nodeManagersLiveView = AppNodeManagersLiveView.create({model_type:null, model: test.model});
       it('content', function() {
       it('content', function() {
         expect(nodeManagersLiveView.get('content')).to.equal(test.e.content);
         expect(nodeManagersLiveView.get('content')).to.equal(test.e.content);
       });
       });