some bug fixes. Works.

This commit is contained in:
Alexey Lavrenuke (load testing) 2013-06-25 17:18:36 +04:00
parent 1e869411e5
commit c07fb1e17a
4 changed files with 21 additions and 17 deletions

View File

@ -147,7 +147,9 @@ class PhantomConfig:
if result.rps_schedule:
result.rps_schedule = u'multiple'
else:
result.rps_schedule = stream.stepper_wrapper.steps
# TODO: what do we actually expect here?
result.rps_schedule = ['%s %s' % (load, time)
for time, load in stream.stepper_wrapper.steps]
if result.loadscheme:
result.loadscheme = ''
@ -161,7 +163,8 @@ class PhantomConfig:
result.ammo_file += stream.stepper_wrapper.ammo_file + ' '
result.ammo_count += stream.stepper_wrapper.ammo_count
result.duration = max(result.duration, stream.stepper_wrapper.duration)
result.duration = max(
result.duration, stream.stepper_wrapper.duration)
result.instances += stream.instances
if not result.ammo_count:
@ -262,8 +265,8 @@ class StreamConfig:
kwargs['answ_log_level'] = self.answ_log_level
kwargs['comment_answ'] = "# " if self.answ_log_level == 'none' else ''
kwargs['stpd'] = self.stpd
kwargs['source_log_prefix'] = self.source_log_prefix
kwargs['method_options'] = self.method_options
kwargs['source_log_prefix'] = self.source_log_prefix
kwargs['method_options'] = self.method_options
if self.tank_type:
kwargs[
'proto'] = "proto=http_proto%s" % self.sequence_no if self.tank_type == 'http' else "proto=none_proto"
@ -533,7 +536,7 @@ class StepperWrapper:
loop_limit=self.loop_limit,
ammo_limit=None,
uris=self.uris,
headers=self.headers,
headers=[header.strip('[]') for header in self.headers],
autocases=self.autocases,
)
with open(self.stpd, 'w') as os:

View File

@ -11,4 +11,4 @@ class Stpd(object):
self.af = ammo_factory
def __iter__(self):
return ("%s %s %s\n%s\n" % (timestamp, len(missile), marker, missile) for timestamp, marker, missile in self.af)
return ("%s %s %s\n%s\n" % (len(missile), timestamp, marker, missile) for timestamp, marker, missile in self.af)

View File

@ -16,7 +16,7 @@ class Const(object):
def __iter__(self):
if self.rps == 0:
return iter([])
interval = 1000000 / self.rps
interval = 1000 / self.rps
return (i * interval for i in xrange(0, self.rps * self.duration))
def rps_at(self, t):
@ -35,7 +35,7 @@ class Const(object):
return self.duration * self.rps
def get_rps_list(self):
return [(self.duration, self.rps)]
return [(self.rps, int(self.duration))]
class Line(object):
@ -44,8 +44,8 @@ class Line(object):
self.minrps = float(minrps)
self.maxrps = float(maxrps)
self.duration = float(duration)
self.k = self.maxrps - self.minrps / self.duration
print minrps, maxrps, duration
self.k = (self.maxrps - self.minrps) / self.duration
#print minrps, maxrps, duration
self.b = 1 + 2 * self.minrps / self.k
def __iter__(self):
@ -63,7 +63,7 @@ class Line(object):
r0 is initial rps.
'''
def timestamp(n):
return int((math.sqrt(b ** 2 + 8 * n / k) - b) * 500000) # (sqrt(b^2 + 8 * n / k) - b) / 2 -- time in seconds
return int((math.sqrt(b ** 2 + 8 * n / k) - b) / 2 * 1000) # (sqrt(b^2 + 8 * n / k) - b) / 2 -- time in seconds
''' Find ammo count given the time '''
def number(t):
@ -87,9 +87,8 @@ class Line(object):
def get_rps_list(self):
int_rps = xrange(int(self.minrps), int(self.maxrps) + 1)
step_size = float(self.duration) / len(int_rps)
print int_rps, self.k, self.b
return [(step_size, rps) for rps in int_rps]
step_duration = float(self.duration) / len(int_rps)
return [(rps, int(step_duration)) for rps in int_rps]
class Composite(object):
@ -102,7 +101,7 @@ class Composite(object):
for step in self.steps:
for ts in step:
yield ts + base
base += step.get_duration() * 1000000
base += step.get_duration() * 1000
def get_duration(self):
'''Return total duration'''

View File

@ -15,7 +15,9 @@ class HttpAmmo(object):
self.loops = 0
def to_s(self):
return "%s %s %s\n%s" % (self.method, self.uri, self.proto, '\n'.join(self.headers))
if self.headers:
headers = '\r\n'.join(self.headers) + '\r\n'
return "%s %s %s\r\n%s\r\n" % (self.method, self.uri, self.proto, headers)
class SimpleGenerator(object):
@ -38,7 +40,7 @@ class UriStyleGenerator(SimpleGenerator):
self.ammo_number = 0
self.loop_limit = loop_limit
self.uri_count = len(uris)
self.missiles = cycle([(HttpAmmo(uri, headers, http_ver).to_s(), None) for uri in uris])
self.missiles = cycle([(HttpAmmo(uri, headers, http_ver=http_ver).to_s(), None) for uri in uris])
def __iter__(self):
for m in self.missiles: