continuous infrastructure testing

Post on 11-Jun-2015

390 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

Continuous Infrastructure

Testing

WHOAMI

class daniël {

class {'::work': company => 'Inuits', location => 'Rotterdam', role => 'Open Source Consultant', contact => 'daniel@inuits.eu', }

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

}

THE PROBLEM

Ever worked on external managed infrastructure?

“The application stopped working all of a sudden”

“We didn't change anything!”

How can we validate external managed systems?

SERVERSPEC

Test servers actual state through SSH access

require 'spec_helper'

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

describe user 'daniel' do

it { should exist }

it { should belong_to_group 'sudo' }

it { should have_home '/home/daniel' }

end

describe package 'ntp' doit { should be_installed }

end

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

end

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

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

-> % rake spec

.........

Finished in 2.55 seconds9 examples, 0 failures

AUTOMATE THE TESTS

Show your <3 to Jenkins

DEMO

top related