Преглед на файлове

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

Jun Aoki преди 10 години
родител
ревизия
4d5d882db5
променени са 2 файла, в които са добавени 221 реда и са изтрити 11 реда
  1. 11 11
      ambari-web/app/controllers/main/service/info/configs.js
  2. 210 0
      ambari-web/test/controllers/main/service/info/config_test.js

+ 11 - 11
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;

+ 210 - 0
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 = [