22
Continuous Infrastructure Testing

Continuous infrastructure testing

Embed Size (px)

DESCRIPTION

In this talk I show a usecase to use ServerSpec to test external managed systems with ease.

Citation preview

Page 1: Continuous infrastructure testing

Continuous Infrastructure

Testing

Page 2: Continuous infrastructure testing

WHOAMI

Page 3: Continuous infrastructure testing

class daniël {

class {'::work': company => 'Inuits', location => 'Rotterdam', role => 'Open Source Consultant', contact => '[email protected]', }

class {'::social': twitter => '@dpnl87', github => 'dpnl87', blog => 'danielpaulus.com', }

}

Page 4: Continuous infrastructure testing

THE PROBLEM

Page 5: Continuous infrastructure testing

Ever worked on external managed infrastructure?

Page 6: Continuous infrastructure testing

“The application stopped working all of a sudden”

Page 7: Continuous infrastructure testing

“We didn't change anything!”

Page 8: Continuous infrastructure testing

How can we validate external managed systems?

Page 9: Continuous infrastructure testing

SERVERSPEC

Page 10: Continuous infrastructure testing

Test servers actual state through SSH access

Page 11: Continuous infrastructure testing

require 'spec_helper'

describe '<name of the resource>' do # your tests ...end

Page 12: Continuous infrastructure testing

describe user 'daniel' do

it { should exist }

it { should belong_to_group 'sudo' }

it { should have_home '/home/daniel' }

end

Page 13: Continuous infrastructure testing

describe package 'ntp' doit { should be_installed }

end

describe package 'chef' doit { should be_installed.by('gem') }

end

Page 14: Continuous infrastructure testing

describe service 'ssh' doit { should be_enabled }

end

describe process 'sshd' doit { should be_running }

end

describe file '/etc/ssh/sshd_config' doits(:content) {

should match /^PermitEmptyPasswords\W+no$/

}end

Page 15: Continuous infrastructure testing

describe file '~/.ssh/' doit { should be_directory }it { should be_mode 700 }

end

describe file '~/.ssh/authorized_keys' doit { should be_file }it { should be_mode 600 }it { should contain('daniel@inuits') }it { should be_owned_by 'daniel' }

end

Page 16: Continuous infrastructure testing

-> % rake spec

.........

Finished in 2.55 seconds9 examples, 0 failures

Page 17: Continuous infrastructure testing

AUTOMATE THE TESTS

Page 18: Continuous infrastructure testing

Show your <3 to Jenkins

Page 19: Continuous infrastructure testing
Page 20: Continuous infrastructure testing
Page 21: Continuous infrastructure testing
Page 22: Continuous infrastructure testing

DEMO