ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject git commit: AMBARI-7639 HDFS config will not save (nandat via jaoki)
Date Fri, 10 Oct 2014 00:20:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 06f54386c -> 4d5d882db


AMBARI-7639 HDFS config will not save (nandat via jaoki)


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

Branch: refs/heads/trunk
Commit: 4d5d882db57041898be7286dfd948e6e8a946202
Parents: 06f5438
Author: Jun Aoki <jaoki@apache.org>
Authored: Thu Oct 9 17:20:13 2014 -0700
Committer: Jun Aoki <jaoki@apache.org>
Committed: Thu Oct 9 17:20:13 2014 -0700

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    |  22 +-
 .../main/service/info/config_test.js            | 210 +++++++++++++++++++
 2 files changed, 221 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4d5d882d/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 2210920..386ec96 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1313,23 +1313,23 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
     if (serviceName === 'HDFS') {
       var hdfsConfigs = this.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs');
       if (App.get('isHadoop2Stack')) {
-        if (hdfsConfigs.findProperty('name', 'dfs.namenode.name.dir').get('isNotDefaultValue')
||
-          hdfsConfigs.findProperty('name', 'dfs.namenode.checkpoint.dir').get('isNotDefaultValue')
||
-          hdfsConfigs.findProperty('name', 'dfs.datanode.data.dir').get('isNotDefaultValue'))
{
-          dirChanged = true;
+        if ((hdfsConfigs.findProperty('name', 'dfs.namenode.name.dir') && hdfsConfigs.findProperty('name',
'dfs.namenode.name.dir').get('isNotDefaultValue')) ||
+            (hdfsConfigs.findProperty('name', 'dfs.namenode.checkpoint.dir') && hdfsConfigs.findProperty('name',
'dfs.namenode.checkpoint.dir').get('isNotDefaultValue')) ||
+            (hdfsConfigs.findProperty('name', 'dfs.datanode.data.dir') && hdfsConfigs.findProperty('name',
'dfs.datanode.data.dir').get('isNotDefaultValue'))) {
+            dirChanged = true;
         }
       } else {
-        if (hdfsConfigs.findProperty('name', 'dfs.name.dir').get('isNotDefaultValue') ||
-          hdfsConfigs.findProperty('name', 'fs.checkpoint.dir').get('isNotDefaultValue')
||
-          hdfsConfigs.findProperty('name', 'dfs.data.dir').get('isNotDefaultValue')) {
-          dirChanged = true;
+        if ((hdfsConfigs.findProperty('name', 'dfs.name.dir') && hdfsConfigs.findProperty('name',
'dfs.name.dir').get('isNotDefaultValue')) ||
+            (hdfsConfigs.findProperty('name', 'fs.checkpoint.dir') && hdfsConfigs.findProperty('name',
'fs.checkpoint.dir').get('isNotDefaultValue')) ||
+            (hdfsConfigs.findProperty('name', 'dfs.data.dir') && hdfsConfigs.findProperty('name',
'dfs.data.dir').get('isNotDefaultValue'))) {
+             dirChanged = true;
         }
       }
     } else if (serviceName === 'MAPREDUCE') {
       var mapredConfigs = this.get('stepConfigs').findProperty('serviceName', 'MAPREDUCE').get('configs');
-      if (mapredConfigs.findProperty('name', 'mapred.local.dir').get('isNotDefaultValue')
||
-        mapredConfigs.findProperty('name', 'mapred.system.dir').get('isNotDefaultValue'))
{
-        dirChanged = true;
+      if ((mapredConfigs.findProperty('name', 'mapred.local.dir') && mapredConfigs.findProperty('name',
'mapred.local.dir').get('isNotDefaultValue')) ||
+          (mapredConfigs.findProperty('name', 'mapred.system.dir') && mapredConfigs.findProperty('name',
'mapred.system.dir').get('isNotDefaultValue'))) {
+            dirChanged = true;
       }
     }
     return dirChanged;

http://git-wip-us.apache.org/repos/asf/ambari/blob/4d5d882d/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index e11ad38..e2cf89b 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -650,6 +650,216 @@ describe("App.MainServiceInfoConfigsController", function () {
     });
   });
 
+  describe("#isDirChanged", function() {
+
+    describe("when service name is HDFS", function() {
+      beforeEach(function() {
+        mainServiceInfoConfigsController.set('content', Ember.Object.create ({ serviceName:
'HDFS' }));
+      });
+
+      describe("when isHadoop2Stack is true", function() {
+
+        var tests = [
+          {
+            it: "should set dirChanged to false if none of the properties exist",
+            expect: false,
+            config: Ember.Object.create ({})
+          },
+          {
+            it: "should set dirChanged to true if dfs.namenode.name.dir is not default",
+            expect: true,
+            config: Ember.Object.create ({
+              name: 'dfs.namenode.name.dir',
+              isNotDefaultValue: true
+            })
+          },
+          {
+            it: "should set dirChanged to false if dfs.namenode.name.dir is default",
+            expect: false,
+            config: Ember.Object.create ({
+              name: 'dfs.namenode.name.dir',
+              isNotDefaultValue: false
+            })
+          },
+          {
+            it: "should set dirChanged to true if dfs.namenode.checkpoint.dir is not default",
+            expect: true,
+            config: Ember.Object.create ({
+              name: 'dfs.namenode.checkpoint.dir',
+              isNotDefaultValue: true
+            })
+          },
+          {
+            it: "should set dirChanged to false if dfs.namenode.checkpoint.dir is default",
+            expect: false,
+            config: Ember.Object.create ({
+              name: 'dfs.namenode.checkpoint.dir',
+              isNotDefaultValue: false
+            })
+          },
+          {
+            it: "should set dirChanged to true if dfs.datanode.data.dir is not default",
+            expect: true,
+            config: Ember.Object.create ({
+              name: 'dfs.datanode.data.dir',
+              isNotDefaultValue: true
+            })
+          },
+          {
+            it: "should set dirChanged to false if dfs.datanode.data.dir is default",
+            expect: false,
+            config: Ember.Object.create ({
+              name: 'dfs.datanode.data.dir',
+              isNotDefaultValue: false
+            })
+          }
+        ];
+
+        beforeEach(function() {
+          sinon.stub(App, 'get').returns(true);
+        });
+
+        afterEach(function() {
+          App.get.restore();
+        });
+
+        tests.forEach(function(test) {
+          it(test.it, function() {
+            mainServiceInfoConfigsController.set('stepConfigs', [Ember.Object.create ({ configs:
[test.config], serviceName: 'HDFS' })]);
+            expect(mainServiceInfoConfigsController.isDirChanged()).to.equal(test.expect);
+          })
+        });
+      });
+
+      describe("when isHadoop2Stack is false", function() {
+
+        var tests = [
+          {
+            it: "should set dirChanged to false if none of the properties exist",
+            expect: false,
+            config: Ember.Object.create ({})
+          },
+          {
+            it: "should set dirChanged to true if dfs.name.dir is not default",
+            expect: true,
+            config: Ember.Object.create ({
+              name: 'dfs.name.dir',
+              isNotDefaultValue: true
+            })
+          },
+          {
+            it: "should set dirChanged to false if dfs.name.dir is default",
+            expect: false,
+            config: Ember.Object.create ({
+              name: 'dfs.name.dir',
+              isNotDefaultValue: false
+            })
+          },
+          {
+            it: "should set dirChanged to true if fs.checkpoint.dir is not default",
+            expect: true,
+            config: Ember.Object.create ({
+              name: 'fs.checkpoint.dir',
+              isNotDefaultValue: true
+            })
+          },
+          {
+            it: "should set dirChanged to false if fs.checkpoint.dir is default",
+            expect: false,
+            config: Ember.Object.create ({
+              name: 'fs.checkpoint.dir',
+              isNotDefaultValue: false
+            })
+          },
+          {
+            it: "should set dirChanged to true if dfs.data.dir is not default",
+            expect: true,
+            config: Ember.Object.create ({
+              name: 'dfs.data.dir',
+              isNotDefaultValue: true
+            })
+          },
+          {
+            it: "should set dirChanged to false if dfs.data.dir is default",
+            expect: false,
+            config: Ember.Object.create ({
+              name: 'dfs.data.dir',
+              isNotDefaultValue: false
+            })
+          }
+        ];
+
+        beforeEach(function() {
+          sinon.stub(App, 'get').returns(false);
+        });
+
+        afterEach(function() {
+          App.get.restore();
+        });
+
+        tests.forEach(function(test) {
+          it(test.it, function() {
+            mainServiceInfoConfigsController.set('stepConfigs', [Ember.Object.create ({ configs:
[test.config], serviceName: 'HDFS' })]);
+            expect(mainServiceInfoConfigsController.isDirChanged()).to.equal(test.expect);
+          })
+        });
+      });
+    });
+
+    describe("when service name is MAPREDUCE", function() {
+      beforeEach(function() {
+        mainServiceInfoConfigsController.set('content', Ember.Object.create ({ serviceName:
'MAPREDUCE' }));
+      });
+
+      var tests = [
+        {
+          it: "should set dirChanged to false if none of the properties exist",
+          expect: false,
+          config: Ember.Object.create ({})
+        },
+        {
+          it: "should set dirChanged to true if mapred.local.dir is not default",
+          expect: true,
+          config: Ember.Object.create ({
+            name: 'mapred.local.dir',
+            isNotDefaultValue: true
+          })
+        },
+        {
+          it: "should set dirChanged to false if mapred.local.dir is default",
+          expect: false,
+          config: Ember.Object.create ({
+            name: 'mapred.local.dir',
+            isNotDefaultValue: false
+          })
+        },
+        {
+          it: "should set dirChanged to true if mapred.system.dir is not default",
+          expect: true,
+          config: Ember.Object.create ({
+            name: 'mapred.system.dir',
+            isNotDefaultValue: true
+          })
+        },
+        {
+          it: "should set dirChanged to false if mapred.system.dir is default",
+          expect: false,
+          config: Ember.Object.create ({
+            name: 'mapred.system.dir',
+            isNotDefaultValue: false
+          })
+        }
+      ];
+
+      tests.forEach(function(test) {
+        it(test.it, function() {
+          mainServiceInfoConfigsController.set('stepConfigs', [Ember.Object.create ({ configs:
[test.config], serviceName: 'MAPREDUCE' })]);
+          expect(mainServiceInfoConfigsController.isDirChanged()).to.equal(test.expect);
+        })
+      });
+    });
+  });
+
   describe("#addDynamicProperties", function() {
 
     var tests = [


Mime
View raw message