SlideShare una empresa de Scribd logo
Test DrivenTest Driven
InfrastructureInfrastructure
Angel NúñezAngel Núñez
@snahider@snahider
Agile Developer,Agile Developer,
Consultant & TrainerConsultant & Trainer
InfrastructureInfrastructure
asas
CodeCode
Desafíos deDesafíos de
Operaciones e InfrastructuraOperaciones e Infrastructura
Alta disponibilidad.
Respuesta rápida a petición de infraestructura.
Evitar 'Configuration Drifts'.
Alta confianza al realizar cambios.
Auditoría, versionamiento y seguimiento a los cambios.
Scripts y Virtualización noScripts y Virtualización no
son suficientes.son suficientes.
¿Qué es¿Qué es
Infrastructure as Code?Infrastructure as Code?
Significa escribir código
(usualmente utilizando un lenguaje de alto nivel)
para aprovisionar la infraestructura
(proveer todo lo necesario para su funcionamiento)
utilizando buenas prácticas de desarrollo de software
(prácticas que ya se utilizan en el desarrollo de aplicaciones).
Aparecen las HerramientasAparecen las Herramientas
PuppetPuppet ChefChef
package { 'apache2':
ensure => installed,
}
service { 'apache2':
ensure => running,
require => Package['apache2'],
}
file { '/var/www/html/index.html':
content => '<html>hello world</html>',
owner => 'root',
mode => '640',
ensure => present,
}
package 'apache2' do
action :install
end
service 'apache2' do
action [:enable, :start]
end
file '/var/www/html/index.html' do
content '<html>hello world</html>'
owner 'root'
mode '640'
action :create
end
Características: Abstracción e Idempotencia
¿Cómo es el código¿Cómo es el código
de infraestructura?de infraestructura?
Nuestro ContextoNuestro Contexto
Nuestra empresa a invertido en infraestructura como
código para manejar diversos servidores.
El área de desarrollo está compuesta por 4 divisiones
de productos, cada división trabaja con su propio
ambiente de IC utilizando Jenkins.
Gestionamos los servidores donde se encuentra
Jenkins a través de un módulo de Puppet.
Módulo de JenkinsMódulo de Jenkins
class myjenkins(
$plugins = undef
){
include jenkins
include myjenkins::default_plugins
if ($plugins){
jenkins::plugin { $plugins: }
}
}
class myjenkins::default_plugins{
$default_plugins = ['greenballs']
jenkins::plugin{$default_plugins:}
}
El códigoEl código
Cómo se utilizaCómo se utiliza
node 'ciserver'{
class {'myjenkins':
plugins => ['chucknorris','htmlpublisher']
}
include 'sonar'
}
ProbandoProbando
Infrastructure CodeInfrastructure Code
Unit TestUnit Test
Probar unitariamente el código sin
provisionar (alterar) un nodo real.
Integration TestsIntegration Tests
Verificar que el código provisiona
un nodo real de la manera
esperada.
Tipos de PruebasTipos de Pruebas
(Chef) Simular una ejecución y verificar
si la llamada a un recurso se ha
realizado.
(Puppet) Generar el catálogo y verificar
si un recurso se encuentra presente.
UnitUnit
TestingTesting
RSpec-PuppetRSpec-Puppet
https://github.com/rodjek/rspec-puppet
HerramientaHerramienta
TestsTests
# manifests/init.pp
class myjenkins(
$plugins = undef
){
include jenkins
if ($plugins){
jenkins::plugin { $plugins: }
}
}
# spec/classes/jenkins_spec.rb
describe 'myjenkins' do
context 'the following should be in the catalog' do
it { should contain_class('jenkins')}
end
context 'with plugins' do
let(:params){
{
:plugins => ['htmlpublisher']
}
}
it { should contain_jenkins__plugin('htmlpublisher')}
end
end
ProducciónProducción
Unit TestsUnit Tests
MockMock
# spec/spec_helper.rb
RSpec.configure do |c|
c.default_facts = {
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '14.04',
:osfamily => 'Debian',
:path => '/usr/local/bin/'
}
end
Unit TestsUnit Tests
IntegrationIntegration
TestingTesting
Desafíos al RealizarDesafíos al Realizar
Integration TestingIntegration Testing
Crear ambientes de pruebas
de manera fácil y repetible.
Interrogar el estado real del servidor.
Un Test Harness que combine lo anterior.
VagrantVagrant
https://www.vagrantup.com/
ServerspecServerspec
http://serverspec.org/
BeakerBeaker
https://github.com/puppetlabs/beaker
PruebaPrueba
# spec/acceptance/jenkins_spec.rb
describe 'jenkins class' do
it 'should work with no errors' do
pp = "include myjenkins"
# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).to eq(0)
expect(apply_manifest(pp).exit_code).to eq(0)
end
#Serverspec
describe service('jenkins') do
it { should be_enabled }
end
end
# spec/acceptance/nodesets/default.yml
HOSTS:
ubuntu-1404-x86:
roles:
- masterless
platform: ubuntu-1404-x86_64
hypervisor: vagrant
box: ubuntu14.04-x86
Ambiente de PruebaAmbiente de Prueba
Integration TestsIntegration Tests
Configuración delConfiguración del
AmbienteAmbiente
# spec/spec_helper_acceptance.rb
RSpec.configure do |c|
# Configure all nodes in nodeset
c.before :suite do
hosts.each do |host|
# Install this module
copy_module_to(host, :source => module_root,
:module_name => 'myjenkins')
# copies all the module dependencies
rsync_to(host ,fixture_modules, '/etc/puppet/modules/')
end
end
end
Test DrivenTest Driven
InfrastructureInfrastructure
El CicloEl Ciclo
Test Driven InfrastructureTest Driven Infrastructure
Integration TestIntegration Test Unit TestUnit Test
El CasoEl Caso
Varios equipos tienen la iniciativa de empezar a
trabajar con Git.
Como encargados de gestionar la infraestructura
necesitamos soportar Git en los ambientes de
Integración Continua.
Para eso vamos a extender el módulo de Jenkins
para que incluya el Plugin de git por defecto y
también instale Git en el sistema.
Let's Code!Let's Code!
ReflexionesReflexiones
¿A nivel Unitario estamos diseñando?
¿Escribimos una prueba por cada recurso?
¿Hay practicas que no se trasladan directamente
desde software a infraestructura?
Porqué CD y DevopsPorqué CD y Devops
necesitannecesitan
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code es un habilitador:
Permite agregar la infraestructura al pipeline de
Continuous Delivery.
Permite que Operaciones pueda utilizar prácticas
ágiles para gestionar la infraestructura.
Rompe barreras entre Dev y OPS.
PreguntasPreguntas
ReferenciasReferencias
Presentación (código y slides):
https://github.com/snahider/test-driven-infrastructure

Más contenido relacionado

PPTX
Unit testing
PPTX
Test Automation .NET
PPTX
Testing Con Visual Studio Team System 2008
PPS
Unit Testing
PDF
Integración contínua con Jenkins
PDF
Introduction to unit testing
PDF
Continuous Delivery Un caso de estudio
PPTX
Dev ops e infraestructura – acompañando nuestro software a producción
Unit testing
Test Automation .NET
Testing Con Visual Studio Team System 2008
Unit Testing
Integración contínua con Jenkins
Introduction to unit testing
Continuous Delivery Un caso de estudio
Dev ops e infraestructura – acompañando nuestro software a producción

La actualidad más candente (20)

PDF
Probando aplicaciones AngularJS
PPTX
Artesania de Software y TDD
PPSX
7iSF-4 test driver development
PPTX
Unit testing consejos
ODP
Testing Ruby on Rails (spanish)
PDF
PPTX
Mejoras Lenguaje Java 7
PDF
PPTX
Defensive code
PDF
Bdd (Behavior Driven Development)
PPTX
Meetup Integración Continua y Jenkins
PDF
Argentesting 2018 - Introducción a la automatización de pruebas con tecnologí...
PPT
Introducción a Team Foundation Service, ALM en la Nube
PPT
Despliegue de la solución de software
PPTX
Tu primer script en Katalon - Paso a Paso
PDF
DevOps: una breve introducción
PPTX
Azure infrastructure testing con inspec
PPTX
Pruebade j unit
PPTX
Pruebade j unit
Probando aplicaciones AngularJS
Artesania de Software y TDD
7iSF-4 test driver development
Unit testing consejos
Testing Ruby on Rails (spanish)
Mejoras Lenguaje Java 7
Defensive code
Bdd (Behavior Driven Development)
Meetup Integración Continua y Jenkins
Argentesting 2018 - Introducción a la automatización de pruebas con tecnologí...
Introducción a Team Foundation Service, ALM en la Nube
Despliegue de la solución de software
Tu primer script en Katalon - Paso a Paso
DevOps: una breve introducción
Azure infrastructure testing con inspec
Pruebade j unit
Pruebade j unit
Publicidad

Destacado (19)

DOCX
Crónica. Relato sobre la experiencia Tit@5
PDF
Consultaexternalarvas
DOC
Brusselse regering staat borg voor meer dan miljard euro
PPTX
101019 Reunión Padres
PPT
PRUEBAS SABER
PPTX
Sp3 phys. characteristics
PPT
Memorias
PPTX
Cluetrain manifesto (En Español)
PPT
PresentacióN1
PDF
Cijfers gastrobar Sepideh Sedaghatnia kleuren rood
PPSX
How to communicate with cats
PPTX
ERP Waldbott Versión 8.0
PPT
Profesionistas vslimosneros
PDF
Локальное позиционирование для больниц, поликлиник и медицинских центров
DOC
Belgisch parlement erkent polygamie
DOC
Dr. Wail Alzebdah CV 2016
PDF
Catàleg 2015 d'AC's al VxL del CNL Barcelona
PDF
Meine familie
PPT
Ich und meine familie
Crónica. Relato sobre la experiencia Tit@5
Consultaexternalarvas
Brusselse regering staat borg voor meer dan miljard euro
101019 Reunión Padres
PRUEBAS SABER
Sp3 phys. characteristics
Memorias
Cluetrain manifesto (En Español)
PresentacióN1
Cijfers gastrobar Sepideh Sedaghatnia kleuren rood
How to communicate with cats
ERP Waldbott Versión 8.0
Profesionistas vslimosneros
Локальное позиционирование для больниц, поликлиник и медицинских центров
Belgisch parlement erkent polygamie
Dr. Wail Alzebdah CV 2016
Catàleg 2015 d'AC's al VxL del CNL Barcelona
Meine familie
Ich und meine familie
Publicidad

Similar a Test Driven Infrastructure (20)

PDF
Infrastructure as Code
PDF
Argentesting 2018 - Deployment y Testing automatizado en infraestructura
PDF
Infraestructura agil
PPTX
Automatice el proceso de entrega con CI/CD en AWS
PDF
La Caja de Herramientas del Desarrollador Moderno PHPConferenceAR
KEY
Desmontando a Jenkins :-)
PDF
Cabalgando a la bestia: una experiencia de rediseño legacy
PDF
[DrupalCampSpain2018] CircleCI
PDF
Testing Day Peru 2025 Introducción al testing en Infrastructure as Code
PDF
Infraestructura como código
PDF
Continuous Delivery Un caso de estudio
PDF
Daniel González & Helena Jalain - DevSecOps y la caída de Babilonia: cómo olv...
PDF
03 de Marzo 2015: Andrés Villarreal - Herramientas del Desarrollador Moderno
PPTX
Mejores prácticas de CI / CD para construir aplicaciones modernas
PPTX
El coste de no usar integración continua
PPTX
Flujo de desarrollo para drupal (PFC)
PDF
DotNet 2019 | Alberto Varela - Infraestructura como código en Azure
ODP
Ci4 free
PDF
PHP Conference Argentina 2013 - Deployment de aplicaciones PHP a prueba de balas
PDF
Terraform Ansible v3.0
Infrastructure as Code
Argentesting 2018 - Deployment y Testing automatizado en infraestructura
Infraestructura agil
Automatice el proceso de entrega con CI/CD en AWS
La Caja de Herramientas del Desarrollador Moderno PHPConferenceAR
Desmontando a Jenkins :-)
Cabalgando a la bestia: una experiencia de rediseño legacy
[DrupalCampSpain2018] CircleCI
Testing Day Peru 2025 Introducción al testing en Infrastructure as Code
Infraestructura como código
Continuous Delivery Un caso de estudio
Daniel González & Helena Jalain - DevSecOps y la caída de Babilonia: cómo olv...
03 de Marzo 2015: Andrés Villarreal - Herramientas del Desarrollador Moderno
Mejores prácticas de CI / CD para construir aplicaciones modernas
El coste de no usar integración continua
Flujo de desarrollo para drupal (PFC)
DotNet 2019 | Alberto Varela - Infraestructura como código en Azure
Ci4 free
PHP Conference Argentina 2013 - Deployment de aplicaciones PHP a prueba de balas
Terraform Ansible v3.0

Más de Angel Nuñez (20)

PDF
Structural Agility
PDF
Architecting Sociotechnical Systems
PDF
Product Development Flow
PDF
Chaos Engineering
PDF
Hackeando la Cultura Organizacional
PDF
Liderazgo Transformacional
PDF
Liderazgo Transformacional y DevOps
PDF
Exploratory Testing
PDF
Coding Dojo
PDF
Kubernetes - Container Orchestration, Deployment and Scaling
PDF
Agile Test Strategy
PDF
Kubernetes - #gdglimasummit
PDF
Agile Testing - Software Testing Club
PDF
Kubernetes - #dockerconlima
PDF
Software Debt: Qué Es y Cómo Gestionarlo Holísticamente
PPTX
Refactoring
PPTX
Refactoring to Patterns
PPTX
Continuous Integration - Going from Zero to Hero
PPTX
Refactoring Golf
PPTX
Pruebas Automatizadas
Structural Agility
Architecting Sociotechnical Systems
Product Development Flow
Chaos Engineering
Hackeando la Cultura Organizacional
Liderazgo Transformacional
Liderazgo Transformacional y DevOps
Exploratory Testing
Coding Dojo
Kubernetes - Container Orchestration, Deployment and Scaling
Agile Test Strategy
Kubernetes - #gdglimasummit
Agile Testing - Software Testing Club
Kubernetes - #dockerconlima
Software Debt: Qué Es y Cómo Gestionarlo Holísticamente
Refactoring
Refactoring to Patterns
Continuous Integration - Going from Zero to Hero
Refactoring Golf
Pruebas Automatizadas

Último (6)

PPTX
Derechos_de_Autor_y_Creative_Commons.pptx
PDF
AutoCAD Herramientas para el futuro, Juan Fandiño
PPTX
Conceptos basicos de Base de Datos y sus propiedades
PDF
Su punto de partida en la IA: Microsoft 365 Copilot Chat
DOCX
trabajo programacion.docxxdxxxddxdxxdxdxxxdxxdxdxd
PPTX
sistemas de informacion.................
Derechos_de_Autor_y_Creative_Commons.pptx
AutoCAD Herramientas para el futuro, Juan Fandiño
Conceptos basicos de Base de Datos y sus propiedades
Su punto de partida en la IA: Microsoft 365 Copilot Chat
trabajo programacion.docxxdxxxddxdxxdxdxxxdxxdxdxd
sistemas de informacion.................

Test Driven Infrastructure