Пример #1
0
    def test_is_swift_enabled(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertTrue(c_h.is_swift_enabled(cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general': {c_h.ENABLE_SWIFT.name: False}})
        self.assertFalse(c_h.is_swift_enabled(cluster))
Пример #2
0
    def test_is_hbase_common_lib_enabled(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertTrue(c_h.is_hbase_common_lib_enabled(cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general':
                             {c_h.ENABLE_HBASE_COMMON_LIB.name: False}})
        self.assertFalse(c_h.is_hbase_common_lib_enabled(cluster))
Пример #3
0
    def test_get_cdh5_key_url(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertEqual(c_h.CDH5_REPO_KEY_URL.default_value,
                         c_h.get_cdh5_key_url(cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general': {c_h.CDH5_REPO_KEY_URL.name: 'spam'}})
        self.assertEqual('spam', c_h.get_cdh5_key_url(cluster))
Пример #4
0
    def test_get_extjs_lib_url(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertEqual(c_h.DEFAULT_EXTJS_LIB_URL,
                         c_h.get_extjs_lib_url(cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general': {c_h.EXTJS_LIB_URL.name: 'spam'}})
        self.assertEqual('spam', c_h.get_extjs_lib_url(cluster))
Пример #5
0
    def test_get_swift_lib_url(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertEqual(self.c_h.DEFAULT_SWIFT_LIB_URL,
                         self.c_h.get_swift_lib_url(cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general': {
                self.c_h.SWIFT_LIB_URL.name: 'spam'
            }})
        self.assertEqual('spam', self.c_h.get_swift_lib_url(cluster))
Пример #6
0
    def test_get_cm5_repo_url(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertEqual(self.c_h.CM5_REPO_URL.default_value,
                         self.c_h.get_cm5_repo_url(cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general': {
                self.c_h.CM5_REPO_URL.name: 'spam'
            }})
        self.assertEqual('spam', self.c_h.get_cm5_repo_url(cluster))
Пример #7
0
    def test_get_required_anti_affinity(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertTrue(self.c_h.get_required_anti_affinity(cluster))

        cluster = ctu.get_fake_cluster(cluster_configs={
            'general': {
                self.c_h.REQUIRE_ANTI_AFFINITY.name: False
            }
        })
        self.assertFalse(self.c_h.get_required_anti_affinity(cluster))
Пример #8
0
    def test_get_kms_key_url(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertEqual(self.c_h.KMS_REPO_KEY_URL.default_value,
                         self.c_h.get_kms_key_url(cluster))

        cluster = ctu.get_fake_cluster(cluster_configs={
            'general': {
                self.c_h.KMS_REPO_KEY_URL.name: 'spam'
            }
        })
        self.assertEqual('spam', self.c_h.get_kms_key_url(cluster))
Пример #9
0
    def test_get_service(self, mock_get_cl_cluster):
        self.assertRaises(ValueError, CU.get_service_by_role, 'NAMENODE')

        cluster = ctu.get_fake_cluster()
        inst = cluster.node_groups[0].instances[0]
        mock_get_cl_cluster.return_value = None

        self.assertRaises(ValueError, CU.get_service_by_role, 'spam',
                          cluster)
        self.assertRaises(ValueError, CU.get_service_by_role, 'spam',
                          instance=inst)

        mock_get_cl_cluster.reset_mock()

        mock_get_service = mock.MagicMock()
        mock_get_service.get_service.return_value = mock.Mock()
        mock_get_cl_cluster.return_value = mock_get_service

        CU.get_service_by_role('NAMENODE', cluster)
        args = ((CU.HDFS_SERVICE_NAME,),)
        self.assertEqual(args, mock_get_service.get_service.call_args)

        mock_get_service.reset_mock()
        CU.get_service_by_role('JOBHISTORY', instance=inst)
        args = ((CU.YARN_SERVICE_NAME,),)
        self.assertEqual(args, mock_get_service.get_service.call_args)

        mock_get_service.reset_mock()
        CU.get_service_by_role('OOZIE_SERVER', cluster)
        args = ((CU.OOZIE_SERVICE_NAME,),)
        self.assertEqual(args, mock_get_service.get_service.call_args)
Пример #10
0
    def test_get_service(self, mock_get_cl_cluster):
        self.assertRaises(ValueError, CU.get_service_by_role, 'NAMENODE')

        cluster = ctu.get_fake_cluster()
        inst = cluster.node_groups[0].instances[0]
        mock_get_cl_cluster.return_value = None

        self.assertRaises(ValueError, CU.get_service_by_role, 'spam', cluster)
        self.assertRaises(ValueError,
                          CU.get_service_by_role,
                          'spam',
                          instance=inst)

        mock_get_cl_cluster.reset_mock()

        mock_get_service = mock.MagicMock()
        mock_get_service.get_service.return_value = mock.Mock()
        mock_get_cl_cluster.return_value = mock_get_service

        CU.get_service_by_role('NAMENODE', cluster)
        args = ((CU.HDFS_SERVICE_NAME, ), )
        self.assertEqual(args, mock_get_service.get_service.call_args)

        mock_get_service.reset_mock()
        CU.get_service_by_role('JOBHISTORY', instance=inst)
        args = ((CU.YARN_SERVICE_NAME, ), )
        self.assertEqual(args, mock_get_service.get_service.call_args)

        mock_get_service.reset_mock()
        CU.get_service_by_role('OOZIE_SERVER', cluster)
        args = ((CU.OOZIE_SERVICE_NAME, ), )
        self.assertEqual(args, mock_get_service.get_service.call_args)
Пример #11
0
    def test_get_required_anti_affinity(self):
        self.assertTrue(c_h.get_required_anti_affinity(self.cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general': {
                c_h.REQUIRE_ANTI_AFFINITY.name: False}})
        self.assertFalse(c_h.get_required_anti_affinity(cluster))
Пример #12
0
    def test_get_swift_lib_url(self):
        self.assertEqual(c_h.DEFAULT_SWIFT_LIB_URL,
                         c_h.get_swift_lib_url(self.cluster))

        cluster = ctu.get_fake_cluster(
            cluster_configs={'general': {c_h.SWIFT_LIB_URL.name: 'spam'}})
        self.assertEqual('spam', c_h.get_swift_lib_url(cluster))
Пример #13
0
def get_concrete_cluster():
    cluster = ctu.get_fake_cluster()

    # add configs to cluster
    configs = {
        "SQOOP": {},
        "HUE": {},
        "general": {},
        "KMS": {},
        "HIVE": {},
        "SOLR": {},
        "FLUME": {},
        "HDFS": {
            "dfs_replication": 1
        },
        "KS_INDEXER": {},
        "SPARK_ON_YARN": {},
        "SENTRY": {},
        "YARN": {},
        "ZOOKEEPER": {},
        "OOZIE": {},
        "HBASE": {},
        "IMPALA": {}
    }
    # cluster is immutable, a work around
    dict.__setitem__(cluster, "cluster_configs", configs)

    # add fake remotes to instances
    instances = [i for ng in cluster.node_groups for i in ng.instances]
    for i in instances:
        object.__setattr__(i, 'remote', mock.MagicMock())

    # add cluster_id to each node group
    for ng in cluster.node_groups:
        dict.__setitem__(ng, "cluster_id", ng.cluster.id)

    # add extra config
    dict.__setitem__(cluster, "extra", {})
    return cluster
Пример #14
0
def get_concrete_cluster():
    cluster = ctu.get_fake_cluster()

    # add configs to cluster
    configs = {"SQOOP": {}, "HUE": {}, "general": {}, "KMS": {}, "HIVE": {},
               "SOLR": {}, "FLUME": {}, "HDFS": {"dfs_replication": 1},
               "KS_INDEXER": {}, "SPARK_ON_YARN": {}, "SENTRY": {}, "YARN": {},
               "ZOOKEEPER": {}, "OOZIE": {}, "HBASE": {}, "IMPALA": {}}
    # cluster is immutable, a work around
    dict.__setitem__(cluster, "cluster_config", configs)

    # add fake remotes to instances
    instances = [i for ng in cluster.node_groups for i in ng.instances]
    for i in instances:
        object.__setattr__(i, 'remote', mock.MagicMock())

    # add cluster_id to each node group
    for ng in cluster.node_groups:
        dict.__setitem__(ng, "cluster_id", ng.cluster.id)

    # add extra config
    dict.__setitem__(cluster, "extra", {})
    return cluster
Пример #15
0
 def setUp(self):
     super(ConfigHelperTestCase, self).setUp()
     self.cluster = ctu.get_fake_cluster(cluster_configs={})
Пример #16
0
 def test_get_oozie(self):
     cluster = tu.get_fake_cluster()
     inst = u.get_oozie(cluster)
     self.assertEqual('id2', inst.instance_id)
Пример #17
0
 def test_get_historyserver(self):
     cluster = tu.get_fake_cluster()
     inst = u.get_historyserver(cluster)
     self.assertEqual('id2', inst.instance_id)
Пример #18
0
 def test_get_nodemanagers(self):
     cluster = tu.get_fake_cluster()
     nms = u.get_nodemanagers(cluster)
     ids = [nm.instance_id for nm in nms]
     self.assertEqual(sorted(['id00', 'id01', 'id02']), sorted(ids))
Пример #19
0
 def test_get_datanodes(self):
     cluster = tu.get_fake_cluster()
     dns = u.get_datanodes(cluster)
     ids = [dn.instance_id for dn in dns]
     self.assertEqual(sorted(['id00', 'id01', 'id02']), sorted(ids))
Пример #20
0
 def test_get_resourcemanager(self):
     cluster = tu.get_fake_cluster()
     inst = u.get_resourcemanager(cluster)
     self.assertEqual('id2', inst.instance_id)
Пример #21
0
 def test_get_secondarynamenode(self):
     cluster = tu.get_fake_cluster()
     inst = u.get_secondarynamenode(cluster)
     self.assertEqual('id2', inst.instance_id)
Пример #22
0
def get_cluster(version='5.3.0'):
    cluster = c_u.get_fake_cluster(plugin_name='CDH', hadoop_version=version)
    return cluster
Пример #23
0
    def test_get_swift_lib_url(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertEqual(c_h.DEFAULT_SWIFT_LIB_URL, c_h.get_swift_lib_url(cluster))

        cluster = ctu.get_fake_cluster(cluster_configs={"general": {c_h.SWIFT_LIB_URL.name: "spam"}})
        self.assertEqual("spam", c_h.get_swift_lib_url(cluster))
Пример #24
0
    def test_get_cm5_key_url(self):
        cluster = ctu.get_fake_cluster(cluster_configs={})
        self.assertEqual(c_h.CM5_REPO_KEY_URL.default_value, c_h.get_cm5_key_url(cluster))

        cluster = ctu.get_fake_cluster(cluster_configs={"general": {c_h.CM5_REPO_KEY_URL.name: "spam"}})
        self.assertEqual("spam", c_h.get_cm5_key_url(cluster))
Пример #25
0
 def test_get_manager(self):
     cluster = tu.get_fake_cluster()
     inst = PU.get_manager(cluster)
     self.assertEqual('id1', inst.instance_id)
Пример #26
0
 def test_get_manager(self):
     cluster = tu.get_fake_cluster()
     inst = PU.get_manager(cluster)
     self.assertEqual('id1', inst.instance_id)
Пример #27
0
def get_cluster(version='5.3.0'):
    cluster = c_u.get_fake_cluster(plugin_name='CDH', hadoop_version=version)
    return cluster
Пример #28
0
 def setUp(self):
     super(ConfigHelperTestCase, self).setUp()
     self.cluster = ctu.get_fake_cluster(cluster_configs={})