Skip to content

Commit

Permalink
Tests, packaging.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkocikowski committed Oct 1, 2013
1 parent de1a52b commit 6f9150f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.txt
3 changes: 2 additions & 1 deletion esbench/client.py
Expand Up @@ -8,6 +8,7 @@
import logging
import contextlib
import sys
import os.path

import esbench.api
import esbench.analyze
Expand Down Expand Up @@ -48,7 +49,7 @@ def args_parser():
parser_run.add_argument('--repetitions', metavar='N', type=int, default=1000, help='run each query n times per observation; (%(default)i)')
# parser_run.add_argument('--refresh', type=str, metavar='T', default='1s', help="'refresh_interval' for the index, '-1' for none; (%(default)s)")
parser_run.add_argument('--no-optimize-calls', action='store_true', help="if set, do not optimize before observations")
parser_run.add_argument('--config-file-path', metavar='', type=str, default='./config.json', help="path to json config file; (%(default)s)")
parser_run.add_argument('--config-file-path', metavar='', type=str, default='%s/config.json' % (os.path.dirname(os.path.abspath(__file__)), ), help="path to json config file; (%(default)s)")
parser_run.add_argument('--append', action='store_true', help="if set, append data to the index; (%(default)s)")
parser_run.add_argument('--data', metavar='PATH', type=str, action='store', default=None, help="read data from PATH; set to /dev/stdin to read from stdin. Set this only if you want to provide your own data, by default US Patent Application data will be used; (%(default)s)")
parser_run.add_argument('n', nargs="?", type=int, default=100, help='number of documents; (%(default)i)')
Expand Down
16 changes: 15 additions & 1 deletion esbench/test/test_client.py
Expand Up @@ -9,13 +9,27 @@

import esbench.client


class ClientTest(unittest.TestCase):

def test_args(self):
parser = esbench.client.args_parser()
self.assertRaises(SystemExit, parser.parse_args, "".split())
args = parser.parse_args("run".split())
self.assertEqual(args.__dict__, {'no_optimize_calls': False, 'verbose': False, 'segments': None, 'repetitions': 1000, 'n': 100, 'command': 'run', 'observations': 10, 'data': None, 'append': False, 'config_file_path': './config.json'})
self.assertEqual(args.__dict__,
{
'no_optimize_calls': False,
'verbose': False,
'segments': None,
'repetitions': 1000,
'n': 100,
'command': 'run',
'observations': 10,
'data': None,
'append': False,
'config_file_path': os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../", "config.json")),
}
)



Expand Down
8 changes: 5 additions & 3 deletions esbench/test/units.py
Expand Up @@ -8,11 +8,14 @@
import unittest


def suite():
# return unittest.defaultTestLoader.discover(os.path.dirname(__file__), top_level_dir=os.path.abspath("../../"))
return unittest.defaultTestLoader.discover(os.path.dirname(__file__))

if __name__ == "__main__":

suite = unittest.defaultTestLoader.discover(os.path.dirname(__file__), top_level_dir=os.path.abspath("../../"))
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)
result = runner.run(suite())

# doing sys.exit(1) on test failure will signal test failure to other
# processes (this is for when the suite is run automatically, not by hand
Expand All @@ -21,4 +24,3 @@
if not result.wasSuccessful():
sys.exit(1)


13 changes: 9 additions & 4 deletions setup.py
Expand Up @@ -6,6 +6,9 @@
# python setup.py -r http://testpypi.python.org/pypi register
# python setup.py sdist upload -r http://pypi.python.org/pypi

# import ez_setup
# ez_setup.use_setuptools()
#
from setuptools import setup

ld = """Scripts for benchmarking Elasticsearch nodes.
Expand All @@ -18,10 +21,12 @@
author_email = 'mkocikowski@gmail.com',
url = 'https://github.com/mkocikowski/esbench',
description = 'Elasticsearch benchmarking tool',
long_description=ld,
long_description = ld,
packages = ['esbench', 'esbench.test'],
package_data={'': ['README.md',],},
data_files=[('./', './esbench/config.json')],
package_data = {
'': ['README.md'],
'esbench': ['config.json'],
},
entry_points = {
'console_scripts': [
'esbench = esbench.client:main',
Expand All @@ -39,5 +44,5 @@
"Topic :: Utilities",
],
license = 'MIT',
# test_suite = "elsec.test.units.suite",
test_suite = "esbench.test.units.suite",
)

0 comments on commit 6f9150f

Please sign in to comment.