Skip to content

Commit

Permalink
Merge pull request #520 from fomars/develop
Browse files Browse the repository at this point in the history
 send yaml to lunapark
  • Loading branch information
fomars committed Mar 2, 2018
2 parents cb128f9 + c6f2125 commit c97b139
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 81 deletions.
11 changes: 11 additions & 0 deletions docs/example_cfgs/tutorial_load1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
phantom:
address: 203.0.113.1:80 # [Target's address]:[target's port]
uris:
- /
load_profile:
load_type: rps # schedule load by defining requests per second
schedule: line(1, 10, 10m) # starting from 1rps growing linearly to 10rps during 10 minutes
console:
enabled: true # enable console output
telegraf:
enabled: false # let's disable telegraf monitoring for the first time
109 changes: 39 additions & 70 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,48 @@ Create a file on a server with Yandex.Tank: **load.yaml**
.. code-block:: yaml
phantom:
address: 203.0.113.1:80 # [Target's address]:[target's port]
load_profile:
load_type: rps # schedule load by defining requests per second
schedule: line(1, 10, 10m) # starting from 1rps growing linearly to 10rps during 10 minutes
address: 203.0.113.1:80 # [Target's address]:[target's port]
uris:
- /
load_profile:
load_type: rps # schedule load by defining requests per second
schedule: line(1, 10, 10m) # starting from 1rps growing linearly to 10rps during 10 minutes
console:
enabled: true # enable console output
telegraf:
enabled: false # let's disable telegraf monitoring for this time
enabled: false # let's disable telegraf monitoring for the first time
``phantom`` have 3 primitives for describing load scheme:
And run:
``$ yandex-tank -c load.yaml``

------------

1. ``step (a,b,step,dur)`` makes stepped load, where a,b are start/end load
values, step - increment value, dur - step duration.
``phantom`` have 3 primitives for describing load scheme:

Example:
``step(25, 5, 5, 60)`` - stepped load from 25 to 5 rps, with 5 rps steps,
step duration 60s. ``step(5, 25, 5, 60)`` - stepped load from 5 to 25 rps,
with 5 rps steps, step duration 60s
1. ``step (a,b,step,dur)`` makes stepped load, where a,b are start/end load values, step - increment value, dur - step duration.

------------
Examples:
* ``step(25, 5, 5, 60)`` - stepped load from 25 to 5 rps, with 5 rps steps, step duration 60s.
* ``step(5, 25, 5, 60)`` - stepped load from 5 to 25 rps, with 5 rps steps, step duration 60s

2. ``line (a,b,dur)`` makes linear load, where ``a,b`` are start/end load, ``dur``
- the time for linear load increase from a to b.
2. ``line (a,b,dur)`` makes linear load, where ``a,b`` are start/end load, ``dur`` - the time for linear load increase from a to b.

Example:
``line(10, 1, 10m)`` - linear load from 10 to 1 rps, duration - 10
minutes ``line(1, 10, 10m)`` - linear load from 1 to 10 rps, duration
- 10 minutes
Examples:
* ``line(10, 1, 10m)`` - linear load from 10 to 1 rps, duration - 10 minutes
* ``line(1, 10, 10m)`` - linear load from 1 to 10 rps, duration - 10 minutes

------------
3. ``const (load,dur)`` makes constant load. ``load`` - rps amount, ``dur`` - load duration.

3. ``const (load,dur)`` makes constant load. ``load`` - rps amount, ``dur``
- load duration.
Examples:
* ``const(10,10m)`` - constant load for 10 rps for 10 minutes.
* ``const(0, 10)`` - 0 rps for 10 seconds, in fact 10s pause in a test.

.. note::
``const(0, 10)`` - 0 rps for 10 seconds,
in fact 10s pause in a test.

Example:
``const(10,10m)`` - constant load for 10 rps for 10 minutes.

------------

.. note::
You can set fractional load like this: ``line(1.1, 2.5, 10)``
You can set fractional load like this: ``line(1.1, 2.5, 10)``
-- from 1.1rps to 2.5 for 10 seconds.

.. note::
``step`` and ``line`` could be used with increasing and decreasing intensity:
``step`` and ``line`` could be used with increasing and decreasing intensity:


You can specify complex load schemes using those primitives.
Expand All @@ -81,15 +74,17 @@ have following lines:
.. code-block:: yaml
phantom:
address: 203.0.113.1:80
load_profile:
load_type: rps
schedule: const(10, 10m)
uris:
- "/uri1"
- "/uri2"
address: 203.0.113.1:80 # [Target's address]:[target's port]
uris:
- /uri1
- /uri2
load_profile:
load_type: rps # schedule load by defining requests per second
schedule: const(10, 10m) # starting from 1rps growing linearly to 10rps during 10 minutes
console:
enabled: true # enable console output
telegraf:
enabled: false # let's disable telegraf monitoring for this time
enabled: false # let's disable telegraf monitoring for the first time
Preparing requests
Expand Down Expand Up @@ -127,34 +122,6 @@ To specify external ammo file use ``ammofile`` option.
ammofile: https://yourhost.tld/path/to/ammofile.txt


Access mode
-----------

YAML-file configuration: ``ammo_type: access``

You can use ``access.log`` file from your webserver as a source of requests.
Just add to load.yaml options ``ammo_type: access`` and ``ammofile: /tmp/access.log``
where /tmp/access.log is a path to access.log file.

.. code-block:: yaml
phantom:
address: 203.0.113.1:80
load_profile:
load_type: rps
schedule: line(1, 10, 10m)
header_http: "1.1"
headers:
- "[Host: www.target.example.com]"
- "[Connection: close]"
ammofile: /tmp/access.log
ammo_type: access
telegraf:
enabled: false # let's disable telegraf monitoring for this time
Parameter ``headers`` defines headers values (if it necessary).


URI-style, URIs in load.yaml
----------------------------

Expand All @@ -178,8 +145,10 @@ Update configuration file with HTTP headers and URIs:
- "/buy"
- "/sdfg?sdf=rwerf"
- "/sdfbv/swdfvs/ssfsf"
console:
enabled: true
telegraf:
enabled: false # let's disable telegraf monitoring for this time
enabled: false
Parameter ``uris`` contains uri, which should be used for requests generation.

Expand Down
11 changes: 1 addition & 10 deletions yandextank/core/tankcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
import tempfile
import time
import traceback
try:
from StringIO import StringIO
except ImportError:
from io import StringIO

import pkg_resources
import sys
Expand Down Expand Up @@ -133,12 +129,7 @@ def __init__(self, configs, artifacts_base_dir=None, artifacts_dir_name=None, cf
@property
def cfg_snapshot(self):
if not self._cfg_snapshot:
if self.cfg_depr:
output = StringIO()
self.cfg_depr.write(output)
self._cfg_snapshot = output.getvalue()
else:
self._cfg_snapshot = str(self.config)
self._cfg_snapshot = str(self.config)
return self._cfg_snapshot

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion yandextank/plugins/DataUploader/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def get_manual_unlock_link(target):
def send_config_snapshot(self, jobno, config, trace=False):
logger.debug("Sending config snapshot")
addr = "api/job/%s/configinfo.txt" % jobno
self.__post_raw(addr, {"configinfo": config}, trace=trace)
self.__post_raw(addr, {"configinfo": unicode(config)}, trace=trace)

def link_mobile_job(self, lp_key, mobile_key):
addr = "/api/job/{jobno}/edit.json".format(jobno=lp_key)
Expand Down

0 comments on commit c97b139

Please sign in to comment.