Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 45 additions & 10 deletions tests/gold_tests/thread_config/check_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import sys


def count_threads(ts_path, etnet_threads, accept_threads):
def count_threads(ts_path, etnet_threads, accept_threads, task_threads, aio_threads):

for pid in psutil.pids():

Expand All @@ -33,6 +33,8 @@ def count_threads(ts_path, etnet_threads, accept_threads):

etnet_check = set()
accept_check = set()
task_check = set()
aio_check = set()

for t in p.threads():

Expand All @@ -48,7 +50,7 @@ def count_threads(ts_path, etnet_threads, accept_threads):
return 2
elif etnet_id in etnet_check:
sys.stderr.write('ET_NET thread with duplicate thread id created.\n')
return 4
return 3
else:
etnet_check.add(etnet_id)

Expand All @@ -57,18 +59,47 @@ def count_threads(ts_path, etnet_threads, accept_threads):
# Get the id of this thread and check if it's in range.
accept_id = int(thread_name.split(' ')[1].split(':')[0])
if accept_id >= accept_threads:
sys.stderr.write('Too many accept threads created.\n')
return 3
sys.stderr.write('Too many ACCEPT threads created.\n')
return 5
else:
accept_check.add(accept_id)

elif thread_name.startswith('[ET_TASK'):

# Get the id of this thread and check if it's in range.
task_id = int(thread_name.split(' ')[1][:-1])
if task_id >= task_threads:
sys.stderr.write('Too many ET_TASK threads created.\n')
return 7
elif task_id in task_check:
sys.stderr.write('ET_TASK thread with duplicate thread id created.\n')
return 8
else:
task_check.add(task_id)

elif thread_name.startswith('[ET_AIO'):

# Get the id of this thread and check if it's in range.
aio_id = int(thread_name.split(' ')[1].split(':')[0])
if aio_id >= aio_threads:
sys.stderr.write('Too many ET_AIO threads created.\n')
return 10
else:
aio_check.add(aio_id)

# Check the size of the sets, must be equal to the expected size.
if len(etnet_check) != etnet_threads:
sys.stderr.write('Expected ET_NET threads: {0}, found: {1}.\n'.format(etnet_threads, len(etnet_check)))
return 6
return 4
elif len(accept_check) != accept_threads:
sys.stderr.write('Expected accept threads: {0}, found: {1}.\n'.format(accept_threads, len(accept_check)))
return 5
sys.stderr.write('Expected ACCEPT threads: {0}, found: {1}.\n'.format(accept_threads, len(accept_check)))
return 6
elif len(task_check) != task_threads:
sys.stderr.write('Expected ET_TASK threads: {0}, found: {1}.\n'.format(task_threads, len(task_check)))
return 9
elif len(aio_check) != aio_threads:
sys.stderr.write('Expected ET_AIO threads: {0}, found: {1}.\n'.format(aio_threads, len(aio_check)))
return 11
else:
return 0

Expand All @@ -78,13 +109,17 @@ def count_threads(ts_path, etnet_threads, accept_threads):

def main():
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--ts-path', type=str, dest='ts_path', help='path to traffic_server binary', required=True)
parser.add_argument('-p', '--ts-path', type=str, dest='ts_path', help='path to traffic_server binary', required=True)
parser.add_argument('-e', '--etnet-threads', type=int, dest='etnet_threads',
help='expected number of ET_NET threads', required=True)
parser.add_argument('-a', '--accept-threads', type=int, dest='accept_threads',
help='expected number of accept threads', required=True)
help='expected number of ACCEPT threads', required=True)
parser.add_argument('-t', '--task-threads', type=int, dest='task_threads',
help='expected number of TASK threads', required=True)
parser.add_argument('-c', '--aio-threads', type=int, dest='aio_threads',
help='expected number of AIO threads', required=True)
args = parser.parse_args()
exit(count_threads(args.ts_path, args.etnet_threads, args.accept_threads))
exit(count_threads(args.ts_path, args.etnet_threads, args.accept_threads, args.task_threads, args.aio_threads))


if __name__ == '__main__':
Expand Down
9 changes: 0 additions & 9 deletions tests/gold_tests/thread_config/gold/http_200.gold

This file was deleted.

65 changes: 0 additions & 65 deletions tests/gold_tests/thread_config/thread_100_0.test.py

This file was deleted.

65 changes: 0 additions & 65 deletions tests/gold_tests/thread_config/thread_100_1.test.py

This file was deleted.

65 changes: 0 additions & 65 deletions tests/gold_tests/thread_config/thread_100_10.test.py

This file was deleted.

65 changes: 0 additions & 65 deletions tests/gold_tests/thread_config/thread_1_0.test.py

This file was deleted.

Loading