You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/04/16 00:55:41 UTC
[5/8] ambari git commit: AMBARI-9993. Add support for management of
Phoenix Query Server to HDP Stack (Nick Dimiduk via alejandro)
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hadoop-metrics2-hbase.properties-GANGLIA-RS.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hadoop-metrics2-hbase.properties-GANGLIA-RS.j2 b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hadoop-metrics2-hbase.properties-GANGLIA-RS.j2
new file mode 100644
index 0000000..462bef4
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hadoop-metrics2-hbase.properties-GANGLIA-RS.j2
@@ -0,0 +1,104 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# See http://wiki.apache.org/hadoop/GangliaMetrics
+#
+# Make sure you know whether you are using ganglia 3.0 or 3.1.
+# If 3.1, you will have to patch your hadoop instance with HADOOP-4675
+# And, yes, this file is named hadoop-metrics.properties rather than
+# hbase-metrics.properties because we're leveraging the hadoop metrics
+# package and hadoop-metrics.properties is an hardcoded-name, at least
+# for the moment.
+#
+# See also http://hadoop.apache.org/hbase/docs/current/metrics.html
+
+# HBase-specific configuration to reset long-running stats (e.g. compactions)
+# If this variable is left out, then the default is no expiration.
+hbase.extendedperiod = 3600
+
+{% if has_metric_collector %}
+
+*.timeline.plugin.urls=file:///usr/lib/ambari-metrics-hadoop-sink/ambari-metrics-hadoop-sink.jar
+*.sink.timeline.slave.host.name={{hostname}}
+hbase.class=org.apache.hadoop.metrics2.sink.timeline.HadoopTimelineMetricsSink
+hbase.period=10
+hbase.collector={{metric_collector_host}}:{{metric_collector_port}}
+
+jvm.class=org.apache.hadoop.metrics2.sink.timeline.HadoopTimelineMetricsSink
+jvm.period=10
+jvm.collector={{metric_collector_host}}:{{metric_collector_port}}
+
+rpc.class=org.apache.hadoop.metrics2.sink.timeline.HadoopTimelineMetricsSink
+rpc.period=10
+rpc.collector={{metric_collector_host}}:{{metric_collector_port}}
+
+hbase.sink.timeline.class=org.apache.hadoop.metrics2.sink.timeline.HadoopTimelineMetricsSink
+hbase.sink.timeline.period=10
+hbase.sink.timeline.collector={{metric_collector_host}}:{{metric_collector_port}}
+
+{% else %}
+
+# Configuration of the "hbase" context for ganglia
+# Pick one: Ganglia 3.0 (former) or Ganglia 3.1 (latter)
+# hbase.class=org.apache.hadoop.metrics.ganglia.GangliaContext
+hbase.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
+hbase.period=10
+hbase.servers={{ganglia_server_host}}:8656
+
+# Configuration of the "jvm" context for ganglia
+# Pick one: Ganglia 3.0 (former) or Ganglia 3.1 (latter)
+# jvm.class=org.apache.hadoop.metrics.ganglia.GangliaContext
+jvm.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
+jvm.period=10
+jvm.servers={{ganglia_server_host}}:8656
+
+# Configuration of the "rpc" context for ganglia
+# Pick one: Ganglia 3.0 (former) or Ganglia 3.1 (latter)
+# rpc.class=org.apache.hadoop.metrics.ganglia.GangliaContext
+rpc.class=org.apache.hadoop.metrics.ganglia.GangliaContext31
+rpc.period=10
+rpc.servers={{ganglia_server_host}}:8656
+
+#Ganglia following hadoop example
+hbase.sink.ganglia.class=org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31
+hbase.sink.ganglia.period=10
+
+# default for supportsparse is false
+*.sink.ganglia.supportsparse=true
+
+.sink.ganglia.slope=jvm.metrics.gcCount=zero,jvm.metrics.memHeapUsedM=both
+.sink.ganglia.dmax=jvm.metrics.threadsBlocked=70,jvm.metrics.memHeapUsedM=40
+
+hbase.sink.ganglia.servers={{ganglia_server_host}}:8656
+
+{% endif %}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase-smoke.sh.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase-smoke.sh.j2 b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase-smoke.sh.j2
new file mode 100644
index 0000000..458da95
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase-smoke.sh.j2
@@ -0,0 +1,44 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+disable 'ambarismoketest'
+drop 'ambarismoketest'
+create 'ambarismoketest','family'
+put 'ambarismoketest','row01','family:col01','{{service_check_data}}'
+scan 'ambarismoketest'
+exit
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_client_jaas.conf.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_client_jaas.conf.j2 b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_client_jaas.conf.j2
new file mode 100644
index 0000000..38f9721
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_client_jaas.conf.j2
@@ -0,0 +1,23 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+Client {
+com.sun.security.auth.module.Krb5LoginModule required
+useKeyTab=false
+useTicketCache=true;
+};
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_grant_permissions.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_grant_permissions.j2 b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_grant_permissions.j2
new file mode 100644
index 0000000..3378983
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_grant_permissions.j2
@@ -0,0 +1,39 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+grant '{{smoke_test_user}}', '{{smokeuser_permissions}}'
+exit
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_master_jaas.conf.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_master_jaas.conf.j2 b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_master_jaas.conf.j2
new file mode 100644
index 0000000..a93c36c
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_master_jaas.conf.j2
@@ -0,0 +1,26 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+Client {
+com.sun.security.auth.module.Krb5LoginModule required
+useKeyTab=true
+storeKey=true
+useTicketCache=false
+keyTab="{{master_keytab_path}}"
+principal="{{master_jaas_princ}}";
+};
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_regionserver_jaas.conf.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_regionserver_jaas.conf.j2 b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_regionserver_jaas.conf.j2
new file mode 100644
index 0000000..7097481
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/hbase_regionserver_jaas.conf.j2
@@ -0,0 +1,26 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+Client {
+com.sun.security.auth.module.Krb5LoginModule required
+useKeyTab=true
+storeKey=true
+useTicketCache=false
+keyTab="{{regionserver_keytab_path}}"
+principal="{{regionserver_jaas_princ}}";
+};
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/regionservers.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/regionservers.j2 b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/regionservers.j2
new file mode 100644
index 0000000..fc6cc37
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/package/templates/regionservers.j2
@@ -0,0 +1,20 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+{% for host in rs_hosts %}{{host}}
+{% endfor %}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/widgets.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/widgets.json b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/widgets.json
new file mode 100644
index 0000000..a64a2c8
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/HBASE/1.1.0.2.3/widgets.json
@@ -0,0 +1,192 @@
+{
+ "layouts": [
+ {
+ "layout_name": "default_hbase_layout",
+ "section_name": "HBASE_SUMMARY",
+ "widgetLayoutInfo": [
+ {
+ "widget_name": "RS_READS_WRITES",
+ "display_name": "RegionServer Reads and Writes",
+ "description": "This widget shows all the read requests and write requests on all regions for a RegionServer",
+ "widget_type": "GRAPH",
+ "is_visible": true,
+ "metrics": [
+ {
+ "name": "regionserver.Server.Get_num_ops",
+ "ambari_id": "metrics/hbase/regionserver/Server/Get_num_ops",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER",
+ "host_component_criteria": "isActive=true"
+ },
+ {
+ "name": "regionserver.Server.Scan_num_ops",
+ "ambari_id": "metrics/hbase/regionserver/Server/Scan_num_ops",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ },
+ {
+ "name": "regionserver.Server.Append_num_ops",
+ "ambari_id": "metrics/hbase/regionserver/Server/Append_num_ops",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ },
+ {
+ "name": "regionserver.Server.Delete_num_ops",
+ "ambari_id": "metrics/hbase/regionserver/Server/Delete_num_ops",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ },
+ {
+ "name": "regionserver.Server.Increment_num_ops",
+ "ambari_id": "metrics/hbase/regionserver/Server/Increment_num_ops",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ },
+ {
+ "name": "regionserver.Server.Mutate_num_ops",
+ "ambari_id": "metrics/hbase/regionserver/Server/Mutate_num_ops",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ }
+ ],
+ "values": [
+ {
+ "name": "Read Requests",
+ "value": "`${regionserver.Server.Get_num_ops + regionserver.Server.Scan_num_ops}`"
+ },
+ {
+ "name": "Write Requests",
+ "value": "`${metrics.hbase.regionserver.Server.Append_num_ops + metrics.hbase.regionserver.Server.Delete_num_ops + metrics.hbase.regionserver.Server.Increment_num_ops + metrics.hbase.regionserver.Server.Mutate_num_ops}`"
+ }
+ ],
+ "properties": {
+ "display_unit": "Requests",
+ "graph_type": "LINE",
+ "time_ranger": "1 week"
+ }
+ },
+ {
+ "widget_name": "OPEN_CONNECTIONS",
+ "display_name": "Open Connections",
+ "description": "This widget shows number of current open connections",
+ "widget_type": "GRAPH",
+ "is_visible": true,
+ "metrics": [
+ {
+ "name": "ipc.IPC.numOpenConnections",
+ "ambari_id": "metrics/hbase/ipc/IPC/numOpenConnections",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ }
+ ],
+ "values": [
+ {
+ "name": "Open Connections",
+ "value": "`${ipc.IPC.numOpenConnections}`"
+ }
+ ],
+ "properties": {
+ "display_unit": "Connections",
+ "graph_type": "STACK",
+ "time_ranger": "1 hour"
+ }
+ },
+ {
+ "widget_name": "ACTIVE_HANDLER",
+ "display_name": "Active Handlers vs Calls in General Queue",
+ "widget_type": "GRAPH",
+ "is_visible": true,
+ "metrics": [
+ {
+ "name": "ipc.IPC.numOpenConnections",
+ "ambari_id": "metrics/hbase/ipc/IPC/numOpenConnections",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ },
+ {
+ "name": "ipc.IPC.numCallsInGeneralQueue",
+ "ambari_id": "metrics/hbase/ipc/IPC/numOpenConnections",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ }
+ ],
+ "values": [
+ {
+ "name": "Active Handlers",
+ "value": "`${ipc.IPC.numActiveHandler}`"
+ },
+ {
+ "name": "Calls in General Queue",
+ "value": "`${ipc.IPC.numCallsInGeneralQueue}`"
+ }
+ ],
+ "properties": {
+ "graph_type": "LINE",
+ "time_ranger": "1 hour"
+ }
+ },
+ {
+ "widget_name": "FILES_LOCAL",
+ "display_name": "Files Local",
+ "description": "This widget shows percentage of files local.",
+ "widget_type": "NUMBER",
+ "is_visible": true,
+ "metrics": [
+ {
+ "name": "regionserver.Server.percentFilesLocal",
+ "ambari_id": "metrics/hbase/regionserver/percentFilesLocal",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ }
+ ],
+ "values": [
+ {
+ "name": "Files Local",
+ "value": "`${regionserver.Server.percentFilesLocal}`"
+ }
+ ],
+ "properties": {
+ "display_unit": "%"
+ }
+ },
+ {
+ "widget_name": "UPDATED_BLOCKED_TIME",
+ "display_name": "Updated Blocked Time",
+ "description": "",
+ "widget_type": "GRAPH",
+ "is_visible": true,
+ "metrics": [
+ {
+ "name": "regionserver.Server.updatesBlockedTime",
+ "ambari_id": "metrics/hbase/regionserver/Server/updatesBlockedTime",
+ "category": "",
+ "service_name": "HBASE",
+ "component_name": "HBASE_REGIONSERVER"
+ }
+ ],
+ "values": [
+ {
+ "name": "Updated Blocked Time",
+ "value": "`${regionserver.Server.updatesBlockedTime}`"
+ }
+ ],
+ "properties": {
+ "display_unit": "seconds",
+ "graph_type": "LINE",
+ "time_ranger": "1 day"
+ }
+ }
+ ]
+ }
+]
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_client.py b/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_client.py
new file mode 100644
index 0000000..dd58ea2
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_client.py
@@ -0,0 +1,213 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+from mock.mock import MagicMock, call, patch
+from stacks.utils.RMFTestCase import *
+from unittest import skip
+
+@patch("platform.linux_distribution", new = MagicMock(return_value="Linux"))
+@patch("os.path.exists", new = MagicMock(return_value=True))
+class TestHBaseClient(RMFTestCase):
+ COMMON_SERVICES_PACKAGE_DIR = "HBASE/1.1.0.2.3/package"
+ STACK_VERSION = "2.3"
+
+ def test_configure_secured(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_client.py",
+ classname = "HbaseClient",
+ command = "configure",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assertResourceCalled('Directory', '/etc/hbase',
+ mode = 0755
+ )
+ self.assertResourceCalled('Directory', '/etc/hbase/conf',
+ owner = 'hbase',
+ group = 'hadoop',
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase',
+ owner = 'hbase',
+ mode=0775,
+ recursive = True,
+ cd_access='a'
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local/jars',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True,
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'core-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['core-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['core-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hdfs',
+ group = 'hadoop',
+ conf_dir = '/etc/hadoop/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-policy.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-policy'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-policy']
+ )
+ self.assertResourceCalled('File', '/etc/hbase/conf/hbase-env.sh',
+ content = InlineTemplate(self.getConfig()['configurations']['hbase-env']['content']),
+ owner = 'hbase',
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/hadoop-metrics2-hbase.properties',
+ owner = 'hbase',
+ template_tag = 'GANGLIA-RS',
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/regionservers',
+ owner = 'hbase',
+ template_tag = None,
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/hbase_client_jaas.conf',
+ owner = 'hbase',
+ template_tag = None,
+ )
+ self.assertResourceCalled('File',
+ '/etc/hbase/conf/log4j.properties',
+ mode=0644,
+ group='hadoop',
+ owner='hbase',
+ content='log4jproperties\nline2'
+ )
+ self.assertNoMoreResources()
+
+ def test_configure_default(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_client.py",
+ classname = "HbaseClient",
+ command = "configure",
+ config_file="hbase_default.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+ self.assertResourceCalled('Directory', '/etc/hbase',
+ mode = 0755
+ )
+ self.assertResourceCalled('Directory', '/etc/hbase/conf',
+ owner = 'hbase',
+ group = 'hadoop',
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase',
+ owner = 'hbase',
+ mode=0775,
+ recursive = True,
+ cd_access='a'
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local/jars',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True,
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'core-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['core-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['core-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hdfs',
+ group = 'hadoop',
+ conf_dir = '/etc/hadoop/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-policy.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-policy'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-policy']
+ )
+ self.assertResourceCalled('File', '/etc/hbase/conf/hbase-env.sh',
+ content = InlineTemplate(self.getConfig()['configurations']['hbase-env']['content']),
+ owner = 'hbase',
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/hadoop-metrics2-hbase.properties',
+ owner = 'hbase',
+ template_tag = 'GANGLIA-RS',
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/regionservers',
+ owner = 'hbase',
+ template_tag = None,
+ )
+ self.assertResourceCalled('File',
+ '/etc/hbase/conf/log4j.properties',
+ mode=0644,
+ group='hadoop',
+ owner='hbase',
+ content='log4jproperties\nline2'
+ )
+ self.assertNoMoreResources()
http://git-wip-us.apache.org/repos/asf/ambari/blob/54647547/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_master.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_master.py b/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_master.py
new file mode 100644
index 0000000..f4a8d6a
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.3/HBASE/test_hbase_master.py
@@ -0,0 +1,678 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+from mock.mock import MagicMock, patch
+from stacks.utils.RMFTestCase import *
+from unittest import skip
+
+@patch("platform.linux_distribution", new = MagicMock(return_value="Linux"))
+@patch("os.path.exists", new = MagicMock(return_value=True))
+class TestHBaseMaster(RMFTestCase):
+ COMMON_SERVICES_PACKAGE_DIR = "HBASE/1.1.0.2.3/package"
+ STACK_VERSION = "2.3"
+
+ def test_configure_default(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "configure",
+ config_file="hbase_default.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assert_configure_default()
+ self.assertNoMoreResources()
+
+ def test_start_default(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "start",
+ config_file="hbase_default.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assert_configure_default()
+ self.assertResourceCalled('Execute', '/usr/hdp/current/hbase-regionserver/bin/hbase-daemon.sh --config /etc/hbase/conf start master',
+ not_if = 'ls /var/run/hbase/hbase-hbase-master.pid >/dev/null 2>&1 && ps -p `cat /var/run/hbase/hbase-hbase-master.pid` >/dev/null 2>&1',
+ user = 'hbase'
+ )
+ self.assertNoMoreResources()
+
+ def test_stop_default(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "stop",
+ config_file="hbase_default.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assertResourceCalled('Execute', '/usr/hdp/current/hbase-regionserver/bin/hbase-daemon.sh --config /etc/hbase/conf stop master',
+ on_timeout = '! ( ls /var/run/hbase/hbase-hbase-master.pid >/dev/null 2>&1 && ps -p `cat /var/run/hbase/hbase-hbase-master.pid` >/dev/null 2>&1 ) || ambari-sudo.sh -H -E kill -9 `cat /var/run/hbase/hbase-hbase-master.pid`',
+ timeout = 30,
+ user = 'hbase',
+ )
+
+ self.assertResourceCalled('Execute', 'rm -f /var/run/hbase/hbase-hbase-master.pid',
+ )
+ self.assertNoMoreResources()
+
+ def test_decom_default(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "decommission",
+ config_file="hbase_default.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assertResourceCalled('File', '/usr/hdp/current/hbase-regionserver/bin/draining_servers.rb',
+ content = StaticFile('draining_servers.rb'),
+ mode = 0755,
+ )
+ self.assertResourceCalled('Execute', ' /usr/hdp/current/hbase-regionserver/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/hdp/current/hbase-regionserver/bin/draining_servers.rb add host1',
+ logoutput = True,
+ user = 'hbase',
+ )
+ self.assertResourceCalled('Execute', ' /usr/hdp/current/hbase-regionserver/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/hdp/current/hbase-regionserver/bin/region_mover.rb unload host1',
+ logoutput = True,
+ user = 'hbase',
+ )
+ self.assertNoMoreResources()
+
+ def test_decom_default_draining_only(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "decommission",
+ config_file="default.hbasedecom.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assertResourceCalled('File', '/usr/lib/hbase/bin/draining_servers.rb',
+ content = StaticFile('draining_servers.rb'),
+ mode = 0755,
+ )
+ self.assertResourceCalled('Execute', ' /usr/lib/hbase/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/lib/hbase/bin/draining_servers.rb remove host1',
+ logoutput = True,
+ user = 'hbase',
+ )
+ self.assertNoMoreResources()
+
+ def test_configure_secured(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "configure",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assert_configure_secured()
+ self.assertNoMoreResources()
+
+ def test_start_secured(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "start",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assert_configure_secured()
+ self.assertResourceCalled('Execute', '/usr/hdp/current/hbase-regionserver/bin/hbase-daemon.sh --config /etc/hbase/conf start master',
+ not_if = 'ls /var/run/hbase/hbase-hbase-master.pid >/dev/null 2>&1 && ps -p `cat /var/run/hbase/hbase-hbase-master.pid` >/dev/null 2>&1',
+ user = 'hbase',
+ )
+ self.assertNoMoreResources()
+
+ def test_stop_secured(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "stop",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assertResourceCalled('Execute', '/usr/hdp/current/hbase-regionserver/bin/hbase-daemon.sh --config /etc/hbase/conf stop master',
+ on_timeout = '! ( ls /var/run/hbase/hbase-hbase-master.pid >/dev/null 2>&1 && ps -p `cat /var/run/hbase/hbase-hbase-master.pid` >/dev/null 2>&1 ) || ambari-sudo.sh -H -E kill -9 `cat /var/run/hbase/hbase-hbase-master.pid`',
+ timeout = 30,
+ user = 'hbase',
+ )
+
+ self.assertResourceCalled('Execute', 'rm -f /var/run/hbase/hbase-hbase-master.pid',
+ )
+ self.assertNoMoreResources()
+
+ def test_decom_secure(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "decommission",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ self.assertResourceCalled('File', '/usr/hdp/current/hbase-regionserver/bin/draining_servers.rb',
+ content = StaticFile('draining_servers.rb'),
+ mode = 0755,
+ )
+ self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hbase.headless.keytab hbase@EXAMPLE.COM; /usr/hdp/current/hbase-regionserver/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/hdp/current/hbase-regionserver/bin/draining_servers.rb add host1',
+ logoutput = True,
+ user = 'hbase',
+ )
+ self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hbase.headless.keytab hbase@EXAMPLE.COM; /usr/hdp/current/hbase-regionserver/bin/hbase --config /etc/hbase/conf org.jruby.Main /usr/hdp/current/hbase-regionserver/bin/region_mover.rb unload host1',
+ logoutput = True,
+ user = 'hbase',
+ )
+ self.assertNoMoreResources()
+
+ def assert_configure_default(self):
+ self.assertResourceCalled('Directory', '/etc/hbase',
+ mode = 0755
+ )
+ self.assertResourceCalled('Directory', '/etc/hbase/conf',
+ owner = 'hbase',
+ group = 'hadoop',
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase',
+ owner = 'hbase',
+ mode = 0775,
+ recursive = True,
+ cd_access='a'
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local/jars',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True,
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'core-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['core-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['core-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hdfs',
+ group = 'hadoop',
+ conf_dir = '/etc/hadoop/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-policy.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-policy'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-policy']
+ )
+ self.assertResourceCalled('File', '/etc/hbase/conf/hbase-env.sh',
+ owner = 'hbase',
+ content = InlineTemplate(self.getConfig()['configurations']['hbase-env']['content']),
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/hadoop-metrics2-hbase.properties',
+ owner = 'hbase',
+ template_tag = 'GANGLIA-MASTER',
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/regionservers',
+ owner = 'hbase',
+ template_tag = None,
+ )
+ self.assertResourceCalled('Directory', '/var/run/hbase',
+ owner = 'hbase',
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/var/log/hbase',
+ owner = 'hbase',
+ recursive = True,
+ )
+ self.assertResourceCalled('File',
+ '/etc/hbase/conf/log4j.properties',
+ mode=0644,
+ group='hadoop',
+ owner='hbase',
+ content='log4jproperties\nline2'
+ )
+ self.assertResourceCalled('HdfsDirectory', 'hdfs://c6405.ambari.apache.org:8020/apps/hbase/data',
+ security_enabled = False,
+ keytab = UnknownConfigurationMock(),
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = "/usr/bin/kinit",
+ owner = 'hbase',
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create_delayed'],
+ )
+ self.assertResourceCalled('HdfsDirectory', '/apps/hbase/staging',
+ security_enabled = False,
+ keytab = UnknownConfigurationMock(),
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = "/usr/bin/kinit",
+ mode = 0711,
+ owner = 'hbase',
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create_delayed'],
+ )
+ self.assertResourceCalled('HdfsDirectory', None,
+ security_enabled = False,
+ keytab = UnknownConfigurationMock(),
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = "/usr/bin/kinit",
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create'],
+ )
+
+ def assert_configure_secured(self):
+ self.assertResourceCalled('Directory', '/etc/hbase',
+ mode = 0755
+ )
+ self.assertResourceCalled('Directory', '/etc/hbase/conf',
+ owner = 'hbase',
+ group = 'hadoop',
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase',
+ owner = 'hbase',
+ mode = 0775,
+ recursive = True,
+ cd_access='a'
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True
+ )
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local/jars',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True,
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'core-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['core-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['core-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hdfs',
+ group = 'hadoop',
+ conf_dir = '/etc/hadoop/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site']
+ )
+ self.assertResourceCalled('XmlConfig', 'hbase-policy.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-policy'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-policy']
+ )
+ self.assertResourceCalled('File', '/etc/hbase/conf/hbase-env.sh',
+ owner = 'hbase',
+ content = InlineTemplate(self.getConfig()['configurations']['hbase-env']['content']),
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/hadoop-metrics2-hbase.properties',
+ owner = 'hbase',
+ template_tag = 'GANGLIA-MASTER',
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/regionservers',
+ owner = 'hbase',
+ template_tag = None,
+ )
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/hbase_master_jaas.conf',
+ owner = 'hbase',
+ template_tag = None,
+ )
+ self.assertResourceCalled('Directory', '/var/run/hbase',
+ owner = 'hbase',
+ recursive = True,
+ )
+ self.assertResourceCalled('Directory', '/var/log/hbase',
+ owner = 'hbase',
+ recursive = True,
+ )
+ self.assertResourceCalled('File',
+ '/etc/hbase/conf/log4j.properties',
+ mode=0644,
+ group='hadoop',
+ owner='hbase',
+ content='log4jproperties\nline2'
+ )
+ self.assertResourceCalled('HdfsDirectory', 'hdfs://c6405.ambari.apache.org:8020/apps/hbase/data',
+ security_enabled = True,
+ keytab = '/etc/security/keytabs/hdfs.headless.keytab',
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = '/usr/bin/kinit',
+ owner = 'hbase',
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create_delayed'],
+ )
+ self.assertResourceCalled('HdfsDirectory', '/apps/hbase/staging',
+ security_enabled = True,
+ keytab = '/etc/security/keytabs/hdfs.headless.keytab',
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = '/usr/bin/kinit',
+ mode = 0711,
+ owner = 'hbase',
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create_delayed'],
+ )
+ self.assertResourceCalled('HdfsDirectory', None,
+ security_enabled = True,
+ keytab = '/etc/security/keytabs/hdfs.headless.keytab',
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = '/usr/bin/kinit',
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create'],
+ )
+
+ @skip("enable when there's an upgrade target to test")
+ def test_start_default_22(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "start",
+ config_file="hbase-2.2.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES)
+
+ self.assertResourceCalled('Directory', '/etc/hbase',
+ mode = 0755)
+
+ self.assertResourceCalled('Directory', '/etc/hbase/conf',
+ owner = 'hbase',
+ group = 'hadoop',
+ recursive = True)
+
+ self.assertResourceCalled('Directory', '/hadoop/hbase',
+ owner = 'hbase',
+ mode = 0775,
+ recursive = True,
+ cd_access='a')
+
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True)
+
+ self.assertResourceCalled('Directory', '/hadoop/hbase/local/jars',
+ owner = 'hbase',
+ group = 'hadoop',
+ mode=0775,
+ recursive = True)
+
+ self.assertResourceCalled('XmlConfig', 'hbase-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-site'])
+ self.assertResourceCalled('XmlConfig', 'core-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['core-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['core-site'])
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site'])
+
+ self.assertResourceCalled('XmlConfig', 'hdfs-site.xml',
+ owner = 'hdfs',
+ group = 'hadoop',
+ conf_dir = '/etc/hadoop/conf',
+ configurations = self.getConfig()['configurations']['hdfs-site'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hdfs-site'])
+
+ self.assertResourceCalled('XmlConfig', 'hbase-policy.xml',
+ owner = 'hbase',
+ group = 'hadoop',
+ conf_dir = '/etc/hbase/conf',
+ configurations = self.getConfig()['configurations']['hbase-policy'],
+ configuration_attributes = self.getConfig()['configuration_attributes']['hbase-policy'])
+
+ self.assertResourceCalled('File', '/etc/hbase/conf/hbase-env.sh',
+ owner = 'hbase',
+ content = InlineTemplate(self.getConfig()['configurations']['hbase-env']['content']))
+
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/hadoop-metrics2-hbase.properties',
+ owner = 'hbase',
+ template_tag = 'GANGLIA-MASTER')
+
+ self.assertResourceCalled('TemplateConfig', '/etc/hbase/conf/regionservers',
+ owner = 'hbase',
+ template_tag = None)
+
+ self.assertResourceCalled('Directory', '/var/run/hbase',
+ owner = 'hbase',
+ recursive = True)
+
+ self.assertResourceCalled('Directory', '/var/log/hbase',
+ owner = 'hbase',
+ recursive = True)
+
+ self.assertResourceCalled('File',
+ '/etc/hbase/conf/log4j.properties',
+ mode=0644,
+ group='hadoop',
+ owner='hbase',
+ content='log4jproperties\nline2')
+
+ self.assertResourceCalled('HdfsDirectory', 'hdfs://nn1/apps/hbase/data',
+ security_enabled = False,
+ keytab = UnknownConfigurationMock(),
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = "/usr/bin/kinit",
+ owner = 'hbase',
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create_delayed'])
+
+ self.assertResourceCalled('HdfsDirectory', '/apps/hbase/staging',
+ security_enabled = False,
+ keytab = UnknownConfigurationMock(),
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = "/usr/bin/kinit",
+ mode = 0711,
+ owner = 'hbase',
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create_delayed'])
+
+ self.assertResourceCalled('HdfsDirectory', None,
+ security_enabled = False,
+ keytab = UnknownConfigurationMock(),
+ conf_dir = '/etc/hadoop/conf',
+ hdfs_user = 'hdfs',
+ kinit_path_local = "/usr/bin/kinit",
+ bin_dir = '/usr/hdp/current/hadoop-client/bin',
+ action = ['create'])
+
+ self.assertResourceCalled('Execute', '/usr/hdp/current/hbase-master/bin/hbase-daemon.sh --config /etc/hbase/conf start master',
+ not_if = 'ls /var/run/hbase/hbase-hbase-master.pid >/dev/null 2>&1 && ps -p `cat /var/run/hbase/hbase-hbase-master.pid` >/dev/null 2>&1',
+ user = 'hbase')
+
+ self.assertNoMoreResources()
+
+ @patch("resource_management.libraries.functions.security_commons.build_expectations")
+ @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem")
+ @patch("resource_management.libraries.functions.security_commons.validate_security_config_properties")
+ @patch("resource_management.libraries.functions.security_commons.cached_kinit_executor")
+ @patch("resource_management.libraries.script.Script.put_structured_out")
+ def test_security_status(self, put_structured_out_mock, cached_kinit_executor_mock, validate_security_config_mock, get_params_mock, build_exp_mock):
+ # Test that function works when is called with correct parameters
+
+ security_params = {
+ 'hbase-site': {
+ 'hbase.master.kerberos.principal': '/path/to/hbase_keytab',
+ 'hbase.master.keytab.file': 'hbase_principal'
+ }
+ }
+
+ result_issues = []
+ props_value_check = {"hbase.security.authentication": "kerberos",
+ "hbase.security.authorization": "true"}
+ props_empty_check = ["hbase.master.keytab.file",
+ "hbase.master.kerberos.principal"]
+
+ props_read_check = ["hbase.master.keytab.file"]
+
+ get_params_mock.return_value = security_params
+ validate_security_config_mock.return_value = result_issues
+
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "security_status",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+
+ build_exp_mock.assert_called_with('hbase-site', props_value_check, props_empty_check, props_read_check)
+ put_structured_out_mock.assert_called_with({"securityState": "SECURED_KERBEROS"})
+ cached_kinit_executor_mock.called_with('/usr/bin/kinit',
+ self.config_dict['configurations']['hbase-env']['hbase_user'],
+ security_params['hbase-site']['hbase.master.keytab.file'],
+ security_params['hbase-site']['hbase.master.kerberos.principal'],
+ self.config_dict['hostname'],
+ '/tmp')
+
+ # Testing that the exception throw by cached_executor is caught
+ cached_kinit_executor_mock.reset_mock()
+ cached_kinit_executor_mock.side_effect = Exception("Invalid command")
+
+ try:
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "security_status",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+ except:
+ self.assertTrue(True)
+
+ # Testing with a security_params which doesn't contains hbase-site
+ empty_security_params = {}
+ cached_kinit_executor_mock.reset_mock()
+ get_params_mock.reset_mock()
+ put_structured_out_mock.reset_mock()
+ get_params_mock.return_value = empty_security_params
+
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "security_status",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+ put_structured_out_mock.assert_called_with({"securityIssuesFound": "Keytab file or principal are not set property."})
+
+ # Testing with not empty result_issues
+ result_issues_with_params = {}
+ result_issues_with_params['hbase-site']="Something bad happened"
+
+ validate_security_config_mock.reset_mock()
+ get_params_mock.reset_mock()
+ validate_security_config_mock.return_value = result_issues_with_params
+ get_params_mock.return_value = security_params
+
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "security_status",
+ config_file="hbase_default.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+ put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"})
+
+ # Testing with security_enable = false
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_master.py",
+ classname = "HbaseMaster",
+ command = "security_status",
+ config_file="hbase_secure.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES
+ )
+ put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"})
+
+ @skip("there's no stacks/2.3/configs/hbase-preupgrade.json")
+ def test_upgrade_backup(self):
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hbase_upgrade.py",
+ classname = "HbaseMasterUpgrade",
+ command = "snapshot",
+ config_file="hbase-preupgrade.json",
+ hdp_stack_version = self.STACK_VERSION,
+ target = RMFTestCase.TARGET_COMMON_SERVICES)
+
+ self.assertResourceCalled('Execute', " echo 'snapshot_all' | /usr/hdp/current/hbase-client/bin/hbase shell",
+ user = 'hbase')
+
+ self.assertNoMoreResources()