浏览代码

Revert "AMBARI-8685 Failure handling for repo distribution. (ababiichuk)"

Possible UT failure breakge.
This reverts commit 563861f7fe2bd58c8155372c27023902cd542c37.
Yusaku Sako 10 年之前
父节点
当前提交
71e1377696

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

@@ -126,12 +126,10 @@ App.RepoVersionsController = Em.ArrayController.extend({
    * @method installStackVersionSuccess
    * @method installStackVersionSuccess
    */
    */
   installStackVersionSuccess: function (data, opt, params) {
   installStackVersionSuccess: function (data, opt, params) {
-    App.db.set('repoVersion', 'id', [data.Requests.id]);
-    if(!App.StackVersion.find().findProperty('repositoryVersion.id', params.id)) {
-      App.get('router.mainStackVersionsController').loadStackVersionsToModel().done(function() {
-        var stackVersion = App.StackVersion.find().findProperty('repositoryVersion.id', params.id);
-        App.router.transitionTo('main.admin.adminStackVersions.version', stackVersion);
-      });
-    }
+    App.db.set('stackUpgrade', 'id', [data.Requests.id]);
+    App.get('router.mainStackVersionsController').loadStackVersionsToModel().done(function() {
+      var stackVersion = App.StackVersion.find().findProperty('repositoryVersion.id', params.id);
+      App.router.transitionTo('main.admin.adminStackVersions.version', stackVersion);
+    });
   }
   }
 });
 });

+ 2 - 22
ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js

@@ -31,13 +31,6 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
     return App.get('allHostNames.length');
     return App.get('allHostNames.length');
   }.property('App.allHostNames.length'),
   }.property('App.allHostNames.length'),
 
 
-  /**
-   * true if stack version install is in progress
-   * @type {Boolean}
-   */
-  installFailed: function() {
-    return this.get('content.state') == "INSTALL_FAILED";
-  }.property('content.state'),
   /**
   /**
    * true if stack version install is in progress
    * true if stack version install is in progress
    * @type {Boolean}
    * @type {Boolean}
@@ -58,34 +51,21 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
   /**
   /**
    * depending on state run or install repo request
    * depending on state run or install repo request
    * or show the installation process popup
    * or show the installation process popup
-   * @param event
    * @method installStackVersion
    * @method installStackVersion
    */
    */
-  installStackVersion: function(event) {
+  installStackVersion: function() {
     if (this.get('installInProgress')) {
     if (this.get('installInProgress')) {
       this.showProgressPopup();
       this.showProgressPopup();
-    } else if (this.get('installFailed')) {
-      this.installRepoVersion(event);
     }
     }
   },
   },
 
 
-  /**
-   * install repoVersion using <code>installRepoVersion()<code> method
-   * of <code>repoVersionsController<code> controller
-   * @param event
-   * @method installRepoVersion
-   */
-  installRepoVersion: function(event) {
-    App.get('router.repoVersionsController').installRepoVersion(event);
-  },
-
   /**
   /**
    * opens a popup with installations state per host
    * opens a popup with installations state per host
    * @method showProgressPopup
    * @method showProgressPopup
    */
    */
   showProgressPopup: function() {
   showProgressPopup: function() {
     var popupTitle = Em.I18n.t('admin.stackVersions.datails.install.hosts.popup.title').format(this.get('content.repositoryVersion.displayName'));
     var popupTitle = Em.I18n.t('admin.stackVersions.datails.install.hosts.popup.title').format(this.get('content.repositoryVersion.displayName'));
-    var requestIds = App.get('testMode') ? [1] : App.db.get('repoVersion', 'id');
+    var requestIds = App.get('testMode') ? [1] : App.db.get('stackUpgrade', 'id');
     var hostProgressPopupController = App.router.get('highAvailabilityProgressPopupController');
     var hostProgressPopupController = App.router.get('highAvailabilityProgressPopupController');
     hostProgressPopupController.initPopup(popupTitle, requestIds, this);
     hostProgressPopupController.initPopup(popupTitle, requestIds, this);
   }
   }

+ 0 - 1
ambari-web/app/messages.js

@@ -1281,7 +1281,6 @@ Em.I18n.translations = {
   'admin.stackVersions.datails.not.installed.on': "Not installed on",
   'admin.stackVersions.datails.not.installed.on': "Not installed on",
   'admin.stackVersions.datails.base.url': "Base Url",
   '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.install': "Install to {0} hosts",
   'admin.stackVersions.datails.hosts.btn.installing': "Installing...",
   'admin.stackVersions.datails.hosts.btn.installing': "Installing...",
   'admin.stackVersions.datails.hosts.btn.nothing': "Installed on all hosts",
   'admin.stackVersions.datails.hosts.btn.nothing': "Installed on all hosts",

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

@@ -71,7 +71,7 @@
           </div>
           </div>
         </div>
         </div>
         <div class="span4 align-center">
         <div class="span4 align-center">
-          <a id="repo-version-action-button" {{bindAttr class="view.statusClass :btn :stack-status-button"}} {{action installStackVersion content.repositoryVersion target="controller"}}>
+          <a id="repo-version-action-button" {{bindAttr class="view.statusClass :btn :stack-status-button"}} {{action installStackVersion content target="controller"}}>
             <i {{bindAttr class="installInProgress:icon-cog"}}>&nbsp;</i>{{view.stackTextStatus}}
             <i {{bindAttr class="installInProgress:icon-cog"}}>&nbsp;</i>{{view.stackTextStatus}}
           </a>
           </a>
           <a href="#/main/admin/stack" {{bindAttr class="installedNotUpgraded::hidden"}} >{{t admin.stackVersions.datails.hosts.btn.goto.upgrade}}</a>
           <a href="#/main/admin/stack" {{bindAttr class="installedNotUpgraded::hidden"}} >{{t admin.stackVersions.datails.hosts.btn.goto.upgrade}}</a>

+ 0 - 6
ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js

@@ -43,9 +43,6 @@ App.MainStackVersionsDetailsView = Em.View.extend({
       case 'INIT':
       case 'INIT':
         return Em.I18n.t('admin.stackVersions.datails.hosts.btn.install').format(self.get('totalHostCount') - self.get('content.installedHosts.length'));
         return Em.I18n.t('admin.stackVersions.datails.hosts.btn.install').format(self.get('totalHostCount') - self.get('content.installedHosts.length'));
         break;
         break;
-      case 'INSTALL_FAILED':
-        return Em.I18n.t('admin.stackVersions.datails.hosts.btn.reinstall');
-        break;
       default:
       default:
         return self.get('content.state') && self.get('content.state').toCapital();
         return self.get('content.state') && self.get('content.state').toCapital();
     }
     }
@@ -64,9 +61,6 @@ App.MainStackVersionsDetailsView = Em.View.extend({
       case 'INSTALLING':
       case 'INSTALLING':
         return 'btn-primary';
         return 'btn-primary';
         break;
         break;
-      case 'INSTALL_FAILED':
-        return 'btn-danger';
-        break;
       default:
       default:
         return 'disabled';
         return 'disabled';
     }
     }

+ 9 - 34
ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js

@@ -76,52 +76,27 @@ describe('App.RepoVersionsController', function () {
   });
   });
 
 
   describe('#installStackVersionSuccess()', function () {
   describe('#installStackVersionSuccess()', function () {
-    var repoId = "1";
-    var requestId = "2";
-    var stackVersionObject = {repositoryVersion: {id: repoId}};
-    var stackVersion;
-    beforeEach(function() {
+    it('success callback for install stack version', function () {
+      var repoId = "1";
+      var requestId = "2";
+      var stackVersion = {repositoryVersion: {id: repoId}};
       sinon.stub(App.db, 'set', Em.K);
       sinon.stub(App.db, 'set', Em.K);
+      sinon.stub(App.get('router.mainStackVersionsController'), 'loadStackVersionsToModel', function() { return $.Deferred().resolve()});
       sinon.stub(App.router, 'transitionTo', Em.K);
       sinon.stub(App.router, 'transitionTo', Em.K);
       sinon.stub(App.StackVersion, 'find', function() {
       sinon.stub(App.StackVersion, 'find', function() {
         return [stackVersion];
         return [stackVersion];
       });
       });
-    });
-
-    afterEach(function() {
-      App.db.set.restore();
-      App.router.transitionTo.restore();
-      App.StackVersion.find.restore();
-    });
-    it('success callback for install stack version', function () {
-      stackVersion = null;
-      sinon.stub(App.get('router.mainStackVersionsController'), 'loadStackVersionsToModel', function() {
-        stackVersion = stackVersionObject;
-        return $.Deferred().resolve()});
 
 
       repoVersionsController.installStackVersionSuccess({Requests: {id: requestId}}, null, {id: repoId});
       repoVersionsController.installStackVersionSuccess({Requests: {id: requestId}}, null, {id: repoId});
       expect(App.db.set.calledWith('stackUpgrade', 'id', [requestId])).to.be.true;
       expect(App.db.set.calledWith('stackUpgrade', 'id', [requestId])).to.be.true;
       expect(App.get('router.mainStackVersionsController').loadStackVersionsToModel.calledOnce).to.be.true;
       expect(App.get('router.mainStackVersionsController').loadStackVersionsToModel.calledOnce).to.be.true;
-      expect(App.StackVersion.find.called).to.be.true;
-      expect(App.router.transitionTo.calledWith('main.admin.adminStackVersions.version', stackVersion)).to.be.true;
-
-      App.get('router.mainStackVersionsController').loadStackVersionsToModel.restore();
-    });
-
-    it('success callback for install stack version without redirect', function () {
-      stackVersion = stackVersionObject;
-      sinon.stub(App.get('router.mainStackVersionsController'), 'loadStackVersionsToModel', function() {
-        return $.Deferred().resolve()
-      });
-
-      repoVersionsController.installStackVersionSuccess({Requests: {id: requestId}}, null, {id: repoId});
-      expect(App.db.set.calledWith('stackUpgrade', 'id', [requestId])).to.be.true;
-      expect(App.get('router.mainStackVersionsController').loadStackVersionsToModel.calledOnce).to.be.false;
       expect(App.StackVersion.find.calledOnce).to.be.true;
       expect(App.StackVersion.find.calledOnce).to.be.true;
-      expect(App.router.transitionTo.calledWith('main.admin.adminStackVersions.version', stackVersion)).to.be.false;
+      expect(App.router.transitionTo.calledWith('main.admin.adminStackVersions.version', stackVersion)).to.be.true;
 
 
+      App.db.set.restore();
       App.get('router.mainStackVersionsController').loadStackVersionsToModel.restore();
       App.get('router.mainStackVersionsController').loadStackVersionsToModel.restore();
-
+      App.router.transitionTo.restore();
+      App.StackVersion.find.restore();
     });
     });
   });
   });
 
 

+ 0 - 7
ambari-web/test/controllers/main/admin/stack_version/stack_version_details_controller_test.js

@@ -30,22 +30,15 @@ describe('App.MainStackVersionsDetailsController', function () {
   describe('#installStackVersion', function () {
   describe('#installStackVersion', function () {
     beforeEach(function() {
     beforeEach(function() {
       sinon.stub(mainStackVersionsDetailsController, 'showProgressPopup', Em.K);
       sinon.stub(mainStackVersionsDetailsController, 'showProgressPopup', Em.K);
-      sinon.stub(mainStackVersionsDetailsController, 'installRepoVersion', Em.K);
     });
     });
     afterEach(function() {
     afterEach(function() {
       mainStackVersionsDetailsController.showProgressPopup.restore();
       mainStackVersionsDetailsController.showProgressPopup.restore();
-      mainStackVersionsDetailsController.installRepoVersion.restore();
     });
     });
     it("shows installing proggress", function() {
     it("shows installing proggress", function() {
       mainStackVersionsDetailsController.reopen({'installInProgress': true});
       mainStackVersionsDetailsController.reopen({'installInProgress': true});
       mainStackVersionsDetailsController.installStackVersion({});
       mainStackVersionsDetailsController.installStackVersion({});
       expect(mainStackVersionsDetailsController.showProgressPopup.calledOnce).to.be.true;
       expect(mainStackVersionsDetailsController.showProgressPopup.calledOnce).to.be.true;
     });
     });
-    it("shows senq request to install/reinstall repoVersion", function() {
-      mainStackVersionsDetailsController.reopen({'installFailed': true});
-      mainStackVersionsDetailsController.installStackVersion({context: "1"});
-      expect(mainStackVersionsDetailsController.installRepoVersion.calledWith({context: "1"})).to.be.true;
-    });
   });
   });
 
 
   describe('#showProgressPopup', function () {
   describe('#showProgressPopup', function () {

+ 0 - 41
ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js

@@ -52,45 +52,4 @@ describe('App.MainStackVersionsController', function () {
       App.HttpClient.get.restore();
       App.HttpClient.get.restore();
     });
     });
   });
   });
-
-  describe('#filterHostsByStack()', function () {
-    beforeEach(function() {
-      sinon.stub(App.router.get('mainHostController'), 'filterByStack').returns({done: Em.K});
-      sinon.stub(App.router, 'transitionTo').returns({done: Em.K});
-    });
-    afterEach(function() {
-      App.router.get('mainHostController').filterByStack.restore();
-      App.router.transitionTo.restore();
-    });
-    var tests = [
-      {
-        version: "version1",
-        state: "state1",
-        m: 'go to hosts filtered by host stack version and host stack state',
-        runAll: true
-      },
-      {
-        version: null,
-        state: "state1",
-        m: 'doesn\'t do anything because version is missing'
-      },
-      {
-        version: "version1",
-        state: null,
-        m: 'doesn\'t do anything because state is missing'
-      }
-    ].forEach(function(t) {
-        it(t.m, function () {
-          controller.load(t.version, t.stack);
-          if (t.runAll) {
-            expect(App.router.get('mainHostController').filterByStack.calledWith('hosts.index')).to.be.true;
-            expect(App.router.transitionTo.calledWith('hosts.index')).to.be.true;
-          } else {
-            expect(App.router.get('mainHostController').filterByStack.calledOnce).to.be.false;
-            expect(App.router.transitionTo.calledOnce).to.be.false;
-          }
-
-        });
-      });
-  });
 });
 });

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

@@ -40,10 +40,6 @@ describe('App.MainStackVersionsDetailsView', function () {
       {
       {
         state: "INSTALLING",
         state: "INSTALLING",
         buttonClass: 'btn-primary'
         buttonClass: 'btn-primary'
-      },
-      {
-        state: "INSTALL_FAILED",
-        buttonClass: "btn-danger"
       }
       }
     ].forEach(function(t) {
     ].forEach(function(t) {
       it("status is " + t.status + " class is " + t.buttonClass, function() {
       it("status is " + t.status + " class is " + t.buttonClass, function() {