Slide 1

Slide 1 text

summon_process orchestrating processes Mateusz Lenik [email protected]

Slide 2

Slide 2 text

desclaimer: this is a shameless ripoff of Ruby library called bbq-spawn

Slide 3

Slide 3 text

tests and processes

Slide 4

Slide 4 text

tests and processes •acceptance tests relying on other processes

Slide 5

Slide 5 text

tests and processes •acceptance tests relying on other processes •integration tests of multiple components in separate processes

Slide 6

Slide 6 text

problems

Slide 7

Slide 7 text

problems •the processes need to be started

Slide 8

Slide 8 text

problems •the processes need to be started •sometimes they rely on each other

Slide 9

Slide 9 text

problems •the processes need to be started •sometimes they rely on each other •they may need some time to boot

Slide 10

Slide 10 text

solutions

Slide 11

Slide 11 text

solutions •add time.sleep and pretend it works

Slide 12

Slide 12 text

solutions •add time.sleep and pretend it works •use some orchestration to do it for you

Slide 13

Slide 13 text

orchestrate |ˈɔːkɪstreɪt| verb [ with obj. ] 2 plan or coordinate the elements of (a situation) to produce a desired effect, especially surreptitiously: the situation has been orchestrated by a tiny minority.

Slide 14

Slide 14 text

summon_process

Slide 15

Slide 15 text

summon_process •my first Python library

Slide 16

Slide 16 text

summon_process •my first Python library •layer of orchestration for processes

Slide 17

Slide 17 text

summon_process •my first Python library •layer of orchestration for processes •simple interface

Slide 18

Slide 18 text

summon_process •my first Python library •layer of orchestration for processes •simple interface •provides executors and orchestrators

Slide 19

Slide 19 text

Interface

Slide 20

Slide 20 text

Interface •every executor takes the arguments via constructor

Slide 21

Slide 21 text

Interface •every executor takes the arguments via constructor •every execotor has start method

Slide 22

Slide 22 text

Interface •every executor takes the arguments via constructor •every execotor has start method •every executor has stop method

Slide 23

Slide 23 text

Interface •every executor takes the arguments via constructor •every execotor has start method •every executor has stop method •start method waits for the process to be ready

Slide 24

Slide 24 text

Interface •every executor takes the arguments via constructor •every execotor has start method •every executor has stop method •start method waits for the process to be ready •same goes for orchestrators

Slide 25

Slide 25 text

Executors

Slide 26

Slide 26 text

Executors •creates a process

Slide 27

Slide 27 text

Executors •creates a process •blocks until the process is ready

Slide 28

Slide 28 text

Executors •creates a process •blocks until the process is ready •multiple flavours

Slide 29

Slide 29 text

Executors •creates a process •blocks until the process is ready •multiple flavours •SimpleExecutor

Slide 30

Slide 30 text

Executors •creates a process •blocks until the process is ready •multiple flavours •SimpleExecutor •OutputCoordinatedExecutor

Slide 31

Slide 31 text

Executors •creates a process •blocks until the process is ready •multiple flavours •SimpleExecutor •OutputCoordinatedExecutor •TCPCoordinatedExecutor

Slide 32

Slide 32 text

Executors •creates a process •blocks until the process is ready •multiple flavours •SimpleExecutor •OutputCoordinatedExecutor •TCPCoordinatedExecutor •HTTPCoordinatedExecutor

Slide 33

Slide 33 text

Orchestrators

Slide 34

Slide 34 text

Orchestrators •orchestrate executors

Slide 35

Slide 35 text

Orchestrators •orchestrate executors •use the same interface as executors

Slide 36

Slide 36 text

Orchestrators •orchestrate executors •use the same interface as executors •orchestrated contextmanager as a bonus

Slide 37

Slide 37 text

examples

Slide 38

Slide 38 text

def test_something(self): executor = TCPCoordinatedExecutor( 'command_to_start', host='localhost', post=1234) with orchestrated(executor): # do something

Slide 39

Slide 39 text

def test_something_else(self): srv = TCPCoordinatedExecutor( 'command', host='...', port=...) cli = OutputCoordinatedExecutor( 'command', banner='...') with orchestrated(srv, cli): # do something

Slide 40

Slide 40 text

demo

Slide 41

Slide 41 text

How to add an executor

Slide 42

Slide 42 text

How to add an executor •create a class (optionally inherit from executor)

Slide 43

Slide 43 text

How to add an executor •create a class (optionally inherit from executor) •accept parameters via constructor

Slide 44

Slide 44 text

How to add an executor •create a class (optionally inherit from executor) •accept parameters via constructor •define start method that blocks

Slide 45

Slide 45 text

How to add an executor •create a class (optionally inherit from executor) •accept parameters via constructor •define start method that blocks •define stop method

Slide 46

Slide 46 text

How to add an executor •create a class (optionally inherit from executor) •accept parameters via constructor •define start method that blocks •define stop method •that's all

Slide 47

Slide 47 text

pip install summon_process try it

Slide 48

Slide 48 text

pip install summon_process try it please contribute if you like it github.com/mlen/summon

Slide 49

Slide 49 text

KTHXBYE Mateusz Lenik [email protected]