You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/05/31 08:38:47 UTC
svn commit: r1488110 - in /incubator/ambari/trunk/ambari-server/src:
main/python/ambari-server.py test/python/TestAmbaryServer.py
Author: mahadev
Date: Fri May 31 06:38:46 2013
New Revision: 1488110
URL: http://svn.apache.org/r1488110
Log:
AMBARI-2200. ambari-server start script (ambari-server.py) will never use SERVER_START_CMD_DEBUG. (Chad Roberts via mahadev)
Modified:
incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py
Modified: incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py?rev=1488110&r1=1488109&r2=1488110&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py (original)
+++ incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py Fri May 31 06:38:46 2013
@@ -991,7 +991,8 @@ def start(args):
print_error_msg ("Failed to stop iptables. Exiting")
sys.exit(retcode)
- command = SERVER_START_CMD.format(jdk_path, conf_dir, get_ambari_classpath())
+ command_base = SERVER_START_CMD_DEBUG if (SERVER_DEBUG_MODE or SERVER_START_DEBUG) else SERVER_START_CMD
+ command = command_base.format(jdk_path, conf_dir, get_ambari_classpath())
print "Running server: " + command
server_process = subprocess.Popen(["/bin/sh", "-c", command])
f = open(PID_DIR + os.sep + PID_NAME, "w")
@@ -1265,6 +1266,8 @@ def main():
parser.add_option("-b", "--remote-database",
action="store_true", dest="remote_database", default=False,
help="Set up remote database instead of local")
+ parser.add_option('-g', '--debug', action="store_true", dest='debug', default=False,
+ help="Start ambari-server in debug mode")
(options, args) = parser.parse_args()
@@ -1280,6 +1283,9 @@ def main():
global REMOTE_DATABASE
REMOTE_DATABASE = options.remote_database
+ # debug mode
+ global SERVER_DEBUG_MODE
+ SERVER_DEBUG_MODE = options.debug
Modified: incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py?rev=1488110&r1=1488109&r2=1488110&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py (original)
+++ incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py Fri May 31 06:38:46 2013
@@ -384,6 +384,52 @@ class TestAmbariServer(TestCase):
self.assertFalse(False, ambari_server.SILENT)
+
+ @patch.object(ambari_server, 'setup')
+ @patch.object(ambari_server, 'start')
+ @patch.object(ambari_server, 'stop')
+ @patch.object(ambari_server, 'reset')
+ @patch('optparse.OptionParser')
+ def test_main_test_start_debug_short(self, OptionParserMock, reset_method, stop_method,
+ start_method, setup_method):
+ opm = OptionParserMock.return_value
+ options = MagicMock()
+ args = ["start", "-g"]
+ opm.parse_args.return_value = (options, args)
+
+ ambari_server.main()
+
+ self.assertFalse(setup_method.called)
+ self.assertTrue(start_method.called)
+ self.assertFalse(stop_method.called)
+ self.assertFalse(reset_method.called)
+
+ self.assertTrue(ambari_server.SERVER_DEBUG_MODE)
+
+
+
+ @patch.object(ambari_server, 'setup')
+ @patch.object(ambari_server, 'start')
+ @patch.object(ambari_server, 'stop')
+ @patch.object(ambari_server, 'reset')
+ @patch('optparse.OptionParser')
+ def test_main_test_start_debug_long(self, OptionParserMock, reset_method, stop_method,
+ start_method, setup_method):
+ opm = OptionParserMock.return_value
+ options = MagicMock()
+ args = ["start", "--debug"]
+ opm.parse_args.return_value = (options, args)
+
+ ambari_server.main()
+
+ self.assertFalse(setup_method.called)
+ self.assertTrue(start_method.called)
+ self.assertFalse(stop_method.called)
+ self.assertFalse(reset_method.called)
+
+ self.assertTrue(ambari_server.SERVER_DEBUG_MODE)
+
+
@patch.object(ambari_server, 'setup')
@patch.object(ambari_server, 'start')