Skip to content

Commit f9d08ac

Browse files
author
Craig Cornelius
authored
Reduce debug noise for issue #336 (#369)
* Reducing lots of noise from debug statements and unneeded detail in logs. * Turn off detailed progress in testdriver * Remove extra error info to logged output * remove unneeded debug detail * Fix merge
1 parent 4fd4881 commit f9d08ac

17 files changed

+163
-179
lines changed

schema/check_generated_data.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
import schema_validator
1616
from schema_files import ALL_TEST_TYPES
1717

18+
logger = logging.Logger("Checking Test Data vs. Schemas LOGGER")
19+
logger.setLevel(logging.WARNING)
20+
1821

1922
def main(args):
2023
logging.config.fileConfig("../logging.conf")
2124

2225
if len(args) <= 1:
23-
logging.error('Please specify the path to test data directory')
26+
logger.error('Please specify the path to test data directory')
2427
return
2528
else:
2629
test_data_path = args[1]
2730

28-
logging.debug('TEST DATA PATH = %s', test_data_path)
2931

30-
logger = logging.Logger("Checking Test Data vs. Schemas LOGGER")
31-
logger.setLevel(logging.INFO)
3232
logger.info('+++ Test Generated test data vs. schemas files')
3333

3434
# TODO: get ICU versions
@@ -39,8 +39,8 @@ def main(args):
3939
for dir_name in icu_dirs:
4040
icu_versions.append(os.path.basename(dir_name))
4141

42-
logging.debug('ICU directories = %s', icu_versions)
43-
logging.debug('test types = %s', ALL_TEST_TYPES)
42+
logger.debug('ICU directories = %s', icu_versions)
43+
logger.debug('test types = %s', ALL_TEST_TYPES)
4444

4545
validator = schema_validator.ConformanceSchemaValidator()
4646

@@ -52,7 +52,7 @@ def main(args):
5252
validator.debug = 1
5353

5454
all_results = validator.validate_test_data_with_schema()
55-
logging.info(' %d results for generated test data', len(all_results))
55+
logger.debug(' %d results for generated test data', len(all_results))
5656

5757
schema_errors = []
5858
failed_validations = []
@@ -78,7 +78,7 @@ def main(args):
7878
try:
7979
summary_data = json.dumps(summary_json)
8080
except BaseException as error:
81-
logging.error('json.dumps Summary data problem: %s at %s', error, error)
81+
logger.error('json.dumps Summary data problem: %s at %s', error, error)
8282
sys.exit(1)
8383

8484
output_filename = os.path.join(test_data_path, 'test_data_validation_summary.json')
@@ -88,19 +88,18 @@ def main(args):
8888
file_out.close()
8989
except BaseException as error:
9090
schema_errors.append(output_filename)
91-
logging.fatal('Error: %s. Cannot save validation summary in file %s', error, output_filename)
91+
logger.fatal('Error: %s. Cannot save validation summary in file %s', error, output_filename)
9292
sys.exit(1)
9393

9494
if schema_errors:
95-
logging.critical('Test data file files: %d fail out of %d:',
95+
logger.critical('Test data file files: %d fail out of %d:',
9696
len(schema_errors), schema_count)
9797
for failure in schema_errors:
98-
logging.critical(' %s', failure)
98+
logger.critical(' %s', failure)
9999
sys.exit(1)
100100
else:
101101
logging.info("All %d generated test data files match with schema", schema_count)
102102

103103

104-
105104
if __name__ == "__main__":
106105
main(sys.argv)

schema/check_schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def parallel_validate_schema(validator, file_names):
7676

7777
def main(args):
7878
logger = logging.Logger("TEST SCHEMAS LOGGER")
79-
logger.setLevel(logging.INFO)
79+
logger.setLevel(logging.WARNING)
8080
logger.info('+++ Test JSON Schema files')
8181

8282
validator = schema_validator.ConformanceSchemaValidator()

schema/check_test_output.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ def main(args):
2424
else:
2525
test_output_path = args[1]
2626

27-
logging.debug('TEST OUTPUT PATH = %s', test_output_path)
2827

2928
logger = logging.Logger("Checking Test Data vs. Schemas LOGGER")
30-
logger.setLevel(logging.INFO)
29+
logger.setLevel(logging.WARNING)
30+
31+
logger.debug('TEST OUTPUT PATH = %s', test_output_path)
32+
3133
logger.info('+++ Test Generated test data vs. schemas files')
3234

3335
# TODO: get ICU versions
@@ -54,14 +56,14 @@ def main(args):
5456
test_type = schema_files.TEST_FILE_TO_TEST_TYPE_MAP[test_file_prefix]
5557
test_type_set.add(test_type)
5658
except BaseException as err:
57-
logging.debug('No file (%s) during schema check output: %s', file, err
59+
logger.debug('No file (%s) during schema check output: %s', file, err
5860
)
5961
for dir_nane in icu_dirs:
6062
icu_version_set.add(os.path.basename(dir_nane))
6163

6264
icu_versions = sorted(list(icu_version_set))
63-
logging.debug('ICU directories = %s', icu_versions)
64-
logging.debug('test types = %s', ALL_TEST_TYPES)
65+
logger.debug('ICU directories = %s', icu_versions)
66+
logger.debug('test types = %s', ALL_TEST_TYPES)
6567

6668
validator = schema_validator.ConformanceSchemaValidator()
6769
# Todo: use setters to initialize validator
@@ -74,7 +76,7 @@ def main(args):
7476
validator.debug = 1
7577

7678
all_results, test_validation_plans = validator.validate_test_output_with_schema()
77-
logging.info(' %d results for test output', len(all_results))
79+
logger.info(' %d results for test output', len(all_results))
7880

7981
# Check if any files in the expected list were not validated.
8082
test_paths = set()
@@ -83,7 +85,7 @@ def main(args):
8385

8486
for json_file in json_files:
8587
if json_file not in test_paths:
86-
logging.fatal('JSON file %s was not verified against a schema', json_file)
88+
logger.fatal('JSON file %s was not verified against a schema', json_file)
8789
# Bail out right away!
8890
sys.exit(1)
8991

@@ -109,7 +111,6 @@ def main(args):
109111
}
110112
except BaseException as error:
111113
logging.fatal('Cannot create summary_json %s', error)
112-
sys.exit(1)
113114

114115
# Create outputs from these results.
115116
try:
@@ -124,11 +125,11 @@ def main(args):
124125
file_out.write(summary_data)
125126
file_out.close()
126127
except BaseException as error:
127-
logging.fatal('Error: %s. Cannot save validation summary in file %s', error, output_filename)
128+
logger.fatal('Error: %s. Cannot save validation summary in file %s', error, output_filename)
128129
# Don't continue after this problem.
129130
sys.exit(1)
130131

131-
logging.info("All %d test output files match with schema", schema_count)
132+
logger.info("All %d test output files match with schema", schema_count)
132133
return
133134

134135

schema/schema_validator.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# ?? Move to the initialization
2121
ch = logging.StreamHandler()
22-
ch.setLevel(logging.INFO)
22+
ch.setLevel(logging.WARNING)
2323

2424

2525
# Given a directory, validate JSON files against expected schema
@@ -45,7 +45,6 @@ def __init__(self):
4545
self.test_types = schema_files.ALL_TEST_TYPES
4646
self.executors = []
4747
self.icu_versions = []
48-
self.debug_leve = 0
4948

5049
logging.config.fileConfig("../logging.conf")
5150

@@ -145,7 +144,6 @@ def validate_test_data_with_schema(self):
145144
schema_test_info.append(file_path_pair)
146145
else:
147146
test_data_files_not_found.append([icu_version, test_type])
148-
logging.debug('No data test file %s for %s, %s', file_path_pair, test_type, icu_version)
149147
pass
150148

151149
if test_data_files_not_found:
@@ -161,7 +159,8 @@ def validate_test_data_with_schema(self):
161159
logging.warning('FAIL: Test data %s, %s. MSG=%s',
162160
result_data['test_type'], result_data['icu_version'], result_data['err_info'])
163161
else:
164-
logging.debug('Test data validated: %s %s', result_data['test_type'], result_data['icu_version'])
162+
pass
163+
165164
all_results.append(result_data)
166165
return all_results
167166

@@ -217,7 +216,7 @@ def check_test_data_against_schema(self, schema_info):
217216

218217
def check_test_data_schema(self, icu_version, test_type):
219218
# Check the generated test data for structure against the schema
220-
logging.debug('Validating %s with %s', test_type, icu_version)
219+
logging.info('Validating %s with %s', test_type, icu_version)
221220

222221
# Check test output vs. the test data schema
223222
schema_verify_file = os.path.join(self.schema_base, test_type, 'test_schema.json')
@@ -247,7 +246,7 @@ def check_test_data_schema(self, icu_version, test_type):
247246

248247
results['result'] = result
249248
if result:
250-
logging.debug('Test data %s validated successfully, with ICU %s', test_type, icu_version)
249+
logging.info('Test data %s validated with ICU %s', test_type, icu_version)
251250
else:
252251
logging.error('Test data %s FAILED with ICU %s: %s', test_type, icu_version, err_info)
253252

@@ -278,7 +277,7 @@ def get_test_output_schema_plan(self, icu_version, test_type, executor):
278277

279278
def check_test_output_schema(self, icu_version, test_type, executor):
280279
# Check the output of the tests for structure against the schema
281-
logging.debug('Validating test output: %s %s %s', executor, test_type, icu_version)
280+
logging.info('Validating test output: %s %s %s', executor, test_type, icu_version)
282281

283282
# Check test output vs. the schema
284283
schema_file_name = SCHEMA_FILE_MAP[test_type]['result_data']['schema_file']
@@ -333,7 +332,6 @@ def validate_schema_file(self, schema_file_path):
333332
logging.fatal('%s for %s. Cannot get test_type value', err, schema_file_path, test_type)
334333
return [False, err, schema_file_path, test_type]
335334

336-
logging.info('Checking schema %s', schema_file_path)
337335
try:
338336
# With just a schema, it validates the schema.
339337
# However Validator.check_schema doesn't fail as expected.
@@ -449,7 +447,7 @@ def main(args):
449447
base_folders, test_types, result_folders = process_args(args)
450448

451449
logger = logging.Logger("TEST_GENERATE LOGGER")
452-
logger.setLevel(logging.INFO)
450+
logger.setLevel(logging.WARNING)
453451
logger.info('+++ Running JSON Schema tests')
454452

455453
schema_validator = ConformanceSchemaValidator()
@@ -461,20 +459,20 @@ def main(args):
461459
'icu76']
462460
schema_validator.executors = ['node', 'rust', 'dart_web', 'dart_native', 'icu4j']
463461

464-
logging.info('Checking test outputs')
462+
logger.info('Checking test outputs')
465463
all_test_out_results = schema_validator.validate_test_output_with_schema()
466464

467465
# Check all schema files for correctness.
468466
schema_errors = schema_validator.check_schema_files()
469467
if schema_errors:
470-
logging.error('INVALID SCHEMA: %s', schema_errors)
468+
logger.error('INVALID SCHEMA: %s', schema_errors)
471469
else:
472-
logging.info('All schemas are valid: %s', schema_errors)
470+
logger.info('All schemas are valid: %s', schema_errors)
473471

474-
logging.info('Checking generated data')
472+
logger.info('Checking generated data')
475473
all_test_data_results = schema_validator.validate_test_data_with_schema()
476474

477-
logging.info('Checking test outputs')
475+
logger.info('Checking test outputs')
478476
all_test_out_results = schema_validator.validate_test_output_with_schema()
479477

480478
return

testdriver/datasets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ def printCldrIcuMap():
502502
except KeyError:
503503
logging.debug(' %s not in map', name)
504504

505+
505506
def main(args):
506507

507508
logging.config.fileConfig("../logging.conf")

testdriver/ddtargs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ def __init__(self, args):
5353

5454
setCommonArgs(self.parser)
5555

56+
self.parser.add_argument('--log',
57+
default='WARNING',
58+
help='logging level')
59+
5660
self.parser.add_argument(
5761
'--start_test', default=0,
5862
help='number of tests to skip at start of the test data')
@@ -92,6 +96,10 @@ def __init__(self, args):
9296
help='Verify all available report files',
9397
default=None)
9498

99+
self.parser.add_argument('--log',
100+
default='WARNING',
101+
help='logging level')
102+
95103
self.parser.add_argument(
96104
'--summary_only', action='store_true',
97105
help='Flag to create summaries from current reports',

0 commit comments

Comments
 (0)