SlideShare una empresa de Scribd logo
1 de 26
codecentric AG 1
NoSQL Unit & Travis CI
Test Automation for NoSQL Databases
Tobias.Trelle@codecentric.de @tobiastrelle
codecentric AG 2
Tobias Trelle
Senior IT Consultant @ codecentric AG
Organizer of MongoDB User Group Düsseldorf
Author of
„MongoDB – Ein praktischer Einstieg“
(dpunkt-Verlag)
codecentric AG 3
Agenda
Unit Testing
NoSQL Unit
 Travis CI
codecentric AG 4
Unit Testing Your Persistence Layer
UI Layer
Database
Business Layer
Persistence Layer
DAO /
Repository
Production
codecentric AG 5
Unit Testing Your Persistence Layer
UI Layer
Database
Business Layer
Persistence Layer
DAO /
Repository
Production
UI Layer
Embedded
Database
Business Layer
Persistence Layer
DAO /
Repository
Unit Test
Unit Test
In Process
codecentric AG 6
Unit Testing Your Persistence Layer
Unit tests should …
 be fast
 run in isolation
 load test data
 compare data
codecentric AG 7
NoSQL Unit
Github - https://github.com/lordofthejars/nosql-unit
codecentric AG 8
NoSQL Unit > Overview
Benefits
 Database Lifecycle Management
 Connection Management
 Load Test Data
 Compare Data
codecentric AG 9
NoSQL Unit > Overview
How does it work?
 JUnit Extension
 JUnit Rules
 Annotations
codecentric AG 10
NoSQL Unit > Database Management Options
DatabaseNoSQL Unit
Embedded
JVM
Local Machine
Database
Database
Remote
Machine
Managed Remote
codecentric AG 11
NoSQL Unit > Supported Databases
Database Type Impl
Language
Embedded Managed /
Remote
Cassandra Column Java
 
CouchDB Document Erlang ---

Elasticsearch Document Java
 
HBase Column Java
 
Infinispan In Memory Java
 
MongoDB Document C++ fongo Mock

Neo4j Graph Java
 
Redis Key/Value C/C++ NoSQL Unit
Mock

codecentric AG 12
NoSQL Unit > Lifecycle
NoSQL Unit Database Test Case
Loop
over
tests
Launch (optional)
Connect to
Load Test Data (optional)
Compare Data Sets (optional)
Shutdown (optional)
Run Test
Interact with
codecentric AG 13
NoSQL Unit > Redis Example
public class EmbeddedRedisTest {
@ClassRule
public static EmbeddedRedis embeddedRedis = newEmbeddedRedisRule().build();
@Rule
public RedisRule redisRule = newRedisRule().defaultEmbeddedRedis();
/** Unit under test. */
private KeyValueRepository repository;
@Test
@UsingDataSet( loadStrategy = LoadStrategyEnum.DELETE_ALL )
@ShouldMatchDataSet( location="keyvalue.json" )
public void should_insert_string() {
// given
KeyValueRepository repo = new KeyValueRepository( getJedisInstance() );
// when
repo.setValue("hello", "redis");
// then: should match data
}
}
Create embedded instance
once for all tests
Get connection once per test
Prepare
data
Compare given and
expected data after test
codecentric AG 14
NoSQL Unit > Redis Example > keyvalue.json
{
"data": [
{"simple": [
{ "key":"hello", "value":"redis"}
]
}
]
}
codecentric AG 15
NoSQL Unit > MongoDB Example
public class RemoteMongoDBTest {
@Rule // use already running "remote" instance
public MongoDbRule mongoRule = new MongoDbRule(
mongoDb().databaseName("test").host("localhost").port(27017) .build()
);
/** Unit under test. */
private OrderRepository repository;
@Test
@UsingDataSet(locations = "orders.json", loadStrategy =
LoadStrategyEnum.CLEAN_INSERT)
public void should_find_all_orders() {
// given
repository = createOrderRepository();
// when
List<DBObject> orders = repository.findAll();
// then
assertThat(orders, notNullValue());
assertThat(orders.size(), is(2));
}
Load test data
from JSON file
codecentric AG 16
NoSQL Unit > MongoDB Example > orders.json
{
"orders": [
{
"type": 4711,
"desc": "1st order"
},
{
"type": 42,
"desc": "2nd order"
}
]
}
codecentric AG 17
NoSQL Unit > MongoDB > Advanced Features
NoSQL Unit MongoDB supports
 Replica Sets
 Sharded Environments
 Sharded Env. + Replica Sets
…in managed mode.
codecentric AG 18
Travis CI
http://www.travis-ci.org
codecentric AG 19
Travis CI > Overview
Free Continuous Integration Platform:
Lanuguages:
 C/C++
 Closure
 Erlang
 Go
 Groovy
 Java
 JavaScript / Node.js
 Objective-C
 Ruby
 Scala
 …
Services:
 MySQL
 PostgreSQL
 MongoDB
 CouchDB
 Redis
 Riak
 RabbitMQ
 Memcached
 Cassandra
 Neo4j
 …
codecentric AG 20
Travis CI > Lifecycle
Travis CI Database GitHubTests
start services
shutdown services
clone / checkout
build
& run use
.travis.yml:
language: java
services:
- mongodb
- redis
codecentric AG 21
Travis CI > Demo
codecentric AG 22
Travis CI > Demo
codecentric AG 23
Travis CI > Demo
codecentric AG 24
Online Resources
NoSQL Unit
https://github.com/lordofthejars/nosql-unit
Travis CI
https://travis-ci.org/
NoSQL Unit Examples
https://github.com/ttrelle/nosqlunit-examples
codecentric AG 25
MongoDB User Group Düsseldorf
https://www.xing.com/net/mongodb-dus/
http://www.meetup.com/Dusseldorf-MongoDB-User-Group/
@MongoDUS
Meetup #10:
MongoDB at LUMsearch.com (by Christian Douven)
03.07.2014, 19:00
codecentric AG 26
QUESTIONS?
Tobias Trelle
codecentric AG
Merscheider Str. 1
42699 Solingen
tel +49 (0) 212.233628.47
fax +49 (0) 212.233628.79
mail Tobias.Trelle@codecentric.de
twitter @tobiastrelle
www.codecentric.de
blog.codecentric.de/en/author/tobias-trelle
www.xing.com/net/mongodb-dus

Más contenido relacionado

La actualidad más candente

How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...
How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...
How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...
DataWorks Summit
 
NoSQL - No Security? - The BSides Edition
NoSQL - No Security? - The BSides EditionNoSQL - No Security? - The BSides Edition
NoSQL - No Security? - The BSides Edition
Gavin Holt
 
213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.key213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.key
NAVER D2
 

La actualidad más candente (20)

Cold Storage That Isn't Glacial (Joshua Hollander, Protectwise) | Cassandra S...
Cold Storage That Isn't Glacial (Joshua Hollander, Protectwise) | Cassandra S...Cold Storage That Isn't Glacial (Joshua Hollander, Protectwise) | Cassandra S...
Cold Storage That Isn't Glacial (Joshua Hollander, Protectwise) | Cassandra S...
 
How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...
How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...
How to Use Innovative Data Handling and Processing Techniques to Drive Alpha ...
 
"What database can tell about application issues? What application can tell a...
"What database can tell about application issues? What application can tell a..."What database can tell about application issues? What application can tell a...
"What database can tell about application issues? What application can tell a...
 
SenchaCon 2016: A Data-Driven Application for the Embedded World - Jean-Phili...
SenchaCon 2016: A Data-Driven Application for the Embedded World - Jean-Phili...SenchaCon 2016: A Data-Driven Application for the Embedded World - Jean-Phili...
SenchaCon 2016: A Data-Driven Application for the Embedded World - Jean-Phili...
 
Big data testing (1)
Big data testing (1)Big data testing (1)
Big data testing (1)
 
Architectural Best Practices to Master + Pitfalls to Avoid (P)
Architectural Best Practices to Master + Pitfalls to Avoid (P) Architectural Best Practices to Master + Pitfalls to Avoid (P)
Architectural Best Practices to Master + Pitfalls to Avoid (P)
 
Migrating Data and Databases to Azure
Migrating Data and Databases to AzureMigrating Data and Databases to Azure
Migrating Data and Databases to Azure
 
Provisioning Datadog with Terraform
Provisioning Datadog with TerraformProvisioning Datadog with Terraform
Provisioning Datadog with Terraform
 
Presto: Fast SQL on Everything
Presto: Fast SQL on EverythingPresto: Fast SQL on Everything
Presto: Fast SQL on Everything
 
Gobbin config-meetup-june-2016
Gobbin config-meetup-june-2016Gobbin config-meetup-june-2016
Gobbin config-meetup-june-2016
 
NoSQL - No Security? - The BSides Edition
NoSQL - No Security? - The BSides EditionNoSQL - No Security? - The BSides Edition
NoSQL - No Security? - The BSides Edition
 
Redshift Introduction
Redshift IntroductionRedshift Introduction
Redshift Introduction
 
GraphTour - Albelli: Running Neo4j on a large scale image platform
GraphTour - Albelli: Running Neo4j on a large scale image platformGraphTour - Albelli: Running Neo4j on a large scale image platform
GraphTour - Albelli: Running Neo4j on a large scale image platform
 
Testing Distributed Query Engine as a Service
Testing Distributed Query Engine as a ServiceTesting Distributed Query Engine as a Service
Testing Distributed Query Engine as a Service
 
DataEngConf SF16 - Methods for Content Relevance at LinkedIn
DataEngConf SF16 - Methods for Content Relevance at LinkedInDataEngConf SF16 - Methods for Content Relevance at LinkedIn
DataEngConf SF16 - Methods for Content Relevance at LinkedIn
 
Semantic Image Logging Using Approximate Statistics & MLflow
Semantic Image Logging Using Approximate Statistics & MLflowSemantic Image Logging Using Approximate Statistics & MLflow
Semantic Image Logging Using Approximate Statistics & MLflow
 
213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.key213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.key
 
Encryption and Masking for Sensitive Apache Spark Analytics Addressing CCPA a...
Encryption and Masking for Sensitive Apache Spark Analytics Addressing CCPA a...Encryption and Masking for Sensitive Apache Spark Analytics Addressing CCPA a...
Encryption and Masking for Sensitive Apache Spark Analytics Addressing CCPA a...
 
SQL To NoSQL - Top 6 Questions Before Making The Move
SQL To NoSQL - Top 6 Questions Before Making The MoveSQL To NoSQL - Top 6 Questions Before Making The Move
SQL To NoSQL - Top 6 Questions Before Making The Move
 
GraphTour - Closing Keynote
GraphTour - Closing KeynoteGraphTour - Closing Keynote
GraphTour - Closing Keynote
 

Destacado

Nosql databases for the .net developer
Nosql databases for the .net developerNosql databases for the .net developer
Nosql databases for the .net developer
Jesus Rodriguez
 
NoSQL-Database-Concepts
NoSQL-Database-ConceptsNoSQL-Database-Concepts
NoSQL-Database-Concepts
Bhaskar Gunda
 

Destacado (20)

NoSql Databases
NoSql DatabasesNoSql Databases
NoSql Databases
 
Nosql databases for the .net developer
Nosql databases for the .net developerNosql databases for the .net developer
Nosql databases for the .net developer
 
NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache Cassandra
 
A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014
 
Multi model-databases
Multi model-databasesMulti model-databases
Multi model-databases
 
Big Data and NoSQL for Database and BI Pros
Big Data and NoSQL for Database and BI ProsBig Data and NoSQL for Database and BI Pros
Big Data and NoSQL for Database and BI Pros
 
Nosql databases
Nosql databasesNosql databases
Nosql databases
 
An Intro to NoSQL Databases
An Intro to NoSQL DatabasesAn Intro to NoSQL Databases
An Intro to NoSQL Databases
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
 
NoSQL-Database-Concepts
NoSQL-Database-ConceptsNoSQL-Database-Concepts
NoSQL-Database-Concepts
 
Google Spanner - Synchronously-Replicated, Globally-Distributed, Multi-Versio...
Google Spanner - Synchronously-Replicated, Globally-Distributed, Multi-Versio...Google Spanner - Synchronously-Replicated, Globally-Distributed, Multi-Versio...
Google Spanner - Synchronously-Replicated, Globally-Distributed, Multi-Versio...
 
NoSQL databases and managing big data
NoSQL databases and managing big dataNoSQL databases and managing big data
NoSQL databases and managing big data
 
Spanner
SpannerSpanner
Spanner
 
Critical Issues Matrix - TIP Committee LMRC 22jun15
Critical Issues Matrix - TIP Committee LMRC 22jun15Critical Issues Matrix - TIP Committee LMRC 22jun15
Critical Issues Matrix - TIP Committee LMRC 22jun15
 
Nombres grammaire
Nombres grammaireNombres grammaire
Nombres grammaire
 
Carlos y Maria
Carlos y MariaCarlos y Maria
Carlos y Maria
 
Como funciona bedep malware
Como funciona bedep malwareComo funciona bedep malware
Como funciona bedep malware
 
SEOGuardian - Report posizionamento nei motori di ricerca - Lenti a contatto ...
SEOGuardian - Report posizionamento nei motori di ricerca - Lenti a contatto ...SEOGuardian - Report posizionamento nei motori di ricerca - Lenti a contatto ...
SEOGuardian - Report posizionamento nei motori di ricerca - Lenti a contatto ...
 
Parclick presentation
Parclick presentationParclick presentation
Parclick presentation
 
ECR Sweden Forum ‘09. ECRs Packaging Guide
ECR Sweden Forum ‘09. ECRs Packaging GuideECR Sweden Forum ‘09. ECRs Packaging Guide
ECR Sweden Forum ‘09. ECRs Packaging Guide
 

Similar a Test Automation for NoSQL Databases

Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
MongoDB
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 

Similar a Test Automation for NoSQL Databases (20)

Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
 
Integration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBIntegration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDB
 
Android Unit Test
Android Unit TestAndroid Unit Test
Android Unit Test
 
Monitoring your technology stack with New Relic
Monitoring your technology stack with New RelicMonitoring your technology stack with New Relic
Monitoring your technology stack with New Relic
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleGeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassle
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for Government
 
Jenkins' shared libraries in action
Jenkins' shared libraries in actionJenkins' shared libraries in action
Jenkins' shared libraries in action
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
BDD in iOS with Cedar
BDD in iOS with CedarBDD in iOS with Cedar
BDD in iOS with Cedar
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11g
 
Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application Benchx: An XQuery benchmarking web application
Benchx: An XQuery benchmarking web application
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Data access
Data accessData access
Data access
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
Decomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservicesDecomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservices
 
Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.
 

Más de Tobias Trelle

MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwalten
Tobias Trelle
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & Co
Tobias Trelle
 
BedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDBBedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDB
Tobias Trelle
 

Más de Tobias Trelle (13)

TDD mit JUnit und Mockito
TDD mit JUnit und MockitoTDD mit JUnit und Mockito
TDD mit JUnit und Mockito
 
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jNoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
 
Einführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenEinführung in NoSQL-Datenbanken
Einführung in NoSQL-Datenbanken
 
MongoDB Einführung
MongoDB EinführungMongoDB Einführung
MongoDB Einführung
 
MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwalten
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & Co
 
Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Spring Data, Jongo & Co.
Spring Data, Jongo & Co.
 
An introduction to MongoDB and Ruby
An introduction to MongoDB and RubyAn introduction to MongoDB and Ruby
An introduction to MongoDB and Ruby
 
BedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDBBedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDB
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
OOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBOOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDB
 
MongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBMongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDB
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live Hacking
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Test Automation for NoSQL Databases

  • 1. codecentric AG 1 NoSQL Unit & Travis CI Test Automation for NoSQL Databases Tobias.Trelle@codecentric.de @tobiastrelle
  • 2. codecentric AG 2 Tobias Trelle Senior IT Consultant @ codecentric AG Organizer of MongoDB User Group Düsseldorf Author of „MongoDB – Ein praktischer Einstieg“ (dpunkt-Verlag)
  • 3. codecentric AG 3 Agenda Unit Testing NoSQL Unit  Travis CI
  • 4. codecentric AG 4 Unit Testing Your Persistence Layer UI Layer Database Business Layer Persistence Layer DAO / Repository Production
  • 5. codecentric AG 5 Unit Testing Your Persistence Layer UI Layer Database Business Layer Persistence Layer DAO / Repository Production UI Layer Embedded Database Business Layer Persistence Layer DAO / Repository Unit Test Unit Test In Process
  • 6. codecentric AG 6 Unit Testing Your Persistence Layer Unit tests should …  be fast  run in isolation  load test data  compare data
  • 7. codecentric AG 7 NoSQL Unit Github - https://github.com/lordofthejars/nosql-unit
  • 8. codecentric AG 8 NoSQL Unit > Overview Benefits  Database Lifecycle Management  Connection Management  Load Test Data  Compare Data
  • 9. codecentric AG 9 NoSQL Unit > Overview How does it work?  JUnit Extension  JUnit Rules  Annotations
  • 10. codecentric AG 10 NoSQL Unit > Database Management Options DatabaseNoSQL Unit Embedded JVM Local Machine Database Database Remote Machine Managed Remote
  • 11. codecentric AG 11 NoSQL Unit > Supported Databases Database Type Impl Language Embedded Managed / Remote Cassandra Column Java   CouchDB Document Erlang ---  Elasticsearch Document Java   HBase Column Java   Infinispan In Memory Java   MongoDB Document C++ fongo Mock  Neo4j Graph Java   Redis Key/Value C/C++ NoSQL Unit Mock 
  • 12. codecentric AG 12 NoSQL Unit > Lifecycle NoSQL Unit Database Test Case Loop over tests Launch (optional) Connect to Load Test Data (optional) Compare Data Sets (optional) Shutdown (optional) Run Test Interact with
  • 13. codecentric AG 13 NoSQL Unit > Redis Example public class EmbeddedRedisTest { @ClassRule public static EmbeddedRedis embeddedRedis = newEmbeddedRedisRule().build(); @Rule public RedisRule redisRule = newRedisRule().defaultEmbeddedRedis(); /** Unit under test. */ private KeyValueRepository repository; @Test @UsingDataSet( loadStrategy = LoadStrategyEnum.DELETE_ALL ) @ShouldMatchDataSet( location="keyvalue.json" ) public void should_insert_string() { // given KeyValueRepository repo = new KeyValueRepository( getJedisInstance() ); // when repo.setValue("hello", "redis"); // then: should match data } } Create embedded instance once for all tests Get connection once per test Prepare data Compare given and expected data after test
  • 14. codecentric AG 14 NoSQL Unit > Redis Example > keyvalue.json { "data": [ {"simple": [ { "key":"hello", "value":"redis"} ] } ] }
  • 15. codecentric AG 15 NoSQL Unit > MongoDB Example public class RemoteMongoDBTest { @Rule // use already running "remote" instance public MongoDbRule mongoRule = new MongoDbRule( mongoDb().databaseName("test").host("localhost").port(27017) .build() ); /** Unit under test. */ private OrderRepository repository; @Test @UsingDataSet(locations = "orders.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT) public void should_find_all_orders() { // given repository = createOrderRepository(); // when List<DBObject> orders = repository.findAll(); // then assertThat(orders, notNullValue()); assertThat(orders.size(), is(2)); } Load test data from JSON file
  • 16. codecentric AG 16 NoSQL Unit > MongoDB Example > orders.json { "orders": [ { "type": 4711, "desc": "1st order" }, { "type": 42, "desc": "2nd order" } ] }
  • 17. codecentric AG 17 NoSQL Unit > MongoDB > Advanced Features NoSQL Unit MongoDB supports  Replica Sets  Sharded Environments  Sharded Env. + Replica Sets …in managed mode.
  • 18. codecentric AG 18 Travis CI http://www.travis-ci.org
  • 19. codecentric AG 19 Travis CI > Overview Free Continuous Integration Platform: Lanuguages:  C/C++  Closure  Erlang  Go  Groovy  Java  JavaScript / Node.js  Objective-C  Ruby  Scala  … Services:  MySQL  PostgreSQL  MongoDB  CouchDB  Redis  Riak  RabbitMQ  Memcached  Cassandra  Neo4j  …
  • 20. codecentric AG 20 Travis CI > Lifecycle Travis CI Database GitHubTests start services shutdown services clone / checkout build & run use .travis.yml: language: java services: - mongodb - redis
  • 24. codecentric AG 24 Online Resources NoSQL Unit https://github.com/lordofthejars/nosql-unit Travis CI https://travis-ci.org/ NoSQL Unit Examples https://github.com/ttrelle/nosqlunit-examples
  • 25. codecentric AG 25 MongoDB User Group Düsseldorf https://www.xing.com/net/mongodb-dus/ http://www.meetup.com/Dusseldorf-MongoDB-User-Group/ @MongoDUS Meetup #10: MongoDB at LUMsearch.com (by Christian Douven) 03.07.2014, 19:00
  • 26. codecentric AG 26 QUESTIONS? Tobias Trelle codecentric AG Merscheider Str. 1 42699 Solingen tel +49 (0) 212.233628.47 fax +49 (0) 212.233628.79 mail Tobias.Trelle@codecentric.de twitter @tobiastrelle www.codecentric.de blog.codecentric.de/en/author/tobias-trelle www.xing.com/net/mongodb-dus