Unlocking Developer Productivity: A Dual Perspective on Best Practices & Testing

A presentation at Montreal JUG Meeting October 2023 in October 2023 in Montreal, QC, Canada by Baruch Sadogursky

Slide 1

Slide 1

Slide 2

Slide 2

Slide 3

Slide 3

Slide 4

Slide 4

Slide 5

Slide 5

Baruch Sadogursky - @jbaru ch × Developer Productivity Advocate × Gradle Inc × Development -> DevOps -> #DPE

Slide 6

Slide 6

Eli Aleyner - @ealeyner × × × × Co-founder AtomicJar Inc Founding team @AWS Founding team @Bing.com

Slide 7

Slide 7

shownotes × × × × speaking.jbaru.ch Slides Video All the links!

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

Don’t ruin the flow

Slide 11

Slide 11

“The build takes forever, I am distracted to do other things and the context switch is terrible”

Slide 12

Slide 12

Slide 13

Slide 13

Don’t frustrate the developers

Slide 14

Slide 14

“we have a flanky test, it is irrelevant 99.5% of the time , but it always runs and it is last in the suite”

Slide 15

Slide 15

Slide 16

Slide 16

Don’t boil the frog

Slide 17

Slide 17

“I have a feeling that everything is slower somehow…”

Slide 18

Slide 18

Slide 19

Slide 19

Developer Productivity == A/M Autonomy /P == motivation Tools and people aren’t in my way Mastery Tools and processes help me to excel Purpose I want to be productive, i.e. create the product

Slide 20

Slide 20

Developer productivity Enginee ring!

Slide 21

Slide 21

Developer Productivity Enginee Foster Faster Feedback Collaborate through Effective Tooling Eliminate Toil for Developers Dedicated Organizational Mindset ring Embrace Rigorous Observability for Proactive Improvement Prioritize Automation and Eliminate Bottlenecks Outcomes Over Output

Slide 22

Slide 22

Talk is cheap, show me the goods! 22

Slide 23

Slide 23

Small DPE improvements make a × × × × × huge difference Generate code faster: Better IDE Test better: Testcontainers Enforce better code: Sonar Test more reliably: Flaky test detection Foster Faster Feedback:

Slide 24

Slide 24

feedback efficiency × × × × IDE: Sub-seconds (I type, it marks it red) Build: Seconds CI: Minutes Production: Hours/Days

Slide 25

Slide 25

Reverse dependency on distance from developers IDE Build CI Feedback Time Faster Slower Distance from Developers Expected Production

Slide 26

Slide 26

Reverse dependency on distance from developers IDE Build CI Production Feedback Time Faster Slower Distance from Developers Expected Real

Slide 27

Slide 27

Slide 28

Slide 28

It is slow!

Slide 29

Slide 29

Slide 30

Slide 30

It is slow and the developers h ave no idea why!

Slide 31

Slide 31

What is build? × × × × × Project setup Downloading the Internet Artifact generation: Compilation, packaging, etc Tests Artifact deployment

Slide 32

Slide 32

What can go wrong? × × × × × Project setup Downloading the Internet Artifact generation: Compilation, packaging, etc Tests Artifact deployment

Slide 33

Slide 33

When can it go wrong? At any time.

Slide 34

Slide 34

The Build frustrates the developers

Slide 35

Slide 35

Let’s ask Chatgpt

Slide 36

Slide 36

What the actual f*ck?! × Skipping tests defeats the purpose of the build! × How about skipping compilation? × We want faster feedback, not less feedback

Slide 37

Slide 37

What feedback do we want?

Slide 38

Slide 38

Ci/cd pipeline quality gates It compiles Basic Integration tests Basic Unit tests Basic Quality Linting Quality Code coverage Dependency scanning SAST/DAST Quality Sec Static code analysis Sec Sec Secrets scanning Resource Utilization Nonfunc Nonfunc Load Testing Nonfunc Compliance

Slide 39

Slide 39

Slide 40

Slide 40

Two types of feedback x e.g., CI/CD x we never wait for it x results are distracting x e.g., build x we’ll wait for it in the flow x we’ll be pissed off when it’s slow

Slide 41

Slide 41

Reverse dependency on distance from developers Faster IDE Build CI Feedback Time Commit time synchronous asynchronous Slower Distance from Developers Production

Slide 42

Slide 42

Ideal build time feedback It compiles Basic Integration tests Basic Unit tests Basic Quality Linting Quality Code coverage Dependency scanning SAST/DAST Quality Sec Static code analysis Sec Sec Secrets scanning Resource Utilization Nonfunc Nonfunc Load Testing Nonfunc Compliance

Slide 43

Slide 43

Slide 44

Slide 44

Delightful build (pick two): ☑ provides max feedback ☑ fast

Slide 45

Slide 45

Skip what can be skipped (but no more!)

Slide 46

Slide 46

Avoidance: Incremental build × Don’t build what didn’t changed × Don’t build what isn’t affected

Slide 47

Slide 47

Avoidance: Incremental build s hortcomings × Relies on produced artifacts × Relies on architectural desicions

Slide 48

Slide 48

Avoidance: Caching × × × × Makes the build faster Makes the build faster for everybody Makes the build faster always Makes all parts of the build faster

Slide 49

Slide 49

Slide 50

Slide 50

Avoidance: Predictive test selec tion × Learns code changes effects de-facto × Skips tests with high degree of confidence

Slide 51

Slide 51

Slide 52

Slide 52

Speed up what can’t be skipped

Slide 53

Slide 53

Test parallelization × Use max power of local machine × (Yes, your boss should buy you the bleeding edge)

Slide 54

Slide 54

Slide 55

Slide 55

Test distribution × × × × CI uses fan-out to speed-up tests Shouldn’t you enjoy it for local tests? Use the cloud to distribute test load RUN ALL THE TESTS!

Slide 56

Slide 56

Why not just using ci fan-out ? × Relying on shared CI infrastructure × CI infrastructure is not optimized for real-time feedback! × Are the agents as fast as they can be?

Slide 57

Slide 57

Don’t let it slide

Slide 58

Slide 58

Observe and improve × Measure local build times across time and environments × Detect downfacing trends × Find root causes and improve

Slide 59

Slide 59

Slide 60

Slide 60

Same tradeoff for tests expensive, slow, but prod-like Or naïve, useless, but fast

Slide 61

Slide 61

CI often depends on Staging environments But fixing staging environments is just “faster horses” Value of Staging Environment tests degrades over time as they become longer to run, provide flaky outcomes, while still sitting too far from Software Development Lifecycle project maturity Cost of maintaining Staging Environment based tests increases as projects mature project maturity

Slide 62

Slide 62

Modern Infrastructure Has Made Testing Harder For Developers

Slide 63

Slide 63

The Testcontainers Experience Unit tests with real dependencies

Slide 64

Slide 64

Unit Tests with Real Dependencies Testcontainers is an open source framework for providing throwaway, lightweight instances of databases, message brokers, web browsers, or just about anything that can run in a Docker container.

Slide 65

Slide 65

Testcontainers is an open source framework for providing throwaway, lightweight instances of test dependencies. GenericContainer redis = new GenericContainer(“redis:5.0.3-alpine”) .withExposedPorts(6379)

Slide 66

Slide 66

Slide 67

Slide 67

Testcontainers is used by

Slide 68

Slide 68

Test against any database, message broker, browser… or just about anything that runs in a Docker container!

Slide 69

Slide 69

testcontainers.com/modules

Slide 70

Slide 70

Testcontainers libraries exist for all popular languages including Java, Go, .NET, NodeJS, and more. Java Python Go .NET Node.js Rust Haskell Ruby

Slide 71

Slide 71

Simple Local Development with Real Dependencies Testcontainers Desktop is the free companion app to open source Testcontainers libraries.

Slide 72

Slide 72

Testcontainers Desktop The free companion app. Debug your Testcontainerspowered dependencies Track and analyze your test sessions Switch container runtimes and burst to the cloud The app lets you proxy any service to a fixed port to easily inspect it with your favorite debugging tools. Dashboards that provide you and your team with insights into your development and testing patterns. With Testcontainers Cloud, you can even run them in the cloud on demand, while saving your local resources.

Slide 73

Slide 73

Testcontainers Cloud: Test without limits. Ship with confidence. Developer-first Testing Effortlessly Fast CI Reliable Test Suites Test everything on your laptop without worrying about resources; no local docker daemon needed Run your ever-growing test suite without scaling your CI, and speed it up by running tests in parallel Enhance team efficiency by getting rid of flaky tests and ensuring consistency from dev to CI

Slide 74

Slide 74

How it works

Slide 75

Slide 75

The gains are real!

Slide 76

Slide 76

Slide 77

Slide 77

Slide 78

Slide 78

Learn more and try it today! × × × × Take the Gradle/Maven Speed Challenge! Be DPE Agent of Change! Read the DPE Handbook! Watch the DPE Summit videos! x speaking.jbaru.ch

Slide 79

Slide 79