You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2016/05/16 10:00:49 UTC
ambari git commit: AMBARI-16655 Stack advisor recommendation not
working for HDFS,
YARN when ranger-plugin flag is enabled/disabled.(ababiichuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 9540df5a8 -> 31ea86c73
AMBARI-16655 Stack advisor recommendation not working for HDFS, YARN when ranger-plugin flag is enabled/disabled.(ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/31ea86c7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/31ea86c7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/31ea86c7
Branch: refs/heads/trunk
Commit: 31ea86c73b4ce8778b6bf6f44949c140cc553c13
Parents: 9540df5
Author: ababiichuk <ab...@hortonworks.com>
Authored: Fri May 13 14:03:28 2016 +0300
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Mon May 16 13:00:21 2016 +0300
----------------------------------------------------------------------
.../configs/config_recommendation_parser.js | 32 ++++++++++++-
.../config_recommendation_parser_test.js | 49 ++++++++++++++++++--
2 files changed, 77 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/31ea86c7/ambari-web/app/mixins/common/configs/config_recommendation_parser.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/config_recommendation_parser.js b/ambari-web/app/mixins/common/configs/config_recommendation_parser.js
index 65cc20f..7c5d2ae 100644
--- a/ambari-web/app/mixins/common/configs/config_recommendation_parser.js
+++ b/ambari-web/app/mixins/common/configs/config_recommendation_parser.js
@@ -23,6 +23,19 @@ App.ConfigRecommendationParser = Em.Mixin.create(App.ConfigRecommendations, {
stepConfigs: [],
+ modifiedFileNames: [],
+
+ /**
+ * Adds new modified file name if it's not in the list yet
+ *
+ * @param filename
+ */
+ addModifiedFileName: function(filename) {
+ App.assertExists(filename);
+ if (!this.get('modifiedFileNames').contains(filename))
+ this.get('modifiedFileNames').push(filename);
+ },
+
/**
* Method that goes through all configs
* and apply recommendations using callbacks
@@ -190,7 +203,8 @@ App.ConfigRecommendationParser = Em.Mixin.create(App.ConfigRecommendations, {
"value": recommendedValue,
"recommendedValue": recommendedValue,
"initialValue": this.updateInitialOnRecommendations(serviceName) ? recommendedValue : initialValue,
- "savedValue": !this.useInitialValue(serviceName) ? initialValue : null
+ "savedValue": !this.useInitialValue(serviceName) ? initialValue : null,
+ "isNotSaved": Em.isNone(initialValue)
}
},
@@ -207,12 +221,28 @@ App.ConfigRecommendationParser = Em.Mixin.create(App.ConfigRecommendations, {
App.assertObject(config);
App.assertArray(configsCollection);
+ if (this._configHasInitialValue(config)) {
+ this.addModifiedFileName(Em.get(config, 'filename'));
+ }
+
configsCollection.removeObject(config);
this.applyRecommendation(Em.get(config, 'name'), Em.get(config, 'filename'), Em.get(config, 'group.name'),
null, this._getInitialValue(config), parentProperties);
},
+ /**
+ * Defines if property was defined on initial load or was saved.
+ *
+ * @param config
+ * @returns {boolean}
+ * @private
+ */
+ _configHasInitialValue: function(config) {
+ App.assertObject(config);
+ return !Em.isNone(Em.get(config, 'savedValue')) && !Em.isNone(Em.get(config, 'initialValue'));
+ },
+
/**
* Update config valueAttributes by recommendations
*
http://git-wip-us.apache.org/repos/asf/ambari/blob/31ea86c7/ambari-web/test/mixins/common/configs/config_recommendation_parser_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/config_recommendation_parser_test.js b/ambari-web/test/mixins/common/configs/config_recommendation_parser_test.js
index 8b983f1..8572772 100644
--- a/ambari-web/test/mixins/common/configs/config_recommendation_parser_test.js
+++ b/ambari-web/test/mixins/common/configs/config_recommendation_parser_test.js
@@ -339,7 +339,8 @@ describe('App.ConfigRecommendationParser', function() {
'value': 'recommendedValue',
'recommendedValue': 'recommendedValue',
'initialValue': 'recommendedValue',
- 'savedValue': null
+ 'savedValue': null,
+ 'isNotSaved': false
}
},
{
@@ -350,7 +351,8 @@ describe('App.ConfigRecommendationParser', function() {
'value': 'recommendedValue',
'recommendedValue': 'recommendedValue',
'initialValue': 'initValue',
- 'savedValue': null
+ 'savedValue': null,
+ 'isNotSaved': false
}
},
{
@@ -361,7 +363,8 @@ describe('App.ConfigRecommendationParser', function() {
'value': 'recommendedValue',
'recommendedValue': 'recommendedValue',
'initialValue': 'initValue',
- 'savedValue': 'initValue'
+ 'savedValue': 'initValue',
+ 'isNotSaved': false
}
}
];
@@ -474,6 +477,46 @@ describe('App.ConfigRecommendationParser', function() {
expect(instanceObject.allowUpdateProperty()).to.be.true;
});
});
+
+ describe('#_configHasInitialValue', function() {
+ it('throws error when config is null', function() {
+ expect(instanceObject._configHasInitialValue.bind(instanceObject, null)).to.throw(App.ObjectTypeError);
+ });
+
+ it('throws error when config is not object', function() {
+ expect(instanceObject._configHasInitialValue.bind(instanceObject, 'not object')).to.throw(App.ObjectTypeError);
+ });
+
+ it('returns true if initial and saved value is defined', function() {
+ expect(instanceObject._configHasInitialValue({'savedValue': 'some', 'initialValue': 'most of all the same'})).to.be.true;
+ });
+
+ it('returns false if saved value is not defined', function() {
+ expect(instanceObject._configHasInitialValue({'savedValue': null, 'initialValue': 'some'})).to.be.false;
+ });
+
+ it('returns false if initial value is not defined', function() {
+ expect(instanceObject._configHasInitialValue({'savedValue': 'some', 'initialValue': null })).to.be.false;
+ });
+ });
+
+ describe('#addModifiedFileName', function() {
+ it('throws error when filename is not defined', function() {
+ expect(instanceObject.addModifiedFileName.bind(instanceObject, null)).to.throw(App.NotNullTypeError);
+ });
+
+ it('add new file name', function() {
+ instanceObject.set('modifiedFileNames', ['someFile']);
+ instanceObject.addModifiedFileName('otherFile');
+ expect(instanceObject.get('modifiedFileNames').join(',')).to.eql('someFile,otherFile');
+ });
+
+ it('do not add file that already in list', function() {
+ instanceObject.set('modifiedFileNames', ['someFile']);
+ instanceObject.addModifiedFileName('someFile');
+ expect(instanceObject.get('modifiedFileNames').join(',')).to.eql('someFile');
+ });
+ });
});