def test_scoreboard_exclude_exe(): """cli.darshan_scoreboard --exclude-exe """ # get a reference dataset without anything removed argv = ['--json', INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) reference_result = json.loads(output_str) print("Result: %s" % reference_result) for appname in INDEXDB_EXES + [','.join(INDEXDB_EXES)]: argv = ['--json', '--exclude-exe', appname, INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print("Result: %s" % decoded_result) # make sure we got SOME results assert len(decoded_result['per_exe']) # make sure the app is not included in the results assert appname not in [x[3] for x in decoded_result['per_exe']] # make sure that we successfully removed something that was present in # the unfiltered reference assert len(decoded_result['per_exe']) < len( reference_result['per_exe'])
def test_scoreboard_combo(): """cli.darshan_scoreboard with multiple excludes/limits Tests the combinatorial logic when specifying multiple things to include (OR) and things to exclude (AND). """ argv = ['--json', INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print("Result: %s" % json.dumps(decoded_result)) for user_exe_fs in decoded_result['per_user_exe_fs']: username, exename, mountpt = user_exe_fs[3].split('|') # jobcount = user_exe_fs[-1] argv = ['--json', INDEXDB] argv += ['--limit-user', username] argv += ['--limit-exe', exename] argv += ['--limit-fs', mountpt] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) subresult = json.loads(output_str) for category in ['per_user', 'per_exe', 'per_fs', 'per_user_exe_fs']: assert len(subresult[category]) == 1
def limit_fs(indexdb_mounts): """cli.darshan_scoreboard --limit-fs """ # include ALL file systems - expect everything to return argv = ['--json', '--limit-fs', ",".join(indexdb_mounts), INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print("Result: %s" % decoded_result) assert decoded_result['per_user'] assert decoded_result['per_fs'] assert decoded_result['per_exe'] # include only one file system - expect a subset of above results wanted_fs = indexdb_mounts[0] argv = ['--json', '--limit-fs', wanted_fs, INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result2 = json.loads(output_str) print("Result: %s" % decoded_result2) # make sure we got something back assert len(decoded_result2['per_fs']) # make sure that we got back one and only one file system assert len(decoded_result2['per_fs']) == 1 # make sure that each app we wanted is defined in the results all_fs = [x[3] for x in decoded_result2['per_fs'] ] + [x[4] for x in decoded_result2['per_fs']] assert wanted_fs in all_fs
def exclude_fs(indexdb_mounts): """cli.darshan_scoreboard --exclude-fs """ argv = ['--json', '--exclude-fs', ",".join(indexdb_mounts), INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print(decoded_result) assert not decoded_result['per_user'] assert not decoded_result['per_exe'] assert not decoded_result['per_fs'] # now test excluding just one file system excluded_fs = indexdb_mounts[0] argv = ['--json', '--exclude-fs', "%s" % excluded_fs, INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result2 = json.loads(output_str) print(decoded_result2) # make sure we got something back assert len(decoded_result2['per_fs']) # make sure that results don't include the thing we excluded all_fs = [x[3] for x in decoded_result2['per_fs'] ] + [x[4] for x in decoded_result2['per_fs']] assert excluded_fs not in all_fs
def test_scoreboard_exclude_exe(): """bin/darshan_scoreboard.py --exclude-exe """ argv = ['--output', tokiotest.TEMP_FILE.name] + LOGS_FROM_DIR print "Executing:", " ".join(argv) tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) # get a reference dataset without anything removed argv = ['--json', tokiotest.TEMP_FILE.name] print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.darshan_scoreboard, argv) reference_result = json.loads(output_str) print "Result:", reference_result for appname in FILTER_FOR_EXE + [','.join(FILTER_FOR_EXE)]: argv = ['--json', '--exclude-exe', appname, tokiotest.TEMP_FILE.name] print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print "Result:", decoded_result # make sure the app is not included in the results assert appname not in decoded_result['per_exe'] # make sure that we successfully removed something that was present in # the unfiltered reference assert len(decoded_result['per_exe']) < len( reference_result['per_exe'])
def test_input_file(): """cli.index_darshanlogs with one input log """ tokiotest.check_darshan() argv = ['--output', tokiotest.TEMP_FILE.name] + [SAMPLE_DARSHAN_LOGS[0]] print("Executing: %s" % " ".join(argv)) tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) verify_index_db(tokiotest.TEMP_FILE.name) assert get_table_len(tokio.cli.index_darshanlogs.HEADERS_TABLE, output_file=tokiotest.TEMP_FILE.name) == 1
def test_multithreaded(): """cli.index_darshanlogs --threads """ raise nose.SkipTest("threading causes deadlocks") tokiotest.check_darshan() argv = ['--threads', '4', '--output', tokiotest.TEMP_FILE.name ] + SAMPLE_DARSHAN_LOGS print("Executing: %s" % " ".join(argv)) tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) verify_index_db(tokiotest.TEMP_FILE.name)
def test_max_mb(): """cli.index_darshanlogs, lite parser """ tokiotest.check_darshan() argv = [ '--max-mb', str(1.0 / 1024.0), '--output', tokiotest.TEMP_FILE.name ] + SAMPLE_DARSHAN_LOGS print("Executing: %s" % " ".join(argv)) tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) verify_index_db(tokiotest.TEMP_FILE.name)
def test_input_dir(): """cli.index_darshanlogs with input dir """ tokiotest.check_darshan() argv = ['--quiet', '--output', tokiotest.TEMP_FILE.name ] + [os.path.dirname(SAMPLE_DARSHAN_LOGS[0])] print("Executing: %s" % " ".join(argv)) tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) verify_index_db(tokiotest.TEMP_FILE.name) assert get_table_len(tokio.cli.index_darshanlogs.HEADERS_TABLE, output_file=tokiotest.TEMP_FILE.name) > 1
def all_headers_half_summaries(): """Test database with half of the summaries rows missing """ print("Test database with all headers, only half summaries") cursor.execute("DELETE FROM summaries WHERE log_id % 2 = 0") conn.commit() # sqlite3.IntegrityError tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) for table in TABLES: num_rows = get_table_len(table=table, conn=conn, cursor=cursor) assert num_rows == orig_num_rows[table]
def test_scoreboard(): """bin/darshan_scoreboard.py ascii output """ argv = ['--output', tokiotest.TEMP_FILE.name] + LOGS_FROM_DIR print "Executing:", " ".join(argv) tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) argv = [tokiotest.TEMP_FILE.name] print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.darshan_scoreboard, argv) assert len(output_str.splitlines()) > 5
def test_scoreboard_json(): """bin/darshan_scoreboard.py --json """ argv = ['--output', tokiotest.TEMP_FILE.name] + LOGS_FROM_DIR print "Executing:", " ".join(argv) tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) argv = ['--json', tokiotest.TEMP_FILE.name] print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print "Result:", decoded_result assert len(decoded_result) > 0
def test_update(): """cli.index_darshanlogs with an existing database """ tokiotest.check_darshan() # create a database with a couple of entries argv = ['--quiet', '--output', tokiotest.TEMP_FILE.name ] + [os.path.dirname(SAMPLE_DARSHAN_LOGS[0])] print("Executing: %s" % " ".join(argv)) tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) # hack on database conn = sqlite3.connect(tokiotest.TEMP_FILE.name) cursor = conn.cursor() print("Initial database:") orig_num_rows = {} for table in TABLES: orig_num_rows[table] = get_table_len(table=table, conn=conn, cursor=cursor) print("Test database with all headers, all summaries") tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) for table in TABLES: num_rows = get_table_len(table=table, conn=conn, cursor=cursor) assert num_rows == orig_num_rows[table] @nose.tools.raises(sqlite3.IntegrityError) def all_headers_half_summaries(): """Test database with half of the summaries rows missing """ print("Test database with all headers, only half summaries") cursor.execute("DELETE FROM summaries WHERE log_id % 2 = 0") conn.commit() # sqlite3.IntegrityError tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) for table in TABLES: num_rows = get_table_len(table=table, conn=conn, cursor=cursor) assert num_rows == orig_num_rows[table] all_headers_half_summaries() print("Test consistent and half-populated database") cursor.execute("DELETE FROM headers WHERE log_id % 2 = 0") conn.commit() tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) for table in TABLES: num_rows = get_table_len(table=table, conn=conn, cursor=cursor) assert num_rows == orig_num_rows[table] print("Test unpopulated database") cursor.execute("DELETE FROM headers") cursor.execute("DELETE FROM summaries") conn.commit() tokiotest.run_bin(tokio.cli.index_darshanlogs, argv) for table in TABLES: num_rows = get_table_len(table=table, conn=conn, cursor=cursor) assert num_rows == orig_num_rows[table]
def test_scoreboard_limit_user(): """bin/darshan_scoreboard.py --limit-user """ argv = ['--output', tokiotest.TEMP_FILE.name] + LOGS_FROM_DIR print "Executing:", " ".join(argv) tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) argv = [ '--json', '--limit-user', tokiotest.SAMPLE_DARSHAN_LOG_USER, tokiotest.TEMP_FILE.name ] print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print "Result:", decoded_result assert decoded_result['per_user']
def test_scoreboard(): """cli.darshan_scoreboard ascii output """ argv = [INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) assert len(output_str.splitlines()) > 5
def test_summary(): """ cli.compare_isdct --summary human-readable output """ argv = [ "--summary", tokiotest.SAMPLE_NERSCISDCT_PREV_FILE, tokiotest.SAMPLE_NERSCISDCT_DIFF_FILE ] output_str = tokiotest.run_bin(tokio.cli.compare_isdct, argv) ### look for a section on devices removed if tokiotest.SAMPLE_NERSCISDCT_DIFF_RM > 0: func = validate_summary_section func.description = "cli.compare_isdct --summary device removal" yield func, output_str, 'devices removed', verify_nid_line ### look for a section on devices added if tokiotest.SAMPLE_NERSCISDCT_DIFF_ADD > 0: func = validate_summary_section func.description = "cli.compare_isdct --summary device installation" yield func, output_str, 'devices installed', verify_nid_line ### look for a section on errors detected if tokiotest.SAMPLE_NERSCISDCT_DIFF_ERRS > 0: func = validate_summary_section func.description = "cli.compare_isdct --summary error detection" yield func, output_str, 'errors detected', verify_errors_line ### look for a section with the workload statistics func = validate_summary_section func.description = "cli.compare_isdct --summary workload statistics" yield func, output_str, 'workload statistics', verify_workload_line
def test_good_log(): """cli.darshan_bad_ost: detect no false positives in a good Darshan log """ tokiotest.check_darshan() argv = ['--json', "-p", MODEST_PVALUE_CUTOFF, SAMPLE_GOOD_DARSHAN_LOG] output_str = tokiotest.run_bin(tokio.cli.darshan_bad_ost, argv) decoded_result = json.loads(output_str) assert len(decoded_result) == 0
def test_get_biggest_api(): """ summarize_job.get_biggest_api() functionality """ tokiotest.check_darshan() argv = ['--json', tokiotest.SAMPLE_DARSHAN_LOG] output_str = tokiotest.run_bin(tokiobin.summarize_job, argv) assert verify_output_json(output_str, key='darshan_biggest_read_api')
def test_single_file_log(): """cli.darshan_bad_ost: handle log with insufficient data for correlation """ tokiotest.check_darshan() argv = ['--json', SAMPLE_1FILE_DARSHAN_LOG] output_str = tokiotest.run_bin(tokio.cli.darshan_bad_ost, argv) decoded_result = json.loads(output_str) assert len(decoded_result) == 0
def test_scoreboard_exclude_user(): """cli.darshan_scoreboard --exclude-user """ argv = ['--json', '--exclude-user', "%s" % INDEXDB_USER, INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print("Result: %s" % decoded_result) assert INDEXDB_USER not in [x[3] for x in decoded_result['per_user']]
def test_multithreaded(): """bin/summarize_darshanlogs.py --threads """ tokiotest.check_darshan() argv = ['--threads', '4'] + SAMPLE_DARSHAN_LOGS print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) decoded_result = json.loads(output_str) assert len(decoded_result) > 0
def test_get_biggest_api(): """ cli.summarize_job.get_biggest_api() functionality """ tokiotest.check_darshan() argv = ['--json', tokiotest.SAMPLE_DARSHAN_LOG] print("Executing: %s" % ' '.join(argv)) output_str = tokiotest.run_bin(tokio.cli.summarize_job, argv) assert verify_output_json(output_str, key='darshan_biggest_read_api')
def test_input_files(): """bin/summarize_darshanlogs.py with multiple input logs """ tokiotest.check_darshan() argv = SAMPLE_DARSHAN_LOGS print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) decoded_result = json.loads(output_str) assert len(decoded_result) > 0
def test_scoreboard_exclude_fs(): """bin/darshan_scoreboard.py --exclude-fs """ argv = ['--output', tokiotest.TEMP_FILE.name] + LOGS_FROM_DIR print "Executing:", " ".join(argv) tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) argv = [ '--json', '--exclude-fs', "%s" % tokiotest.SAMPLE_DARSHAN_ALL_MOUNTS, tokiotest.TEMP_FILE.name ] print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print decoded_result assert not decoded_result['per_user'] assert not decoded_result['per_exe'] assert not decoded_result['per_fs']
def test_scoreboard_json(): """cli.darshan_scoreboard --json """ argv = ['--json', INDEXDB] print("Executing: %s" % " ".join(argv)) output_str = tokiotest.run_bin(tokio.cli.darshan_scoreboard, argv) decoded_result = json.loads(output_str) print("Result: %s" % decoded_result) assert len(decoded_result) > 0
def wrap_function(test_input): """Allow named args to pass through nosetests """ print("Running: %s" % test_input['descr']) argv = [] if test_input['params']['datetime_start'] is not None: argv += [ '--start', test_input['params']['datetime_start'].strftime("%Y-%m-%d") ] if test_input['params']['datetime_end'] is not None: argv += [ '--end', test_input['params']['datetime_end'].strftime("%Y-%m-%d") ] if test_input['params']['username'] is not None: argv += ['--username', test_input['params']['username']] if test_input['params']['jobid'] is not None: argv += ['--jobid', str(test_input['params']['jobid'])] if 'which' in test_input['params']: tokiotest.check_darshan() argv += ['--load', test_input['params']['which']] if 'system' in test_input['params']: argv += ['--host', test_input['params']['system']] print("Test args: %s" % argv) expected_exception = test_input.get('expect_exception') if expected_exception: # assert_raises doesn't seem to work correctly here # nose.tools.assert_raises(expected_exception, # tokiotest.run_bin(tokio.cli.find_darshanlogs, argv)) caught = False try: output_str = tokiotest.run_bin(tokio.cli.find_darshanlogs, argv) except expected_exception: caught = True assert caught else: output_str = tokiotest.run_bin(tokio.cli.find_darshanlogs, argv) results = output_str.splitlines() assert (test_input['pass_criteria'])(results)
def test_all_json_w_zeros(): """ cli.compare_isdct --all --report-zeros json output """ argv = [ "--all", "--report-zeros", tokiotest.SAMPLE_NERSCISDCT_PREV_FILE, tokiotest.SAMPLE_NERSCISDCT_DIFF_FILE ] output_str = tokiotest.run_bin(tokio.cli.compare_isdct, argv) result = json.loads(output_str) test_connectors_nersc_isdct.validate_diff(result, report_zeros=True)
def test_input_dir(): """bin/summarize_darshanlogs.py with input dir """ # Need lots of error/warning suppression since our input dir contains a ton of non-Darshan logs warnings.filterwarnings('ignore') tokiotest.check_darshan() argv = [os.path.dirname(SAMPLE_DARSHAN_LOGS[0])] print "Executing:", " ".join(argv) output_str = tokiotest.run_bin(tokiobin.summarize_darshanlogs, argv) decoded_result = json.loads(output_str) assert len(decoded_result) > 0
def run_connector(binary, argv): """Default cache_connector run function Args: binary (module): tokiobin module that contains a main() function argv (list of str): list of CLI arguments to pass to connector Returns: Stdout of cache connector script as a string """ return tokiotest.run_bin(binary, argv)
def test_multi_file_log(): """cli.darshan_bad_ost: correctly handle multiple input logs """ tokiotest.check_darshan() argv = [ '--json', '-c', MODEST_CORRELATION_CUTOFF, SAMPLE_BAD_DARSHAN_LOG, SAMPLE_GOOD_DARSHAN_LOG ] output_str = tokiotest.run_bin(tokio.cli.darshan_bad_ost, argv) decoded_result = json.loads(output_str) assert len(decoded_result) == 0