This is an automated email from the ASF dual-hosted git repository.

akovalenko pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 615a86c  AMBARI-25105. Cover views of the JournalNode wizard with unit 
tests
615a86c is described below

commit 615a86ca86d725beaa9744afb82b595247409bc6
Author: Aleksandr Kovalenko <akovale...@apache.org>
AuthorDate: Wed Jan 16 13:57:06 2019 +0200

    AMBARI-25105. Cover views of the JournalNode wizard with unit tests
---
 ambari-web/app/assets/test/tests.js                |   4 +
 .../journalNode/progress_view_test.js              |  70 +++++++
 .../journalNode/step2_view_test.js                 |  70 +++++++
 .../journalNode/step3_view_test.js                 | 208 +++++++++++++++++++++
 .../journalNode/step5_view_test.js                 |  71 +++++++
 5 files changed, 423 insertions(+)

diff --git a/ambari-web/app/assets/test/tests.js 
b/ambari-web/app/assets/test/tests.js
index 91fa7b0..30c9f8d 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -420,6 +420,10 @@ var files = [
   'test/views/main/admin/highAvailability/resourceManager/wizard_view_test',
   'test/views/main/admin/highAvailability/nameNode/wizard_view_test',
   'test/views/main/admin/highAvailability/progress_view_test',
+  'test/views/main/admin/highAvailability/journalNode/progress_view_test',
+  'test/views/main/admin/highAvailability/journalNode/step2_view_test',
+  'test/views/main/admin/highAvailability/journalNode/step3_view_test',
+  'test/views/main/admin/highAvailability/journalNode/step5_view_test',
   'test/views/common/host_progress_popup_body_view_test',
   'test/views/common/configs/config_category_container_view_test',
   'test/views/common/configs/service_config_layout_tab_compare_view_test',
diff --git 
a/ambari-web/test/views/main/admin/highAvailability/journalNode/progress_view_test.js
 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/progress_view_test.js
new file mode 100644
index 0000000..5547f8f
--- /dev/null
+++ 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/progress_view_test.js
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/main/admin/highAvailability/journalNode/progress_view');
+
+var view;
+
+describe('App.ManageJournalNodeProgressPageView', function () {
+
+  beforeEach(function() {
+    view = App.ManageJournalNodeProgressPageView.create({
+      controller: Em.Object.create({
+        loadStep: sinon.spy()
+      })
+    });
+  });
+
+  describe("#didInsertElement()", function () {
+
+    it("loadStep is called once", function () {
+      view.didInsertElement();
+      expect(view.get('controller').loadStep.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#headerTitle", function () {
+    beforeEach(function () {
+      this.mock = sinon.stub(App.router, 'get');
+    });
+    afterEach(function () {
+      this.mock.restore();
+    });
+    it("currentStep is 1", function () {
+      this.mock.returns(1);
+      view.propertyDidChange('headerTitle');
+      
expect(view.get('headerTitle')).to.equal(Em.I18n.t('admin.manageJournalNode.wizard.step1.header'));
+    });
+  });
+
+  describe("#noticeInProgress", function () {
+    beforeEach(function () {
+      this.mock = sinon.stub(App.router, 'get');
+    });
+    afterEach(function () {
+      this.mock.restore();
+    });
+    it("currentStep is 1", function () {
+      this.mock.returns(1);
+      view.propertyDidChange('noticeInProgress');
+      
expect(view.get('noticeInProgress')).to.equal(Em.I18n.t('admin.manageJournalNode.wizard.step1.notice.inProgress'));
+    });
+  });
+});
diff --git 
a/ambari-web/test/views/main/admin/highAvailability/journalNode/step2_view_test.js
 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/step2_view_test.js
new file mode 100644
index 0000000..d7219a7
--- /dev/null
+++ 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/step2_view_test.js
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/main/admin/highAvailability/journalNode/step2_view');
+
+var view;
+
+describe('App.ManageJournalNodeWizardStep2View', function () {
+
+  beforeEach(function() {
+    view = App.ManageJournalNodeWizardStep2View.create({
+      controller: Em.Object.create({
+        loadStep: sinon.spy()
+      })
+    });
+  });
+
+  describe("#didInsertElement()", function () {
+
+    it("loadStep is called once", function () {
+      view.didInsertElement();
+      expect(view.get('controller').loadStep.calledOnce).to.be.true;
+    });
+  });
+  
+  describe('#journalNodesToAdd', function() {
+    
+    it('should return journalNodes', function() {
+      sinon.stub(App.router, 'get').returns({
+        getJournalNodesToAdd: function() {
+          return [{}];
+        }
+      });
+      view.propertyDidChange('journalNodesToAdd');
+      expect(view.get('journalNodesToAdd')).to.be.eql([{}]);
+      App.router.get.restore();
+    });
+  });
+  
+  describe('#journalNodesToDelete', function() {
+    
+    it('should return journalNodes', function() {
+      sinon.stub(App.router, 'get').returns({
+        getJournalNodesToDelete: function() {
+          return [{}];
+        }
+      });
+      view.propertyDidChange('journalNodesToDelete');
+      expect(view.get('journalNodesToDelete')).to.be.eql([{}]);
+      App.router.get.restore();
+    });
+  });
+});
diff --git 
a/ambari-web/test/views/main/admin/highAvailability/journalNode/step3_view_test.js
 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/step3_view_test.js
new file mode 100644
index 0000000..7a01cb5
--- /dev/null
+++ 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/step3_view_test.js
@@ -0,0 +1,208 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/main/admin/highAvailability/journalNode/step3_view');
+
+var view;
+
+describe('App.ManageJournalNodeWizardStep3View', function () {
+
+  beforeEach(function() {
+    view = App.ManageJournalNodeWizardStep3View.create({
+      controller: Em.Object.create({
+        pullCheckPointsStatuses: sinon.spy()
+      })
+    });
+  });
+
+  describe("#didInsertElement()", function () {
+
+    it("loadStep is called once", function () {
+      view.didInsertElement();
+      
expect(view.get('controller').pullCheckPointsStatuses.calledOnce).to.be.true;
+    });
+  });
+  
+  describe('#step3BodyText', function() {
+    beforeEach(function() {
+      this.mock = sinon.stub(App.HDFSService, 'find');
+    });
+    afterEach(function() {
+      this.mock.restore();
+    });
+    
+    it('1 namespace', function() {
+      this.mock.returns(Em.Object.create({
+        masterComponentGroups: [
+          {
+            name: 'g1'
+          }
+        ]
+      }));
+      view.set('controller', {
+        content: {
+          activeNN: {
+            host_name: 'host1'
+          },
+          hdfsUser: 'hdfs'
+        }
+      });
+      view.propertyDidChange('step3BodyText');
+      expect(view.get('step3BodyText')).to.be.equal(
+        Em.I18n.t('admin.manageJournalNode.wizard.step3.body').format(
+          'host1',
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.singleNameSpace.safeModeText'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.singleNameSpace.safeModeCommand').format('hdfs'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.singleNameSpace.checkPointText'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.singleNameSpace.checkPointCommand').format('hdfs'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.singleNameSpace.proceed'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.singleNameSpace.recentCheckPoint')
+        )
+      );
+    });
+  
+    it('2 namespaces', function() {
+      this.mock.returns(Em.Object.create({
+        masterComponentGroups: [
+          {
+            name: 'g1'
+          },
+          {
+            name: 'g2'
+          }
+        ]
+      }));
+      view.set('controller', {
+        content: {
+          activeNN: {
+            host_name: 'host1'
+          },
+          hdfsUser: 'hdfs'
+        }
+      });
+      view.propertyDidChange('step3BodyText');
+      expect(view.get('step3BodyText')).to.be.equal(
+        Em.I18n.t('admin.manageJournalNode.wizard.step3.body').format(
+          'host1',
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.multipleNameSpaces.safeModeText'),
+          ['g1', 'g2'].map(function(ns) {
+            return 
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.multipleNameSpaces.safeModeCommand').format('hdfs',
 ns);
+          }).join('<br>'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.multipleNameSpaces.checkPointText'),
+          ['g1', 'g2'].map(function(ns) {
+            return 
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.multipleNameSpaces.checkPointCommand').format('hdfs',
 ns);
+          }).join('<br>'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.multipleNameSpaces.proceed'),
+          
Em.I18n.t('admin.manageJournalNode.wizard.step3.body.multipleNameSpaces.recentCheckPoint')
+        )
+      );
+    });
+  });
+  
+  describe('#nnCheckPointText', function() {
+    beforeEach(function() {
+      this.mock = sinon.stub(App.HDFSService, 'find');
+    });
+    afterEach(function() {
+      App.HDFSService.find.restore();
+    });
+    
+    it('should be empty when not loaded yet', function() {
+      view.set('controller', {
+        isHDFSNameSpacesLoaded: false
+      });
+      view.propertyDidChange('nnCheckPointText');
+      expect(view.get('nnCheckPointText')).to.be.empty;
+    });
+  
+    it('1 namespace', function() {
+      view.set('controller', {
+        isHDFSNameSpacesLoaded: true,
+        isNextEnabled: true
+      });
+      this.mock.returns(Em.Object.create({
+        masterComponentGroups: [{}]
+      }));
+      view.propertyDidChange('nnCheckPointText');
+      expect(view.get('nnCheckPointText')).to.be.equal(
+        Em.I18n.t('admin.highAvailability.wizard.step4.ckCreated')
+      );
+    });
+  
+    it('2 namespaces', function() {
+      view.set('controller', {
+        isHDFSNameSpacesLoaded: true,
+        isNextEnabled: false
+      });
+      this.mock.returns(Em.Object.create({
+        masterComponentGroups: [{}, {}]
+      }));
+      view.propertyDidChange('nnCheckPointText');
+      expect(view.get('nnCheckPointText')).to.be.equal(
+        Em.I18n.t('admin.manageJournalNode.wizard.step3.checkPointsNotCreated')
+      );
+    });
+  });
+  
+  describe('#errorText', function() {
+    beforeEach(function() {
+      this.mock = sinon.stub(App.HDFSService, 'find');
+    });
+    afterEach(function() {
+      App.HDFSService.find.restore();
+    });
+    
+    it('should be empty when not loaded yet', function() {
+      view.set('controller', {
+        isHDFSNameSpacesLoaded: false
+      });
+      view.propertyDidChange('errorText');
+      expect(view.get('errorText')).to.be.empty;
+    });
+    
+    it('1 namespace', function() {
+      view.set('controller', {
+        isHDFSNameSpacesLoaded: true,
+        isNameNodeStarted: false
+      });
+      this.mock.returns(Em.Object.create({
+        masterComponentGroups: [{}]
+      }));
+      view.propertyDidChange('errorText');
+      expect(view.get('errorText')).to.be.equal(
+        Em.I18n.t('admin.highAvailability.wizard.step4.error.nameNode')
+      );
+    });
+    
+    it('2 namespaces', function() {
+      view.set('controller', {
+        isHDFSNameSpacesLoaded: true,
+        isActiveNameNodesStarted: false
+      });
+      this.mock.returns(Em.Object.create({
+        masterComponentGroups: [{}, {}]
+      }));
+      view.propertyDidChange('errorText');
+      expect(view.get('errorText')).to.be.equal(
+        
Em.I18n.t('admin.manageJournalNode.wizard.step3.error.multipleNameSpaces.nameNodes')
+      );
+    });
+  });
+});
diff --git 
a/ambari-web/test/views/main/admin/highAvailability/journalNode/step5_view_test.js
 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/step5_view_test.js
new file mode 100644
index 0000000..de0bd49
--- /dev/null
+++ 
b/ambari-web/test/views/main/admin/highAvailability/journalNode/step5_view_test.js
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/main/admin/highAvailability/journalNode/step5_view');
+
+var view;
+
+describe('App.ManageJournalNodeWizardStep5View', function () {
+
+  beforeEach(function() {
+    view = App.ManageJournalNodeWizardStep5View.create();
+  });
+  
+  describe('#step5BodyText', function() {
+    beforeEach(function() {
+      sinon.stub(App.HDFSService, 'find').returns(Em.Object.create({
+        masterComponentGroups: [
+          {
+            name: 'g1'
+          }
+        ]
+      }));
+    });
+    afterEach(function() {
+      App.HDFSService.find.restore();
+    });
+    
+    it('should return step5 text', function() {
+      view.set('controller', {
+        content: {
+          masterComponentHosts: [
+            {
+              component: 'JOURNALNODE',
+              isInstalled: true,
+              hostName: 'host1'
+            }
+          ],
+          serviceConfigProperties: {
+            items: [{
+              type: 'hdfs-site',
+              properties: {
+                'dfs.journalnode.edits.dir': 'dir1'
+              }
+            }]
+          }
+        }
+      });
+      view.propertyDidChange('step5BodyText');
+      expect(view.get('step5BodyText')).to.be.equal(
+        Em.I18n.t('admin.manageJournalNode.wizard.step5.body').format('host1', 
'<b>dir1</b>')
+      );
+    });
+  });
+});

Reply via email to