pifpaf


Namepifpaf JSON
Version 3.2.3 PyPI version JSON
download
home_pagehttps://github.com/jd/pifpaf
SummarySuite of tools and fixtures to manage daemons for testing
upload_time2024-10-11 14:12:26
maintainerNone
docs_urlNone
authorJulien Danjou
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==========
 Pifpaf
==========

.. image:: https://badge.fury.io/py/pifpaf.svg
    :target: https://badge.fury.io/py/pifpaf

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`_.

.. _fixtures: https://pypi.python.org/pypi/fixtures
.. _overtest: https://github.com/jd/overtest

Supported daemons
=================

Pifpaf currently supports:

* `PostgreSQL`_
* `MySQL`_
* `Memcached`_
* `InfluxDB`_
* `Etcd`_ (with clustering)
* `Redis`_ (with sentinel mode)
* `Valkey`_
* `Elasticsearch`_
* `ZooKeeper`_
* `Gnocchi`_
* `Aodh`_
* `Ceph`_
* `RabbitMQ`_ (with clustering)
* `FakeS3`_
* `Consul`_
* `Keystone`_
* `CouchDB`_
* `S3rver`_
* `MongoDB`_
* `OpenStack Swift`_
* `Vault`_
* `HttpBin`_

.. _Consul: https://www.consul.io/
.. _PostgreSQL: http://postgresql.org
.. _MySQL: http://mysql.org
.. _Memcached: http://memcached.org
.. _InfluxDB: http://influxdb.org
.. _Etcd: https://coreos.com/etcd/
.. _Redis: http://redis.io/
.. _Valkey: https://valkey.io/
.. _Elasticsearch: https://www.elastic.co/
.. _ZooKeeper: https://zookeeper.apache.org/
.. _Gnocchi: http://gnocchi.xyz
.. _Aodh: http://launchpad.net/aodh
.. _Ceph: http://ceph.com
.. _RabbitMQ: https://www.rabbitmq.com/
.. _FakeS3: https://github.com/jubos/fake-s3
.. _Keystone: https://launchpad.net/keystone
.. _CouchDB: http://couchdb.apache.org/
.. _S3rver: https://www.npmjs.com/package/s3rver
.. _MongoDB: https://www.mongodb.com
.. _OpenStack Swift: https://docs.openstack.org/developer/swift/
.. _Vault: https://www.vaultproject.io/
.. _HttpBin: https://httpbin.org/

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.

.. _integration testing: https://en.wikipedia.org/wiki/Integration_testing


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.

.. image:: pifpaf.jpg

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jd/pifpaf",
    "name": "pifpaf",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Julien Danjou",
    "author_email": "julien@danjou.info",
    "download_url": "https://files.pythonhosted.org/packages/90/cf/9409d3fbfb6c7c8df434bcf342bfd5f03497ec50d38b5ae7245ba4cd3557/pifpaf-3.2.3.tar.gz",
    "platform": null,
    "description": "==========\n Pifpaf\n==========\n\n.. image:: https://badge.fury.io/py/pifpaf.svg\n    :target: https://badge.fury.io/py/pifpaf\n\nPifpaf is a suite of `fixtures`_ and a command-line tool that allows to start\nand stop daemons for a quick throw-away usage. This is typically useful when\nneeding these daemons to run `integration testing`_. It originaly evolved from\nits precussor `overtest`_.\n\n.. _fixtures: https://pypi.python.org/pypi/fixtures\n.. _overtest: https://github.com/jd/overtest\n\nSupported daemons\n=================\n\nPifpaf currently supports:\n\n* `PostgreSQL`_\n* `MySQL`_\n* `Memcached`_\n* `InfluxDB`_\n* `Etcd`_ (with clustering)\n* `Redis`_ (with sentinel mode)\n* `Valkey`_\n* `Elasticsearch`_\n* `ZooKeeper`_\n* `Gnocchi`_\n* `Aodh`_\n* `Ceph`_\n* `RabbitMQ`_ (with clustering)\n* `FakeS3`_\n* `Consul`_\n* `Keystone`_\n* `CouchDB`_\n* `S3rver`_\n* `MongoDB`_\n* `OpenStack Swift`_\n* `Vault`_\n* `HttpBin`_\n\n.. _Consul: https://www.consul.io/\n.. _PostgreSQL: http://postgresql.org\n.. _MySQL: http://mysql.org\n.. _Memcached: http://memcached.org\n.. _InfluxDB: http://influxdb.org\n.. _Etcd: https://coreos.com/etcd/\n.. _Redis: http://redis.io/\n.. _Valkey: https://valkey.io/\n.. _Elasticsearch: https://www.elastic.co/\n.. _ZooKeeper: https://zookeeper.apache.org/\n.. _Gnocchi: http://gnocchi.xyz\n.. _Aodh: http://launchpad.net/aodh\n.. _Ceph: http://ceph.com\n.. _RabbitMQ: https://www.rabbitmq.com/\n.. _FakeS3: https://github.com/jubos/fake-s3\n.. _Keystone: https://launchpad.net/keystone\n.. _CouchDB: http://couchdb.apache.org/\n.. _S3rver: https://www.npmjs.com/package/s3rver\n.. _MongoDB: https://www.mongodb.com\n.. _OpenStack Swift: https://docs.openstack.org/developer/swift/\n.. _Vault: https://www.vaultproject.io/\n.. _HttpBin: https://httpbin.org/\n\nUsage\n=====\nTo use Pifpaf, simply call the `pifpaf run $daemon <command>` program that you\nneed. It will setup the temporary environment and export a few environment\nvariable for you to access it::\n\n  $ pifpaf run postgresql psql template1\n  Expanded display is used automatically.\n  Line style is unicode.\n  SET\n  psql (9.4.5)\n  Type \"help\" for help.\n\n  template1=# \\l\n                                List of databases\n     Name    \u2502 Owner \u2502 Encoding \u2502   Collate   \u2502    Ctype    \u2502 Access privileges\n  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n   postgres  \u2502 jd    \u2502 UTF8     \u2502 en_US.UTF-8 \u2502 en_US.UTF-8 \u2502\n   template0 \u2502 jd    \u2502 UTF8     \u2502 en_US.UTF-8 \u2502 en_US.UTF-8 \u2502 =c/jd            \u21b5\n             \u2502       \u2502          \u2502             \u2502             \u2502 jd=CTc/jd\n   template1 \u2502 jd    \u2502 UTF8     \u2502 en_US.UTF-8 \u2502 en_US.UTF-8 \u2502 =c/jd            \u21b5\n             \u2502       \u2502          \u2502             \u2502             \u2502 jd=CTc/jd\n  (3 rows)\n\n  template1=# \\q\n  $\n\nYou can also run it with no command line provided::\n\n  $ eval `pifpaf run memcached`\n  $ env | grep PIFPAF\n  PIFPAF_PID=13387\n  PIFPAF_DAEMON=memcached\n  PIFPAF_URL=memcached://localhost:11212\n  PIFPAF_MEMCACHED_URL=memcached://localhost:11212\n  $ pifpaf_stop\n\nKilling the daemon whose PID is contained in `$PIFPAF_PID` will stop the\nlaunched daemon and clean the test environment. You can kill it yourself or use\nthe defined function `pifpaf_stop`.\n\nEnvironment variables\n=====================\nPifpaf exports a few environment variable:\n\n* `PIFPAF_DAEMON` which contains the name of the daemon launched\n* `PIFPAF_URL` which contains the URL to the daemon\n* `PIFPAF_PID` the PID of the pifpaf daemon\n* `PIFPAF_$daemon_*` variables, which contains daemon specific variables,\n  such as port, database name, URL, etc.\n\n.. _integration testing: https://en.wikipedia.org/wiki/Integration_testing\n\n\nRunning several programs at once\n================================\nPifpaf provides the ability to change the prefix of its environment variable,\nallowing you to nest several Pifpaf instances and therefore running several\ndaemons at once::\n\n  $ pifpaf --env-prefix STORAGE run memcached -- pifpaf --env-prefix INDEX run postgresql $SHELL\n  $ env | grep STORAGE\n  STORAGE_DATA=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmpVreJ0J\n  STORAGE_MEMCACHED_PORT=11212\n  STORAGE_URL=memcached://localhost:11212\n  STORAGE_PID=71019\n  STORAGE_DAEMON=memcached\n  STORAGE_MEMCACHED_URL=memcached://localhost:11212\n  $ env | grep INDEX\n  INDEX_DATA=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmphAG7tf\n  INDEX_URL=postgresql://localhost/postgres?host=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmphAG7tf&port=9824\n  INDEX_PID=71021\n  INDEX_DAEMON=postgresql\n  INDEX_POSTGRESQL_URL=postgresql://localhost/postgres?host=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmphAG7tf&port=9824\n  $ echo $PIFPAF_URLS\n  memcached://localhost:11212;postgresql://localhost/postgres?host=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmpQ2BWFH&port=9824\n\nThe `PIFPAF_URLS` environment variable will contain the list of all URLs\ndetected and set-up by Pifpaf. You can override this variable name with the\n`--global-urls-variable` option.\n\nHow it works under the hood\n===========================\n\nPifpaf will start the asked daemon using the current Posix user. The data file\nof the daemon will be placed in a temporary directory. The system-wide\nconfigured daemon that might exists is not touched at all.\n\nPifpaf expected to find daemon binaries on your system (like `mysql`, `mysqld`,\n`pg_config`, `pg_ctl`, `rabbitmq-server`, etc).\n\nWhen the Python fixture is cleaned or when Pifpaf is terminated, the daemon is\nstopped and the temporary directory removed.\n\n.. image:: pifpaf.jpg\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Suite of tools and fixtures to manage daemons for testing",
    "version": "3.2.3",
    "project_urls": {
        "Homepage": "https://github.com/jd/pifpaf"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "410794380a430676891516b301f6015ebe4520c7e4c0ae0382c84fd82e802bd1",
                "md5": "c2c2bdb03c08dccacce84294830032eb",
                "sha256": "dbe5e5f46a5aa51883a5d086f2bb5ae5aca55d8d7d60da964c0f4814000d1e08"
            },
            "downloads": -1,
            "filename": "pifpaf-3.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c2c2bdb03c08dccacce84294830032eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 63519,
            "upload_time": "2024-10-11T14:12:20",
            "upload_time_iso_8601": "2024-10-11T14:12:20.726277Z",
            "url": "https://files.pythonhosted.org/packages/41/07/94380a430676891516b301f6015ebe4520c7e4c0ae0382c84fd82e802bd1/pifpaf-3.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90cf9409d3fbfb6c7c8df434bcf342bfd5f03497ec50d38b5ae7245ba4cd3557",
                "md5": "3e71313e365fdf3b78cc5493fbf19f69",
                "sha256": "2f4dfd64016760b094e7687549ccc95344fbfb582e7f142557342bd443c2a9cf"
            },
            "downloads": -1,
            "filename": "pifpaf-3.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "3e71313e365fdf3b78cc5493fbf19f69",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 185673,
            "upload_time": "2024-10-11T14:12:26",
            "upload_time_iso_8601": "2024-10-11T14:12:26.960812Z",
            "url": "https://files.pythonhosted.org/packages/90/cf/9409d3fbfb6c7c8df434bcf342bfd5f03497ec50d38b5ae7245ba4cd3557/pifpaf-3.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-11 14:12:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jd",
    "github_project": "pifpaf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pifpaf"
}
        
Elapsed time: 0.62170s