AMBARI-9268. Config changes doesn't affect client components (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 1d01d35a6cc612ca4562371fa84e4a3064a05f91
Parents: 2e10a75
Author: Alex Antonenko <hiv...@gmail.com>
Authored: Thu Jan 22 20:59:05 2015 +0200
Committer: Alex Antonenko <hiv...@gmail.com>
Committed: Thu Jan 22 22:50:29 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/models/service.js       |  2 +-
 ambari-web/test/models/service_test.js | 31 ++++++++++++++++++++++-------
 2 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1d01d35a/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index 69fa446..3de8001 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -95,7 +95,7 @@ App.Service = DS.Model.extend({
    * actual_configs, then a restart is required.
    */
   isRestartRequired: function () {
-    var rhc = this.get('hostComponents').filterProperty('staleConfigs', true);
+    var rhc = App.HostComponent.find().filterProperty('service.serviceName', 
this.get('serviceName')).filterProperty('staleConfigs', true);
     var hc = {};
     rhc.forEach(function(_rhc) {
       var hostName = _rhc.get('hostName');

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d01d35a/ambari-web/test/models/service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/service_test.js 
b/ambari-web/test/models/service_test.js
index f93f0e0..ad7d7fa 100644
--- a/ambari-web/test/models/service_test.js
+++ b/ambari-web/test/models/service_test.js
@@ -140,7 +140,9 @@ var service,
     ],
     [
       {
-        serviceName: 'HIVE',
+        service: {
+          serviceName: 'HIVE'
+        },
         staleConfigs: false
       }
     ]
@@ -148,6 +150,9 @@ var service,
   hostComponentsDataTrue = [
     [
       Em.Object.create({
+        service: {
+          serviceName: 'HDFS'
+        },
         staleConfigs: true,
         displayName: 'service0'
       })
@@ -157,6 +162,9 @@ var service,
         host: {
           publicHostName: 'host0'
         },
+        service: {
+          serviceName: 'HDFS'
+        },
         staleConfigs: true,
         displayName: 'service1'
       })
@@ -214,19 +222,28 @@ describe('App.Service', function () {
   });
 
   describe('#isRestartRequired', function () {
+    var mockHostComponentModel = function (mock) {
+      sinon.stub(App.HostComponent, 'find', function () {
+        return mock;
+      });
+    }
+    beforeEach(function () {
+      service.reopen({
+        serviceName: 'HDFS'
+      });
+    });
+    afterEach(function () {
+      App.HostComponent.find.restore();
+    });
     hostComponentsDataFalse.forEach(function (item) {
       it('should be false', function () {
-        service.reopen({
-          hostComponents: item
-        });
+        mockHostComponentModel(item);
         expect(service.get('isRestartRequired')).to.be.false;
       });
     });
     hostComponentsDataTrue.forEach(function (item) {
       it('should be true', function () {
-        service.reopen({
-          hostComponents: item
-        });
+        mockHostComponentModel(item);
         expect(service.get('isRestartRequired')).to.be.true;
       });
     });

Reply via email to