mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 10:25:17 +00:00
make some properties in status
This commit is contained in:
parent
d91aff809b
commit
b1ddf06f37
@ -69,6 +69,26 @@ class StepperStatus(object):
|
||||
self.log.debug('Published %s to %s', value, key)
|
||||
self.info[key] = value
|
||||
|
||||
@property
|
||||
def ammo_count(self):
|
||||
#return self._ammo_count
|
||||
return self.info['ammo_count']
|
||||
|
||||
@ammo_count.setter
|
||||
def ammo_count(self, value):
|
||||
#self._ammo_count = value
|
||||
self.info['ammo_count'] = value
|
||||
|
||||
@property
|
||||
def loop_count(self):
|
||||
#return self._loop_count
|
||||
return self.info['loop_count']
|
||||
|
||||
@loop_count.setter
|
||||
def loop_count(self, value):
|
||||
#self._loop_count = value
|
||||
self.info['loop_count'] = value
|
||||
|
||||
def get_info(self):
|
||||
for key in self.info:
|
||||
if self.info[key] is None:
|
||||
|
@ -1,5 +1,7 @@
|
||||
'''
|
||||
Missile object and generators
|
||||
|
||||
You should update STATUS.ammo_count and STATUS.loop_count in your custom generators!
|
||||
'''
|
||||
from itertools import cycle
|
||||
from module_exceptions import AmmoFileError
|
||||
@ -43,8 +45,8 @@ class SimpleGenerator(object):
|
||||
def __iter__(self):
|
||||
for m in self.missiles:
|
||||
self.loops += 1
|
||||
STATUS.publish('loop_count', self.loops)
|
||||
STATUS.publish('ammo_count', self.loops) # loops equals ammo count
|
||||
STATUS.loop_count = self.loops
|
||||
STATUS.ammo_count = self.loops # loops equals ammo count
|
||||
yield m
|
||||
|
||||
def loop_count(self):
|
||||
@ -71,7 +73,7 @@ class UriStyleGenerator(SimpleGenerator):
|
||||
def __iter__(self):
|
||||
for m in self.missiles:
|
||||
self.ammo_count += 1
|
||||
STATUS.publish('ammo_count', self.ammo_count)
|
||||
STATUS.ammo_count = self.ammo_count
|
||||
self.update_loop_count()
|
||||
if self.loop_limit and self.loop_count > self.loop_limit:
|
||||
raise StopIteration
|
||||
@ -81,7 +83,7 @@ class UriStyleGenerator(SimpleGenerator):
|
||||
def update_loop_count(self):
|
||||
loop_count = self.ammo_count / self.uri_count
|
||||
if self.loop_count != loop_count:
|
||||
STATUS.publish('loop_count', loop_count)
|
||||
STATUS.loop_count = loop_count
|
||||
self.loop_count = loop_count
|
||||
|
||||
|
||||
@ -109,7 +111,7 @@ class AmmoFileReader(SimpleGenerator):
|
||||
raise AmmoFileError(
|
||||
"Unexpected end of file: read %s bytes instead of %s" % (len(missile), chunk_size))
|
||||
ammo_count += 1
|
||||
STATUS.publish('ammo_count', ammo_count)
|
||||
STATUS.ammo_count = ammo_count
|
||||
yield (missile, marker)
|
||||
except (IndexError, ValueError):
|
||||
raise AmmoFileError(
|
||||
@ -117,6 +119,6 @@ class AmmoFileReader(SimpleGenerator):
|
||||
chunk_header = ammo_file.readline()
|
||||
if not chunk_header and (self.loops < self.loop_limit or self.loop_limit == 0):
|
||||
self.loops += 1
|
||||
STATUS.publish('loop_count', self.loops)
|
||||
STATUS.loop_count = self.loops
|
||||
ammo_file.seek(0)
|
||||
chunk_header = ammo_file.readline()
|
||||
|
Loading…
Reference in New Issue
Block a user