Top Banner
Precisamos falar sobre teste de infra Infradel Team
30

Precisamos falar sobre Testes de infraestrutura

Apr 12, 2017

Download

Technology

Rafael Gomes
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Precisamos falar sobre Testes de infraestrutura

Precisamos falar sobre teste de infra

Infradel Team

Page 2: Precisamos falar sobre Testes de infraestrutura

Quem somos

Infradel:● Objetivo: Consultoria para migração de projetos

do modelo centralizado para cloud, com automação e auto-serviço.

● Membros:○ Rafael Gomes (PoA - Brasil)○ Rafael Nunes (PoA - Brasil)○ Augusto Amaral (PoA - Brasil)○ Fernando Laimer (PoA - Brasil)○ Vinicius Gama (Belo Horizonte - Brasil)○ Ronak Jain (Belo Horizonte - Brasil)○ Chris Briesemeister ( Chicago - EUA)○ Luisa Emme ( Quito - Equador)

● Principais tecnologias○ Cloud (AWS)○ Automação de infra (Ansible, Cloudformation)○ Testes de infraestrutura (ServerSpec, Testinfra)○ Container (Docker)○ Programação (Python e Ruby)

Page 3: Precisamos falar sobre Testes de infraestrutura

Quem sou eu

Rafael Gomes:● Soteropolitano● Apaixonado por compartilhamento● Consultor na Thoughtworks● Blog: techfree.com.br● Twitter/github: @gomex● Áreas de interesse/foco:

○ Cultura DevOps○ Cloud○ Entrega contínua○ Automação de infraestrutura○ Teste de infraestrutura○ Monitoramento

Page 4: Precisamos falar sobre Testes de infraestrutura

O que estou fazendo de relevante agora

Livro:

http://tinyurl.com/docker-devel

● Pague quanto quiser, inclusive nada

● Não precisa saber nada de Docker

● Licenciado com Creative Commons

Page 5: Precisamos falar sobre Testes de infraestrutura

O que estou fazendo de relevante agora

Livro Impresso:

● Livro numerado

● Autografado

● Recompensa de R$ 40,00 com entrega

https://www.catarse.me/versao_impressa_do_livro_docker_para_desenvolvedores_c403?ref=project_link

Page 6: Precisamos falar sobre Testes de infraestrutura

Pra que testar?Pergunta sincera...

Page 7: Precisamos falar sobre Testes de infraestrutura

O que acontece quando não testo

Page 8: Precisamos falar sobre Testes de infraestrutura

Como os testes eram feitos antigamente

Page 9: Precisamos falar sobre Testes de infraestrutura

● Falta de padronização● Testes insuficientes● Sem rastreabilidade● Pouco interesse em reproduzir● Necessidade de conhecimento especializado

Problemas dos testes manuais

Page 10: Precisamos falar sobre Testes de infraestrutura

Manutenção de ambientes

Dev

Necessidade de Ambientes

agent1

agent2

dev

ticket ops

devTestes

manuais

git

server app A

server app Bserver app C

teste uat prod

Page 11: Precisamos falar sobre Testes de infraestrutura

Manutenção de ambientes

Dev

Deploy nosAmbientes

ticket ops

Testes manuais

teste

uat

prodTestes manuais

Testes manuais

Teste pós

UAT pós

Prod pós

Page 12: Precisamos falar sobre Testes de infraestrutura

Manutenção de ambientes

AtualizaçãoNo ambiente

Testes manuais

ops

teste

uat

prodTestes manuais

Testes manuais

Teste pós

UAT pós

Prod pós

Page 13: Precisamos falar sobre Testes de infraestrutura

Infraestrutura virou código!

Page 14: Precisamos falar sobre Testes de infraestrutura

Imperativo vs Declarativo

Page 15: Precisamos falar sobre Testes de infraestrutura

Automação de ambientes

ops

teste

uat

prod

Teste pós

UAT pós

Prod pós

ops

commit

no git repo

git

Page 16: Precisamos falar sobre Testes de infraestrutura

● Não há como atender a

demanda de infra sem automação

● Automação como método de garantia de padronização

Infra virou código

Fatos:● Atualização de servidores

não se fazem de forma manual

● Até mesmo redes já tem SDN

Page 17: Precisamos falar sobre Testes de infraestrutura

Se infra virou código, precisamos testar!

Page 18: Precisamos falar sobre Testes de infraestrutura

Necessidade de teste

ops

teste

uat

prod

Teste pós

UAT pós

Prod pós

commit Dockerfile

no git repo

git

CDAtualiza

Page 19: Precisamos falar sobre Testes de infraestrutura

Testes manuais?

Testes manuais

ops

teste

uat

prodTestes manuais

Testes manuais

Teste pós

UAT pós

Prod pós

Page 20: Precisamos falar sobre Testes de infraestrutura

Necessidade de teste

ops

teste

uat

prod

Teste pós

UAT pós

Prod pós

commit Dockerfile

no git repo

git

CD

Testa

Atualiza

Page 21: Precisamos falar sobre Testes de infraestrutura

TDD para infra?

Page 22: Precisamos falar sobre Testes de infraestrutura

Soluções de teste

Page 23: Precisamos falar sobre Testes de infraestrutura

● Boa documentação

● Facilidade na execução dos testes automatizados

Soluções

Fatos:● Abstração que permitem

não DEV criarem testes

● Tem boas opções escritas em ruby e python

Page 24: Precisamos falar sobre Testes de infraestrutura

Veja como é fácil testar automaticamente

Arquivo "test_mytest.py":def test_nginx_is_installed(Package): nginx = Package("nginx") assert nginx.is_installed assert nginx.version.startswith("1.2")

Comandos para executar o teste:

# pip install testinfra# testinfra --sudo --connection=ssh --hosts=servidor_a_ser_testado test_mytest.py

Page 25: Precisamos falar sobre Testes de infraestrutura

Soluções

Lista:● Serverspec

○ Escrita em ruby, mais popular

● Testinfra○ Escrita em python

● Inspec○ Escrita em ruby, mantida pela Chef

● Beaker○ Escrita em ruby, mantida pela Puppet

Page 26: Precisamos falar sobre Testes de infraestrutura

Sysadmin, você sabe desenvolver?

Page 27: Precisamos falar sobre Testes de infraestrutura

Como construir seus testes!

Page 28: Precisamos falar sobre Testes de infraestrutura

Pirâmide de testes de infra

Page 29: Precisamos falar sobre Testes de infraestrutura

Dúvidas?

Page 30: Precisamos falar sobre Testes de infraestrutura

Rafael Gomes:

twitter.com/gomex

[email protected]

twitter.com/thoughtworks_pt

Obrigado!