Jelajahi Sumber

AMBARI-16814. Hive service property fields related to database setting could be deleted (alexantonenko)

Alex Antonenko 9 tahun lalu
induk
melakukan
a1ea08deb1

+ 6 - 2
ambari-web/app/controllers/wizard.js

@@ -926,8 +926,12 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
         var configProperty = App.config.createDefaultConfig(
           _configProperties.get('name'),
           _configProperties.get('filename'),
-          _configProperties.get('isUserProperty'),
-          {value: _configProperties.get('value')}
+          // need to invert boolean because this argument will be inverted in method body
+          !_configProperties.get('isUserProperty'),
+          {
+            value: _configProperties.get('value'),
+            isRequired: _configProperties.get('isRequired')
+           }
         );
         configProperty = App.config.mergeStaticProperties(configProperty, _configProperties, [], ['name', 'filename', 'isUserProperty', 'value']);
 

+ 37 - 2
ambari-web/test/controllers/wizard_test.js

@@ -1138,11 +1138,34 @@ describe('App.WizardController', function () {
             isFinal: true,
             defaultIsFinal: true,
             supportsFinal: true,
-            filename: 'filename',
+            filename: 'hdfs-site',
             displayType: 'string',
             isRequiredByAgent: true,
             hasInitialValue: true,
             isRequired: true,
+            isUserProperty: true,
+            showLabel: true,
+            category: 'some_category'
+          }),
+          Em.Object.create({
+            id: 'id',
+            name: 'name2',
+            value: 'value',
+            defaultValue: 'defaultValue',
+            description: 'description',
+            serviceName: 'serviceName',
+            domain: 'domain',
+            isVisible: true,
+            isNotDefaultValue: true,
+            isFinal: true,
+            defaultIsFinal: true,
+            supportsFinal: true,
+            filename: 'hdfs-site',
+            displayType: 'string',
+            isRequiredByAgent: true,
+            hasInitialValue: true,
+            isRequired: false,
+            isUserProperty: false,
             showLabel: true,
             category: 'some_category'
           })
@@ -1168,6 +1191,7 @@ describe('App.WizardController', function () {
             isRequiredByAgent: true,
             hasInitialValue: true,
             isRequired: true,
+            isUserProperty: false,
             group: {name: 'group'},
             showLabel: true,
             category: 'some_category'
@@ -1179,7 +1203,7 @@ describe('App.WizardController', function () {
     it('should save configs from default config group to content.serviceConfigProperties', function () {
       c.saveServiceConfigProperties(stepController);
       var saved = c.get('content.serviceConfigProperties');
-      expect(saved.length).to.equal(1);
+      expect(saved.length).to.equal(2);
       expect(saved[0].category).to.equal('some_category');
     });
 
@@ -1188,6 +1212,17 @@ describe('App.WizardController', function () {
       var saved = c.get('content.serviceConfigProperties');
       expect(saved.everyProperty('value', '')).to.be.true;
     });
+
+    it('should save `isUserProperty` and `isRequired` attributes correctly', function() {
+      c.saveServiceConfigProperties(stepController);
+      var saved = c.get('content.serviceConfigProperties'),
+          nameProp = saved.filterProperty('filename', 'hdfs-site.xml').findProperty('name', 'name'),
+          name2Prop = saved.filterProperty('filename', 'hdfs-site.xml').findProperty('name', 'name2');
+      assert.isTrue(Em.get(nameProp, 'isRequired'), 'hdfs-site.xml:name isRequired validation');
+      assert.isTrue(Em.get(nameProp, 'isUserProperty'), 'hdfs-site.xml:name isUserProperty validation');
+      assert.isFalse(Em.get(name2Prop, 'isRequired'), 'hdfs-site.xml:name2 isRequired validation');
+      assert.isFalse(Em.get(name2Prop, 'isUserProperty'), 'hdfs-site.xml:name2 isUserProperty validation');
+    });
   });
 
   describe('#enableStep', function () {