|
@@ -18,6 +18,7 @@ See the License for the specific language governing permissions and
|
|
|
limitations under the License.
|
|
|
from ambari_commons import OSCheck
|
|
|
'''
|
|
|
+import json
|
|
|
import os
|
|
|
import tempfile
|
|
|
from stacks.utils.RMFTestCase import *
|
|
@@ -27,7 +28,6 @@ from resource_management.core import shell
|
|
|
from resource_management.core.exceptions import Fail
|
|
|
|
|
|
|
|
|
-@patch.object(shell, "call", new=MagicMock(return_value=(5,"")))
|
|
|
class TestNamenode(RMFTestCase):
|
|
|
COMMON_SERVICES_PACKAGE_DIR = "HDFS/2.1.0.2.0/package"
|
|
|
STACK_VERSION = "2.0.6"
|
|
@@ -43,6 +43,7 @@ class TestNamenode(RMFTestCase):
|
|
|
self.assert_configure_default()
|
|
|
self.assertNoMoreResources()
|
|
|
|
|
|
+ @patch.object(shell, "call", new=MagicMock(return_value=(5,"")))
|
|
|
def test_start_default_alt_fs(self):
|
|
|
self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
classname = "NameNode",
|
|
@@ -132,6 +133,7 @@ class TestNamenode(RMFTestCase):
|
|
|
self.assertNoMoreResources()
|
|
|
pass
|
|
|
|
|
|
+ @patch.object(shell, "call", new=MagicMock(return_value=(5,"")))
|
|
|
def test_start_default(self):
|
|
|
self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
classname = "NameNode",
|
|
@@ -252,6 +254,8 @@ class TestNamenode(RMFTestCase):
|
|
|
self.assert_configure_secured()
|
|
|
self.assertNoMoreResources()
|
|
|
|
|
|
+
|
|
|
+ @patch.object(shell, "call", new=MagicMock(return_value=(5,"")))
|
|
|
def test_start_secured(self):
|
|
|
self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
classname = "NameNode",
|
|
@@ -610,6 +614,7 @@ class TestNamenode(RMFTestCase):
|
|
|
# tests namenode start command when NameNode HA is enabled, and
|
|
|
# the HA cluster is started initially, rather than using the UI Wizard
|
|
|
# this test verifies the startup of a "standby" namenode
|
|
|
+ @patch.object(shell, "call", new=MagicMock(return_value=(5,"")))
|
|
|
def test_start_ha_bootstrap_standby_from_blueprint(self):
|
|
|
self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
classname = "NameNode",
|
|
@@ -1039,6 +1044,113 @@ class TestNamenode(RMFTestCase):
|
|
|
target = RMFTestCase.TARGET_COMMON_SERVICES)
|
|
|
|
|
|
|
|
|
+ def test_pre_rolling_restart(self):
|
|
|
+ config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
|
|
|
+ with open(config_file, "r") as f:
|
|
|
+ json_content = json.load(f)
|
|
|
+ version = '2.2.1.0-3242'
|
|
|
+ json_content['commandParams']['version'] = version
|
|
|
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
+ classname = "NameNode",
|
|
|
+ command = "pre_rolling_restart",
|
|
|
+ config_dict = json_content,
|
|
|
+ hdp_stack_version = self.STACK_VERSION,
|
|
|
+ target = RMFTestCase.TARGET_COMMON_SERVICES)
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ 'hdp-select set hadoop-hdfs-namenode %s' % version,)
|
|
|
+ self.assertNoMoreResources()
|
|
|
+
|
|
|
+
|
|
|
+ def test_post_rolling_restart(self):
|
|
|
+ config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
|
|
|
+ with open(config_file, "r") as f:
|
|
|
+ json_content = json.load(f)
|
|
|
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
+ classname = "NameNode",
|
|
|
+ command = "post_rolling_restart",
|
|
|
+ config_dict = json_content,
|
|
|
+ hdp_stack_version = self.STACK_VERSION,
|
|
|
+ target = RMFTestCase.TARGET_COMMON_SERVICES)
|
|
|
+ self.assertResourceCalled('Execute', 'hdfs dfsadmin -report -live',
|
|
|
+ user = 'hdfs',
|
|
|
+ )
|
|
|
+ self.assertNoMoreResources()
|
|
|
+
|
|
|
+
|
|
|
+ @patch.object(shell, "call")
|
|
|
+ def test_prepare_rolling_upgrade__upgrade(self, shell_call_mock):
|
|
|
+ config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/secured.json"
|
|
|
+ with open(config_file, "r") as f:
|
|
|
+ json_content = json.load(f)
|
|
|
+ json_content['commandParams']['upgrade_direction'] = 'upgrade'
|
|
|
+
|
|
|
+ # Mock safemode_check call
|
|
|
+ shell_call_mock.return_value = 0, "Safe mode is OFF in c6401.ambari.apache.org"
|
|
|
+
|
|
|
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
+ classname = "NameNode",
|
|
|
+ command = "prepare_rolling_upgrade",
|
|
|
+ config_dict = json_content,
|
|
|
+ hdp_stack_version = self.STACK_VERSION,
|
|
|
+ target = RMFTestCase.TARGET_COMMON_SERVICES)
|
|
|
+ self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hdfs.headless.keytab hdfs',)
|
|
|
+ self.assertResourceCalled('Execute', 'hdfs dfsadmin -rollingUpgrade prepare',
|
|
|
+ logoutput = True,
|
|
|
+ user = 'hdfs',
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute', 'hdfs dfsadmin -rollingUpgrade query',
|
|
|
+ logoutput = True,
|
|
|
+ user = 'hdfs',
|
|
|
+ )
|
|
|
+ self.assertNoMoreResources()
|
|
|
+
|
|
|
+
|
|
|
+ @patch.object(shell, "call")
|
|
|
+ def test_prepare_rolling_upgrade__downgrade(self, shell_call_mock):
|
|
|
+ config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/secured.json"
|
|
|
+ with open(config_file, "r") as f:
|
|
|
+ json_content = json.load(f)
|
|
|
+ json_content['commandParams']['upgrade_direction'] = 'downgrade'
|
|
|
+
|
|
|
+ # Mock safemode_check call
|
|
|
+ shell_call_mock.return_value = 0, "Safe mode is OFF in c6401.ambari.apache.org"
|
|
|
+
|
|
|
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
+ classname = "NameNode",
|
|
|
+ command = "prepare_rolling_upgrade",
|
|
|
+ config_dict = json_content,
|
|
|
+ hdp_stack_version = self.STACK_VERSION,
|
|
|
+ target = RMFTestCase.TARGET_COMMON_SERVICES)
|
|
|
+ self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hdfs.headless.keytab hdfs',)
|
|
|
+ self.assertNoMoreResources()
|
|
|
+
|
|
|
+
|
|
|
+ def test_finalize_rolling_upgrade(self):
|
|
|
+ config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
|
|
|
+ with open(config_file, "r") as f:
|
|
|
+ json_content = json.load(f)
|
|
|
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/namenode.py",
|
|
|
+ classname = "NameNode",
|
|
|
+ command = "finalize_rolling_upgrade",
|
|
|
+ config_dict = json_content,
|
|
|
+ hdp_stack_version = self.STACK_VERSION,
|
|
|
+ target = RMFTestCase.TARGET_COMMON_SERVICES)
|
|
|
+
|
|
|
+ self.assertResourceCalled('Execute', 'hdfs dfsadmin -rollingUpgrade query',
|
|
|
+ logoutput = True,
|
|
|
+ user = 'hdfs',
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute', 'hdfs dfsadmin -rollingUpgrade finalize',
|
|
|
+ logoutput = True,
|
|
|
+ user = 'hdfs',
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute', 'hdfs dfsadmin -rollingUpgrade query',
|
|
|
+ logoutput = True,
|
|
|
+ user = 'hdfs',
|
|
|
+ )
|
|
|
+ self.assertNoMoreResources()
|
|
|
+
|
|
|
+
|
|
|
class Popen_Mock:
|
|
|
return_value = 1
|
|
|
lines = ['Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved\n',
|