Skip to main content

tests build codecov Python 3.7 Python 3.8 Python 3.9

Yapam

Yapam is a tool that aims to simplify the process of working with Yandex Tank

Edit tool config, and it automatically creates ammo that you can use for your tests. For now, it can create only Phantom-type ammo. If the app that you need to test is not stateless - probably you should find another way.

I have nothing to do with the Tank or Yandex itself but was impressed by the great work that they did.

Remark

Sooner or later for any project, questions arise:

 What load can it handle? 
 Which handlers are slow? 
 What exactly happens if you increase the number of application instances?

Your first mind maybe I should use one of the stress testing tools!, but if you do not have colleagues who could do this, then the task will fall on your shoulders. In my opinion, Yandex Tank is an easy and convenient way to do this type of task (and as far as I know - it is free and opensource). The right way is to read official docs, but... Ok, if you want to do it ASAP here is a small Python script that will generate all you need to generate for tank shooting.

Installation

Your Python version should be 3.5 or above. Simply install with Python package manager like pip: pip install yapam

Configuration

Configuration file should be JSON-type file with .json extension.

Configuration options:

LOG_DATE_FMT: date format for internal logging

LOG_FMT: internal logging log format (same as Python basic logging format)

LOG_LVL: level of logging (same as Python basic logging levels)

AMMO_FILE: a path to file where results should be saved

REQUESTS: list of requests for your shooting

Example:

{
  "AMMO_FILE": "ammo",
  "LOG_DATE_FMT": "%H:%M:%S",
  "LOG_FMT": "%(asctime)s.%(msecs)d|%(levelname).1s|%(message)s",
  "LOG_LVL": "DEBUG",
  "REQUESTS": [
    {
      "host": "192.168.7.178",
      "url": "/api/auth",
      "port": 443,
      "method": "POST",
      "body": {"username": "vdiadmin", "password": "admin"}
    },
    {
      "host": "127.0.0.1",
      "port": 8888,
      "url":  "/auth",
      "method":  "POST",
      "body": {"username": "admin", "password": "admin"}
    }
  ]
}

Usage

create local runner, like app.py

# -*- coding: utf-8 -*-

import argparse
import sys
from distutils.util import strtobool

from yapam.armory import Armory
from yapam.config import AmmoConfig


def parse_args():
    """Script arguments parser."""
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', default='config.json', type=str,
                        help='Path to configuration file, ex: config.json')
    parser.add_argument('--template', default=False, type=strtobool, nargs='?', const=True,
                        help='Create config template')
    return parser.parse_args()


def main():
    args = parse_args()

    if args.template:
        cfg = AmmoConfig()
        cfg.log.debug('Trying to create a template of configuration file.')
        cfg.create_template(args.config)
        cfg.log.debug('Exit.')
        sys.exit(0)

    try:
        user_config = AmmoConfig(args.config)
        user_config.log.debug(f'Configuration file loaded: {user_config.public_attrs()}')

        armory = Armory(user_config.requests, user_config.ammo_file, user_config.log)
        armory.generate_ammo()
    except (AssertionError, FileExistsError) as error_msg:
        user_config.log.critical(str(error_msg))
        sys.exit(1)

    sys.exit(0)


if __name__ == '__main__':
    main()

create a template for your future configuration file

python app.py --template

edit configuration file

run your runner

python app.py or python app.py --config 'my.json'

use your ammo for tank shooting!

I read everything, but still did not understand anything. Show me a super short way to run the whole thing?

Try this

https://yandex.ru/dev/tank/

https://yandextank.readthedocs.io/en/latest/

https://gist.github.com/sameoldmadness/9abeef4c2125bc760ba2f09ee1150330

https://www.youtube.com/watch?v=gws7L3EaeC0

Metadata

Release files for yapam 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yapam 0.1.5
File Size Uploaded Provenance Actions
yapam-0.1.5.tar.gz 12.1 kB Without provenance Details for yapam-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yapam 0.1.5
File Interpreter ABI Platform Actions
yapam-0.1.5-py3-none-any.whl Python 3 none any Details for yapam-0.1.5-py3-none-any.whl

Total release size: 24.6 kB

Release files / yapam-0.1.5.tar.gz

Download URL yapam-0.1.5.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ec8d50a7500e3e7ed1e41d4630b13de8343334e775edf99411d5a2d6f581f396
BLAKE2b-256 checksum
How to use checksums
698ff6dd16638fd1299925d4b0396438404a9702cb23ce4be79d5d2b05c3709b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / yapam-0.1.5-py3-none-any.whl

Download URL yapam-0.1.5-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a94dec81a84f8e497c32dced6abaee51386ac1e3fd3a281224545bfc242abd10
BLAKE2b-256 checksum
How to use checksums
45682ba83496ae360858ac287d4ee0f75b091e8f96c5494e4922236c2d530474
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Security for yapam 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page