You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by od...@apache.org on 2013/08/13 21:45:47 UTC
git commit: AMBARI-2887. JN smoke test problem on multinode cluster.
(odiachenko)
Updated Branches:
refs/heads/trunk c0925b995 -> 72311b797
AMBARI-2887. JN smoke test problem on multinode cluster. (odiachenko)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/72311b79
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/72311b79
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/72311b79
Branch: refs/heads/trunk
Commit: 72311b797289ca591537650dcea40ac40f513b20
Parents: c0925b9
Author: Oleksandr Diachenko <od...@hortonworks.com>
Authored: Tue Aug 13 22:44:14 2013 +0300
Committer: Oleksandr Diachenko <od...@hortonworks.com>
Committed: Tue Aug 13 22:44:40 2013 +0300
----------------------------------------------------------------------
ambari-agent/pom.xml | 2 +-
.../modules/hdp-hadoop/files/checkWebUI.py | 28 ++++----
.../hdp-hadoop/manifests/hdfs/service_check.pp | 9 ++-
.../functions/hdp_comma_list_from_array.rb | 25 ++++++++
ambari-agent/src/test/python/TestCheckWebUI.py | 67 ++++++++++++++++++++
5 files changed, 115 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/72311b79/ambari-agent/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/pom.xml b/ambari-agent/pom.xml
index e98f7d2..eb9b0fd 100644
--- a/ambari-agent/pom.xml
+++ b/ambari-agent/pom.xml
@@ -122,7 +122,7 @@
<argument>unitTests.py</argument>
</arguments>
<environmentVariables>
- <PYTHONPATH>${project.basedir}/../ambari-common/src/test/python:${project.basedir}/src/main/python/ambari_agent:$PYTHONPATH</PYTHONPATH>
+ <PYTHONPATH>${project.basedir}/../ambari-common/src/test/python:${project.basedir}/src/main/python/ambari_agent:${project.basedir}/src/main/puppet/modules/hdp-hadoop/files:$PYTHONPATH</PYTHONPATH>
</environmentVariables>
<skip>${skipTests}</skip>
</configuration>
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/72311b79/ambari-agent/src/main/puppet/modules/hdp-hadoop/files/checkWebUI.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/puppet/modules/hdp-hadoop/files/checkWebUI.py b/ambari-agent/src/main/puppet/modules/hdp-hadoop/files/checkWebUI.py
index 2679e94..defa05e 100644
--- a/ambari-agent/src/main/puppet/modules/hdp-hadoop/files/checkWebUI.py
+++ b/ambari-agent/src/main/puppet/modules/hdp-hadoop/files/checkWebUI.py
@@ -26,21 +26,25 @@ import urllib
#
def main():
parser = optparse.OptionParser(usage="usage: %prog [options] component ")
- parser.add_option("-u", "--url", dest="url", help="Host:Port for WEB UI to check it availability")
+ parser.add_option("-m", "--hosts", dest="hosts", help="Comma separated hosts list for WEB UI to check it availability")
+ parser.add_option("-p", "--port", dest="port", help="Port of WEB UI to check it availability")
(options, args) = parser.parse_args()
- url = options.url
-
- try:
- httpCode = urllib.urlopen('http://' + url).getcode()
- except Exception:
- httpCode = 404
-
- if httpCode != 200:
- exit(1)
- else:
- exit(0)
+ hosts = options.hosts.split(',')
+ port = options.port
+
+ for host in hosts:
+ try:
+ url = 'http://' + host + ':' + port
+ httpCode = urllib.urlopen(url).getcode()
+ except Exception:
+ httpCode = 404
+
+ if httpCode != 200:
+ print "Cannot access WEB UI on: " + url
+ exit(1)
+
if __name__ == "__main__":
main()
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/72311b79/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/hdfs/service_check.pp
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/hdfs/service_check.pp b/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/hdfs/service_check.pp
index f50aa29..7b49ed5 100644
--- a/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/hdfs/service_check.pp
+++ b/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/hdfs/service_check.pp
@@ -91,8 +91,11 @@ class hdp-hadoop::hdfs::service_check()
require => Hdp-hadoop::Exec-hadoop['hdfs::service_check::create_file'],
before => Class['hdp-hadoop::journalnode::service_check']
}
+
+ $journalnode_hosts_comma_sep = hdp_comma_list_from_array($hdp::params::journalnode_hosts)
+
class { 'hdp-hadoop::journalnode::service_check':
- journalnode_host => $hdp::params::journalnode_hosts,
+ journalnode_hosts => $journalnode_hosts_comma_sep,
require => Hdp-hadoop::Exec-hadoop['hdfs::service_check::test'],
before => Anchor['hdp-hadoop::hdfs::service_check::end']
}
@@ -103,7 +106,7 @@ class hdp-hadoop::hdfs::service_check()
}
-class hdp-hadoop::journalnode::service_check($journalnode_host)
+class hdp-hadoop::journalnode::service_check($journalnode_hosts)
{
$journalnode_port = $hdp::params::journalnode_port
@@ -112,7 +115,7 @@ class hdp-hadoop::journalnode::service_check($journalnode_host)
$checkWebUIFileName = "checkWebUI.py"
$checkWebUIFilePath = "/tmp/$checkWebUIFileName"
- $checkWebUICmd = "su - ${smoke_test_user} -c 'python $checkWebUIFilePath -u $journalnode_host:$journalnode_port'"
+ $checkWebUICmd = "su - ${smoke_test_user} -c 'python $checkWebUIFilePath -m $journalnode_hosts -p $journalnode_port'"
file { $checkWebUIFilePath:
ensure => present,
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/72311b79/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_comma_list_from_array.rb
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_comma_list_from_array.rb b/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_comma_list_from_array.rb
new file mode 100644
index 0000000..41007a4
--- /dev/null
+++ b/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_comma_list_from_array.rb
@@ -0,0 +1,25 @@
+#
+#
+# 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.
+#
+#
+module Puppet::Parser::Functions
+ newfunction(:hdp_comma_list_from_array, :type => :rvalue) do |args|
+ args[0].join(",")
+ end
+end
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/72311b79/ambari-agent/src/test/python/TestCheckWebUI.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestCheckWebUI.py b/ambari-agent/src/test/python/TestCheckWebUI.py
new file mode 100644
index 0000000..c8d6b18
--- /dev/null
+++ b/ambari-agent/src/test/python/TestCheckWebUI.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python2.6
+
+'''
+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.
+'''
+
+import unittest
+import StringIO
+import sys
+
+from mock.mock import MagicMock, patch
+
+import checkWebUI
+
+class TestMain(unittest.TestCase):
+
+ def setUp(self):
+ # disable stdout
+ out = StringIO.StringIO()
+ sys.stdout = out
+
+
+ def tearDown(self):
+ # enable stdout
+ sys.stdout = sys.__stdout__
+
+ @patch("optparse.OptionParser.parse_args")
+ @patch('urllib.urlopen')
+ def test_check_web_ui(self, urlopen_mock, parse_args_mock):
+
+ #Positive scenario
+ options = MagicMock()
+ options.hosts = 'host1,host2'
+ options.port = '10000'
+ get_code_mock = MagicMock()
+ get_code_mock.getcode.return_value = 200
+ urlopen_mock.return_value = get_code_mock
+
+ parse_args_mock.return_value = (options, MagicMock)
+ checkWebUI.main()
+
+ #Negative scenario
+ options = MagicMock()
+ options.hosts = 'host1,host2'
+ options.port = '10000'
+ get_code_mock = MagicMock()
+ get_code_mock.getcode.return_value = 404
+ urlopen_mock.return_value = get_code_mock
+
+ parse_args_mock.return_value = (options, MagicMock)
+ with self.assertRaises(SystemExit) as e:
+ checkWebUI.main()
+ self.assertEqual(e.exception.code, 1)