Bladeren bron

Admin Web > Version Management add unit tests and small fix for host counters. (ababiichuk)

aBabiichuk 10 jaren geleden
bovenliggende
commit
2ec55887c0

+ 15 - 6
ambari-web/app/controllers/main/admin/stack_versions/repo_version_management_controller.js

@@ -52,6 +52,10 @@ App.RepoVersionsManagementController = Em.ArrayController.extend({
     return App.apiPrefix + '/clusters/' + App.get('clusterName') + '/stack_versions?fields=*,repository_versions/*,repository_versions/operatingSystems/repositories/*';
   }.property('App.clusterName'),
 
+  /**
+   * api to get ClusterStackVersions without repository_versions (use to update data)
+   * @type {String}
+   */
   realUpdateUrl: function () {
     return App.apiPrefix + '/clusters/' + App.get('clusterName') + '/stack_versions?fields=ClusterStackVersions/*';
   }.property('App.clusterName'),
@@ -106,6 +110,11 @@ App.RepoVersionsManagementController = Em.ArrayController.extend({
     return dfd.promise();
   },
 
+  /**
+   * loads all needed data
+   * @returns {$.Deferred().promise()}
+   * @method load
+   */
   load: function() {
     var dfd = $.Deferred();
     var self = this;
@@ -157,21 +166,21 @@ App.RepoVersionsManagementController = Em.ArrayController.extend({
    */
   showHosts: function(event) {
     var self = this;
-    var status = event.currentTarget.title.toCapital();
-    var version = event.contexts[0];
-    var hosts = event.contexts[1];
+    var status = event.contexts[0];
+    var version = event.contexts[1];
+    var hosts = event.contexts[2];
     if (hosts.length) {
       return App.ModalPopup.show({
         bodyClass: Ember.View.extend({
-          title: Em.I18n.t('admin.stackVersions.hosts.popup.title').format(version, status, hosts.length),
+          title: Em.I18n.t('admin.stackVersions.hosts.popup.title').format(version, status.label, hosts.length),
           template: Em.Handlebars.compile('<h4>{{view.title}}</h4><span class="limited-height-2">'+ hosts.join('<br/>') + '</span>')
         }),
-        header: Em.I18n.t('admin.stackVersions.hosts.popup.header').format(status),
+        header: Em.I18n.t('admin.stackVersions.hosts.popup.header').format(status.label),
         primary: Em.I18n.t('admin.stackVersions.hosts.popup.primary'),
         secondary: Em.I18n.t('common.close'),
         onPrimary: function() {
           this.hide();
-          self.filterHostsByStack(version, status);
+          self.filterHostsByStack(version, status.id);
         }
       });
     }

+ 7 - 1
ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js

@@ -25,7 +25,13 @@ App.RepoVersionsController = App.RepoVersionsManagementController.extend({
     return App.RepositoryVersion.find().filterProperty('stackVersion', null);
   }.property('dataIsLoaded'),
 
+  /**
+   * installs repoversion to the cluster by running <code>installRepoVersion<code> method
+   * of <code>mainStackVersionsDetailsController<code> controller
+   * @param event
+   * @method installRepoVersion
+   */
   installRepoVersion: function(event) {
-   App.get('router.mainStackVersionsDetailsController').installRepoVersion(event);
+    App.get('router.mainStackVersionsDetailsController').installRepoVersion(event);
   }
 });

+ 4 - 12
ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js

@@ -29,14 +29,6 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    */
   timeoutRef: null,
 
-  /**
-   * amount of all hosts installed on cluster
-   * @type {Number}
-   */
-  totalHostCount: function() {
-    return App.get('allHostNames.length');
-  }.property('App.allHostNames.length'),
-
   /**
    * true if stack version install is in progress
    * @type {Boolean}
@@ -86,7 +78,7 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    * @type {Number}
    */
   hostsToInstall: function() {
-    return this.get('content.stackVersion') ? this.get('content.stackVersion.initHosts.length') : this.get('totalHostCount');
+    return this.get('content.stackVersion') ? this.get('content.stackVersion.initHosts.length') : App.get('allHostNames.length');
   }.property('content.stackVersion.initHosts.length'),
 
   /**
@@ -100,7 +92,7 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    * @method showProgressPopup
    */
   showProgressPopup: function() {
-    var popupTitle = Em.I18n.t('admin.stackVersions.datails.install.hosts.popup.title').format(this.get('content.displayName'));
+    var popupTitle = Em.I18n.t('admin.stackVersions.details.install.hosts.popup.title').format(this.get('content.displayName'));
     var requestIds = App.get('testMode') ? [1] : App.db.get('repoVersion', 'id');
     var hostProgressPopupController = App.router.get('highAvailabilityProgressPopupController');
     hostProgressPopupController.initPopup(popupTitle, requestIds, this);
@@ -172,7 +164,7 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
       name: 'admin.stack_version.install.repo_version',
       sender: this,
       data: data,
-      success: 'installStackVersionSuccess'
+      success: 'installRepoVersionSuccess'
     });
   },
 
@@ -185,7 +177,7 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    * @param params
    * @method installStackVersionSuccess
    */
-  installStackVersionSuccess: function (data, opt, params) {
+  installRepoVersionSuccess: function (data, opt, params) {
     var self = this;
     App.db.set('repoVersion', 'id', [data.Requests.id]);
     App.get('router.repoVersionsManagementController').loadStackVersionsToModel(true).done(function() {

+ 19 - 14
ambari-web/app/messages.js

@@ -1286,20 +1286,25 @@ Em.I18n.translations = {
   'admin.stackVersions.table.empty': "No cluster stack versions to display",
   'admin.repoVersions.table.empty': "No repository versions to display",
 
-  'admin.stackVersions.datails.versionName': "Version Name",
-  'admin.stackVersions.datails.installed.on': "Installed On",
-  'admin.stackVersions.datails.current.on': "Current On",
-  'admin.stackVersions.datails.not.installed.on': "Not installed on",
-  'admin.stackVersions.datails.base.url': "Base Url",
-
-  'admin.stackVersions.datails.hosts.btn.reinstall': "Reinstall on failed hosts",
-  'admin.stackVersions.datails.hosts.btn.install': "Install to {0} hosts",
-  'admin.stackVersions.datails.hosts.btn.installing': "Installing...",
-  'admin.stackVersions.datails.hosts.btn.nothing': "Installed on all hosts",
-  'admin.stackVersions.datails.hosts.btn.goto.upgrade': "Proceed to upgrade",
-  'admin.stackVersions.datails.hosts.btn.na': "Status not available",
-  'admin.stackVersions.datails.install.hosts.popup.title': "Install {0} version",
-
+  'admin.stackVersions.details.versionName': "Version Name",
+  'admin.stackVersions.details.installed.on': "Installed on",
+  'admin.stackVersions.details.current.on': "Current on",
+  'admin.stackVersions.details.not.installed.on': "Not installed on",
+  'admin.stackVersions.details.host': "host",
+  'admin.stackVersions.details.hosts': "hosts",
+  'admin.stackVersions.details.base.url': "Base Url",
+
+  'admin.stackVersions.details.hosts.btn.reinstall': "Reinstall on failed hosts",
+  'admin.stackVersions.details.hosts.btn.install': "Install to {0} hosts",
+  'admin.stackVersions.details.hosts.btn.installing': "Installing...",
+  'admin.stackVersions.details.hosts.btn.nothing': "Installed on all hosts",
+  'admin.stackVersions.details.hosts.btn.goto.upgrade': "Proceed to upgrade",
+  'admin.stackVersions.details.hosts.btn.na': "Status not available",
+  'admin.stackVersions.details.install.hosts.popup.title': "Install {0} version",
+
+  'admin.stackVersions.hosts.popup.header.current': "Current",
+  'admin.stackVersions.hosts.popup.header.installed': "Installed",
+  'admin.stackVersions.hosts.popup.header.not_installed': "Not installed",
   'admin.stackVersions.hosts.popup.header': "Version Status: {0}",
   'admin.stackVersions.hosts.popup.title': "{0} Version is {1} on {2} hosts:",
   'admin.stackVersions.hosts.popup.primary': "Go to Hosts",

+ 22 - 21
ambari-web/app/templates/main/admin/stack_versions/stack_version_details.hbs

@@ -26,37 +26,38 @@
     <div class="version-content">
       <div class="row-fluid">
         <div class="span7">
-          <div {{bindAttr class="view.showCounters::hide"}}>
           {{#unless installComplete}}
             <div class="row-fluid">
-              <div class="span3">{{t admin.stackVersions.datails.not.installed.on}}</div>
-              <div {{bindAttr class="content.stackVersion.noInitHosts:not-active-link :span6"}}>
-                <a href="#" title='current' class="not-installed-hosts-count"
-                  {{action showHosts content.displayName content.stackVersion.initHosts target="App.router.mainStackVersionsController"}}>
-                  {{content.stackVersion.initHosts.length}}&nbsp;{{pluralize content.stackVersion.initHosts.length singular="t:common.host" plural="t:common.hosts"}}
+              <div class="span3">{{t admin.stackVersions.details.not.installed.on}}</div>
+              <div {{bindAttr class="view.noInitHosts:not-active-link :span6"}}>
+                <a href="#" class="not-installed-hosts-count"
+                  {{action showHosts view.versionStateMap.not_installed content.repositoryVersion view.initHosts target="App.router.mainStackVersionsController"}}>
+                  {{view.initHosts.length}}&nbsp;
+                  {{pluralize view.initHosts.length singular="t:admin.stackVersions.details.host" plural="t:admin.stackVersions.details.hosts"}}
                 </a>
               </div>
             </div>
           {{/unless}}
           <div class="row-fluid">
-            <div class="span3">{{t admin.stackVersions.datails.installed.on}}</div>
-            <div {{bindAttr class="content.stackVersion.noInstalledHosts:not-active-link :span6"}}>
-              <a href="#" title='installed' class="installed-hosts-count"
-                {{action showHosts content.displayName content.stackVersion.installedHosts target="App.router.mainStackVersionsController"}}>
-                {{content.stackVersion.installedHosts.length}}&nbsp;{{pluralize content.stackVersion.installedHosts.length singular="t:common.host" plural="t:common.hosts"}}
+            <div class="span3">{{t admin.stackVersions.details.installed.on}}</div>
+            <div {{bindAttr class="view.noInstalledHosts:not-active-link :span6"}}>
+              <a href="#" class="installed-hosts-count"
+                {{action showHosts view.versionStateMap.installed content.repositoryVersion view.installedHosts target="App.router.mainStackVersionsController"}}>
+                {{view.installedHosts.length}}&nbsp;
+                {{pluralize view.installedHosts.length singular="t:admin.stackVersions.details.host" plural="t:admin.stackVersions.details.hosts"}}
               </a>
             </div>
           </div>
           <div class="row-fluid">
-            <div class="span3">{{t admin.stackVersions.datails.current.on}}</div>
-            <div {{bindAttr class="content.stackVersion.noCurrentHosts:not-active-link :span6"}}>
-              <a href="#" title='current' class="current-hosts-count"
-                {{action showHosts content.displayName content.stackVersion.currentHosts target="App.router.mainStackVersionsController"}}>
-                {{content.stackVersion.currentHosts.length}}&nbsp;{{pluralize content.stackVersion.currentHosts.length singular="t:common.host" plural="t:common.hosts"}}
+            <div class="span3">{{t admin.stackVersions.details.current.on}}</div>
+            <div {{bindAttr class="view.noCurrentHosts:not-active-link :span6"}}>
+              <a href="#" class="current-hosts-count"
+                {{action showHosts view.versionStateMap.current content.repositoryVersion view.currentHosts target="App.router.mainStackVersionsController"}}>
+                {{view.currentHosts.length}}&nbsp;
+                {{pluralize view.currentHosts.length singular="t:admin.stackVersions.details.host" plural="t:admin.stackVersions.details.hosts"}}
               </a>
             </div>
           </div>
-          </div>
         </div>
         <div class="span5 align-center">
           {{!show progress when install repo is in progress}}
@@ -64,7 +65,7 @@
             <div class="repo-installing-info">
             <i class="icon-cog">&nbsp;</i>
             <a href="javascript:void(null);" id="repo-installing-link" {{action showProgressPopup target="controller"}}>
-              {{t admin.stackVersions.datails.hosts.btn.installing}}
+              {{t admin.stackVersions.details.hosts.btn.installing}}
             </a>
             </div>
             <div class="progress-striped active progress-info progress repo-installing-progress"><div class="bar" {{bindAttr style="view.progress"}}></div></div>
@@ -79,11 +80,11 @@
           {{!show success mesasge when install complete}}
           {{#if installComplete}}
             <i class="icon-ok">&nbsp;</i>
-            <span>{{t admin.stackVersions.datails.hosts.btn.nothing}}</span>&nbsp;
+            <span>{{t admin.stackVersions.details.hosts.btn.nothing}}</span>&nbsp;
             {{#if controller.current}}
               <span class="label label-success">{{t common.current}}</span>
             {{else}}
-              <a href="#/main/admin/stack">{{t admin.stackVersions.datails.hosts.btn.goto.upgrade}}</a>
+              <a href="#/main/admin/stack">{{t admin.stackVersions.details.hosts.btn.goto.upgrade}}</a>
             {{/if}}
           {{/if}}
         </div>
@@ -106,7 +107,7 @@
             {{t common.name}}
           </th>
           <th>
-            {{t admin.stackVersions.datails.base.url}}
+            {{t admin.stackVersions.details.base.url}}
           </th>
         </tr>
         </thead>

+ 2 - 2
ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs

@@ -46,7 +46,7 @@
             <td class="installed-hosts-count">
               <span  {{bindAttr class="view.content.noInstalledHosts:not-active-link"}}>
                 <a href="#"
-                  title='installed' {{action showHosts view.content.repositoryVersion.displayName view.content.installedHosts target="controller"}}>
+                  {{action showHosts view.versionStateMap.installed view.content.repositoryVersion.repositoryVersion view.content.installedHosts target="controller"}}>
                   <span>{{view.content.installedHosts.length}}</span>
                 </a>
               </span>
@@ -54,7 +54,7 @@
             <td class="current-hosts-count">
               <span {{bindAttr class="view.content.noCurrentHosts:not-active-link"}}>
                 <a href="#"
-                  title='current' {{action showHosts view.content.repositoryVersion.displayName view.content.currentHosts target="controller"}}>
+                  {{action showHosts view.versionStateMap.current view.content.repositoryVersion.repositoryVersion view.content.currentHosts target="controller"}}>
                   <span>{{view.content.currentHosts.length}}</span>
                 </a>
               </span>

+ 1 - 1
ambari-web/app/views/main/admin/stack_versions/operating_systems.js

@@ -49,7 +49,7 @@ App.OperatingSystemsView = Em.View.extend({
         return this.get('content.operatingSystems').getEach('osType');
         break;
       default :
-        return this.get('content.operatingSystems.length') + Em.I18n.t("common.oss");
+        return this.get('content.operatingSystems.length') + " " + Em.I18n.t("common.oss");
     }
   }.property('content.operatingSystems.length'),
 

+ 1 - 4
ambari-web/app/views/main/admin/stack_versions/repo_version_view.js

@@ -95,10 +95,7 @@ App.RepoVersionsView = App.TableView.extend({
   },
 
   RepositoryVersionView: Em.View.extend({
-    tagName: 'tr',
-    didInsertElement: function () {
-      App.tooltip(this.$("[rel='Tooltip']"));
-    }
+    tagName: 'tr'
   })
 
 });

+ 58 - 2
ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js

@@ -33,8 +33,8 @@ App.MainStackVersionsDetailsView = Em.View.extend({
    */
   installButtonMsg: function() {
     return this.get('content.stackVersion.state') == 'INSTALL_FAILED'
-      ? Em.I18n.t('admin.stackVersions.datails.hosts.btn.reinstall')
-      : Em.I18n.t('admin.stackVersions.datails.hosts.btn.install').format(this.get('controller.hostsToInstall'))
+      ? Em.I18n.t('admin.stackVersions.details.hosts.btn.reinstall')
+      : Em.I18n.t('admin.stackVersions.details.hosts.btn.install').format(this.get('controller.hostsToInstall'))
   }.property('content.stackVersion.state', 'parentView.content.stackVersion.initHosts.length'),
 
   /**
@@ -63,6 +63,62 @@ App.MainStackVersionsDetailsView = Em.View.extend({
     return this.get('content.stackVersion') != null;
   }.property('content.stackVersion'),
 
+
+  /**
+   * hosts with stack versions in not installed state
+   * when stack version for repoversion is not created returns all hosts in cluster
+   */
+  initHosts: function() {
+    if (this.get('showCounters') && this.get('content.stackVersion.installingHosts') && this.get('content.stackVersion.installFailedHosts')) {
+      return this.get('content.stackVersion.installingHosts').concat(this.get('content.stackVersion.installFailedHosts'));
+    } else {
+      return App.get('allHostNames');
+    }
+  }.property('showCounters', 'content.stackVersion.installingHosts.length', 'content.stackVersion.installFailedHosts.length', 'App.allHostNames'),
+
+  /**
+   * hosts with stack versions in installed state
+   * when stack version for repoversion is not created returns an empty array
+   */
+  installedHosts: function() {
+    return this.get('showCounters') ? this.get('content.stackVersion.installedHosts') : [];
+  }.property('showCounters', 'content.stackVersion.installedHosts.length'),
+
+  /**
+   * hosts with stack versions in current state
+   * when stack version for repoversion is not created returns an empty array
+   */
+  currentHosts: function() {
+    return this.get('showCounters') ? this.get('content.stackVersion.currentHosts') : [];
+  }.property('showCounters', 'content.stackVersion.currentHosts.length'),
+
+  noInitHosts: function() {
+    return this.get('showCounters') ? this.get('content.stackVersion.noInitHosts') : false;
+  }.property('showCounters', 'content.stackVersion.noInitHosts'),
+
+  noInstalledHosts:  function() {
+    return this.get('showCounters') ? this.get('content.stackVersion.noInstalledHosts') : true;
+  }.property('showCounters', 'content.stackVersion.noInstalledHosts'),
+
+  noCurrentHosts: function() {
+    return this.get('showCounters') ? this.get('content.stackVersion.noCurrentHosts') : true;
+  }.property('showCounters', 'content.stackVersion.noCurrentHosts'),
+
+  versionStateMap: {
+    'current': {
+      'id': 'current',
+      'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.current')
+    },
+    'installed': {
+      'id': 'installed',
+      'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.installed')
+    },
+    'not_installed': {
+      'id': 'installing',
+      'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.not_installed')
+    }
+  },
+
   didInsertElement: function() {
     App.get('router.mainStackVersionsController').set('isPolling', true);
     App.get('router.mainStackVersionsController').doPolling();

+ 13 - 12
ambari-web/app/views/main/admin/stack_versions/stack_version_view.js

@@ -134,20 +134,21 @@ App.MainStackVersionsView = App.TableView.extend({
 
   StackVersionView: Em.View.extend({
     tagName: 'tr',
-    didInsertElement: function () {
-      App.tooltip(this.$("[rel='Tooltip']"));
-      this.set('isOsCollapsed', true);
-    },
 
-    toggleOs: function(event) {
-      this.set('isOsCollapsed', !this.get('isOsCollapsed'));
-      this.$('.operating-systems').toggle();
+    versionStateMap: {
+      'current': {
+        'id': 'current',
+        'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.current')
+      },
+      'installed': {
+        'id': 'installed',
+        'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.installed')
+      },
+      'not_installed': {
+        'id': 'installing',
+        'label': Em.I18n.t('admin.stackVersions.hosts.popup.header.not_installed')
+      }
     },
-
-    labels: function() {
-      return this.get('content.repositoryVersion.operatingSystems') &&
-        this.get('content.repositoryVersion.operatingSystems').getEach('osType').join("<br/>");
-    }.property('content.repositoryVersion.operatingSystems.length')
   })
 
 });

+ 48 - 0
ambari-web/test/controllers/main/admin/stack_version/repo_version_management_controller_test.js

@@ -27,6 +27,43 @@ describe('App.RepoVersionsManagementController', function () {
     controller = App.RepoVersionsManagementController.create({});
   });
 
+  describe('#getUrl()', function () {
+    beforeEach(function() {
+      controller.reopen({
+        'mockStackUrl': 'mockStackUrl',
+        'mockRepoUrl': 'mockRepoUrl',
+        'realStackUrl': 'realStackUrl',
+        'realRepoUrl': 'realRepoUrl',
+        'realUpdateUrl': 'realUpdateUrl'
+      });
+    });
+    afterEach(function() {
+      App.set('testMode', false);
+    });
+
+    it('gets url for testMode for stackVersion', function () {
+      App.set('testMode', true);
+      expect(controller.getUrl(true)).to.be.equal('mockStackUrl');
+    });
+    it('gets url for testMode for repoVersion', function () {
+      App.set('testMode', true);
+      expect(controller.getUrl(false)).to.equal('mockRepoUrl');
+    });
+    it('gets url for stackVersion', function () {
+      App.set('testMode', false);
+      expect(controller.getUrl(true, true)).to.be.equal('realStackUrl');
+    });
+    it('gets url for repoVersion', function () {
+      App.set('testMode', false);
+      expect(controller.getUrl(false, true)).to.be.equal('realRepoUrl');
+    });
+    it('gets url to upadte stackVersion', function () {
+      App.set('testMode', false);
+      expect(controller.getUrl(true)).to.be.equal('realUpdateUrl');
+    });
+
+  });
+
   describe('#load()', function () {
     it('loads data to model by running loadStackVersionsToModel', function () {
       sinon.stub(controller, 'loadStackVersionsToModel').returns($.Deferred().resolve());
@@ -118,4 +155,15 @@ describe('App.RepoVersionsManagementController', function () {
         });
       });
   });
+
+  describe('#showHosts()', function () {
+    it('show list of hosts for current version in choosen state', function () {
+      sinon.stub(controller, 'filterHostsByStack', Em.K);
+
+      controller.showHosts({ contexts: [{id: "state", label: "label"}, "version",["host"]]}).onPrimary();
+      expect(controller.filterHostsByStack.calledWith("version", "state")).to.be.true;
+
+      controller.filterHostsByStack.restore();
+    });
+  });
 });

+ 54 - 4
ambari-web/test/controllers/main/admin/stack_version/stack_version_details_controller_test.js

@@ -38,13 +38,63 @@ describe('App.MainStackVersionsDetailsController', function () {
     });
     it("runs initPopup", function() {
       controller.reopen({'content': { 'displayName': "v1"}});
-      var popupTitle = Em.I18n.t('admin.stackVersions.datails.install.hosts.popup.title').format("v1");
+      var popupTitle = Em.I18n.t('admin.stackVersions.details.install.hosts.popup.title').format("v1");
       var requestIds =[1];
       controller.showProgressPopup();
       expect(App.router.get('highAvailabilityProgressPopupController').initPopup.calledWith(popupTitle, requestIds, controller)).to.be.true;
     });
   });
 
+  describe("#doPolling()", function () {
+    beforeEach(function () {
+      sinon.stub(controller, 'updateProgress', Em.K);
+      sinon.spy(controller, 'doPolling');
+      this.clock = sinon.useFakeTimers();
+    });
+    afterEach(function () {
+      controller.updateProgress.restore();
+      controller.doPolling.restore();
+      this.clock.restore();
+    });
+    it("installInProgress false", function () {
+      controller.set('installInProgress', false);
+      controller.doPolling();
+      expect(controller.updateProgress.calledOnce).to.be.true;
+      expect(controller.doPolling.calledOnce).to.be.true;
+    });
+    it("installInProgress true", function () {
+      controller.set('installInProgress', true);
+      controller.doPolling();
+      this.clock.tick(App.componentsUpdateInterval);
+      expect(controller.doPolling.called).to.be.true;
+      expect(controller.updateProgress.called).to.be.true;
+    });
+  });
+
+  describe('#updateProgress', function () {
+    beforeEach(function () {
+      sinon.stub(App.ajax, 'send', Em.K);
+      sinon.stub(App.db, 'get').withArgs('repoVersion','id').returns(1)
+    });
+    afterEach(function () {
+      App.ajax.send.restore();
+      App.db.get.restore();
+    });
+    it("runs get request to get install progress", function () {
+      controller.updateProgress();
+      expect(App.ajax.send.getCall(0).args[0].data).to.deep.eql({
+        requestId: 1
+      });
+    });
+  });
+
+  describe('#updateProgressSuccess', function () {
+    it("saves progress state t othe controller", function () {
+      controller.updateProgressSuccess({Requests: {progress_percent: 10} });
+      expect(controller.get('progress')).to.equal(10);
+    });
+  });
+
   describe('#installRepoVersion', function () {
     beforeEach(function () {
       sinon.stub(App.ajax, 'send', Em.K);
@@ -67,7 +117,7 @@ describe('App.MainStackVersionsDetailsController', function () {
     });
   });
 
-  describe('#installStackVersionSuccess()', function () {
+  describe('#installRepoVersionSuccess()', function () {
     var repoId = "1";
     var requestId = "2";
     var repoVersion = {id: repoId};
@@ -91,7 +141,7 @@ describe('App.MainStackVersionsDetailsController', function () {
       App.set('router.currentState.name', route);
     });
     it('success callback for install stack version without redirect', function () {
-      controller.installStackVersionSuccess({Requests: {id: requestId}}, null, {id: repoId});
+      controller.installRepoVersionSuccess({Requests: {id: requestId}}, null, {id: repoId});
       expect(App.db.set.calledWith('repoVersion', 'id', [requestId])).to.be.true;
       expect(App.get('router.repoVersionsManagementController').loadStackVersionsToModel.calledWith(true)).to.be.true;
       expect(App.RepositoryVersion.find.calledOnce).to.be.true;
@@ -100,7 +150,7 @@ describe('App.MainStackVersionsDetailsController', function () {
 
     it('success callback for install stack version', function () {
       App.set('router.currentState.name', "update");
-      controller.installStackVersionSuccess({Requests: {id: requestId}}, null, {id: repoId});
+      controller.installRepoVersionSuccess({Requests: {id: requestId}}, null, {id: repoId});
       expect(App.db.set.calledWith('repoVersion', 'id', [requestId])).to.be.true;
       expect(App.get('router.repoVersionsManagementController').loadStackVersionsToModel.calledOnce).to.be.true;
       expect(App.RepositoryVersion.find.called).to.be.true;

+ 2 - 2
ambari-web/test/views/main/admin/stack_version/stack_version_details_test.js

@@ -43,12 +43,12 @@ describe('App.MainStackVersionsDetailsView', function () {
     it("install button msg for init state" , function() {
       view.set("controller.hostsToInstall", 2);
       view.set("content.stackVersion.state", "ANY");
-      expect(view.get('installButtonMsg')).to.equal(Em.I18n.t('admin.stackVersions.datails.hosts.btn.install').format(2))
+      expect(view.get('installButtonMsg')).to.equal(Em.I18n.t('admin.stackVersions.details.hosts.btn.install').format(2))
     });
 
     it("install button msg for install failed state" , function() {
       view.set("content.stackVersion.state", "INSTALL_FAILED");
-      expect(view.get('installButtonMsg')).to.equal(Em.I18n.t('admin.stackVersions.datails.hosts.btn.reinstall'))
+      expect(view.get('installButtonMsg')).to.equal(Em.I18n.t('admin.stackVersions.details.hosts.btn.reinstall'))
     });
   });