PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform...

62
Delivering Premium Quality Puppet Modules René Last & Dimitri Tischenko Puppetconf 2016 Using Beaker and VMpooler for Mul4-Pla7orm Tes4ng

Transcript of PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform...

Page 1: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

DeliveringPremiumQualityPuppetModules

RenéLast&DimitriTischenkoPuppetconf2016

Using Beaker and VMpooler for Mul4-Pla7orm Tes4ng

Page 2: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Whoarewe?

Page 3: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Agenda

AboutKPNOurproblemOursoluBon

Page 4: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

AboutKPN

Page 5: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Ourproblem

KPNdecidedtomanage10Kserversforvariousclients

withPuppet…

Page 6: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Ourproblem

…mostofthemWindows.

Page 7: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Ourproblem–consequences(1)

NeedtosupportWindows

Page 8: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Ourproblem–consequences(2)

Needtoguaranteestableandpredictableinfrastructurestate

Page 9: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Ourproblem–consequences(3)

Needtoguaranteecodequality

Page 10: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

OursoluEon(1)

Adedicatedteamtodevelopmodules

Page 11: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

OursoluEon(2)

AnautomatedtesBngfactory

Page 12: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

TesEngFactoryRequirements

AutomatedpipelineconfiguraBonPuppet3.xtestsPuppet4.xtestsUnittestsonLinuxandWindowsAcceptancetestsonallplaQorms(currently8)Runtestsinparallel

Page 13: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

ModuleCI/CDPipelineOverview

syntaxcheck

Auto

puppet-lint

rspectest

acceptancetest

ReleasetoTEST

Auto Auto Manual

ReleasetoPROD

ManualChangein

git

Periodictrigger

NoEfybymail&Hipchat

Fail Fail Fail Fail

Page 14: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

PuppetCIComponents

JenkinsMaster

JenkinsLinuxSlave

JenkinsWindowsSlave

vmpooler

GithubEnterprise

vcenter

beaker

CreateVMs

Linuxpipeline

WindowspipelineMulE-PlaXormAcceptanceTests

Syntax,lint&rspec

Syntax,lint&rspec

SystemsUnderTest

Page 15: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik
Page 16: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Jenkinsmasterandbuildslaves

rtyler/jenkinspuppetmodule

Page 17: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Ruby

maestrodev/rvmPIKoruru!=rvmL

Page 18: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Jenkinsjobs

Jenkinsjobbuilderstankevich/python

Page 19: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

PuppeEzingJenkinsJobs

puppet Yamlfile Jenkinsjobbuilder xml Jenkinsjob

Page 20: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Howtoaddamodule

1.  kpn_jenkins::pipeline::module{'kpn-puppet-forge/puppet-kpn-hosts':2.  ensure=>present,3.  test_platform=>['linux','windows'],4.  pe3_syntax=>false,5.  pe4_syntax=>true,6.  pe4_unit=>true,7.  pe3_unit=>false,8.  acceptance_test=>true,9.  acceptance_platform=>['centos-7-x64-pe4',10.  'windows-2008r2-x64',11.  'windows-2012r2-x64',12.  'windows-2008r2-x64-pe4',13.  'windows-2012r2-x64-pe4',14.  'windows-2016-x64-pe4',15.  ],16.  hipchat_notification=>true,17.  hipchat_room=>'Moduleteam',18.  email=>‘[email protected]',19.  }

Page 21: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Howtoaddamodule

Page 22: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

JenkinsMaster

JenkinsLinuxSlave

JenkinsWindowsSlave

vmpooler

GithubEnterprise

vcenterCreateVMs

WindowspipelineMulE-PlaXormAcceptanceTests

Syntax,lint&rspec

Syntax,lint&rspec

SystemsUnderTest

Beaker

beaker

Linuxpipeline

Page 23: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik
Page 24: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Beaker

AtestharnessfocusedonacceptancetesBngusing(virtual)machines

Page 25: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Beaker

Runstestson“real”servers

Page 26: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Beaker

SupportsvmproviderslikeVagrant,vSphere,docker,AWSorvmpooler

Page 27: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

BeakerInstallaEon

#geminstallbeakerbeaker-rspecbeaker-puppet_install_helper

Page 28: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

BeakerConfiguraEonspec/acceptance/nodesets/*.yml 1.  HOSTS:2.  centos-7-x64-pe4:3.  roles:4.  -agent5.  platform:el-7-x86_646.  hypervisor:vmpooler7.  template:centos-7-x648.  CONFIG:9.  masterless:true10.  pe_ver:'2016.2.0'11.  pe_promoted_builds_url:'http://repo.kpn.com/pe'12.  pooling_api:'http://vmpooler.kpn.com:4567'13.  ssh:14.  auth_methods:15.  -password16.  user:root17.  password:XXXXXXXX

Page 29: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

PrepareaSystemForTesEngspec/spec_helper_acceptance.rb 1.  require'beaker-rspec/spec_helper'2.  require'beaker-rspec/helpers/serverspec'3.  require'beaker/puppet_install_helper'4.  5.  #Installpuppetagentonanode6.  run_puppet_install_helper7.  8.  #CopyourmoduledependenciestotheSUT9.  system('[email protected]/stdlibspec/fixtures/modules/stdlib')10. 11. copy_module_to(hosts,:source=>'spec/fixtures/modules/stdlib',12. :module=>'stdlib')13. 14. #Orifyouhaveinternetaccess15. install_puppet_module_via_pmt_on(host,:module_name=>'stdlib')

Page 30: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

ExampleTestspec/acceptance/*_spec.rb 1.  require'spec_helper_acceptance'2.  3.  describe'kpn-centerity_agentmodule'do4.  context'installcenterity_agentsoftware'do5.  pp=<<-EOS6.  class{'centerity_agent':}7.  EOS8.  it'1stapplyshouldrunwithouterrors'do9.  apply_manifest(pp,:catch_failures=>true)10. end11. it'2ndapplyshouldrunwithoutchanges'do12. apply_manifest(pp,:catch_changes=>true)13. end14. end15. end

Page 31: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

TesEngforInstalledPackages

1.  context'Testinstalledsoftware'do2.  casefact('osfamily')3.  when/RedHat/4.  describepackage('sshd')do5.  it{shouldbe_installed}6.  end7.  when/windows/8.  describecommand('C:\Programs\Chocolatey\bin\clist-l')do9.  its(:stdout){shouldmatch/sshd/}10. end11. end12. end13. end

Page 32: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Run,beaker,Run!

#exportBEAKER_setfile=~/nodesets/${platform}.yml

#rakebeaker

Page 33: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

RulesforWriEngAcceptanceTests(1)

Onlytestyourpuppetcode,

notthesupplier’ssocware

Page 34: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

RulesforWriEngAcceptanceTests(2)

Abeakertestshouldbeself-contained

Page 35: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

RulesforWriEngAcceptanceTests(3)

Ifyoucanrspecit,don’tbeakerit

Page 36: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

ImprovingBeakerDocumentaEon

heps://github.com/RARYates/beaker

Page 37: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

JenkinsMaster

JenkinsLinuxSlave

JenkinsWindowsSlave

GithubEnterprise

vcenterCreateVMs

WindowspipelineMulE-PlaXormAcceptanceTests

Syntax,lint&rspec

Syntax,lint&rspec

SystemsUnderTestbeaker

vmpooler

vmpoolerLinuxpipeline

Page 38: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpooler

VmpoolerpoolsVMs

Providesconfigurablepoolsofinstantly-available

(running)virtualmachines

Page 39: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpooler

NeedsitsownDHCPzone

andproperlyconfiguredDDNS

Page 40: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpooler

Systemrunningbeakermustusevmpooler’s

nameserver

Page 41: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpooler

vmpoolerhasastrangelogo

Page 42: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpoolerinstallaEon

include‘vmpooler’

Page 43: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpooler

❝Templateset-upislecasanexercisetothereader.Somehow,eitherviaPXE,embeddedbootstrapscripts,orsomeothermethod--clonesofVMtemplatesneedtobeabletoset

theirhostname,registerthemselvesinyourDNS,andberesolvablebythevmpoolerapplicaBonacercompleBngtheclonetaskandbooBngup.

Page 44: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpoolerhostnamingpuzzle

vmname!=hostnameneedtosethostnameautomaBcallytovmnamedon’twanttogiveeachvmvspherecredenBals

so-howtodoit?

Page 45: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Just5linesofcode(2monthslater)#Annotatewithcreationtime,origintemplate,etc.#AddextraconfigoptionsthatcanbequeriedbyvmtoolsconfigSpec=RbVmomi::VIM.VirtualMachineConfigSpec(annotation:JSON.pretty_generate(name:vm['hostname'],created_by:$config[:vsphere]['username'],base_template:vm['template'],creation_timestamp:Time.now.utc),extraConfig:[{key:'guestinfo.hostname',value:vm['hostname']}])

Page 46: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Seangthehostname

Linux:#hostname=$(vmtoolsd--cmd"info-getguestinfo.hostname")Windows:>$hostname=cmd.exe/c'C:\Progra~1\VMware\vmtoolsd.exe--cmd"info-getguestinfo.hostname"'

Page 47: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

vmpoolerlessonslearned

• Canusemorelogging(PRsforthcoming)• Poolnameneedstoequaltemplatename• Docsrefertovmtemplates,needtobevms• WillnotinstallifESXhostisnot“green”• CanusebeeerexcepBonhandling

Page 48: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Conclusions

AutomatedpipelineconfiguraBonPuppet3.xtestsPuppet4.xtestsUnittestsonLinuxandWindowsAcceptancetestsonallplaQorms(currently8)Runtestsinparallel

PPP

P P

P

Page 49: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Whatdidwelearn?

+ Regressiontest+ MulBplaQorm

+ Catcherrorsearly

Page 50: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Whatdidwelearn?

Page 51: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

FutureImprovements

Speedoftests

Page 52: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik
Page 53: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

FutureImprovements

StabilityofvmpoolerWindowssupport

Page 54: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik
Page 55: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Andnow…forsomenumbers

Page 56: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

ModulesperOperaEngSystem

Windows32

Linux43

LinuxandWindows

16

Page 57: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

TestTypes

102 9479

0

20

40

60

80

100

120

Syntax Rspec(unit) Acceptance

#modules

Page 58: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

TestRunsFlow8%

Init14%

Syntax21%

Unit18%

Acceptance39%

Page 59: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Top10ModuleswithFailedTests

Page 60: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Vmpooler:AverageTimetoReady

Page 61: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

Q&A

Page 62: PuppetConf 2016: Delivering Premium Quality Modules: Using Beaker and VMpooler for Multi-Platform Testing – Rene Last, KPN B.V & Dimitri Tischenko, Myndrik

WindowsModules

•  kpn-ad_ds•  kpn-dotnet•  kpn-rdp•  kpn-kms•  kpn-chocolatey_client•  kpn-chocolatey_server•  kpn-local_security_policy