Skip to content

Commit

Permalink
Extended test coverage to include CSV client stats
Browse files Browse the repository at this point in the history
  • Loading branch information
filipecosta90 committed Dec 22, 2023
1 parent d36622a commit c1d08b5
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 6 deletions.
28 changes: 28 additions & 0 deletions tests/include.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,31 @@ def agg_keyspace_range(master_nodes_connections):
shard_count = int(shard_reply['db0']['keys'])
overall_keyspace_range = overall_keyspace_range + shard_count
return overall_keyspace_range


def get_column_csv(filename,column_name):
found = False
with open(filename,"r") as fd:
stop_line = 0
lines = fd.readlines()
for line in lines:
# CSV is the first part of file
if "Full-Test GET Latency" in line or len(line) == 0:
break
stop_line = stop_line + 1
print(stop_line)
csv_lines = lines[1:stop_line-1]
header_line = csv_lines[0].strip().split(",")
col_pos = -1
for col_index,col in enumerate(header_line):
if column_name == col:
col_pos = col_index
found = True
data_lines = []
for line in csv_lines[1:]:
data_lines.append(line.strip().split(","))
column_data = []
if found is True:
for line in data_lines:
column_data.append(line[col_pos])
return found, column_data
47 changes: 41 additions & 6 deletions tests/tests_oss_simple_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,17 @@ def test_default_set(env):
for master_connection in master_nodes_connections:
master_connection.execute_command("CONFIG", "RESETSTAT")

benchmark_specs = {"name": env.testName, "args": ['--pipeline=10','--ratio=1:0','--key-pattern=R:R','--key-minimum={}'.format(key_min),'--key-maximum={}'.format(key_max)]}
benchmark_specs = {"name": env.testName, "args": ['--client-stats',f'{test_dir}/set_client_stats','--pipeline=10','--ratio=1:0','--key-pattern=R:R','--key-minimum={}'.format(key_min),'--key-maximum={}'.format(key_max)]}
addTLSArgs(benchmark_specs, env)
config = get_default_memtier_config(threads=2, clients=10, requests=200000)
master_nodes_list = env.getMasterNodesList()
overall_expected_request_count = get_expected_request_count(config,key_min, key_max)

add_required_env_arguments(benchmark_specs, config, env, master_nodes_list)

# Create a temporary directory
test_dir = tempfile.mkdtemp()

config = RunConfig(test_dir, env.testName, config, {})
ensure_clean_benchmark_folder(config.results_dir)
results_dir = config.results_dir
ensure_clean_benchmark_folder(results_dir)

benchmark = Benchmark.from_json(config, benchmark_specs)

Expand All @@ -129,8 +127,45 @@ def test_default_set(env):
assert_minimum_memtier_outcomes(config, env, memtier_ok, overall_expected_request_count,
overall_request_count)

# Assert that all CSV BW metrics are properly stored and calculated
first_client_csv_stats = '{0}/set_client_stats-1-0-0.csv'.format(test_dir)
found, set_tx_column_data = get_column_csv(first_client_csv_stats,"SET Total Bytes TX")
env.assertTrue(found)
found, set_rx_column_data = get_column_csv(first_client_csv_stats,"SET Total Bytes RX")
env.assertTrue(found)
found, set_tx_rx_column_data = get_column_csv(first_client_csv_stats,"SET Total Bytes")
env.assertTrue(found)
found, set_reqs_column_data = get_column_csv(first_client_csv_stats,"SET Requests")
env.assertTrue(found)
for col_pos, ops_sec in enumerate(set_reqs_column_data):
if int(ops_sec) > 0:
set_tx = int(set_tx_column_data[col_pos])
set_rx = int(set_rx_column_data[col_pos])
set_tx_rx = int(set_tx_rx_column_data[col_pos])
env.assertTrue(set_tx > 0)
env.assertTrue(set_rx > 0)
env.assertTrue(set_tx_rx > 0)
env.assertAlmostEqual(set_tx_rx,set_tx+set_rx,1)

# the GET bw should be 0
found, get_tx_column_data = get_column_csv(first_client_csv_stats,"GET Total Bytes TX")
env.assertTrue(found)
found, get_rx_column_data = get_column_csv(first_client_csv_stats,"GET Total Bytes RX")
env.assertTrue(found)
found, get_tx_rx_column_data = get_column_csv(first_client_csv_stats,"GET Total Bytes")
env.assertTrue(found)
for col_pos, ops_sec in enumerate(set_reqs_column_data):
if int(ops_sec) > 0:
get_tx = int(get_tx_column_data[col_pos])
get_rx = int(get_rx_column_data[col_pos])
get_tx_rx = int(get_tx_rx_column_data[col_pos])
env.assertTrue(get_tx == 0)
env.assertTrue(get_rx == 0)
env.assertTrue(get_tx_rx == 0)
env.assertAlmostEqual(set_tx_rx,set_tx+set_rx,1)

## Assert that all JSON BW metrics are properly stored and calculated
json_filename = '{0}/mb.json'.format(config.results_dir)
## Assert that all BW metrics are properly stored and calculated
with open(json_filename) as results_json:
results_dict = json.load(results_json)
set_metrics = results_dict['ALL STATS']['Sets']
Expand Down

0 comments on commit c1d08b5

Please sign in to comment.