Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout...

90
@giltayar Four Pillars and a Base: The Nuts and Bolts of a Microservice Project Gil Tayar (@giltayar) March 2019 This presentation: http://bit.ly/microservice-nuts-bolts 1

Transcript of Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout...

Page 1: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Four Pillars and a Base: The Nuts and Bolts of a Microservice

ProjectGil Tayar (@giltayar)March 2019

This presentation: http://bit.ly/microservice-nuts-bolts

1

Page 2: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar@giltayar

About Me ● My developer experience goes all the way back to the ‘80s.

● Am, was, and always will be a developer● Testing the code I write is my passion● Currently evangelist and architect @

Applitools● We deliver Visual Testing tools:

If you’re serious about testing, checkout Applitools Eyes

● Sometimes my arms bend back● But the gum I like is coming back in style

@giltayar

2

Page 3: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Four Pillars and a Base

3

Page 4: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Firefox

rendering

worker

Hea

dles

s FF

Firefox

rendering

worker

Hea

dles

s FF

Chrome

rendering

worker

Headless

Chrome

Chrome

rendering

worker

Headless

Chrome

Rendering

job

4

rendering-api

rendering job

(url, webhook,

browser-info,

auth token)

Chrome

Rendering Job

QueueChrome

rendering

worker

Headless

Chrome

render-status?

(polling)

Firefox

rendering

worker

Hea

dles

s FF

Firefox

Rendering Job

QueueRendering

job

render-status

The V

isual G

rid

Applitools Eyes

Server

This is the Visual Grid

Page 5: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Firefox

rendering

worker

Hea

dles

s FF

Firefox

rendering

worker

Hea

dles

s FF

Chrome

rendering

worker

Headless

Chrome

Chrome

rendering

worker

Headless

Chrome

Rendering

job

5

rendering-api

rendering job

(url, webhook,

browser-info,

auth token)

Chrome

Rendering Job

QueueChrome

rendering

worker

Headless

Chrome

render-status?

(polling)

Firefox

rendering

worker

Hea

dles

s FF

Firefox

Rendering Job

QueueRendering

job

render-status

The V

isual G

rid

Applitools Eyes

Server

Page 6: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

I want to talk about…

How we built the Visual Grid

6

Page 7: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

But first: why we built it the way we did7

Page 8: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Dynamic Languages vs Static Languages

8

Page 9: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar@giltayar

And It’s War!

Between

● Java, C#, C++, Haskell, Kotlin and, yes, TypeScript

and

● Python, Ruby, Clojure, and, yes,JavaScript

9

Page 10: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Static Languages Lovers: Dynamic Languages are Scary!● You can’t trust the code

○ because no type safety

● Difficult to comprehend○ because no type documentation

10

Page 11: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Static Languages Lovers: Dynamic Languages are Scary!● You can’t trust the code

○ because no type safety

● Difficult to comprehend○ because no type documentation

11

Page 12: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

12

Dynamic Typing is not a weakness to overcome,but a strength to take advantage of

But…

Page 13: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

13

Dynamic Typing is not a weakness to overcome,but a strength to take advantage of

Page 14: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Safety Nets

14

Page 15: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Dynamic Languages Force You To Be Better❖ You can’t trust the code!

➢ Testing

❖ Difficult to comprehend!➢ Loosely-coupled small packages

15

Page 16: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Dynamic Languages Drive Two Pillars16

TestingLoosely-coupled

small packages

Page 17: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

The Other Two Pillars (which give structure to the first two)17

TestingLoosely-coupled

small packagesMonorepo

Uniform

Packages

Page 18: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

And these four pillars enable the base...

18

Page 19: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

19Testing

Loosely-coupled

small packagesMonorepo

Uniform

Packages

Frictionless Development

Page 20: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

20Testing

Loosely-coupled

small packagesMonorepo

Uniform

Packages

Frictionless Development

Page 21: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Monorepo Pillar

21

Page 22: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

All Source Code is in One Git Repository

22

Page 23: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

23

Page 24: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

24

Page 25: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

25

Page 26: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Why? Why One Repo?● Remember many small packages?● Remember frictionless development?

26

Page 27: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Demo: Creating a Package is Really Easy

27

Page 28: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Packages are...● Written separately● Tested separately● Published Separately

28

Page 29: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Features spanning two packages● Write, test, publish code in package B● `npm update` in package A● Write, test in package A

Or…

● Use `npm link`● And then publish both packages

29

Page 30: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

NPM is our bridge between packages● We will never EVER use

`require('.../package-a')`.

● semver-major supports changes that upstream packages cannot use

30

Page 31: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Two-package development is not common

31

Page 32: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

VSCodeWorkspaces

32

Page 33: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Advantages of monorepos DisadvantagesSimple to move between one package and another

Simple to maintain many packages

Simple to split packages

Packages tend to be small (because easy to create)

“Common” packages are easy to develop and maintain

NPM link is bad

CI is a problem

33

Page 34: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

AdvantagesDisadvantagesSimple to move between one package and another

Simple to maintain many packages

Simple to split packages

Packages tend to be small (because easy to create)

“Common” packages are easy to develop and maintain

NPM link is bad

CI is a problem

34

Frictionless Development

Page 35: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

35Testing

Loosely-coupled

small packagesMonorepo

Uniform

Packages

Frictionless Development

Page 36: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Uniform Packages

36

Page 37: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

All happy families are alike; each unhappy family is unhappy in its own way

37

Page 38: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

All happy families are alike; each unhappy family is unhappy in its own way

-- Tolstoy, “Anna Karenina”

38

Page 39: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

All happy packages are alike; each unhappy package is unhappy in its own way

-- Gil Tayar, “Applitools”

39

Page 40: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

All our packages are happy!● They are uniform in the way we build, test, and publish them.

● They are the same in their folder structure○ but that’s optional

40

Page 41: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Build Uniformity

41

Page 42: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

(in our monorepo)

A package is source code that can generate artifacts,which are used by other packages or in production

What is a Package?42

Page 43: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Two Examples of Packages and their Artifacts❖ Library package

➢ Artifact: an npm package in the repository

❖ Microservice package➢ Artifact: a Docker image to be used in production➢ Artifact: configuration values to be used in production➢ Artifact: an npm package in the repository

43

Page 44: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

A package in our monorepo is an npm package❖ npm install

➢ Bring in the dependent artifacts, and any artifact needed to build this one

❖ npm update

➢ Update dependencies to latest (without breaking backward compatibility)

❖ npm run build

➢ Build the artifact (optional for JavaScript)

❖ npm test

➢ Test the artifact to ensure that it can be published

❖ npm publish

➢ Publish the artifact(s)

❖ npm run deploy

➢ Deploy the artifact to production (only for microservices)

Note: we can use postpublish/postinstall to do more non-npm stuff.

44

Page 45: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Example from a Library Package"scripts": {

"build": "#", // Yay JavaScript!

"test": "npm run eslint && npm run test:mocha-parallel",

"test:mocha": "mocha 'test/unit/*.test.js'

'test/it/*.test.js' 'test/e2e/*.test.js'",

"test:mocha-parallel": "mocha-parallel-tests 'test/unit/*.test.js'

'test/it/*.test.js' 'test/e2e/*.test.js'",

"eslint": "eslint '**/*.js'"

},

45

Page 46: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Example from a Microservice Package"scripts": {

"build": "npm run build:docker",

"build:docker": "docker build -t applitools/chrome-rendering-worker

--build-arg NPM_FILE=`cat ~/.npmrc` .",

"test": "npm run eslint && npm run test:mocha",

"postpublish": "npm run publish:docker",

"publish:docker": "docker tag applitools/chrome-rendering-worker

applitools/chrome-rendering-worker:${npm_package_version} &&

docker push applitools/chrome-rendering-worker:${npm_package_version}

&&

docker push applitools/chrome-rendering-worker:latest",

"deploy": "kdeploy deploy chrome-rendering-worker ${npm_package_version}"

}

46

Page 47: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

AdvantagesDisadvantagesDevelopers can start developing (and

deploying) all packages without understanding anything.

CI (when we have it) will be easier

Sometimes it’s like fitting a square into a circle.

47

Page 48: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

AdvantagesDisadvantagesDevelopers can start developing (and

deploying) all packages without understanding anything.

CI (when we have it) will be easier

Sometimes it’s like fitting a square into a circle.

48

Frictionless Development

Page 49: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Source Code Uniformity

49

Page 50: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Folder Structure50

Page 51: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Source Code Structure51

src and scripts● entrypoint has same name as

package.● All source is inside there.● Whitelist the npm published files

Page 52: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Source Code Structure52

Microservice src and script● src exports a web app● scripts runs the web app. This is

what the Dockerfile runs.

Page 53: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Source Code Structure53

Support files● .vscode for easy debugging● test folder each package● Eslint and prettier

Page 54: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

54Testing

Loosely-coupled

small packagesMonorepo

Uniform

Packages

Frictionless Development

Page 55: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Testing

55

Page 56: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Rule #1:Never EVER EVER run your code locally

(except in a test)

56

Page 57: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

… And You Don’t Have To Test❖ Want to write your feature and immediately deploy it?

➢ Sure!➢

❖ Otherwise, write a test

57

Page 58: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Testing is the epitome ofFrictionless Development

58

Page 59: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Testing is the epitome ofFrictionless Development

59

a person or thing that is

a perfect example of a

particular quality or type

Page 60: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

It is the main reason our velocity is high

60

Page 61: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

It is one of the two reasons we don’t needTypeScript

61

Page 62: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

And I frankly don’t know today how to go to production without tests

62

Page 63: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

But enough crapLet’s see how we test our microservices

63

Page 64: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Unit Testing● Test functions or modules that are mainly algorithmic,

with little to no I/O.○ We mostly don’t write classes

● Usually stateless functions● No need for mocking

○ or the mock is so simple we don’t use a mocking library

● We don’t have a lot of these tests

64

Page 65: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Testing isBlankImageconst isBlankImage = require('../../src/is-blank-image')

describe('isBlankImage', function() {

it('should return true on a blank image', async () => {

const newImage = PNG.createImage({

filterType: 4,

})

const blankImage = await p(newImage.parse.bind(newImage))(

await p(fs.readFile)(path.join(__dirname, 'resources/blank-image.png')),

)

expect(await isBlankImage(blankImage)).to.be.true

})

65

Page 66: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Integration Tests● Test the whole microservice (or large parts thereof)

○ Remember: Microservices are small, so no problem

● If we need a database or the like, we use docker with docker-compose.

● Lots of these tests

66

Page 67: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

const app = require('../..')

function setupApp(app) {

let server

before(async () => {

await new Promise((resolve, reject) => {

server = app({maxNumberOfScreenshots: 50}).

listen(err => (err ? reject(err) : resolve()))

})

})

after(done => server.close(done))

return {

address: () => `localhost:${server.address().port}`,

}

67

Page 68: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

68

describe('screenshot-webhook-app-testkit it', function() {

const {address} = setupApp(app)

it('screenshot count should be correct after accepting a screenshot', async () => {

const screenshotId = `id-${(Math.random() * 100000) | 0}`

const countBefore = await countScreenshots({address: address()})

const response = await fetch(`http://${address()}/accept/screenshotId`, {

method: 'POST',

body: Buffer.from('dummy!'),

})

expect(response.ok).to.be.true

expect(await countScreenshots({address: address()})).to.equal(countBefore + 1)

})

Page 69: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

docker-compose.xml

services:

redis:

image: redis:alpine

ports:

- 6379

command:

- --requirepass

- apassword

69

Page 70: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

E2E Tests● Misnamed—doesn’t test all the microservices.

○ These are tests for one microservice● They do a minimal test for the docker image,

○ to see that it runs○ and passes the environment variables correctly to the app.

● Looks just like the integration○ The docker-compose.xml also includes a container for the

microservice itself.

70

Page 71: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

The Diamond Of Testing

Unit

Integration

E2E

71

Page 72: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar72

How Do I Know I Wrote Enough Tests?

The Shakometer

Page 73: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

● Special package● Deploys all microservices to minikube● And runs tests on all the system● Deployment uses same deployment mechanism as

for production and same configuration values● We run it only sometimes

The E2E Package73

Page 74: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

74Testing

Loosely-coupled

small packagesMonorepo

Uniform

Packages

Frictionless Development

Page 75: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Loosely-CoupledSmall Packages

75

Page 76: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Why● Each Microservice and library is easy to understand● Which means that it is easy to test● Which means that testing is possible● Which is why we don’t need TypeScript

○ We’ve started exploring TypeScript JSDocs

76

Frictionless Development

Page 77: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

CI/CD

77

Page 78: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Mini-CI: BTP

78

Page 79: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

It just runs these steps...❖ Increment version

❖ npm ci

❖ npm update

❖ npm run build

❖ npm test

❖ npm publish

79

Page 80: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

CD: K8s Makes It So Easy80

● And yet I’ve managed to complicate it○ Prodigious use of over-design○ Not to mention over-engineered○ A simple set of yaml files, with some templating, would have

sufficed

● YAGNI!● KISS!

Page 81: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

It’s all Kubernetes Template YAMLs (using Helm)81

Page 82: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Which is customized per microservice82

Page 83: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

npm run deploy

83

Page 84: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

In Summary

84

Page 85: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

85Testing

Loosely-coupled

small packagesMonorepo

Uniform

Packages

Frictionless Development

Page 86: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

I’ll Leave You With These Three Things:

86

Page 87: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar87

Page 88: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

Small is Beautiful

88

Page 89: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

And above all: KISS

Page 90: Four Pillars and a Base: The Nuts and Bolts of a …...If you’re serious about testing, checkout Applitools Eyes Sometimes my arms bend back But the gum I like is coming back in

@giltayar

90Testing

Loosely-coupled

small packagesMonorepo

Uniform

Packages

Frictionless Development

Thank You!