You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2015/10/22 16:09:58 UTC
ambari git commit: AMBARI-13504 Enable Ranger plugin properties
should be validated to have same value as in Ranger service (dsen)
Repository: ambari
Updated Branches:
refs/heads/trunk 381c49f45 -> b9bb0d351
AMBARI-13504 Enable Ranger plugin properties should be validated to have same value as in Ranger service (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b9bb0d35
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b9bb0d35
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b9bb0d35
Branch: refs/heads/trunk
Commit: b9bb0d3518c592b07e4b23db53905c1de20c8529
Parents: 381c49f
Author: Dmytro Sen <ds...@apache.org>
Authored: Thu Oct 22 17:09:48 2015 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Thu Oct 22 17:09:48 2015 +0300
----------------------------------------------------------------------
.../stacks/HDP/2.0.6/services/stack_advisor.py | 11 +-
.../stacks/HDP/2.2/services/stack_advisor.py | 109 +++++++-
.../stacks/2.0.6/common/test_stack_advisor.py | 43 ++++
.../stacks/2.2/common/test_stack_advisor.py | 247 ++++++++++++++++++-
4 files changed, 403 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/b9bb0d35/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index 3db5bfd..d62f44b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -549,7 +549,7 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
if include_zookeeper:
zookeeper_hosts = self.getHostNamesWithComponent("ZOOKEEPER", "ZOOKEEPER_SERVER", services)
- zookeeper_port = 2181 #default port
+ zookeeper_port = '2181' #default port
if 'zoo.cfg' in services['configurations'] and ('clientPort' in services['configurations']['zoo.cfg']['properties']):
zookeeper_port = services['configurations']['zoo.cfg']['properties']['clientPort']
@@ -1190,6 +1190,15 @@ def getSiteProperties(configurations, siteName):
return None
return siteConfig.get("properties")
+def getServicesSiteProperties(services, siteName):
+ configurations = services.get("configurations")
+ if not configurations:
+ return None
+ siteConfig = configurations.get(siteName)
+ if siteConfig is None:
+ return None
+ return siteConfig.get("properties")
+
def to_number(s):
try:
return int(re.sub("\D", "", s))
http://git-wip-us.apache.org/repos/asf/ambari/blob/b9bb0d35/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
index 3192ca2..cf9c91e 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
@@ -751,13 +751,19 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
parentValidators = super(HDP22StackAdvisor, self).getServiceConfigurationValidators()
childValidators = {
"HDFS": {"hdfs-site": self.validateHDFSConfigurations,
- "hadoop-env": self.validateHDFSConfigurationsEnv},
- "YARN": {"yarn-env": self.validateYARNEnvConfigurations},
+ "hadoop-env": self.validateHDFSConfigurationsEnv,
+ "ranger-hdfs-plugin-properties": self.validateHDFSRangerPluginConfigurations},
+ "YARN": {"yarn-env": self.validateYARNEnvConfigurations,
+ "ranger-yarn-plugin-properties": self.validateYARNRangerPluginConfigurations},
"HIVE": {"hiveserver2-site": self.validateHiveServer2Configurations,
"hive-site": self.validateHiveConfigurations,
"hive-env": self.validateHiveConfigurationsEnv},
"HBASE": {"hbase-site": self.validateHBASEConfigurations,
- "hbase-env": self.validateHBASEEnvConfigurations},
+ "hbase-env": self.validateHBASEEnvConfigurations,
+ "ranger-hbase-plugin-properties": self.validateHBASERangerPluginConfigurations},
+ "KNOX": {"ranger-knox-plugin-properties": self.validateKnoxRangerPluginConfigurations},
+ "KAFKA": {"ranger-kafka-plugin-properties": self.validateKafkaRangerPluginConfigurations},
+ "STORM": {"ranger-storm-plugin-properties": self.validateStormRangerPluginConfigurations},
"MAPREDUCE2": {"mapred-site": self.validateMapReduce2Configurations},
"TEZ": {"tez-site": self.validateTezConfigurations}
}
@@ -859,7 +865,22 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
{"config-name": 'namenode_opt_newsize', "item": self.validatorLessThenDefaultValue(properties, recommendedDefaults, 'namenode_opt_newsize')},
{"config-name": 'namenode_opt_maxnewsize', "item": self.validatorLessThenDefaultValue(properties, recommendedDefaults, 'namenode_opt_maxnewsize')}]
return self.toConfigurationValidationProblems(validationItems, "hadoop-env")
-
+
+ def validateHDFSRangerPluginConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
+ validationItems = []
+ ranger_plugin_properties = getSiteProperties(configurations, "ranger-hdfs-plugin-properties")
+ ranger_plugin_enabled = ranger_plugin_properties['ranger-hdfs-plugin-enabled'] if ranger_plugin_properties else 'No'
+ if (ranger_plugin_enabled.lower() == 'yes'):
+ # ranger-hdfs-plugin must be enabled in ranger-env
+ ranger_env = getServicesSiteProperties(services, 'ranger-env')
+ if not ranger_env or not 'ranger-hdfs-plugin-enabled' in ranger_env or \
+ ranger_env['ranger-hdfs-plugin-enabled'].lower() != 'yes':
+ validationItems.append({"config-name": 'ranger-hdfs-plugin-enabled',
+ "item": self.getWarnItem(
+ "ranger-hdfs-plugin-properties/ranger-hdfs-plugin-enabled must correspond ranger-env/ranger-hdfs-plugin-enabled")})
+ return self.toConfigurationValidationProblems(validationItems, "ranger-hdfs-plugin-properties")
+
+
def validateHDFSConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
# We can not access property hadoop.security.authentication from the
# other config (core-site). That's why we are using another heuristics here
@@ -1061,7 +1082,15 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
authorization_item = self.getErrorItem("hive_security_authorization should not be None "
"if hive.security.authorization.enabled is set")
validationItems.append({"config-name": "hive_security_authorization", "item": authorization_item})
-
+ if "hive_security_authorization" in hive_env and \
+ str(hive_env["hive_security_authorization"]).lower() == "ranger":
+ # ranger-hive-plugin must be enabled in ranger-env
+ ranger_env = getServicesSiteProperties(services, 'ranger-env')
+ if not ranger_env or not 'ranger-hive-plugin-enabled' in ranger_env or \
+ ranger_env['ranger-hive-plugin-enabled'].lower() != 'yes':
+ validationItems.append({"config-name": 'hive_security_authorization',
+ "item": self.getWarnItem(
+ "ranger-env/ranger-hive-plugin-enabled must be enabled when hive_security_authorization is set to Ranger")})
return self.toConfigurationValidationProblems(validationItems, "hive-env")
def validateHiveConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
@@ -1185,6 +1214,62 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
return self.toConfigurationValidationProblems(validationItems, "hbase-env")
+ def validateHBASERangerPluginConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
+ validationItems = []
+ ranger_plugin_properties = getSiteProperties(configurations, "ranger-hbase-plugin-properties")
+ ranger_plugin_enabled = ranger_plugin_properties['ranger-hbase-plugin-enabled'] if ranger_plugin_properties else 'No'
+ if ranger_plugin_enabled.lower() == 'yes':
+ # ranger-hdfs-plugin must be enabled in ranger-env
+ ranger_env = getServicesSiteProperties(services, 'ranger-env')
+ if not ranger_env or not 'ranger-hbase-plugin-enabled' in ranger_env or \
+ ranger_env['ranger-hbase-plugin-enabled'].lower() != 'yes':
+ validationItems.append({"config-name": 'ranger-hbase-plugin-enabled',
+ "item": self.getWarnItem(
+ "ranger-hbase-plugin-properties/ranger-hbase-plugin-enabled must correspond ranger-env/ranger-hbase-plugin-enabled")})
+ return self.toConfigurationValidationProblems(validationItems, "ranger-hbase-plugin-properties")
+
+ def validateKnoxRangerPluginConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
+ validationItems = []
+ ranger_plugin_properties = getSiteProperties(configurations, "ranger-knox-plugin-properties")
+ ranger_plugin_enabled = ranger_plugin_properties['ranger-knox-plugin-enabled'] if ranger_plugin_properties else 'No'
+ if ranger_plugin_enabled.lower() == 'yes':
+ # ranger-hdfs-plugin must be enabled in ranger-env
+ ranger_env = getServicesSiteProperties(services, 'ranger-env')
+ if not ranger_env or not 'ranger-knox-plugin-enabled' in ranger_env or \
+ ranger_env['ranger-knox-plugin-enabled'].lower() != 'yes':
+ validationItems.append({"config-name": 'ranger-knox-plugin-enabled',
+ "item": self.getWarnItem(
+ "ranger-knox-plugin-properties/ranger-knox-plugin-enabled must correspond ranger-env/ranger-knox-plugin-enabled")})
+ return self.toConfigurationValidationProblems(validationItems, "ranger-knox-plugin-properties")
+
+ def validateKafkaRangerPluginConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
+ validationItems = []
+ ranger_plugin_properties = getSiteProperties(configurations, "ranger-kafka-plugin-properties")
+ ranger_plugin_enabled = ranger_plugin_properties['ranger-kafka-plugin-enabled'] if ranger_plugin_properties else 'No'
+ if ranger_plugin_enabled.lower() == 'yes':
+ # ranger-hdfs-plugin must be enabled in ranger-env
+ ranger_env = getServicesSiteProperties(services, 'ranger-env')
+ if not ranger_env or not 'ranger-kafka-plugin-enabled' in ranger_env or \
+ ranger_env['ranger-kafka-plugin-enabled'].lower() != 'yes':
+ validationItems.append({"config-name": 'ranger-kafka-plugin-enabled',
+ "item": self.getWarnItem(
+ "ranger-kafka-plugin-properties/ranger-kafka-plugin-enabled must correspond ranger-env/ranger-kafka-plugin-enabled")})
+ return self.toConfigurationValidationProblems(validationItems, "ranger-kafka-plugin-properties")
+
+ def validateStormRangerPluginConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
+ validationItems = []
+ ranger_plugin_properties = getSiteProperties(configurations, "ranger-storm-plugin-properties")
+ ranger_plugin_enabled = ranger_plugin_properties['ranger-storm-plugin-enabled'] if ranger_plugin_properties else 'No'
+ if ranger_plugin_enabled.lower() == 'yes':
+ # ranger-hdfs-plugin must be enabled in ranger-env
+ ranger_env = getServicesSiteProperties(services, 'ranger-env')
+ if not ranger_env or not 'ranger-storm-plugin-enabled' in ranger_env or \
+ ranger_env['ranger-storm-plugin-enabled'].lower() != 'yes':
+ validationItems.append({"config-name": 'ranger-storm-plugin-enabled',
+ "item": self.getWarnItem(
+ "ranger-storm-plugin-properties/ranger-storm-plugin-enabled must correspond ranger-env/ranger-storm-plugin-enabled")})
+ return self.toConfigurationValidationProblems(validationItems, "ranger-storm-plugin-properties")
+
def validateYARNEnvConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
validationItems = []
if "yarn_cgroups_enabled" in properties:
@@ -1198,6 +1283,20 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
"item": self.getWarnItem("CPU Isolation should only be enabled if security is enabled")})
return self.toConfigurationValidationProblems(validationItems, "yarn-env")
+ def validateYARNRangerPluginConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
+ validationItems = []
+ ranger_plugin_properties = getSiteProperties(configurations, "ranger-yarn-plugin-properties")
+ ranger_plugin_enabled = ranger_plugin_properties['ranger-yarn-plugin-enabled'] if ranger_plugin_properties else 'No'
+ if ranger_plugin_enabled.lower() == 'yes':
+ # ranger-hdfs-plugin must be enabled in ranger-env
+ ranger_env = getServicesSiteProperties(services, 'ranger-env')
+ if not ranger_env or not 'ranger-yarn-plugin-enabled' in ranger_env or \
+ ranger_env['ranger-yarn-plugin-enabled'].lower() != 'yes':
+ validationItems.append({"config-name": 'ranger-yarn-plugin-enabled',
+ "item": self.getWarnItem(
+ "ranger-yarn-plugin-properties/ranger-yarn-plugin-enabled must correspond ranger-env/ranger-yarn-plugin-enabled")})
+ return self.toConfigurationValidationProblems(validationItems, "ranger-yarn-plugin-properties")
+
def getMastersWithMultipleInstances(self):
result = super(HDP22StackAdvisor, self).getMastersWithMultipleInstances()
result.extend(['METRICS_COLLECTOR'])
http://git-wip-us.apache.org/repos/asf/ambari/blob/b9bb0d35/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
index 85d6436..0b8430d 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
@@ -1619,3 +1619,46 @@ class TestHDP206StackAdvisor(TestCase):
recommendedDefaults = {}
expected = {'level': 'ERROR', 'message': 'Value should be recommended for property1'}
self.assertEquals(self.stackAdvisor.validatorEqualsToRecommendedItem(properties, recommendedDefaults, "property1"), expected)
+
+ def test_getServicesSiteProperties(self):
+ import imp, os
+ testDirectory = os.path.dirname(os.path.abspath(__file__))
+ hdp206StackAdvisorPath = os.path.join(testDirectory, '../../../../../main/resources/stacks/HDP/2.0.6/services/stack_advisor.py')
+ stack_advisor = imp.load_source('stack_advisor', hdp206StackAdvisorPath)
+ services = {
+ "services": [
+ {
+ "StackServices": {
+ "service_name": "RANGER"
+ },
+ "components": [
+ {
+ "StackServiceComponents": {
+ "component_name": "RANGER_ADMIN",
+ "hostnames": ["host1"]
+ }
+ }
+ ]
+ },
+ ],
+ "configurations": {
+ "admin-properties": {
+ "properties": {
+ "DB_FLAVOR": "NOT_EXISTING",
+ }
+ },
+ "ranger-admin-site": {
+ "properties": {
+ "ranger.service.http.port": "7777",
+ "ranger.service.http.enabled": "true",
+ }
+ }
+ }
+ }
+ expected = {
+ "ranger.service.http.port": "7777",
+ "ranger.service.http.enabled": "true",
+ }
+ siteProperties = stack_advisor.getServicesSiteProperties(services, "ranger-admin-site")
+ self.assertEquals(siteProperties, expected)
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/b9bb0d35/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
index 3362c94..2ce1cee 100644
--- a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
@@ -2916,7 +2916,35 @@ class TestHDP22StackAdvisor(TestCase):
res = self.stackAdvisor.validateHiveConfigurationsEnv(properties, {}, configurations, {}, {})
self.assertEquals(res, res_expected)
- pass
+ # 2) fail: hive_security_authorization=Ranger but ranger plugin is disabled in ranger-env
+ properties = {"hive_security_authorization": "Ranger"}
+ configurations = {
+ "ranger-env":{
+ "properties":{
+ "ranger-hive-plugin-enabled":"No",
+ }
+ },
+ "hive-env":{
+ "properties":{
+ "hive_security_authorization": "Ranger",
+ }
+ }
+ }
+ services = {
+ "configurations": configurations
+ }
+ res_expected = []
+
+ services['configurations']['ranger-env']['properties']['ranger-hive-plugin-enabled'] = 'No'
+ res_expected = [{'config-type': 'hive-env',
+ 'message': 'ranger-env/ranger-hive-plugin-enabled must be enabled when hive_security_authorization is set to Ranger',
+ 'type': 'configuration',
+ 'config-name': 'hive_security_authorization',
+ 'level': 'WARN'}]
+
+ res = self.stackAdvisor.validateHiveConfigurationsEnv(properties, {}, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
def test_validateHiveConfigurations(self):
properties = {"hive_security_authorization": "None",
@@ -3137,3 +3165,220 @@ class TestHDP22StackAdvisor(TestCase):
}
self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services, hosts)
self.assertEquals(configurations, expected)
+
+ def test_validateHDFSRangerPluginConfigurations(self):
+ configurations = {}
+ # 1) ok: ranger plugin is enabled in ranger-env and ranger-hdfs-plugin-properties
+ recommendedDefaults = {}
+ properties = {}
+ configurations = {
+ "ranger-env":{
+ "properties":{
+ "ranger-hdfs-plugin-enabled":"Yes",
+ }
+ },
+ "ranger-hdfs-plugin-properties":{
+ "properties":{
+ "ranger-hdfs-plugin-enabled":"Yes",
+ }
+ }
+ }
+ services = {
+ "configurations": configurations
+ }
+ res_expected = []
+
+ res = self.stackAdvisor.validateHDFSRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ # 2) fail: ranger plugin is disabled in ranger-env
+ services['configurations']['ranger-env']['properties']['ranger-hdfs-plugin-enabled'] = 'No'
+ res_expected = [{'config-type': 'ranger-hdfs-plugin-properties',
+ 'message': 'ranger-hdfs-plugin-properties/ranger-hdfs-plugin-enabled must correspond ranger-env/ranger-hdfs-plugin-enabled',
+ 'type': 'configuration',
+ 'config-name': 'ranger-hdfs-plugin-enabled',
+ 'level': 'WARN'}]
+
+ res = self.stackAdvisor.validateHDFSRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ def test_validateYARNRangerPluginConfigurations(self):
+ configurations = {}
+ # 1) ok: ranger plugin is enabled in ranger-env and ranger-yarn-plugin-properties
+ recommendedDefaults = {}
+ properties = {}
+ configurations = {
+ "ranger-env":{
+ "properties":{
+ "ranger-yarn-plugin-enabled":"Yes",
+ }
+ },
+ "ranger-yarn-plugin-properties":{
+ "properties":{
+ "ranger-yarn-plugin-enabled":"Yes",
+ }
+ }
+ }
+ services = {
+ "configurations": configurations
+ }
+ res_expected = []
+
+ res = self.stackAdvisor.validateYARNRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ # 2) fail: ranger plugin is disabled in ranger-env
+ services['configurations']['ranger-env']['properties']['ranger-yarn-plugin-enabled'] = 'No'
+ res_expected = [{'config-type': 'ranger-yarn-plugin-properties',
+ 'message': 'ranger-yarn-plugin-properties/ranger-yarn-plugin-enabled must correspond ranger-env/ranger-yarn-plugin-enabled',
+ 'type': 'configuration',
+ 'config-name': 'ranger-yarn-plugin-enabled',
+ 'level': 'WARN'}]
+
+ res = self.stackAdvisor.validateYARNRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ def test_validateHBASERangerPluginConfigurations(self):
+ configurations = {}
+ # 1) ok: ranger plugin is enabled in ranger-env and ranger-hbase-plugin-properties
+ recommendedDefaults = {}
+ properties = {}
+ configurations = {
+ "ranger-env":{
+ "properties":{
+ "ranger-hbase-plugin-enabled":"Yes",
+ }
+ },
+ "ranger-hbase-plugin-properties":{
+ "properties":{
+ "ranger-hbase-plugin-enabled":"Yes",
+ }
+ }
+ }
+ services = {
+ "configurations": configurations
+ }
+ res_expected = []
+
+ res = self.stackAdvisor.validateHBASERangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ # 2) fail: ranger plugin is disabled in ranger-env
+ services['configurations']['ranger-env']['properties']['ranger-hbase-plugin-enabled'] = 'No'
+ res_expected = [{'config-type': 'ranger-hbase-plugin-properties',
+ 'message': 'ranger-hbase-plugin-properties/ranger-hbase-plugin-enabled must correspond ranger-env/ranger-hbase-plugin-enabled',
+ 'type': 'configuration',
+ 'config-name': 'ranger-hbase-plugin-enabled',
+ 'level': 'WARN'}]
+
+ res = self.stackAdvisor.validateHBASERangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ def test_validateKnoxRangerPluginConfigurations(self):
+ configurations = {}
+ # 1) ok: ranger plugin is enabled in ranger-env and ranger-knox-plugin-properties
+ recommendedDefaults = {}
+ properties = {}
+ configurations = {
+ "ranger-env":{
+ "properties":{
+ "ranger-knox-plugin-enabled":"Yes",
+ }
+ },
+ "ranger-knox-plugin-properties":{
+ "properties":{
+ "ranger-knox-plugin-enabled":"Yes",
+ }
+ }
+ }
+ services = {
+ "configurations": configurations
+ }
+ res_expected = []
+
+ res = self.stackAdvisor.validateKnoxRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ # 2) fail: ranger plugin is disabled in ranger-env
+ services['configurations']['ranger-env']['properties']['ranger-knox-plugin-enabled'] = 'No'
+ res_expected = [{'config-type': 'ranger-knox-plugin-properties',
+ 'message': 'ranger-knox-plugin-properties/ranger-knox-plugin-enabled must correspond ranger-env/ranger-knox-plugin-enabled',
+ 'type': 'configuration',
+ 'config-name': 'ranger-knox-plugin-enabled',
+ 'level': 'WARN'}]
+
+ res = self.stackAdvisor.validateKnoxRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ def test_validateKafkaRangerPluginConfigurations(self):
+ configurations = {}
+ # 1) ok: ranger plugin is enabled in ranger-env and ranger-kafka-plugin-properties
+ recommendedDefaults = {}
+ properties = {}
+ configurations = {
+ "ranger-env":{
+ "properties":{
+ "ranger-kafka-plugin-enabled":"Yes",
+ }
+ },
+ "ranger-kafka-plugin-properties":{
+ "properties":{
+ "ranger-kafka-plugin-enabled":"Yes",
+ }
+ }
+ }
+ services = {
+ "configurations": configurations
+ }
+ res_expected = []
+
+ res = self.stackAdvisor.validateKafkaRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ # 2) fail: ranger plugin is disabled in ranger-env
+ services['configurations']['ranger-env']['properties']['ranger-kafka-plugin-enabled'] = 'No'
+ res_expected = [{'config-type': 'ranger-kafka-plugin-properties',
+ 'message': 'ranger-kafka-plugin-properties/ranger-kafka-plugin-enabled must correspond ranger-env/ranger-kafka-plugin-enabled',
+ 'type': 'configuration',
+ 'config-name': 'ranger-kafka-plugin-enabled',
+ 'level': 'WARN'}]
+
+ res = self.stackAdvisor.validateKafkaRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ def test_validateStormRangerPluginConfigurations(self):
+ configurations = {}
+ # 1) ok: ranger plugin is enabled in ranger-env and ranger-storm-plugin-properties
+ recommendedDefaults = {}
+ properties = {}
+ configurations = {
+ "ranger-env":{
+ "properties":{
+ "ranger-storm-plugin-enabled":"Yes",
+ }
+ },
+ "ranger-storm-plugin-properties":{
+ "properties":{
+ "ranger-storm-plugin-enabled":"Yes",
+ }
+ }
+ }
+ services = {
+ "configurations": configurations
+ }
+ res_expected = []
+
+ res = self.stackAdvisor.validateStormRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+
+ # 2) fail: ranger plugin is disabled in ranger-env
+ services['configurations']['ranger-env']['properties']['ranger-storm-plugin-enabled'] = 'No'
+ res_expected = [{'config-type': 'ranger-storm-plugin-properties',
+ 'message': 'ranger-storm-plugin-properties/ranger-storm-plugin-enabled must correspond ranger-env/ranger-storm-plugin-enabled',
+ 'type': 'configuration',
+ 'config-name': 'ranger-storm-plugin-enabled',
+ 'level': 'WARN'}]
+
+ res = self.stackAdvisor.validateStormRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {})
+ self.assertEquals(res, res_expected)
+