Coder Social home page Coder Social logo

glucoseinc / mirakuru Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clearcodehq/mirakuru

0.0 10.0 0.0 266 KB

Mirakuru - a python library that starts your subprocess and waits for a clear indication, that it's running (process orchestrator)

Home Page: https://pypi.python.org/pypi/mirakuru

License: GNU Lesser General Public License v3.0

Python 100.00%

mirakuru's Introduction

mirakuru

Mirakuru is a process orchestration tool designed for functional and integration tests.

Maybe you want to be able to start a database before you start your program or maybe you just need to set additional services up for your tests. This is where you should consider using mirakuru to add superpowers to your program or tests.

Latest PyPI version Documentation Status Wheel Status Supported Python Versions License

Package status

Tests Coverage Status Requirements Status

About

In a project that relies on multiple processes there might be a need to guard code with tests that verify interprocess communication. So one needs to set up all of required databases, auxiliary and application services to verify their cooperation. Synchronising (or orchestrating) test procedure with tested processes might be a hell.

If so, then mirakuru is what you need.

Mirakuru starts your process and waits for the clear indication that it's running. Library provides six executors to fit different cases:

  • SimpleExecutor - starts a process and does not wait for anything. It is useful to stop or kill a process and its subprocesses. Base class for all the rest of executors.
  • Executor - base class for executors verifying if a process has started.
  • OutputExecutor - waits for a specified output to be printed by a process.
  • TCPExecutor - waits for the ability to connect through TCP with a process.
  • HTTPExecutor - waits for a successful HEAD request (and TCP before).
  • PidExecutor - waits for a specified .pid file to exist.
from mirakuru import HTTPExecutor
from httplib import HTTPConnection, OK


def test_it_works():
    # The ``./http_server`` here launches some HTTP server on the 6543 port,
    # but naturally it is not immediate and takes a non-deterministic time:
    executor = HTTPExecutor("./http_server", url="http://127.0.0.1:6543/")

    # Start the server and wait for it to run (blocking):
    executor.start()
    # Here the server should be running!
    conn = HTTPConnection("127.0.0.1", 6543)
    conn.request("GET", "/")
    assert conn.getresponse().status is OK
    executor.stop()

A command by which executor spawns a process can be defined by either string or list.

# command as string
TCPExecutor('python -m smtpd -n -c DebuggingServer localhost:1025', host='localhost', port=1025)
# command as list
TCPExecutor(
    ['python', '-m', 'smtpd', '-n', '-c', 'DebuggingServer', 'localhost:1025'],
    host='localhost', port=1025
)

Authors

The project was firstly developed by Mateusz Lenik as the summon_process. Later forked, renamed into mirakuru and tended to by The A Room @ Clearcode and the other authors.

License

mirakuru is licensed under LGPL license, version 3.

Contributing and reporting bugs

Source code is available at: ClearcodeHQ/mirakuru. Issue tracker is located at GitHub Issues. Projects PyPI page.

When contributing, don't forget to add your name to the AUTHORS.rst file.

mirakuru's People

Contributors

fizyk avatar tomislater avatar luqasz avatar mlen avatar pwilczynskiclearcode avatar requires avatar jotes avatar mruwnik avatar mekto avatar not-raspberry avatar quantifiedcode-bot avatar xuru avatar

Watchers

Shin Adachi avatar James Cloos avatar Manabu Matsuura avatar hira avatar sasau avatar Akutsu avatar Wataru HASHIMOTO avatar  avatar Yuta Nakajima avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.