Slide 1

Slide 1 text

Concurrent Testing with py.test Reverb Chu, Sr. SWE @ Trend Micro James Wang, UGrad CS Student @ Uni. of Washington

Slide 2

Slide 2 text

https://goo.gl/mxthn3

Slide 3

Slide 3 text

https://goo.gl/mxthn3 https://www.apple.com/macbook/

Slide 4

Slide 4 text

https://goo.gl/mxthn3

Slide 5

Slide 5 text

Current Solutions https://goo.gl/mxthn3

Slide 6

Slide 6 text

Current Solutions 1. pytest-xdist https://goo.gl/mxthn3

Slide 7

Slide 7 text

Current Solutions 1. pytest-xdist 2. ...there’s no 2. https://goo.gl/mxthn3

Slide 8

Slide 8 text

Why Not pytest-xdist? - Designed for test distribution - Only support multiprocessing - Not able to do test grouping https://goo.gl/mxthn3

Slide 9

Slide 9 text

pytest-concurrent life is too short for sequential tests https://goo.gl/mxthn3

Slide 10

Slide 10 text

Different Concurrent Mode mthread - Impl. with threading - For IO intensive tests mproc - Impl. with multiprocessing - For CPU intensive tests asyncnet - Impl. with gevent - For network IO intensive tests https://goo.gl/mxthn3

Slide 11

Slide 11 text

Configurable Worker Amount $ pytest --concmode=mthread --concworkers=10 https://goo.gl/mxthn3

Slide 12

Slide 12 text

Configurable Worker Amount $ pytest --concmode=mthread --concworkers=max https://goo.gl/mxthn3

Slide 13

Slide 13 text

Testing in Groups import pytest import time @pytest.mark.concgroup(1) @pytest.mark.parametrize('para', [1, 2, 3, 4, 5]) def test_something(para): time.sleep(2) assert para % 2 @pytest.mark.concgroup(1) def test_something_else(): time.sleep(1) assert 1 == 2 @pytest.mark.concgroup(2) @pytest.mark.parametrize('name', ['this', 'is', 'a', 'book']) def test_second_group(name): time.sleep(2) def test_something_last(): time.sleep(2) raise MemoryError @pytest.mark.concgroup(group: int) https://goo.gl/mxthn3

Slide 14

Slide 14 text

May ?? I want it... https://goo.gl/mxthn3

Slide 15

Slide 15 text

May ?? I want it... Jun 20 Intern Onboard https://goo.gl/mxthn3

Slide 16

Slide 16 text

May ?? I want it... Jul 31 Let’s Do This Jun 20 Intern Onboard https://goo.gl/mxthn3

Slide 17

Slide 17 text

May ?? I want it... Aug 11 v0.1.2 Jul 31 Let’s Do This Jun 20 Intern Onboard Aug 10 v0.1.1 Aug 9 v0.1.0 https://goo.gl/mxthn3

Slide 18

Slide 18 text

$ pip install pytest-concurrent https://goo.gl/mxthn3 @reverbc @jamesw96