Skip to content

Commit bc23552

Browse files
Miscellaneous Alias Test Improvements (#1248)
* adding tokenization, masking log warnings for credentials, fixing logging * more logging changes * Update verifier.py
1 parent 7c2a4ec commit bc23552

23 files changed

+207
-72
lines changed

integration-tests/alias-test/generate/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
<environmentVariables>
182182
<JAVA_HOME>${env.JAVA_HOME}</JAVA_HOME>
183183
<WLSDEPLOY_HOME>${project.build.directory}/weblogic-deploy</WLSDEPLOY_HOME>
184+
<WLSDEPLOY_LOG_PROPERTIES>${project.basedir}/src/test/resources/logging.properties</WLSDEPLOY_LOG_PROPERTIES>
184185
<TEST_HOME>${test_home}</TEST_HOME>
185186
</environmentVariables>
186187
<arguments>
@@ -213,6 +214,7 @@
213214
<environmentVariables>
214215
<JAVA_HOME>${env.JAVA_HOME}</JAVA_HOME>
215216
<WLSDEPLOY_HOME>${project.build.directory}/weblogic-deploy</WLSDEPLOY_HOME>
217+
<WLSDEPLOY_LOG_PROPERTIES>${project.basedir}/src/test/resources/logging.properties</WLSDEPLOY_LOG_PROPERTIES>
216218
<TEST_HOME>${test_home}</TEST_HOME>
217219
</environmentVariables>
218220
<arguments>
@@ -245,6 +247,7 @@
245247
<environmentVariables>
246248
<JAVA_HOME>${env.JAVA_HOME}</JAVA_HOME>
247249
<WLSDEPLOY_HOME>${project.build.directory}/weblogic-deploy</WLSDEPLOY_HOME>
250+
<WLSDEPLOY_LOG_PROPERTIES>${project.basedir}/src/test/resources/logging.properties</WLSDEPLOY_LOG_PROPERTIES>
248251
<TEST_HOME>${test_home}</TEST_HOME>
249252
</environmentVariables>
250253
<arguments>

integration-tests/alias-test/generate/src/test/bin/doGenerateOffline.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ WLST_PROPERTIES="${WLST_PROPERTIES} ${WLSDEPLOY_PROPERTIES}"
150150
export WLST_PROPERTIES
151151

152152
if [ "${WLSDEPLOY_LOG_PROPERTIES}" = "" ]; then
153-
WLSDEPLOY_LOG_PROPERTIES=${WLSDEPLOY_HOME}/etc/logging.properties; export WLSDEPLOY_LOG_PROPERTIES
153+
WLSDEPLOY_LOG_PROPERTIES=${WLSDEPLOY_HOME}/etc/logging.properties
154154
fi
155+
export WLSDEPLOY_LOG_PROPERTIES
155156

156157
if [ "${WLSDEPLOY_LOG_DIRECTORY}" = "" ]; then
157158
WLSDEPLOY_LOG_DIRECTORY=${WLSDEPLOY_HOME}/logs; export WLSDEPLOY_LOG_DIRECTORY

integration-tests/alias-test/generate/src/test/bin/doGenerateOnline.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ WLST_PROPERTIES="${WLST_PROPERTIES} ${WLSDEPLOY_PROPERTIES}"
165165
export WLST_PROPERTIES
166166

167167
if [ "${WLSDEPLOY_LOG_PROPERTIES}" = "" ]; then
168-
WLSDEPLOY_LOG_PROPERTIES=${WLSDEPLOY_HOME}/etc/logging.properties; export WLSDEPLOY_LOG_PROPERTIES
168+
WLSDEPLOY_LOG_PROPERTIES=${WLSDEPLOY_HOME}/etc/logging.properties
169169
fi
170+
export WLSDEPLOY_LOG_PROPERTIES
170171

171172
if [ "${WLSDEPLOY_LOG_DIRECTORY}" = "" ]; then
172173
WLSDEPLOY_LOG_DIRECTORY=${WLSDEPLOY_HOME}/logs; export WLSDEPLOY_LOG_DIRECTORY

integration-tests/alias-test/generate/src/test/bin/doGenerateSC.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ WLST_PROPERTIES="${WLST_PROPERTIES} ${WLSDEPLOY_PROPERTIES}"
165165
export WLST_PROPERTIES
166166

167167
if [ "${WLSDEPLOY_LOG_PROPERTIES}" = "" ]; then
168-
WLSDEPLOY_LOG_PROPERTIES=${WLSDEPLOY_HOME}/etc/logging.properties; export WLSDEPLOY_LOG_PROPERTIES
168+
WLSDEPLOY_LOG_PROPERTIES=${WLSDEPLOY_HOME}/etc/logging.properties
169169
fi
170+
export WLSDEPLOY_LOG_PROPERTIES
171+
170172

171173
if [ "${WLSDEPLOY_LOG_DIRECTORY}" = "" ]; then
172174
WLSDEPLOY_LOG_DIRECTORY=${WLSDEPLOY_HOME}/logs; export WLSDEPLOY_LOG_DIRECTORY

integration-tests/alias-test/generate/src/test/python/aliastest/generate/generator_base.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.lang.Boolean as Boolean
88
import java.lang.Exception as JException
99
import java.lang.Object as JObject
10-
import java.util.logging.Level as Level
1110
import javax.management.ObjectName as JObjectName
1211

1312
import org.python.core.PyArray as PyArray
@@ -61,11 +60,11 @@ class GeneratorBase(object):
6160
Common helper methods for generation of folder and attribute information for both online and offline
6261
generators.
6362
"""
64-
__logger = PlatformLogger('test.aliases.generate')
65-
__logger.set_level(Level.FINER)
63+
__logger = PlatformLogger('test.aliases.generate.base')
6664

6765
def __init__(self, model_context, dictionary):
6866
self.__class_name = self.__class__.__name__
67+
self._model_context = model_context
6968
self._dictionary = dictionary
7069
self._aliases = \
7170
Aliases(model_context, model_context.get_target_wlst_mode(), model_context.get_target_wls_version())
@@ -111,9 +110,9 @@ def add_default_value(self, dictionary, lsa_map, cmo_helper, method_helper, attr
111110
if get_value != FAIL:
112111
dictionary[GET_TYPE] = self.type_it(mbean_type, attribute_name, get_attr_type)
113112
dictionary[GET_DEFAULT] = self.convert_attribute(attribute_name, get_value, value_type=dictionary[GET_TYPE])
114-
self.__logger.finest('Attribute {0} {1} is {2} and {3} is {4}', attribute_name, GET_TYPE,
115-
dictionary[GET_TYPE], GET_DEFAULT, dictionary[GET_DEFAULT],
116-
class_name=self.__class_name, method_name=_method_name)
113+
self.__logger.finer('Attribute {0} {1} is {2} and {3} is {4}', attribute_name, GET_TYPE,
114+
dictionary[GET_TYPE], GET_DEFAULT, dictionary[GET_DEFAULT],
115+
class_name=self.__class_name, method_name=_method_name)
117116

118117
lsa_attr_type, lsa_value = self._get_lsa_type_and_value(lsa_map, attribute_name)
119118
if lsa_value != FAIL:
@@ -125,9 +124,11 @@ def add_default_value(self, dictionary, lsa_map, cmo_helper, method_helper, attr
125124
dictionary[LSA_TYPE] = self.type_it(mbean_type, attribute_name, lsa_attr_type)
126125
dictionary[LSA_DEFAULT] = self.convert_attribute(attribute_name, lsa_value, value_type=dictionary[LSA_TYPE])
127126
self._add_lsa_readwrite(dictionary, attribute_name)
128-
self.__logger.finest('Attribute {0} {1} is {2} and {3} is {4}', attribute_name, LSA_TYPE,
129-
dictionary[LSA_TYPE], LSA_DEFAULT, dictionary[LSA_DEFAULT],
130-
class_name=self.__class_name, method_name=_method_name)
127+
self.__logger.finer('Attribute {0} {1} is {2} and {3} is {4} and {5} is {6}', attribute_name, LSA_TYPE,
128+
dictionary[LSA_TYPE], LSA_DEFAULT, dictionary[LSA_DEFAULT], READ_TYPE,
129+
dictionary[READ_TYPE], class_name=self.__class_name, method_name=_method_name)
130+
else:
131+
self.__logger.finer('Attribute {0} has lsa_value of {1} so skipping', attribute_name, FAIL)
131132

132133
if lsa_value == FAIL and get_value == FAIL and cmo_value == FAIL:
133134
self.__logger.fine(BAD_ATTR_ERR, attribute_name, class_name=self.__class_name, method_name=_method_name)
@@ -354,6 +355,9 @@ def convert_attribute(self, attribute, value, value_type=None):
354355
else:
355356
return_value = value
356357

358+
if generator_wlst.is_path_field(attribute):
359+
return_value = generator_wlst.tokenize_path_value(self._model_context, attribute, value)
360+
357361
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=return_value)
358362
return return_value
359363

@@ -415,26 +419,50 @@ def type_it(self, mbean_type, attr_name, attr_type):
415419
return return_type
416420

417421
def _add_lsa_readwrite(self, attribute_map, lsa_name):
418-
_method_name = '_get_lsa_readwrite'
422+
_method_name = '_add_lsa_readwrite'
419423
self.__logger.entering(lsa_name, class_name=self.__class_name, method_name=_method_name)
420424

425+
# We cannot simply parse the attribute name out of the lsa_string() results. If the attribute name is too
426+
# long, it will run into the value making it difficult to separate the name from the value. For example,
427+
# the first field below will never have a value for attr because there is no space between the
428+
# attribute name and value.
429+
#
430+
# -rw- CustomClusterConfigurationFileLastUpdatedTimestamp0
431+
# -rw- CustomClusterConfigurationFileName null
432+
# -rw- Name foo
433+
# -rw- Version null
434+
#
435+
# Figuring out if the row matches the lsa_name or not is tricky. But, we can rely on the lsa_string to have
436+
# the fields in alphabetical order such that the first <rest-of-the-row>.startswith(lsa_name) match should
437+
# always be the correct row.
438+
#
421439
attributes_str = generator_wlst.lsa_string()
422440
read_type = None
423441
if attributes_str is not None:
424442
for attribute_str in attributes_str.split('\n'):
425443
if attribute_str:
426444
read_type = attribute_str[0:4].strip()
427445
attr = attribute_str[7:attribute_str.find(' ', 7)+1].strip()
428-
if attr == lsa_name:
446+
447+
if attr == lsa_name or (len(attr) == 0 and attributes_str[7:].strip().startswith(lsa_name)):
448+
self.__logger.finer('Attribute {0} has read_type {1}', lsa_name, read_type,
449+
class_name=self.__class_name, method_name=_method_name)
429450
if read_type == '-rw-':
430451
attribute_map[READ_TYPE] = READ_WRITE
431452
elif read_type == '-r--':
432453
attribute_map[READ_TYPE] = READ_ONLY
454+
else:
455+
self.__logger.warning('READ_TYPE for attribute {0} with read_type "{1}"'
456+
' not added to attribute map', lsa_name, read_type,
457+
class_name=self.__class_name, method_name=_method_name)
433458
break
459+
else:
460+
self.__logger.finer('Attribute "{0}" not a match with the lsa_name "{1}"',
461+
attr, lsa_name, class_name=self.__class_name, method_name=_method_name)
434462

435463
self.__logger.finer('MBeanInfo property descriptors has attribute {0} access {1}', lsa_name, read_type,
436464
class_name=self.__class_name, method_name=_method_name)
437-
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)
465+
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=attribute_map[READ_TYPE])
438466

439467
def _can_get(self, mbean_type, attribute_name, index=0):
440468
success = generator_wlst.can_get(mbean_type, attribute_name)
@@ -522,7 +550,3 @@ def _is_valid_folder(self, attribute_helper):
522550

523551
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=Boolean(result))
524552
return result
525-
526-
527-
def filename():
528-
return 'generated'

integration-tests/alias-test/generate/src/test/python/aliastest/generate/generator_offline.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ class OfflineGenerator(GeneratorBase):
4646
Generate the offline folder and attribute information into a dictionary. The offline generate is seeded
4747
by the mbean information in dictionary generated from online.
4848
"""
49-
__logger = PlatformLogger('test.aliases.generate')
50-
__logger.set_level(Level.FINER)
51-
49+
__logger = PlatformLogger('test.aliases.generate.offline')
50+
5251
def __init__(self, model_context, sc_providers, online_dictionary):
5352
super(OfflineGenerator, self).__init__(model_context, PyOrderedDict())
5453
self.__class_name = self.__class__.__name__
@@ -93,16 +92,21 @@ def __folder_hierarchy(self, mbean_dictionary, online_dictionary, mbean_path, pa
9392

9493
info_helper = MBeanInfoHelper(mbean_instance, mbean_path)
9594
info_map = generator_utils.reorder_info_map(mbean_path, info_helper.get_child_mbeans())
95+
self.__logger.finest('At {0}, MBeanInfoHelper found child MBeans: {1}', mbean_path, info_map.keys(),
96+
class_name=self.__class_name, method_name=_method_name)
9697

9798
methods_helper = MBeanMethodHelper(mbean_instance, mbean_path)
9899
methods_map = methods_helper.get_child_mbeans()
99100
methods_name_list = methods_map.keys()
100101
methods_name_list.sort()
102+
self.__logger.finest('At {0}, MBeanMethodHelper found child MBeans: {1}', mbean_path, methods_name_list,
103+
class_name=self.__class_name, method_name=_method_name)
101104

102105
online_dictionary_names = copy.copy(online_dictionary.keys())
103106
online_dictionary_names.sort()
104-
self.__logger.fine('Online dictionary names for location {0} : {1}', mbean_path, online_dictionary_names,
105-
class_name=self.__class_name, method_name=_method_name)
107+
self.__logger.finest('At {0}, online dictionary names: {1}', mbean_path, online_dictionary_names,
108+
class_name=self.__class_name, method_name=_method_name)
109+
106110
for mbean_type, mbean_helper in info_map.iteritems():
107111
if mbean_type in methods_name_list:
108112
self.__logger.fine('Child MBean {0} of {1} in both the MBeanInfo and the CMO methods',
@@ -142,23 +146,26 @@ def __folder_hierarchy(self, mbean_dictionary, online_dictionary, mbean_path, pa
142146
class_name=self.__class_name, method_name=_method_name)
143147

144148
if len(online_dictionary_names) > 0:
145-
self.__logger.finest('The online dictionary names has MBeans not in MBeanInfo or methods',
146-
class_name=self.__class_name, method_name=_method_name)
149+
self.__logger.finest('The online dictionary names at path {0} has MBeans not in MBeanInfo or methods',
150+
mbean_path, class_name=self.__class_name, method_name=_method_name)
147151
for online_dictionary_name in online_dictionary_names:
152+
self.__logger.finest('Processing online_dictionary_name {0} at path {1}', online_dictionary_name,
153+
mbean_path, class_name=self.__class_name, method_name=_method_name)
148154
if online_dictionary_name in methods_name_list:
149-
self.__logger.fine('Child MBean {0} of {1} found in CMO methods',
150-
online_dictionary_name, parent_mbean_type,
151-
class_name=self.__class_name, method_name=_method_name)
155+
self.__logger.fine('Found Child MBean {0} of {1} found in CMO methods', online_dictionary_name,
156+
parent_mbean_type, class_name=self.__class_name, method_name=_method_name)
152157
methods_name_list.remove(online_dictionary_name)
153158

154159
# Have to make sure what we are processing is not a security provider type.
155160
if online_dictionary_name in PROVIDERS:
156161
self.__logger.fine('Found security provider folder {0} in online_dictionary_names',
157-
online_dictionary_name)
162+
online_dictionary_name, class_name=self.__class_name, method_name=_method_name)
158163
success, lsc_name, attributes = self.create_security_type(online_dictionary_name)
159164
mbean_dictionary[lsc_name] = attributes
160165
continue
161166
else:
167+
self.__logger.fine('Found folder {0} in online_dictionary_names', online_dictionary_name,
168+
class_name=self.__class_name, method_name=_method_name)
162169
success, lsc_name, attributes = \
163170
self.__generate_folder(mbean_instance, parent_mbean_type, online_dictionary_name, None)
164171
if success:
@@ -288,15 +295,15 @@ def __get_attributes(self, mbean_instance):
288295
method_helper = MBeanMethodHelper(mbean_instance, mbean_path)
289296
methods_map = method_helper.get_attributes()
290297
methods_attributes = methods_map.keys()
291-
self.__logger.finer('MBeanMethodHelper found attributes: {0}', methods_attributes,
298+
self.__logger.finer('At {0}, MBeanMethodHelper found attributes: {1}', mbean_path, methods_attributes,
292299
class_name=self.__class_name, method_name=_method_name)
293300

294301
# As the driver it needs to have all attributes
295302
info_helper = MBeanInfoHelper(mbean_instance, mbean_path)
296303
info_map = info_helper.get_all_attributes()
297304
mbean_type = info_helper.get_mbean_type()
298-
self.__logger.finer('MBeanInfoHelper for MBean type {0} found attributes: {1}', mbean_type, info_map,
299-
class_name=self.__class_name, method_name=_method_name)
305+
self.__logger.finer('At {0}, MBeanInfoHelper for MBean type {0} found attributes: {1}', mbean_type,
306+
info_map.keys(), class_name=self.__class_name, method_name=_method_name)
300307

301308
for attribute, attribute_helper in info_map.iteritems():
302309
method_attribute_helper = None

integration-tests/alias-test/generate/src/test/python/aliastest/generate/generator_online.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55

66
import java.lang.Boolean as Boolean
7-
import java.util.logging.Level as Level
87

98
from oracle.weblogic.deploy.util import PyOrderedDict
109

@@ -37,7 +36,6 @@ class OnlineGenerator(GeneratorBase):
3736
The data is traversed using the registered mbean information for the online session.
3837
"""
3938
__logger = PlatformLogger('test.aliases.generate.online')
40-
__logger.set_level(Level.FINER)
4139

4240
def __init__(self, model_context, sc_providers):
4341
super(OnlineGenerator, self).__init__(model_context, PyOrderedDict())

0 commit comments

Comments
 (0)