• Stars
    star
    193
  • Rank 201,081 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python fixtures and daemon managing tools for functional testing

Pifpaf

Build Status

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

More Repositories

1

tenacity

Retrying library for Python
Python
5,200
star
2

asciidoc-book-toolchain

Book publishing toolchain based on AsciiDoc
XSLT
123
star
3

google-maps.el

Google Maps support for Emacs
Emacs Lisp
48
star
4

fastcounter

Fast counters for Python
Python
42
star
5

google-contacts.el

Google Contacts for Emacs
Emacs Lisp
28
star
6

sysrqd

Linux SysRQ daemon
C
24
star
7

serious-python.com

Serious Python website
CSS
21
star
8

naquadah-theme

Naquadah theme for Emacs
Emacs Lisp
20
star
9

julien.danjou.info

Julien Danjou's blog and personal website
Makefile
19
star
10

telak

Draw images on your X root window
C
17
star
11

lwn2pocket

Push LWN.net Weekly Edition to Pocket
Python
16
star
12

emacs.d

My Emacs configuration files
Emacs Lisp
14
star
13

offlineimap.el

OfflineIMAP support for Emacs
Emacs Lisp
12
star
14

trelloha

Trello Organizer
Python
9
star
15

scaling-python.com

scaling-python.com website
CSS
9
star
16

pymunincli

munin client Python library
Python
4
star
17

git-tag-pbr

Git tag projects using pbr
Shell
4
star
18

google-weather.el

Emacs support for Google Weather
Emacs Lisp
4
star
19

mod_defensible

Apache 2 module for blocking access using DNSBL
C
4
star
20

overtest

Daemon managing tools for functional testing
Shell
3
star
21

erc-track-score.el

Erc tracking with score module
Emacs Lisp
3
star
22

kawoosh

IRC/HTTP REST gateway
Common Lisp
3
star
23

osjenkins-twitter

Twitter bot for @OSJenkins
Python
1
star
24

spotless

Python pedantic checks
Python
1
star
25

muse-blog.el

Blogging extension for Muse
Emacs Lisp
1
star
26

runtastic2strava

Sent Runtastic sessions to Strava
Python
1
star
27

trollstack

Detects trolls in OpenStack reviews
Python
1
star
28

varmon

Management tool for DAC960/DAC1164 controller family
C
1
star
29

libparportled

Library to control a LED system via parallel port
C
1
star