ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-8685 Failure handling for repo distribution. (ababiichuk)
Date Mon, 15 Dec 2014 13:16:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 12ac2945f -> bbd9961cd


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


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

Branch: refs/heads/trunk
Commit: bbd9961cd650624660e646dc49e823ba459480fb
Parents: 12ac294
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Mon Dec 15 14:49:23 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Mon Dec 15 14:49:23 2014 +0200

----------------------------------------------------------------------
 .../stack_versions/repo_versions_controller.js  | 12 ++---
 .../stack_version_details_controller.js         | 24 +++++++++-
 ambari-web/app/messages.js                      |  1 +
 .../stack_versions/stack_version_details.hbs    |  2 +-
 .../stack_version_details_view.js               |  6 +++
 .../repo_versions_controller_test.js            | 47 +++++++++++++++-----
 .../stack_version_details_controller_test.js    |  9 +++-
 .../stack_versions_controller_test.js           | 41 +++++++++++++++++
 .../stack_version/stack_version_details_test.js |  4 ++
 9 files changed, 126 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
b/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
index 9b95941..002bcbe 100644
--- a/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
@@ -126,10 +126,12 @@ App.RepoVersionsController = Em.ArrayController.extend({
    * @method installStackVersionSuccess
    */
   installStackVersionSuccess: function (data, opt, params) {
-    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);
-    });
+    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);
+      });
+    }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js
b/ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js
index faf56c3..7678c5a 100644
--- a/ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js
@@ -35,6 +35,13 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    * 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
+   * @type {Boolean}
+   */
   installInProgress: function() {
     return this.get('content.state') == "INSTALLING";
   }.property('content.state'),
@@ -51,21 +58,34 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
   /**
    * depending on state run or install repo request
    * or show the installation process popup
+   * @param event
    * @method installStackVersion
    */
-  installStackVersion: function() {
+  installStackVersion: function(event) {
     if (this.get('installInProgress')) {
       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
    * @method showProgressPopup
    */
   showProgressPopup: function() {
     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('stackUpgrade', 'id');
+    var requestIds = App.get('testMode') ? [1] : App.db.get('repoVersion', 'id');
     var hostProgressPopupController = App.router.get('highAvailabilityProgressPopupController');
     hostProgressPopupController.initPopup(popupTitle, requestIds, this);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 5da9d96..83eacf6 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1287,6 +1287,7 @@ Em.I18n.translations = {
   '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",

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/app/templates/main/admin/stack_versions/stack_version_details.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_versions/stack_version_details.hbs
b/ambari-web/app/templates/main/admin/stack_versions/stack_version_details.hbs
index 5696a77..c984bdf 100644
--- a/ambari-web/app/templates/main/admin/stack_versions/stack_version_details.hbs
+++ b/ambari-web/app/templates/main/admin/stack_versions/stack_version_details.hbs
@@ -71,7 +71,7 @@
           </div>
         </div>
         <div class="span4 align-center">
-          <a id="repo-version-action-button" {{bindAttr class="view.statusClass :btn :stack-status-button"}}
{{action installStackVersion content target="controller"}}>
+          <a id="repo-version-action-button" {{bindAttr class="view.statusClass :btn :stack-status-button"}}
{{action installStackVersion content.repositoryVersion target="controller"}}>
             <i {{bindAttr class="installInProgress:icon-cog"}}>&nbsp;</i>{{view.stackTextStatus}}
           </a>
           <a href="#/main/admin/stack" {{bindAttr class="installedNotUpgraded::hidden"}}
>{{t admin.stackVersions.datails.hosts.btn.goto.upgrade}}</a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js
b/ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js
index 4cdcac5..f4d213b 100644
--- a/ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js
+++ b/ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js
@@ -43,6 +43,9 @@ App.MainStackVersionsDetailsView = Em.View.extend({
       case 'INIT':
         return Em.I18n.t('admin.stackVersions.datails.hosts.btn.install').format(self.get('totalHostCount')
- self.get('content.installedHosts.length'));
         break;
+      case 'INSTALL_FAILED':
+        return Em.I18n.t('admin.stackVersions.datails.hosts.btn.reinstall');
+        break;
       default:
         return self.get('content.state') && self.get('content.state').toCapital();
     }
@@ -61,6 +64,9 @@ App.MainStackVersionsDetailsView = Em.View.extend({
       case 'INSTALLING':
         return 'btn-primary';
         break;
+      case 'INSTALL_FAILED':
+        return 'btn-danger';
+        break;
       default:
         return 'disabled';
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
b/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
index 90598ad..1fef683 100644
--- a/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
@@ -76,29 +76,54 @@ describe('App.RepoVersionsController', function () {
   });
 
   describe('#installStackVersionSuccess()', function () {
-    it('success callback for install stack version', function () {
-      var repoId = "1";
-      var requestId = "2";
-      var stackVersion = {repositoryVersion: {id: repoId}};
+    var repoId = "1";
+    var requestId = "2";
+    var stackVersionObject = {repositoryVersion: {id: repoId}};
+    var stackVersion;
+    beforeEach(function() {
       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.StackVersion, 'find', function() {
         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});
-      expect(App.db.set.calledWith('stackUpgrade', 'id', [requestId])).to.be.true;
+      expect(App.db.set.calledWith('repoVersion', 'id', [requestId])).to.be.true;
       expect(App.get('router.mainStackVersionsController').loadStackVersionsToModel.calledOnce).to.be.true;
-      expect(App.StackVersion.find.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.db.set.restore();
       App.get('router.mainStackVersionsController').loadStackVersionsToModel.restore();
-      App.router.transitionTo.restore();
-      App.StackVersion.find.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('repoVersion', '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.router.transitionTo.calledWith('main.admin.adminStackVersions.version',
stackVersion)).to.be.false;
+
+      App.get('router.mainStackVersionsController').loadStackVersionsToModel.restore();
+
     });
   });
 
 
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/test/controllers/main/admin/stack_version/stack_version_details_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_version/stack_version_details_controller_test.js
b/ambari-web/test/controllers/main/admin/stack_version/stack_version_details_controller_test.js
index d449547..95fa393 100644
--- a/ambari-web/test/controllers/main/admin/stack_version/stack_version_details_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_version/stack_version_details_controller_test.js
@@ -30,15 +30,22 @@ describe('App.MainStackVersionsDetailsController', function () {
   describe('#installStackVersion', function () {
     beforeEach(function() {
       sinon.stub(mainStackVersionsDetailsController, 'showProgressPopup', Em.K);
+      sinon.stub(mainStackVersionsDetailsController, 'installRepoVersion', Em.K);
     });
     afterEach(function() {
       mainStackVersionsDetailsController.showProgressPopup.restore();
+      mainStackVersionsDetailsController.installRepoVersion.restore();
     });
     it("shows installing proggress", function() {
       mainStackVersionsDetailsController.reopen({'installInProgress': true});
       mainStackVersionsDetailsController.installStackVersion({});
       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 () {
@@ -58,4 +65,4 @@ describe('App.MainStackVersionsDetailsController', function () {
       expect(App.router.get('highAvailabilityProgressPopupController').initPopup.calledWith(popupTitle,
requestIds, mainStackVersionsDetailsController)).to.be.true;
     });
   });
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
b/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
index 402b3d7..b05c40c 100644
--- a/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
@@ -52,4 +52,45 @@ describe('App.MainStackVersionsController', function () {
       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;
+          }
+
+        });
+      });
+  });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbd9961c/ambari-web/test/views/main/admin/stack_version/stack_version_details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_version/stack_version_details_test.js
b/ambari-web/test/views/main/admin/stack_version/stack_version_details_test.js
index ae16e25..61c0cb4 100644
--- a/ambari-web/test/views/main/admin/stack_version/stack_version_details_test.js
+++ b/ambari-web/test/views/main/admin/stack_version/stack_version_details_test.js
@@ -40,6 +40,10 @@ describe('App.MainStackVersionsDetailsView', function () {
       {
         state: "INSTALLING",
         buttonClass: 'btn-primary'
+      },
+      {
+        state: "INSTALL_FAILED",
+        buttonClass: "btn-danger"
       }
     ].forEach(function(t) {
       it("status is " + t.status + " class is " + t.buttonClass, function() {


Mime
View raw message