Skip to content

Commit ac3f603

Browse files
committed
Fixes and refactoring for integration tests
1 parent 3d1e0a6 commit ac3f603

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

examples/integration_test.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# Confluent schema-registry
5050
schema_registry_url = None
5151

52-
# Topic to use
52+
# Topic prefix to use
5353
topic = 'test'
5454

5555
# API version requests are only implemented in Kafka broker >=0.10
@@ -962,35 +962,37 @@ def verify_admin():
962962
if error is not None:
963963
raise error
964964

965+
966+
all_modes = ['consumer', 'producer', 'avro', 'performance', 'admin', 'none']
967+
"""All test modes"""
968+
969+
965970
def print_usage(exitcode, reason=None):
966971
""" Print usage and exit with exitcode """
967972
if reason is not None:
968973
print('Error: %s' % reason)
969-
print('Usage: %s <broker> [opts] [<topic>] [<schema_registry>]' % sys.argv[0])
974+
print('Usage: %s [options] <broker> [<topic>] [<schema_registry>]' % sys.argv[0])
970975
print('Options:')
971-
print(' --consumer, --producer, --avro, --performance - limit to matching tests')
976+
print(' %s - limit to matching tests' % ', '.join(['--' + x for x in all_modes]))
972977

973978
sys.exit(exitcode)
974979

975980

976-
def run():
977-
"""Run integration tests"""
981+
if __name__ == '__main__':
982+
"""Run test suites"""
983+
984+
if with_pympler:
985+
tr = tracker.SummaryTracker()
986+
print('Running with pympler memory tracker')
978987

979988
modes = list()
980989

981990
# Parse options
982991
while len(sys.argv) > 1 and sys.argv[1].startswith('--'):
983-
opt = sys.argv.pop(1)
984-
if opt == '--consumer':
985-
modes.append('consumer')
986-
elif opt == '--producer':
987-
modes.append('producer')
988-
elif opt == '--avro':
989-
modes.append('avro')
990-
elif opt == '--performance':
991-
modes.append('performance')
992-
else:
993-
print_usage(1, 'unknown option ' + opt)
992+
opt = sys.argv.pop(1)[2:]
993+
if opt not in all_modes:
994+
print_usage(1, 'unknown option --' + opt)
995+
modes.append(opt)
994996

995997
if len(sys.argv) > 1:
996998
bootstrap_servers = sys.argv[1]
@@ -1002,10 +1004,13 @@ def run():
10021004
print_usage(1)
10031005

10041006
if len(modes) == 0:
1005-
modes = ['consumer', 'producer', 'avro', 'performance']
1007+
modes = all_modes
10061008

10071009
print('Using confluent_kafka module version %s (0x%x)' % confluent_kafka.version())
10081010
print('Using librdkafka version %s (0x%x)' % confluent_kafka.libversion())
1011+
print('Testing: %s' % modes)
1012+
print('Brokers: %s' % bootstrap_servers)
1013+
print('Topic prefix: %s' % topic)
10091014

10101015
if 'producer' in modes:
10111016
print('=' * 30, 'Verifying Producer', '=' * 30)
@@ -1047,15 +1052,6 @@ def run():
10471052

10481053
print('=' * 30, 'Done', '=' * 30)
10491054

1050-
1051-
if __name__ == '__main__':
1052-
if with_pympler:
1053-
tr = tracker.SummaryTracker()
1054-
print('Running with pympler memory tracker')
1055-
1056-
# Run tests
1057-
run()
1058-
10591055
if with_pympler:
10601056
gc.collect()
10611057
print('Memory tracker results')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy