SlideShare una empresa de Scribd logo
1 de 21
Testando a integração 
entre serviços 
Lucas Cavalcanti 
@lucascs 
https://github.com/lucascs
Um pouco de contexto
Sistema 
http://en.wikipedia.org/wiki/File:MasterCard_Logo.svg 
https://www.flickr.com/photos/pargon/2444943158/ 
http://commons.wikimedia.org/wiki/File:POS_device.jpg
Transações 
Faturas 
Contas e Limites 
Dados do cliente 
MasterCard-client 
Dados de usuário 
Localização 
Notificações
Serviços 
Clojure 
iOS Android 
Web 
http://commons.wikimedia.org/wiki/File:Google_Chrome_icon_(2011).png 
http://commons.wikimedia.org/wiki/File:Mac.svg 
http://commons.wikimedia.org/wiki/File:Android_robot.png 
https://registry.hub.docker.com/_/clojure/
Integração 
Síncrona Assíncrona 
HTTP 
REST 
Hypermedia 
Kafka 
JSON 
mensagens padronizadas
Schemata 
(ns common-schemata.wire.payment) 
(def links {:self {:schema link-schema 
:allow #{:get} 
:description "Entity. The owner should be able to GET it.”}}) 
(def skeleton 
{:_links {:schema (csc/gen-schema links)} 
:id {:required true :eg #uuid "d6e73cc5-95bc-496a-951c-87f11af0d838" 
:schema UUID} 
:post-date {:required true :eg #nu/date "2013-10-23" 
:schema LocalDate} 
:account-id {:required false :eg #uuid "d6e73cc5-95bc-496a-951c-87f11af0d839" 
:schema UUID} 
:time {:required false :eg #nu/time "2013-10-23T11:53:26Z" 
:schema LocalDateTime} 
:amount {:required false :eg 133700 
:schema t-money/cents} 
:precise-amount {:required false :eg 1337.00M 
:schema t-money/precise-amount}})
Arquitetura Hexagonal 
http://www.dossier-andreas.net/software_architecture/ports_and_adapters.html 
http://alistair.cockburn.us/Hexagonal+architecture
Testes de unidade
Testes de unidade
Testes de unidade
Testes de Unidade 
(def internal-payment {:payment/id payment-id 
:line-item/precise-amount -10.00M 
:line-item/amount -1000 
:line-item/account {:account/id account-id} 
:line-item/time (time/date-time 2014 5 14 2 59 59) 
:line-item/post-date (time/date 2014 5 13)}) 
(def external-payment {:id payment-id 
:amount 1000 
:paid -1000 
:time (time/date-time 2014 5 14 2 59 59) 
:post-date (time/date 2014 5 13) }) 
(sm/with-fn-validation 
(fact “adapts internal representation to external” 
(a-pmt/internal->wire internal-payment) => {:payment external-payment}))
Testes de integração 
Contas 
HTTP 
Kafka msg 
HTTP 
Kafka msg
Testes de integração 
(fact "a new account is created on April” 
(as-of (time/date-time 2020 4 2 13 37 42) 
(next-state) => :account-created)) 
(fact "a purchase is made some days later” 
(as-of (time/date-time 2020 4 4 13 37 0) 
(next-state) => :with-txs)) 
(fact "as well as a payment” 
(as-of (time/date-time 2020 4 6 13 37 0) 
(next-state) => :paid-some-money)) 
(fact "they are all there” 
(as-of (time/date-time 2020 4 9 13 37 0) 
(next-state) => :with-stuff-appearing-on-the-bill)) 
(fact "we close the bill” 
(as-of (time/date-time 2020 4 5 13 37 0) 
(next-state) => :bill-closed)) 
(fact "two bills we now have” 
(as-of (time/date-time 2020 6 8 13 37 0) 
(next-state) => :bill-containing-new-charge))
Testes ponta a ponta 
MasterCard-client 
MasterCard-mock 
Aquisição 
Contas 
Notificações
Testes ponta a ponta 
describe "until account creation" do 
it "adds a prospect to the waiting list" do...end 
it "initiates an account request on behalf of a prospect" do...end 
it "gets all account requests associated with the prospect" do...end 
it "the new account request has a waiting status" do...end 
it "sends an email invitation, including an invite code" do...end 
it "fails to start the acquisition process with the wrong invite-code" do...end 
it "engages, using the invite-code from the email" do...end 
#... 
end
Build pipeline
Build pipeline
Pendente 
Testes Exploratórios 
Testes Performance 
Testes Carga
Obrigado! 
Lucas Cavalcanti 
@lucascs 
https://github.com/lucascs 
www.nubank.com.br

Más contenido relacionado

Similar a Testando a integracao entre serviços - Agile Brazil 2014

java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guide
Zenita Smythe
 
Integrate Sas With Google Maps
Integrate Sas With Google MapsIntegrate Sas With Google Maps
Integrate Sas With Google Maps
vineetkaul
 
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
confluent
 

Similar a Testando a integracao entre serviços - Agile Brazil 2014 (20)

Html5 websockets
Html5 websocketsHtml5 websockets
Html5 websockets
 
The Future of Progressive Web Apps - Google for Indonesia
The Future of Progressive Web Apps - Google for IndonesiaThe Future of Progressive Web Apps - Google for Indonesia
The Future of Progressive Web Apps - Google for Indonesia
 
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Building and deploying microservices with event sourcing, CQRS and Docker (QC...Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
 
Sherlock Homepage - A detective story about running large web services - NDC ...
Sherlock Homepage - A detective story about running large web services - NDC ...Sherlock Homepage - A detective story about running large web services - NDC ...
Sherlock Homepage - A detective story about running large web services - NDC ...
 
MongoDB Stitch Tutorial
MongoDB Stitch TutorialMongoDB Stitch Tutorial
MongoDB Stitch Tutorial
 
java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guide
 
What 100M downloads taught us about iOS architectures
What 100M downloads taught us about iOS architecturesWhat 100M downloads taught us about iOS architectures
What 100M downloads taught us about iOS architectures
 
Using Apache Spark to Solve Sessionization Problem in Batch and Streaming
Using Apache Spark to Solve Sessionization Problem in Batch and StreamingUsing Apache Spark to Solve Sessionization Problem in Batch and Streaming
Using Apache Spark to Solve Sessionization Problem in Batch and Streaming
 
Data Modeling and Relational to NoSQL
Data Modeling and Relational to NoSQLData Modeling and Relational to NoSQL
Data Modeling and Relational to NoSQL
 
Socket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time ApplicationSocket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time Application
 
Integrate Sas With Google Maps
Integrate Sas With Google MapsIntegrate Sas With Google Maps
Integrate Sas With Google Maps
 
Deep dive into stateful stream processing in structured streaming by Tathaga...
Deep dive into stateful stream processing in structured streaming  by Tathaga...Deep dive into stateful stream processing in structured streaming  by Tathaga...
Deep dive into stateful stream processing in structured streaming by Tathaga...
 
Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...
 
Receipt processing with Google Cloud Platform and the Google Assistant
Receipt processing with Google Cloud Platform and the Google AssistantReceipt processing with Google Cloud Platform and the Google Assistant
Receipt processing with Google Cloud Platform and the Google Assistant
 
Veryfi API for document data extraction (OCR) & tax coding
Veryfi API for document data extraction (OCR) & tax codingVeryfi API for document data extraction (OCR) & tax coding
Veryfi API for document data extraction (OCR) & tax coding
 
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
 
Powering Consistent, High-throughput, Real-time Distributed Calculation Engin...
Powering Consistent, High-throughput, Real-time Distributed Calculation Engin...Powering Consistent, High-throughput, Real-time Distributed Calculation Engin...
Powering Consistent, High-throughput, Real-time Distributed Calculation Engin...
 
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
 

Último

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Último (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

Testando a integracao entre serviços - Agile Brazil 2014

  • 1. Testando a integração entre serviços Lucas Cavalcanti @lucascs https://github.com/lucascs
  • 2. Um pouco de contexto
  • 3.
  • 5. Transações Faturas Contas e Limites Dados do cliente MasterCard-client Dados de usuário Localização Notificações
  • 6. Serviços Clojure iOS Android Web http://commons.wikimedia.org/wiki/File:Google_Chrome_icon_(2011).png http://commons.wikimedia.org/wiki/File:Mac.svg http://commons.wikimedia.org/wiki/File:Android_robot.png https://registry.hub.docker.com/_/clojure/
  • 7. Integração Síncrona Assíncrona HTTP REST Hypermedia Kafka JSON mensagens padronizadas
  • 8. Schemata (ns common-schemata.wire.payment) (def links {:self {:schema link-schema :allow #{:get} :description "Entity. The owner should be able to GET it.”}}) (def skeleton {:_links {:schema (csc/gen-schema links)} :id {:required true :eg #uuid "d6e73cc5-95bc-496a-951c-87f11af0d838" :schema UUID} :post-date {:required true :eg #nu/date "2013-10-23" :schema LocalDate} :account-id {:required false :eg #uuid "d6e73cc5-95bc-496a-951c-87f11af0d839" :schema UUID} :time {:required false :eg #nu/time "2013-10-23T11:53:26Z" :schema LocalDateTime} :amount {:required false :eg 133700 :schema t-money/cents} :precise-amount {:required false :eg 1337.00M :schema t-money/precise-amount}})
  • 13. Testes de Unidade (def internal-payment {:payment/id payment-id :line-item/precise-amount -10.00M :line-item/amount -1000 :line-item/account {:account/id account-id} :line-item/time (time/date-time 2014 5 14 2 59 59) :line-item/post-date (time/date 2014 5 13)}) (def external-payment {:id payment-id :amount 1000 :paid -1000 :time (time/date-time 2014 5 14 2 59 59) :post-date (time/date 2014 5 13) }) (sm/with-fn-validation (fact “adapts internal representation to external” (a-pmt/internal->wire internal-payment) => {:payment external-payment}))
  • 14. Testes de integração Contas HTTP Kafka msg HTTP Kafka msg
  • 15. Testes de integração (fact "a new account is created on April” (as-of (time/date-time 2020 4 2 13 37 42) (next-state) => :account-created)) (fact "a purchase is made some days later” (as-of (time/date-time 2020 4 4 13 37 0) (next-state) => :with-txs)) (fact "as well as a payment” (as-of (time/date-time 2020 4 6 13 37 0) (next-state) => :paid-some-money)) (fact "they are all there” (as-of (time/date-time 2020 4 9 13 37 0) (next-state) => :with-stuff-appearing-on-the-bill)) (fact "we close the bill” (as-of (time/date-time 2020 4 5 13 37 0) (next-state) => :bill-closed)) (fact "two bills we now have” (as-of (time/date-time 2020 6 8 13 37 0) (next-state) => :bill-containing-new-charge))
  • 16. Testes ponta a ponta MasterCard-client MasterCard-mock Aquisição Contas Notificações
  • 17. Testes ponta a ponta describe "until account creation" do it "adds a prospect to the waiting list" do...end it "initiates an account request on behalf of a prospect" do...end it "gets all account requests associated with the prospect" do...end it "the new account request has a waiting status" do...end it "sends an email invitation, including an invite code" do...end it "fails to start the acquisition process with the wrong invite-code" do...end it "engages, using the invite-code from the email" do...end #... end
  • 20. Pendente Testes Exploratórios Testes Performance Testes Carga
  • 21. Obrigado! Lucas Cavalcanti @lucascs https://github.com/lucascs www.nubank.com.br