فهرست منبع

AMBARI-14663. Ambari Web UT failure in trunk (App.InstallerStep7Controller) (onechiporenko)

Oleg Nechiporenko 9 سال پیش
والد
کامیت
8ae2c8b7c7

+ 25 - 11
ambari-web/test/controllers/wizard/step7_test.js

@@ -108,7 +108,11 @@ function getController() {
 describe('App.InstallerStep7Controller', function () {
 
   beforeEach(function () {
-    sinon.stub(App.ajax, 'send', Em.K);
+    sinon.stub(App.ajax, 'send', function () {
+      return {
+        then: Em.K
+      }
+    });
     sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
     installerStep7Controller = getController();
   });
@@ -1169,6 +1173,7 @@ describe('App.InstallerStep7Controller', function () {
   });
 
   describe('#updateHawqConfigs', function() {
+    var isSingleNode = false;
     var testHawqSiteConfigs = [
       {
         name: 'hawq_standby_address_host',
@@ -1180,24 +1185,33 @@ describe('App.InstallerStep7Controller', function () {
       }
     ];
     var oldHawqSiteLength = testHawqSiteConfigs.length;
+
+    beforeEach(function () {
+      sinon.stub(App, 'get', function () {
+        return isSingleNode;
+      });
+    });
+
+    afterEach(function () {
+      App.get.restore()
+    });
+
     it('hawq_standby_address_host should be removed on single node cluster', function() {
-      sinon.stub(App, 'get').withArgs('isSingleNode').returns(true);
+      isSingleNode = true;
       var hawqSiteConfigs = testHawqSiteConfigs.slice();
       var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
-      expect(updatedHawqSiteConfigs.length).to.be.eql(oldHawqSiteLength-1);
-      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host')).to.be.eql(undefined);
-      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.eql('h1');
-      App.get.restore()
+      expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength-1);
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host')).to.not.exist;
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
     });
 
     it('hawq_standby_address_host should not be removed on multi node clusters', function() {
-      sinon.stub(App, 'get').withArgs('isSingleNode').returns(false);
+      isSingleNode = false;
       var hawqSiteConfigs = testHawqSiteConfigs.slice();
       var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
-      expect(updatedHawqSiteConfigs.length).to.be.eql(oldHawqSiteLength);
-      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host').value).to.be.eql('h2');
-      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.eql('h1');
-      App.get.restore();
+      expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength);
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host').value).to.be.equal('h2');
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
     });
 
   });

+ 6 - 6
ambari-web/test/mixins/common/configs/config_recommendation_parser_test.js

@@ -19,7 +19,7 @@
 var App = require('app');
 
 describe('App.ConfigRecommendationParser', function() {
-  var mixinObject =  Em.Controller.extend(App.ConfigRecommendationParser, {});
+  var mixinObject = Em.Controller.extend(App.ConfigRecommendationParser, {});
   var instanceObject = mixinObject.create({});
 
   var recommendationObject = {
@@ -97,12 +97,12 @@ describe('App.ConfigRecommendationParser', function() {
       });
 
       it('updateBoundariesCallback maximum', function() {
-        expect(instanceObject.updateBoundariesCallback.calledWith({ name: 'p3',  filename: 'fileName1' },
+        expect(instanceObject.updateBoundariesCallback.calledWith({ name: 'p3', filename: 'fileName1' },
           'maximum', 100, null)).to.be.true;
       });
 
       it('updateBoundariesCallback minimum', function() {
-        expect(instanceObject.updateBoundariesCallback.calledWith({ name: 'p3',  filename: 'fileName1' },
+        expect(instanceObject.updateBoundariesCallback.calledWith({ name: 'p3', filename: 'fileName1' },
           'minimum', 1, null)).to.be.true;
       });
     });
@@ -121,7 +121,7 @@ describe('App.ConfigRecommendationParser', function() {
   });
 
   describe('#addByRecommendations', function(){
-    var recommendationObject = {
+    var _recommendationObject = {
       'file-name': {
         'properties': {
           'p1': 'v1'
@@ -151,7 +151,7 @@ describe('App.ConfigRecommendationParser', function() {
             'name': 'p1',
             'filename': 'file-name'
           }));
-          instanceObject.addByRecommendations(recommendationObject, []);
+          instanceObject.addByRecommendations(_recommendationObject, []);
         });
 
         afterEach(function() {
@@ -316,7 +316,7 @@ describe('App.ConfigRecommendationParser', function() {
       expect(instanceObject._removeConfigByRecommendation.bind(instanceObject, null)).to.throw(App.ObjectTypeError);
     });
 
-    it('throws error', function() {
+    it('throws error (2)', function() {
       expect(instanceObject._removeConfigByRecommendation.bind(instanceObject, {}, null)).to.throw(App.ArrayTypeError);
     });
   });

+ 2 - 2
ambari-web/test/mixins/main/host/details/host_components/install_component_test.js

@@ -56,7 +56,7 @@ describe('App.InstallComponent', function () {
           component: component,
           data: JSON.stringify({
             RequestInfo: {
-              "context": Em.I18n.t('requestInfo.installHostComponent') + " " + 'c1'
+              "context": Em.I18n.t('requestInfo.installHostComponent') + ' c1'
             },
             Body: {
               host_components: [
@@ -103,7 +103,7 @@ describe('App.InstallComponent', function () {
           componentName: 'C1',
           serviceName: 'S1',
           component: params.component,
-          "context": Em.I18n.t('requestInfo.installNewHostComponent') + " " + 'c1',
+          "context": Em.I18n.t('requestInfo.installNewHostComponent') + ' c1',
           HostRoles: {
             state: 'INSTALLED'
           },