Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 ab3985b37 -> d60e9612c


AMBARI-19208. Manage Journalnode Wizard: error on step3 akovalenko)


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

Branch: refs/heads/branch-2.5
Commit: d60e9612c73f980390a71142267f1b362830b862
Parents: ab3985b
Author: Aleksandr Kovalenko <akovale...@hortonworks.com>
Authored: Thu Dec 15 13:38:34 2016 +0200
Committer: Aleksandr Kovalenko <akovale...@hortonworks.com>
Committed: Thu Dec 15 13:38:44 2016 +0200

----------------------------------------------------------------------
 .../main/admin/highAvailability_controller.js   | 15 ++++--
 ambari-web/app/messages.js                      |  1 +
 .../admin/highAvailability_controller_test.js   | 53 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d60e9612/ambari-web/app/controllers/main/admin/highAvailability_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/main/admin/highAvailability_controller.js 
b/ambari-web/app/controllers/main/admin/highAvailability_controller.js
index 71c11db..4899b43 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability_controller.js
@@ -115,10 +115,19 @@ App.MainAdminHighAvailabilityController = 
App.WizardController.extend({
     App.router.transitionTo('main.services.enableRAHighAvailability');
     return true;
   },
-  
+
+  /**
+   * open Manage JournalNode Wizard if there are two started NameNodes with 
defined active/standby state
+   * @returns {boolean}
+   */
   manageJournalNode: function() {
-    App.router.transitionTo('main.services.manageJournalNode');
-    return true;
+    var nameNodes = App.HostComponent.find().filterProperty('componentName', 
'NAMENODE');
+    if (nameNodes.someProperty('displayNameAdvanced', 'Active NameNode') && 
nameNodes.someProperty('displayNameAdvanced', 'Standby NameNode')) {
+      App.router.transitionTo('main.services.manageJournalNode');
+      return true;
+    }
+    this.showErrorPopup(Em.I18n.t('admin.manageJournalNode.warning'));
+    return false;
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/d60e9612/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 974b543..8ff4b55 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1269,6 +1269,7 @@ Em.I18n.translations = {
   'admin.kerberos.wizard.step1.notice.inProgress': 'Please wait while cluster 
is being unkerberized',
 
   'admin.manageJournalNode.label': 'Manage JournalNodes',
+  'admin.manageJournalNode.warning': 'Manage JournalNodes Wizard requires all 
NameNodes be started and have Active/Standby state defined',
   'admin.manageJournalNode.wizard.header': 'Manage JournalNodes Wizard',
   'admin.manageJournalNode.wizard.step1.header': 'Assign JournalNodes',
   'admin.manageJournalNode.wizard.step2.header': 'Review',

http://git-wip-us.apache.org/repos/asf/ambari/blob/d60e9612/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js 
b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
index 1e3d140..f5a144b 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
@@ -200,4 +200,57 @@ describe('App.MainAdminHighAvailabilityController', 
function () {
     });
   });
 
+  describe('#manageJournalNode()', function () {
+
+    beforeEach(function () {
+      this.mock = sinon.stub(App.HostComponent, 'find');
+      sinon.stub(App.router, 'transitionTo', Em.K);
+      sinon.spy(controller, "showErrorPopup");
+    });
+
+    afterEach(function () {
+      App.router.transitionTo.restore();
+      controller.showErrorPopup.restore();
+      App.HostComponent.find.restore();
+    });
+
+    it('should show error popup if there is no NNs', function () {
+      this.mock.returns([]);
+      var result = controller.manageJournalNode();
+      expect(result).to.be.false;
+      expect(controller.showErrorPopup.calledOnce).to.be.true;
+    });
+
+    it('should show error popup if there is no NNs', function () {
+      this.mock.returns([
+        Em.Object.create({
+          componentName: 'NAMENODE',
+          displayNameAdvanced: 'Active NameNode'
+        }),
+        Em.Object.create({
+          componentName: 'NAMENODE'
+        })
+      ]);
+      var result = controller.manageJournalNode();
+      expect(result).to.be.false;
+      expect(controller.showErrorPopup.calledOnce).to.be.true;
+    });
+
+    it('should call transition to wizard if we have both standby and active 
NNs', function () {
+      this.mock.returns([
+        Em.Object.create({
+          componentName: 'NAMENODE',
+          displayNameAdvanced: 'Active NameNode'
+        }),
+        Em.Object.create({
+          componentName: 'NAMENODE',
+          displayNameAdvanced: 'Standby NameNode'
+        })
+      ]);
+      var result = controller.manageJournalNode();
+      expect(result).to.be.true;
+      expect(App.router.transitionTo.calledOnce).to.be.true;
+    });
+  });
+
 });

Reply via email to