Dockerize your unit tests for faster feedback

Michelangelo van Dam
Michelangelo van DamSenior PHP architect & QA Specialist at In2IT
β€’β€’
DOCKERIZE YOUR UNIT TESTS FOR
FASTER FEEDBACK
Let’s speed up your tests!
https://goo.gl/images/OdSqB4
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 2
FotobyAnnaFilinaatBGPHP16
Michelangelo van Dam
β€£ Pro PHP consultant at in2it
β€£ President of PHPBenelux
β€£ Open-Source contributor
β€£ Conference Speaker
β€£ ZCE and ZF-CE
in itPROFESSIONAL PHP SERVICES
PHPUnit + Docker = πŸš—πŸ’¨ 3
PHPUNIT
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 4
https://goo.gl/images/eBa0vw
EXTRAS TO RUN PHPUNIT
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 5
β€£ Command-line?
β€£ Run from IDE?
β€£ Test server?
β€£ Jenkins, TeamCity, Bamboo?
β€£ Vagrant?
β€£ Docker?
https://goo.gl/images/l0HXj7
DRAWBACKS
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 6
β€£ Takes long time for many tests
β€£ Environment not always ready for testing
β€£ Tests don’t provide good feedback
https://goo.gl/images/TajZrP
SYSTEM FAILURES
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 7
β€£ Memory Exhausted
β€£ Disk full
β€£ No network or network latency
β€£ Systems crash
https://goo.gl/images/ruod6b
DOCKER
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 8
https://goo.gl/images/vhDEGy
WHAT IS DOCKER?
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 9
β€£ Technology platform
β€£ Run processes in separate containers
β€£ Scales fast and seemlessly
β€£ Containers are easy shippable
β€£ Best next thing since sliced bread
https://goo.gl/images/xEfLk5
DOCKER USAGE
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 10
β€£ Mimic distributed architectures
β€£ Isolate applications
β€£ Run single purpose commands
https://goo.gl/images/LIfWVb
DEMO TIME
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 11
RUN THEM ALL
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 12
https://goo.gl/images/grh4mu
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 13
USING @GROUP
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 14
https://www.flickr.com/photos/bgphp/21210790293
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 15
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 16
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 17
for i in `./vendor/bin/phpunit --list-groups | grep "^
-" | awk {'print $2'}`; do ./vendor/bin/phpunit --group
$i; done;
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 18
SHIP IT WITH DOCKER!!!
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 19
https://goo.gl/images/Fo0dVi
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 20
docker run -ti --rm -v "$PWD":/usr/src/myapp -w /usr/
src/myapp php:7.0-cli ./vendor/bin/phpunit
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 21
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 22
https://www.gnu.org/software/parallel/
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 23
for i in `./vendor/bin/phpunit β€”list-groups | grep "^
-β€œ | awk {'print $2'}`; do echo $i; done | /usr/local/
bin/parallel docker run -v "$PWD":/usr/src/myapp -w /
usr/src/myapp php:7.0-cli ./vendor/bin/phpunit --log-
junit=build/junit-{}.xml --group {}
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 24
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 25
for i in `./vendor/bin/phpunit β€”list-groups | grep "^
-β€œ | awk {'print $2'}`; do echo $i; done | time /usr/
local/bin/parallel docker run -d -v "$PWD":/usr/src/
myapp -w /usr/src/myapp php:7.0-cli ./vendor/bin/
phpunit --log-junit=build/junit-{}.xml --group {}
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 26
WHERE ARE MY FAILURES?
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 27
https://goo.gl/images/VWpYFO
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 28
for i in `./vendor/bin/phpunit --list-groups | grep "^
-" | awk {'print $2'}`; do echo $i; done | time
parallel docker run -d -v "$PWD":/var/run/phpunit -w /
var/run/phpunit --name pu-docker-{} php:7.0-cli /var/
run/phpunit/vendor/bin/phpunit --group {} && for i in
`./vendor/bin/phpunit --list-groups | grep "^ -" | awk
{'print $2'}`; do docker wait pu-docker-$i | grep -c 0
> /dev/null || docker logs pu-docker-$i && docker rm -f
pu-docker-$i > /dev/null; done;
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 29
β€£ loop over our @group list entries
β€£ run these in docker (daemonized)
β€£ loop over our @group list entries
β€£ fetch the exit status of phpunit from the containers
β€£ if not 0 -> show us the failure
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 30
#FTW #PARTY #AWESOME
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 31
https://goo.gl/images/uWs8N0
OTHER SCENARIOS
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 32
β€£ Test on different PHP versions
β€£ Test separation based on TestSuite, Directory, …
β€£ Testing long running integration tests separately
β€£ Resilience testing
https://goo.gl/images/JnY8yr
QUESTIONS
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 33
https://goo.gl/images/mM3D3j
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 34
PHPUnit/Unit Testing
Ensure your apps are
of high quality
Zend Framework 2/3
Build robust web
applications
Azure PHP
Quick time to market
Scale up and out
jQuery
Professional jQuery
PHP 7
Learn the web language
that powers 80% of the
internet
On-site Training
Personal coaching and
mentoring on-site
Training courses 2016 - 2017
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 35
phpcon.eu
Ticket sales start soon!
January 27 & 28 in Antwerp (Belgium)
www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 36
https://goo.gl/images/dKsFdO
1 of 36

Recommended

Docker for Developers - Sunshine PHP by
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPChris Tankersley
812 viewsβ€’97 slides
SunshinePHP 2017 - Making the most out of MySQL by
SunshinePHP 2017 - Making the most out of MySQLSunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLGabriela Ferrara
1.1K viewsβ€’58 slides
My app is secure... I think by
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
642 viewsβ€’123 slides
JWT - To authentication and beyond! by
JWT - To authentication and beyond!JWT - To authentication and beyond!
JWT - To authentication and beyond!LuΓ­s Cobucci
3.8K viewsβ€’89 slides
PHP UK 2017 - Don't Lose Sleep - Secure Your REST by
PHP UK 2017 - Don't Lose Sleep - Secure Your RESTPHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your RESTAdam Englander
666 viewsβ€’64 slides
Open source for a successful business by
Open source for a successful businessOpen source for a successful business
Open source for a successful businessMichelangelo van Dam
589 viewsβ€’70 slides

More Related Content

Viewers also liked

Testing with Docker by
Testing with DockerTesting with Docker
Testing with Dockertoffermann
5.9K viewsβ€’56 slides
The road to php 7.1 by
The road to php 7.1The road to php 7.1
The road to php 7.1Michelangelo van Dam
2.1K viewsβ€’33 slides
200K+ reasons security is a must by
200K+ reasons security is a must200K+ reasons security is a must
200K+ reasons security is a mustMichelangelo van Dam
1.8K viewsβ€’75 slides
Code Coverage for Total Security in Application Migrations by
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsDana Luther
328 viewsβ€’29 slides
Debugging Effectively - SunshinePHP 2017 by
Debugging Effectively - SunshinePHP 2017Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017Colin O'Dell
432 viewsβ€’72 slides
Dip Your Toes in the Sea of Security by
Dip Your Toes in the Sea of SecurityDip Your Toes in the Sea of Security
Dip Your Toes in the Sea of SecurityJames Titcumb
463 viewsβ€’88 slides

Viewers also liked(19)

Testing with Docker by toffermann
Testing with DockerTesting with Docker
Testing with Docker
toffermannβ€’5.9K views
Code Coverage for Total Security in Application Migrations by Dana Luther
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
Dana Lutherβ€’328 views
Debugging Effectively - SunshinePHP 2017 by Colin O'Dell
Debugging Effectively - SunshinePHP 2017Debugging Effectively - SunshinePHP 2017
Debugging Effectively - SunshinePHP 2017
Colin O'Dellβ€’432 views
Dip Your Toes in the Sea of Security by James Titcumb
Dip Your Toes in the Sea of SecurityDip Your Toes in the Sea of Security
Dip Your Toes in the Sea of Security
James Titcumbβ€’463 views
A World Without PHP by Ben Marks
A World Without PHPA World Without PHP
A World Without PHP
Ben Marksβ€’649 views
Learn To Test Like A Grumpy Programmer - 3 hour workshop by chartjes
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshop
chartjesβ€’746 views
Amp your site: An intro to accelerated mobile pages by Robert McFrazier
Amp your site: An intro to accelerated mobile pagesAmp your site: An intro to accelerated mobile pages
Amp your site: An intro to accelerated mobile pages
Robert McFrazierβ€’544 views
A recommendation engine for your php application by Michele Orselli
A recommendation engine for your php applicationA recommendation engine for your php application
A recommendation engine for your php application
Michele Orselliβ€’9.6K views
From Docker to Production - SunshinePHP 2017 by Chris Tankersley
From Docker to Production - SunshinePHP 2017From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017
Chris Tankersleyβ€’853 views
Taming the resource tiger by Elizabeth Smith
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
Elizabeth Smithβ€’603 views
Testing strategies for Docker containers by Alexei Ledenev
Testing strategies for Docker containersTesting strategies for Docker containers
Testing strategies for Docker containers
Alexei Ledenevβ€’2.7K views
WordPress for the modern PHP developer by Chris Sherry
WordPress for the modern PHP developerWordPress for the modern PHP developer
WordPress for the modern PHP developer
Chris Sherryβ€’2.5K views
Docker Testing by Alex Soto
Docker TestingDocker Testing
Docker Testing
Alex Sotoβ€’810 views
Community works for business - LoneStarPHP 2014 by Michelangelo van Dam
Community works for business - LoneStarPHP 2014Community works for business - LoneStarPHP 2014
Community works for business - LoneStarPHP 2014
Michelangelo van Damβ€’4.4K views
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes by NLJUG
Using Docker to Develop, Test and Run Maven Projects - Wouter DanesUsing Docker to Develop, Test and Run Maven Projects - Wouter Danes
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
NLJUGβ€’5.5K views
DevOps Summit 2015 Presentation: Continuous Testing At the Speed of DevOps by Sailaja Tennati
DevOps Summit 2015 Presentation: Continuous Testing At the Speed of DevOpsDevOps Summit 2015 Presentation: Continuous Testing At the Speed of DevOps
DevOps Summit 2015 Presentation: Continuous Testing At the Speed of DevOps
Sailaja Tennatiβ€’8.3K views

More from Michelangelo van Dam

GDPR Art. 25 - Privacy by design and default by
GDPR Art. 25 - Privacy by design and defaultGDPR Art. 25 - Privacy by design and default
GDPR Art. 25 - Privacy by design and defaultMichelangelo van Dam
114 viewsβ€’39 slides
Moving from app services to azure functions by
Moving from app services to azure functionsMoving from app services to azure functions
Moving from app services to azure functionsMichelangelo van Dam
568 viewsβ€’40 slides
Privacy by design by
Privacy by designPrivacy by design
Privacy by designMichelangelo van Dam
785 viewsβ€’69 slides
DevOps or DevSecOps by
DevOps or DevSecOpsDevOps or DevSecOps
DevOps or DevSecOpsMichelangelo van Dam
994 viewsβ€’63 slides
Privacy by design by
Privacy by designPrivacy by design
Privacy by designMichelangelo van Dam
1.1K viewsβ€’73 slides
Continuous deployment 2.0 by
Continuous deployment 2.0Continuous deployment 2.0
Continuous deployment 2.0Michelangelo van Dam
1.4K viewsβ€’73 slides

More from Michelangelo van Dam(20)

GDPR Art. 25 - Privacy by design and default by Michelangelo van Dam
GDPR Art. 25 - Privacy by design and defaultGDPR Art. 25 - Privacy by design and default
GDPR Art. 25 - Privacy by design and default
Michelangelo van Damβ€’114 views
Moving from app services to azure functions by Michelangelo van Dam
Moving from app services to azure functionsMoving from app services to azure functions
Moving from app services to azure functions
Michelangelo van Damβ€’568 views
General Data Protection Regulation, a developer's story by Michelangelo van Dam
General Data Protection Regulation, a developer's storyGeneral Data Protection Regulation, a developer's story
General Data Protection Regulation, a developer's story
Michelangelo van Damβ€’1.5K views
Leveraging a distributed architecture to your advantage by Michelangelo van Dam
Leveraging a distributed architecture to your advantageLeveraging a distributed architecture to your advantage
Leveraging a distributed architecture to your advantage
Michelangelo van Damβ€’1.5K views
Decouple your framework now, thank me later by Michelangelo van Dam
Decouple your framework now, thank me laterDecouple your framework now, thank me later
Decouple your framework now, thank me later
Michelangelo van Damβ€’1K views
Zf2 how arrays will save your project by Michelangelo van Dam
Zf2   how arrays will save your projectZf2   how arrays will save your project
Zf2 how arrays will save your project
Michelangelo van Damβ€’1.3K views
PHPUnit Episode iv.iii: Return of the tests by Michelangelo van Dam
PHPUnit Episode iv.iii: Return of the testsPHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the tests
Michelangelo van Damβ€’872 views
Easily extend your existing php app with an api by Michelangelo van Dam
Easily extend your existing php app with an apiEasily extend your existing php app with an api
Easily extend your existing php app with an api
Michelangelo van Damβ€’1.5K views
90K Reasons Security is a Must - PHPWorld 2014 by Michelangelo van Dam
90K Reasons Security is a Must - PHPWorld 201490K Reasons Security is a Must - PHPWorld 2014
90K Reasons Security is a Must - PHPWorld 2014
Michelangelo van Damβ€’2.2K views
Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014 by Michelangelo van Dam
Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014
Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014
Michelangelo van Damβ€’1.6K views

Recently uploaded

SPICE PARK DEC2023 (6,625 SPICE Models) by
SPICE PARK DEC2023 (6,625 SPICE Models) SPICE PARK DEC2023 (6,625 SPICE Models)
SPICE PARK DEC2023 (6,625 SPICE Models) Tsuyoshi Horigome
28 viewsβ€’218 slides
GDSC Mikroskil Members Onboarding 2023.pdf by
GDSC Mikroskil Members Onboarding 2023.pdfGDSC Mikroskil Members Onboarding 2023.pdf
GDSC Mikroskil Members Onboarding 2023.pdfgdscmikroskil
53 viewsβ€’62 slides
Searching in Data Structure by
Searching in Data StructureSearching in Data Structure
Searching in Data Structureraghavbirla63
7 viewsβ€’8 slides
Investor Presentation by
Investor PresentationInvestor Presentation
Investor Presentationeser sevinΓ§
25 viewsβ€’26 slides
Ansari: Practical experiences with an LLM-based Islamic Assistant by
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic AssistantM Waleed Kadous
5 viewsβ€’29 slides
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc... by
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...csegroupvn
5 viewsβ€’210 slides

Recently uploaded(20)

SPICE PARK DEC2023 (6,625 SPICE Models) by Tsuyoshi Horigome
SPICE PARK DEC2023 (6,625 SPICE Models) SPICE PARK DEC2023 (6,625 SPICE Models)
SPICE PARK DEC2023 (6,625 SPICE Models)
Tsuyoshi Horigomeβ€’28 views
GDSC Mikroskil Members Onboarding 2023.pdf by gdscmikroskil
GDSC Mikroskil Members Onboarding 2023.pdfGDSC Mikroskil Members Onboarding 2023.pdf
GDSC Mikroskil Members Onboarding 2023.pdf
gdscmikroskilβ€’53 views
Searching in Data Structure by raghavbirla63
Searching in Data StructureSearching in Data Structure
Searching in Data Structure
raghavbirla63β€’7 views
Investor Presentation by eser sevinΓ§
Investor PresentationInvestor Presentation
Investor Presentation
eser sevinΓ§β€’25 views
Ansari: Practical experiences with an LLM-based Islamic Assistant by M Waleed Kadous
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic Assistant
M Waleed Kadousβ€’5 views
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc... by csegroupvn
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
Design of Structures and Foundations for Vibrating Machines, Arya-ONeill-Pinc...
csegroupvnβ€’5 views
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx by lwang78
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
lwang78β€’83 views
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ... by AltinKaradagli
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...
Investigation of Physicochemical Changes of Soft Clay around Deep Geopolymer ...
AltinKaradagliβ€’12 views
MongoDB.pdf by ArthyR3
MongoDB.pdfMongoDB.pdf
MongoDB.pdf
ArthyR3β€’35 views
_MAKRIADI-FOTEINI_diploma thesis.pptx by fotinimakriadi
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptx
fotinimakriadiβ€’8 views
Generative AI Models & Their Applications by SN
Generative AI Models & Their ApplicationsGenerative AI Models & Their Applications
Generative AI Models & Their Applications
SNβ€’8 views
MSA Website Slideshow (16).pdf by msaucla
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdf
msauclaβ€’76 views
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth by Innomantra
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth
Innomantra β€’6 views
REACTJS.pdf by ArthyR3
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
ArthyR3β€’27 views
DevOps-ITverse-2023-IIT-DU.pptx by Anowar Hossain
DevOps-ITverse-2023-IIT-DU.pptxDevOps-ITverse-2023-IIT-DU.pptx
DevOps-ITverse-2023-IIT-DU.pptx
Anowar Hossainβ€’12 views
Effect of deep chemical mixing columns on properties of surrounding soft clay... by AltinKaradagli
Effect of deep chemical mixing columns on properties of surrounding soft clay...Effect of deep chemical mixing columns on properties of surrounding soft clay...
Effect of deep chemical mixing columns on properties of surrounding soft clay...
AltinKaradagliβ€’9 views

Dockerize your unit tests for faster feedback

  • 1. DOCKERIZE YOUR UNIT TESTS FOR FASTER FEEDBACK Let’s speed up your tests! https://goo.gl/images/OdSqB4
  • 2. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 2 FotobyAnnaFilinaatBGPHP16
  • 3. Michelangelo van Dam β€£ Pro PHP consultant at in2it β€£ President of PHPBenelux β€£ Open-Source contributor β€£ Conference Speaker β€£ ZCE and ZF-CE in itPROFESSIONAL PHP SERVICES PHPUnit + Docker = πŸš—πŸ’¨ 3
  • 4. PHPUNIT www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 4 https://goo.gl/images/eBa0vw
  • 5. EXTRAS TO RUN PHPUNIT www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 5 β€£ Command-line? β€£ Run from IDE? β€£ Test server? β€£ Jenkins, TeamCity, Bamboo? β€£ Vagrant? β€£ Docker? https://goo.gl/images/l0HXj7
  • 6. DRAWBACKS www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 6 β€£ Takes long time for many tests β€£ Environment not always ready for testing β€£ Tests don’t provide good feedback https://goo.gl/images/TajZrP
  • 7. SYSTEM FAILURES www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 7 β€£ Memory Exhausted β€£ Disk full β€£ No network or network latency β€£ Systems crash https://goo.gl/images/ruod6b
  • 8. DOCKER www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 8 https://goo.gl/images/vhDEGy
  • 9. WHAT IS DOCKER? www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 9 β€£ Technology platform β€£ Run processes in separate containers β€£ Scales fast and seemlessly β€£ Containers are easy shippable β€£ Best next thing since sliced bread https://goo.gl/images/xEfLk5
  • 10. DOCKER USAGE www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 10 β€£ Mimic distributed architectures β€£ Isolate applications β€£ Run single purpose commands https://goo.gl/images/LIfWVb
  • 11. DEMO TIME www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 11
  • 12. RUN THEM ALL www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 12 https://goo.gl/images/grh4mu
  • 13. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 13
  • 14. USING @GROUP www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 14 https://www.flickr.com/photos/bgphp/21210790293
  • 15. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 15
  • 16. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 16
  • 17. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 17 for i in `./vendor/bin/phpunit --list-groups | grep "^ -" | awk {'print $2'}`; do ./vendor/bin/phpunit --group $i; done;
  • 18. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 18
  • 19. SHIP IT WITH DOCKER!!! www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 19 https://goo.gl/images/Fo0dVi
  • 20. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 20 docker run -ti --rm -v "$PWD":/usr/src/myapp -w /usr/ src/myapp php:7.0-cli ./vendor/bin/phpunit
  • 21. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 21
  • 22. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 22 https://www.gnu.org/software/parallel/
  • 23. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 23 for i in `./vendor/bin/phpunit β€”list-groups | grep "^ -β€œ | awk {'print $2'}`; do echo $i; done | /usr/local/ bin/parallel docker run -v "$PWD":/usr/src/myapp -w / usr/src/myapp php:7.0-cli ./vendor/bin/phpunit --log- junit=build/junit-{}.xml --group {}
  • 24. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 24
  • 25. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 25 for i in `./vendor/bin/phpunit β€”list-groups | grep "^ -β€œ | awk {'print $2'}`; do echo $i; done | time /usr/ local/bin/parallel docker run -d -v "$PWD":/usr/src/ myapp -w /usr/src/myapp php:7.0-cli ./vendor/bin/ phpunit --log-junit=build/junit-{}.xml --group {}
  • 26. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 26
  • 27. WHERE ARE MY FAILURES? www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 27 https://goo.gl/images/VWpYFO
  • 28. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 28 for i in `./vendor/bin/phpunit --list-groups | grep "^ -" | awk {'print $2'}`; do echo $i; done | time parallel docker run -d -v "$PWD":/var/run/phpunit -w / var/run/phpunit --name pu-docker-{} php:7.0-cli /var/ run/phpunit/vendor/bin/phpunit --group {} && for i in `./vendor/bin/phpunit --list-groups | grep "^ -" | awk {'print $2'}`; do docker wait pu-docker-$i | grep -c 0 > /dev/null || docker logs pu-docker-$i && docker rm -f pu-docker-$i > /dev/null; done;
  • 29. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 29 β€£ loop over our @group list entries β€£ run these in docker (daemonized) β€£ loop over our @group list entries β€£ fetch the exit status of phpunit from the containers β€£ if not 0 -> show us the failure
  • 30. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 30
  • 31. #FTW #PARTY #AWESOME www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 31 https://goo.gl/images/uWs8N0
  • 32. OTHER SCENARIOS www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 32 β€£ Test on different PHP versions β€£ Test separation based on TestSuite, Directory, … β€£ Testing long running integration tests separately β€£ Resilience testing https://goo.gl/images/JnY8yr
  • 33. QUESTIONS www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 33 https://goo.gl/images/mM3D3j
  • 34. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 34 PHPUnit/Unit Testing Ensure your apps are of high quality Zend Framework 2/3 Build robust web applications Azure PHP Quick time to market Scale up and out jQuery Professional jQuery PHP 7 Learn the web language that powers 80% of the internet On-site Training Personal coaching and mentoring on-site Training courses 2016 - 2017
  • 35. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 35 phpcon.eu Ticket sales start soon! January 27 & 28 in Antwerp (Belgium)
  • 36. www.in2it.be - @in2itvof PHPUnit + Docker = πŸš—πŸ’¨ 36 https://goo.gl/images/dKsFdO