You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2014/09/09 03:23:20 UTC

git commit: AMBARI-7213. Fix ui unit tests for app.js. (jaimin)

Repository: ambari
Updated Branches:
  refs/heads/trunk aed657853 -> 221c5a13f


AMBARI-7213. Fix ui unit tests for app.js. (jaimin)


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

Branch: refs/heads/trunk
Commit: 221c5a13f29d4bdf3df463a968f34b4b45a39203
Parents: aed6578
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Mon Sep 8 18:23:25 2014 -0700
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Mon Sep 8 18:23:31 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/app.js                           |  2 +-
 ambari-web/test/app_test.js                     | 39 +++++++++++++++++++-
 .../test/controllers/main/host/details_test.js  |  9 ++++-
 3 files changed, 47 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/221c5a13/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index aa1281a..a690e82 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -88,7 +88,7 @@ module.exports = Em.Application.create({
   isHaEnabled: function () {
     if (!this.get('isHadoop2Stack')) return false;
     var isHDFSInstalled = App.Service.find().findProperty('serviceName','HDFS');
-    return isHDFSInstalled && !this.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE');
+    return !!isHDFSInstalled && !this.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE');
   }.property('router.clusterController.isLoaded', 'isHadoop2Stack'),
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/221c5a13/ambari-web/test/app_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js
index 749b245..a8f5151 100644
--- a/ambari-web/test/app_test.js
+++ b/ambari-web/test/app_test.js
@@ -199,7 +199,20 @@ describe('App', function () {
     });
   });
 
-  describe('#isHaEnabled', function () {
+  describe('#isHaEnabled when HDFS is installed:', function () {
+
+    beforeEach(function () {
+      sinon.stub(App.Service, 'find', function () {
+        return [{
+          id : 'HDFS',
+          serviceName: 'HDFS'
+        }];
+      });
+    });
+
+    afterEach(function () {
+      App.Service.find.restore();
+    });
 
     it('if hadoop stack version less than 2 then isHaEnabled should be false', function () {
       App.set('currentStackVersion', 'HDP-1.3.1');
@@ -222,6 +235,30 @@ describe('App', function () {
     });
   });
 
+  describe('#isHaEnabled when HDFS is not installed:', function () {
+
+    beforeEach(function () {
+      sinon.stub(App.Service, 'find', function () {
+        return [{
+          id : 'ZOOKEEPER',
+          serviceName: 'ZOOKEEPER'
+        }];
+      });
+    });
+
+    afterEach(function () {
+      App.Service.find.restore();
+    });
+
+    it('if hadoop stack version higher than 2 but HDFS not installed then isHaEnabled should be false', function () {
+      App.set('currentStackVersion', 'HDP-2.1');
+      expect(App.get('isHaEnabled')).to.equal(false);
+      App.set('currentStackVersion', "HDP-1.2.2");
+    });
+
+  });
+
+
   describe('#services', function () {
     var stackServices = [
       Em.Object.create({

http://git-wip-us.apache.org/repos/asf/ambari/blob/221c5a13/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index bd5ad09..bc4159a 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -429,6 +429,10 @@ describe('App.MainHostDetailsController', function () {
       expect(controller.constructConfigUrlParams(data)).to.eql([]);
     });
     it('isHaEnabled = true', function () {
+      App.store.load(App.Service, {
+        id: 'HDFS',
+        service_name: 'HDFS'
+      });
       var data = {Clusters: {desired_configs: {'core-site': {tag: 1}}}};
       App.HostComponent.find().clear();
       App.set('currentStackVersion', 'HDP-2.0.2');
@@ -540,7 +544,6 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#setZKConfigs()', function () {
-
     it('configs is null', function () {
       expect(controller.setZKConfigs(null)).to.be.false;
     });
@@ -550,6 +553,10 @@ describe('App.MainHostDetailsController', function () {
     it('isHaEnabled = true', function () {
       var configs = {'core-site': {}};
       App.HostComponent.find().clear();
+      App.store.load(App.Service, {
+        id: 'HDFS',
+        service_name: 'HDFS'
+      });
       App.set('currentStackVersion', 'HDP-2.0.2');
       expect(controller.setZKConfigs(configs, 'host1:2181', [])).to.be.true;
       expect(configs).to.eql({"core-site": {