コード例 #1
0
    def test_get_property(self):
        package_dir = os.path.join(RMFTestCase._getCommonServicesFolder(),
                                   self.COMMON_SERVICES_PACKAGE_DIR)
        scripts_dir = os.path.join(package_dir, "scripts")
        sys.path += [scripts_dir]
        from ambari_commons.kerberos.utils import get_property_value

        d = {
            'non_empty': "Nonempty value",
            'unicode_non_empty': u"Nonempty value",
            'number': 33,
            'number_string': "33",
            'empty': "",
            'unicode_empty': u"",
            'whitespace': "    ",
            'unicode_whitespace': u"    ",
            'none': None,
        }

        self.assertEqual('Nonempty value', get_property_value(d, 'non_empty'))
        self.assertEqual('Nonempty value',
                         get_property_value(d, 'non_empty', None, True, None))

        self.assertEqual('Nonempty value',
                         get_property_value(d, 'unicode_non_empty'))
        self.assertEqual(
            'Nonempty value',
            get_property_value(d, 'unicode_non_empty', None, True, None))

        self.assertEqual('33', get_property_value(d, 'number_string'))
        self.assertEqual(
            '33', get_property_value(d, 'number_string', None, True, None))

        self.assertEqual(33, get_property_value(d, 'number'))
        self.assertEqual(33, get_property_value(d, 'number', None, True, None))

        self.assertEqual('', get_property_value(d, 'empty'))
        self.assertEqual(
            "I'm empty", get_property_value(d, 'empty', None, True,
                                            "I'm empty"))
        self.assertEqual(
            '', get_property_value(d, 'empty', None, False, "I'm empty"))

        self.assertEqual('', get_property_value(d, 'unicode_empty'))
        self.assertEqual(
            "I'm empty",
            get_property_value(d, 'unicode_empty', None, True, "I'm empty"))
        self.assertEqual(
            '', get_property_value(d, 'unicode_empty', None, False,
                                   "I'm empty"))

        self.assertEqual("    ", get_property_value(d, 'whitespace'))
        self.assertEqual(
            "I'm empty",
            get_property_value(d, 'whitespace', None, True, "I'm empty"))
        self.assertEqual(
            '    ',
            get_property_value(d, 'whitespace', None, False, "I'm empty"))

        self.assertEqual("    ", get_property_value(d, 'unicode_whitespace'))
        self.assertEqual(
            "I'm empty",
            get_property_value(d, 'unicode_whitespace', None, True,
                               "I'm empty"))
        self.assertEqual(
            '    ',
            get_property_value(d, 'unicode_whitespace', None, False,
                               "I'm empty"))

        self.assertEqual(None, get_property_value(d, 'none'))
        self.assertEqual(
            "I'm empty", get_property_value(d, 'none', None, True,
                                            "I'm empty"))
        self.assertEqual(
            None, get_property_value(d, 'none', None, False, "I'm empty"))
        self.assertEqual("I'm empty",
                         get_property_value(d, 'none', '', True, "I'm empty"))
        self.assertEqual("",
                         get_property_value(d, 'none', '', False, "I'm empty"))
コード例 #2
0
smoke_user = '******'

manage_identities = 'true'

artifact_dir = format("{tmp_dir}/AMBARI-artifacts/")
jce_policy_zip = default("/hostLevelParams/jce_name",
                         None)  # None when jdk is already installed by user
jce_location = config['ambariLevelParams']['jdk_location']
jdk_name = default("/hostLevelParams/jdk_name", None)
java_home = config['ambariLevelParams']['java_home']
java_version = expect("/hostLevelParams/java_version", int)

security_enabled = config['configurations']['cluster-env']['security_enabled']

if config is not None:
    kerberos_command_params = get_property_value(config,
                                                 'kerberosCommandParams')

    cluster_host_info = get_property_value(config, 'clusterHostInfo')
    if cluster_host_info is not None:
        kdc_server_hosts = get_property_value(cluster_host_info,
                                              'kdc_server_hosts')

        if (kdc_server_hosts is not None) and (len(kdc_server_hosts) > 0):
            kdc_server_host = kdc_server_hosts[0]

    configurations = get_property_value(config, 'configurations')
    if configurations is not None:
        cluster_env = get_property_value(configurations, 'cluster-env')

        if cluster_env is not None:
            smoke_test_principal = get_property_value(