You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/04/12 00:31:30 UTC
svn commit: r1467123 - in /incubator/ambari/trunk: CHANGES.txt
ambari-server/src/main/python/ambari-server.py
ambari-server/src/test/python/TestAmbaryServer.py
Author: swagle
Date: Thu Apr 11 22:31:29 2013
New Revision: 1467123
URL: http://svn.apache.org/r1467123
Log:
AMBARI-1899. ambari-reset does not respect -s. (swagle)
Modified:
incubator/ambari/trunk/CHANGES.txt
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/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1467123&r1=1467122&r2=1467123&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr 11 22:31:29 2013
@@ -692,6 +692,8 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-1899. ambari-reset does not respect -s. (swagle)
+
AMBARI-1898. Update stack definitions for 1.3.0. (smohanty)
AMBARI-1886. Derived properties not being overridden for hosts. (srimanth)
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=1467123&r1=1467122&r2=1467123&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 Thu Apr 11 22:31:29 2013
@@ -900,24 +900,22 @@ def setup(args):
#
def reset(args):
okToRun = False
- choice = raw_input("**** WARNING **** You are about to reset and clear the "
+ choice = get_YN_input("**** WARNING **** You are about to reset and clear the "
"Ambari Server database. This will remove all cluster "
"host and configuration information from the database. "
"You will be required to re-configure the Ambari server "
"and re-run the cluster wizard. \n"
"Are you SURE you want to perform the reset "
- "[yes/no]? ").lower()
- if choice in set(['yes']):
- okToRun = True
+ "[yes/no]? ", True)
+ okToRun = choice
if not okToRun:
print "Ambari Server 'reset' cancelled"
return -1
okToRun = False
- choice = raw_input("Confirm server reset [yes/no]? ").lower()
- if choice in set(['yes']):
- okToRun = True
+ choice = get_YN_input("Confirm server reset [yes/no]? ", True)
+ okToRun = choice
if not okToRun:
print "Ambari Server 'reset' cancelled"
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=1467123&r1=1467122&r2=1467123&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py (original)
+++ incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py Thu Apr 11 22:31:29 2013
@@ -23,6 +23,7 @@ from mock.mock import patch
from mock.mock import MagicMock
from mock.mock import create_autospec
import os, errno, tempfile
+import signal
import stat
# We have to use this import HACK because the filename contains a dash
ambari_server = __import__('ambari-server')
@@ -932,24 +933,24 @@ class TestAmbariServer(TestCase):
- @patch("__builtin__.raw_input")
+ @patch.object(ambari_server, "get_YN_input")
@patch.object(ambari_server, "setup_db")
@patch.object(ambari_server, "print_info_msg")
@patch.object(ambari_server, "run_os_command")
@patch.object(ambari_server, "configure_postgres_username_password")
def test_reset(self, configure_postgres_username_password_mock,
run_os_command_mock, print_info_msg_mock,
- setup_db_mock, raw_inputMock):
+ setup_db_mock, get_YN_inputMock):
out = StringIO.StringIO()
sys.stdout = out
args = MagicMock()
- raw_inputMock.return_value = "No"
+ get_YN_inputMock.return_value = False
rcode = ambari_server.reset(args)
self.assertEqual(-1, rcode)
- raw_inputMock.return_value = "yes"
+ get_YN_inputMock.return_value = True
run_os_command_mock.return_value = (1, None, None)
rcode = ambari_server.reset(args)
self.assertEqual(1, rcode)
@@ -963,6 +964,36 @@ class TestAmbariServer(TestCase):
+ @patch.object(ambari_server, "setup_db")
+ @patch.object(ambari_server, "print_info_msg")
+ @patch.object(ambari_server, "run_os_command")
+ @patch.object(ambari_server, "configure_postgres_username_password")
+ def test_silent_reset(self, configure_postgres_username_password_mock,
+ run_os_command_mock, print_info_msg_mock,
+ setup_db_mock):
+
+ out = StringIO.StringIO()
+ sys.stdout = out
+
+ args = MagicMock()
+ ambari_server.SILENT = True
+ self.assertTrue(ambari_server.SILENT)
+ run_os_command_mock.return_value = (0, None, None)
+
+ def signal_handler(signum, frame):
+ self.fail("Timed out!")
+
+ signal.signal(signal.SIGALRM, signal_handler)
+ signal.alarm(5)
+ rcode = ambari_server.reset(args)
+
+ self.assertEqual(None, rcode)
+ self.assertTrue(setup_db_mock.called)
+
+ sys.stdout = sys.__stdout__
+
+
+
@patch("os.kill")
@patch("os.path.exists")
@patch("__builtin__.open")