Skip to main content

Suite of tools and fixtures to manage daemons for testing

Project description

Build Status https://badge.fury.io/py/pifpaf.svg

Pifpaf is a suite of fixtures and a command-line tool that allows to start and stop daemons for a quick throw-away usage. This is typically useful when needing these daemons to run integration testing. It originaly evolved from its precussor overtest.

Supported daemons

Pifpaf currently supports:

Usage

To use Pifpaf, simply call the pifpaf run $daemon <command> program that you need. It will setup the temporary environment and export a few environment variable for you to access it:

$ pifpaf run postgresql psql template1
Expanded display is used automatically.
Line style is unicode.
SET
psql (9.4.5)
Type "help" for help.

template1=# \l
                              List of databases
   Name    │ Owner │ Encoding │   Collate   │    Ctype    │ Access privileges
───────────┼───────┼──────────┼─────────────┼─────────────┼───────────────────
 postgres  │ jd    │ UTF8     │ en_US.UTF-8 │ en_US.UTF-8 │
 template0 │ jd    │ UTF8     │ en_US.UTF-8 │ en_US.UTF-8 │ =c/jd            ↵
           │       │          │             │             │ jd=CTc/jd
 template1 │ jd    │ UTF8     │ en_US.UTF-8 │ en_US.UTF-8 │ =c/jd            ↵
           │       │          │             │             │ jd=CTc/jd
(3 rows)

template1=# \q
$

You can also run it with no command line provided:

$ eval `pifpaf run memcached`
$ env | grep PIFPAF
PIFPAF_PID=13387
PIFPAF_DAEMON=memcached
PIFPAF_URL=memcached://localhost:11212
PIFPAF_MEMCACHED_URL=memcached://localhost:11212
$ pifpaf_stop

Killing the daemon whose PID is contained in $PIFPAF_PID will stop the launched daemon and clean the test environment. You can kill it yourself or use the defined function pifpaf_stop.

Environment variables

Pifpaf exports a few environment variable:

  • PIFPAF_DAEMON which contains the name of the daemon launched

  • PIFPAF_URL which contains the URL to the daemon

  • PIFPAF_PID the PID of the pifpaf daemon

  • PIFPAF_$daemon_* variables, which contains daemon specific variables, such as port, database name, URL, etc.

Running several programs at once

Pifpaf provides the ability to change the prefix of its environment variable, allowing you to nest several Pifpaf instances and therefore running several daemons at once:

$ pifpaf --env-prefix STORAGE run memcached -- pifpaf --env-prefix INDEX run postgresql $SHELL
$ env | grep STORAGE
STORAGE_DATA=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmpVreJ0J
STORAGE_MEMCACHED_PORT=11212
STORAGE_URL=memcached://localhost:11212
STORAGE_PID=71019
STORAGE_DAEMON=memcached
STORAGE_MEMCACHED_URL=memcached://localhost:11212
$ env | grep INDEX
INDEX_DATA=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmphAG7tf
INDEX_URL=postgresql://localhost/postgres?host=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmphAG7tf&port=9824
INDEX_PID=71021
INDEX_DAEMON=postgresql
INDEX_POSTGRESQL_URL=postgresql://localhost/postgres?host=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmphAG7tf&port=9824
$ echo $PIFPAF_URLS
memcached://localhost:11212;postgresql://localhost/postgres?host=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmpQ2BWFH&port=9824

The PIFPAF_URLS environment variable will contain the list of all URLs detected and set-up by Pifpaf. You can override this variable name with the –global-urls-variable option.

How it works under the hood

Pifpaf will start the asked daemon using the current Posix user. The data file of the daemon will be placed in a temporary directory. The system-wide configured daemon that might exists is not touched at all.

Pifpaf expected to find daemon binaries on your system (like mysql, mysqld, pg_config, pg_ctl, rabbitmq-server, etc).

When the Python fixture is cleaned or when Pifpaf is terminated, the daemon is stopped and the temporary directory removed.

pifpaf.jpg

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pifpaf-3.1.3.tar.gz (189.9 kB view details)

Uploaded Source

Built Distribution

pifpaf-3.1.3-py3-none-any.whl (62.3 kB view details)

Uploaded Python 3

File details

Details for the file pifpaf-3.1.3.tar.gz.

File metadata

  • Download URL: pifpaf-3.1.3.tar.gz
  • Upload date:
  • Size: 189.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.17

File hashes

Hashes for pifpaf-3.1.3.tar.gz
Algorithm Hash digest
SHA256 06b84199b48ce1d04fb7beab2f075149a45c13250a933946b5048bf7a114db98
MD5 3c2c76dd86649e7b3a09cc9014ca23ea
BLAKE2b-256 970fd975a17fa2096de7e5ac860e62960b09d46df00cb17cf4859f72289420b1

See more details on using hashes here.

File details

Details for the file pifpaf-3.1.3-py3-none-any.whl.

File metadata

  • Download URL: pifpaf-3.1.3-py3-none-any.whl
  • Upload date:
  • Size: 62.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.17

File hashes

Hashes for pifpaf-3.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 983fb7983814cdc99538d6e82cc2a3198a90bfc88b3b6de912bab7feba0d7289
MD5 f3deb94984b2a9f7576c8cabca8ce179
BLAKE2b-256 67cd8959747777ecd3c49b295dda81f71c7f58d76130abc0d0d05a7ba947679f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page