51
Dealing with Data Driven Test Combinatorial Complexity using Jenkins Job DSL

Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Dealing with Data Driven Test

Combinatorial Complexity using

Jenkins Job DSL

Page 2: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

ContentsMotivationⅠ

Jenkins Job DSL Plugin IntroductionⅡ

SummaryⅢ

Page 3: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Motivation

3

Page 4: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Original Task

4

VerdictSmoke Tests

Page 5: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Solution: Create a Jenkins Job

5

Page 6: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Let’s Extend Our Task a Little

6

Smoke Tests

(Conf1)

Smoke Tests

(Conf2)

Smoke Tests

(ConfN)

Verdict1

Verdict2

VerdictN

Page 7: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Naïve Solution 1: Just Copy the Original Job

7

Page 8: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What Could Have Possibly Go Wrong?

8

Preconditions:

1. Each configuration controls 3 parameters

2. Each parameter can take one of the 4 valid values

3. 90% of possible configurations are equally important

Total configuration number: 60

Adding a new testbed (different H/W type) doubles the number

of jobs

Page 9: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

9

Solution 1 Drawbacks

1. New job creation is tedious and error prone

2. Need to change all jobs if additional parameter or execution

step is required

3. Huge effort to recover the jobs in case of Jenkins host

failure

Maintenance nightmare!

Page 10: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Let’s Improve It: MultiJob Step with Parameters

10

1. Create parametrized template job

Page 11: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Let’s Improve It: MultiJob Job with Parameters

11

2. Create MultiJob Project and add each configuration as a

separate phase job

Page 12: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

MultiJob Project Final Configuration

12

Page 13: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Are We There Yet?

13

Let’s debug this failure

Let’s execute all the jobs

Page 14: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Hard to Debug, Unreliable Execution Trend

14

Where does it come from? Same config? Same build?

Which configuration caused the

failure?

Page 15: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Hard to Update the Configurations

15

How to change the configuration AA_11_D4?

Page 16: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Hard to Re-run the Failing Configuration

16

What should we select here?

Page 17: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

In a Nutshell…

17

Debugging Nightmare

Page 18: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Who Could Help Us?

18

Page 19: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Jenkins Job DSL Plugin

19

Page 20: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Introducing Jenkins DSL

20

From https://wiki.jenkins.io

Page 21: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Installation

21

Page 22: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Create First Seed Job

22

Page 23: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Create First Seed Job

23

Page 24: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Generate a Job from the Seed Job

24

Page 25: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Generate a Job from the Seed Job

25

Page 26: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Let’s Add Some Parameters

26

Page 27: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

… and Generate the Jobs

27

Page 28: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What’s Inside?

28

Page 29: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Now DRY It a Little…

29

Can we improve it?

Page 30: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Use a Template Job

30

Page 31: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Build Results

31

Page 32: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What’s Generated?

32

Page 33: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Bringing It All Together…

33

Groovy array

Groovy loop

Page 34: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

And the Amazing Result Is…

34

Page 35: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Most Important Parts in MultiJob Seed

35

Page 36: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What’s Missing?

36

Trigger

Page 37: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What’s Missing?

37

Result Publisher

Page 38: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

It’s a Little Bit Messy

38

Does it even belong

together?

Page 39: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Let’s Organize It Better

39

Create a Separate Folder

Page 40: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Let’s Organize It Better

40

Create a Separate View

Page 41: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What Did We Achieve?

41

Can isolate particular configuration failure

Page 42: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What Did We Achieve?

42

Execution result history is separate for each job

Page 43: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What Did We Achieve?

43

Can easily modify jobs steps or configuration at once or add a

new parametrized job

Note: Job’s execution history is preserved after job is regenerated

Page 44: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

What Did We Achieve?

44

If the lightning strikes our Jenkins host we can re-create all our

jobs easily

Page 45: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Summary

45

Page 46: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Advantages

1. First and foremost: Configuration as Code

a) Can leverage a Version Control system

b) It is easier and faster to update the jobs

c) It is easier to track and fix job configuration errors

2. Probably the easiest way to control multiple related jobs

a) Can keep jobs independent and self-sufficient

b) Apply complex modifications in one go

3. Much more pleasant and fun than just GUI clicking

46

Page 47: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Drawbacks

47

Honestly, I don’t see any

Except of some enigmatic Groovy error messages

Page 48: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

It May Help You a Little (or a Lot)

48

Jenkins Job DSL Documentation (Installed with plugin)

Page 49: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

It May Help You a Little (or a Lot)

49

Jenkins Job DSL Playground (job-dsl.herokuapp.com)

Page 50: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update

Q&A

50

Page 51: Dealing with Data Driven Test Combinatorial …...Advantages 1. First and foremost: Configuration as Code a) Can leverage a Version Control system b) It is easier and faster to update