Skip to content

Commit

Permalink
args in eval
Browse files Browse the repository at this point in the history
  • Loading branch information
andgineer committed Apr 23, 2019
1 parent 8224284 commit e0867c8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bombard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.14.1'
__version__ = '1.15.1'


def version():
Expand Down
2 changes: 1 addition & 1 deletion bombard/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
INIT_EXAMPLE = 'easy.yaml'
REPEAT = 10
THRESHOLD = 1000
TIMEOUT = 10
TIMEOUT = 15


def get_args():
Expand Down
10 changes: 7 additions & 3 deletions bombard/bombardier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


def apply_supply(s: str, supply: dict) -> str:
#todo: add args
if not isinstance(s, str):
return s
try:
Expand Down Expand Up @@ -50,11 +51,13 @@ class Bombardier(WeaverMill):
def __init__(self, supply: dict=None, args=None, campaign_book: dict=None, ok_statuses=None,
overload_statuses=None):
self.supply = supply if supply is not None else {}
self.supply['args'] = args
self.args = args
self.campaign = campaign_book
self.ok = ok_statuses if ok_statuses is not None else DEFAULT_OK
self.overload = overload_statuses if overload_statuses is not None else DEFAULT_OVERLOAD
self.request_fired = False # from any request reload() was called
self.resp_count = 0

self.show_request = {
1: 'Sent 1st request..'
Expand Down Expand Up @@ -194,9 +197,10 @@ def worker(self, thread_id, ammo):

self.process_resp(ammo, status, resp, time_ns() - start_ns, len(resp))

self.resp_count += 1
if self.args.quiet:
if ammo_id in self.show_response:
print(f'{self.show_response[ammo_id].format(id=ammo_id):>15}\r', end='')
if self.resp_count in self.show_response:
print(f'{self.show_response[self.resp_count].format(id=self.resp_count):>15}\r', end='')
log.info(self.status_coloured(status) + f' ({pretty_sz(len(resp))}) ' + pretty_url
+ ' ' + (red(resp) if status == EXCEPTION_STATUS else '')
)
Expand All @@ -214,7 +218,7 @@ def reload(self, requests, repeat=None, prepare=False, **kwargs):
If supply specified it'll be used in addition to self.supply.
Arg `prepare` indicate call from main, not from request script.
So we know if any scripts call reload (self.script_fired)
So we know if any scripts call reload (self.request_fired)
"""
if not prepare:
self.request_fired = True
Expand Down
1 change: 1 addition & 0 deletions bombard/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def parenthesized(self, seq: Sequence):
return '(' + str(len(seq)) + ')' if seq else ''

def report(self):
#todo: show separately fail/success for each request type
by_name = []
for name, stat in self.stat_by_name.items():
by_name.append(f'### {name} {self.parenthesized(stat)}\n' + self.report_dimension(stat))
Expand Down
7 changes: 5 additions & 2 deletions docs/campaign.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ All sections are optional.
But you need section ``prepare`` or ``ammo`` so Bombard will
fire some requests.

Anywhere you can user Python substitution ``{}`` like
Anywhere you can user Python expressions ``{}`` like

.. code-block:: python
repeat: {iters * 2}
repeat: "{args.repeat * 2}"
Command line arguments available as ``args`` in this expressions.
All supply variables - as globals.

HTTP parameters
---------------
Expand Down

0 comments on commit e0867c8

Please sign in to comment.