SlideShare a Scribd company logo
1 of 22
Download to read offline
Effective  Testing  in  DSE
Predrag Knežević
predrag.knezevic@datastax.com
@pedjakknezevic
Why  Taking  Care?
• Automated  testing  for  quality  control  of  shipped  product/service
• Number  of  tests  and  total  testing  times  increase  over  time
• Shorter  delivery  cycles  →  continuous  testing
• Run  tests  on  each  pre-­merge  check,  but
• Keep  feedback  cycles  short
• Ensure  repeatable  test  execution  anywhere
©  DataStax,  All  Rights  Reserved. 2
DSE  Build  Facts
• Junit  based  test  infrastructure
• December  2014  (DSE  4.6)
• Ant  based  build  system
• ~5h  for  running  all  tests  on  Jenkins,  with  a  rather  complicated  job  layout
• July  2016  (DSE  4.7+)
• Gradle based  build  system
• 40-­60mins  for  running  all  tests  on  Jenkins
• 16  hours  of  total  testing  time
• The  number  of  tests  doubled!
• Repeatable  test  execution  across  all  machines
• Simple  setup
©  DataStax,  All  Rights  Reserved. 3
Why  Moving  to  Gradle?
• Built-­in  support  for  parallel  test  execution
• Readable  -­ build  scripts  based  on  Groovy  (easy  learning  for  Java  devs)
• Repeatable  builds/environment  setup  across  machines
• Powerful  dependency  management
• Sane  conventions,  but  configurable  when  needed
• Easy  project  modularization
• Excellent  Eclipse/IntelliJ  support
• Easy  extendable  through  plugins  or  additional  Java/Groovy  code  living  in  the  script  or  project
• All  Ant  tasks  still  available
©  DataStax,  All  Rights  Reserved. 4
Running  Tests
• All:  gradlew test
• Single:  gradlew test -Dtest.single=FooTest
• By  default  sequential  execution
• Low  resources  usage  on  modern  multicore  hardware
• Long  test  round  duration
©  DataStax,  All  Rights  Reserved. 5
Main
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
Parallel  Test  Execution
©  DataStax,  All  Rights  Reserved. 6
build.gradle
test {
maxParallelForks = N
}
Main
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
.
. N
Dockerized Test  Execution
©  DataStax,  All  Rights  Reserved. 7
Main
.
.
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
N
github.com/datastax/gradle-dockerized-test-plugin
Dockerized Test  Execution  (2)
©  DataStax,  All  Rights  Reserved. 8
build.gradle
test {
maxParallelForks = N
docker {
image = ’test-image’
}
}
• Install  Docker  locally  (native  or  boot2docker)
• No  changes  on  production  or  test  code  required
• Test  environment
• Consistent  across  all  machines  (dev  +  CI)
→  no  more  “it  works  on  my  machine”
• Managed  as  code  (Dockerfiles)  within  project
• Easy  machine  bootstraping
• Fully  isolated
• Easy  testing  against  
several  and/or  appropriate  environment
Worker  Starvation
©  DataStax,  All  Rights  Reserved. 9
Main
.
.
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
Static  queue  allocation!
Improved  Queue  Management
©  DataStax,  All  Rights  Reserved. 10
Test Worker
Main
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
Test Worker
Test  Scheduling
©  DataStax,  All  Rights  Reserved. 11
Main
.
.
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
Test Worker
Test Queue
TestClass1
TestClass2
TestClass3
TestClass4
• NP-­hard
• Longest  Processing  Time  (LPT)  
algorithm
• History  access  required
More  Workers  for  Faster  Feedback
• Powerful  multi-­core  machine
• Docker  Swarm
• Virtual  Docker  engine
• Test  workers  run  on  
a  Swam  node
• Cluster  can  shrink  or  grow
• Lower  bound  for  the  test  round  duration  
is  equal  to  the  duration  of  slowest  test  class
©  DataStax,  All  Rights  Reserved. 12
Swarm  master
Main
Swarm  node
Swarm  node
Test  Worker
Test  Worker
Test  Worker
Test  Worker
Split  Slow  Test  Classes for  More  Throughput
class FooTest {
@Test
void bar1() {
}
@Test
void bar2() {
}
}
class Foo1Test {
@Test
void bar1() {
}
}
class Foo2Test {
@Test
void bar2() {
}
}
● Manual
○ Group by common
fixture
○ Extreme: one test per
class
● Bytecode manipulations
(auto split annotated class)
● Grouping tests classes
into JUnit suites forces
their sequential execution!
No  Embedded  DSE  Nodes
• Running  cluster  within  single  test  worker  JVM  possible  only  by  using  separate  classpath loaders
• Still  requires  a  good  amount  of  hacking  to  make  it  work  decently
• Node  shutdowns  might  still  be  problematic
• Thread  can  hang  around
• Some  objects  cannot  be  garbage  collected  →  memory  leaks
• Standalone  nodes  enable  reusage across  test  classes
©  DataStax,  All  Rights  Reserved. 14
Remote  Code  Execution
• MobilityRPC library  (http://github.com/npgall/mobility-­rpc)
• Remote  JUnit  Testrunner
(http://github.com/datastax/remote-­junit-­runner)
• Useful  for  integration  tests  requiring  application  context,  but  
application  cannot  be  easily  embedded  into  test  JVM
• Support  any  existing  JUnit  runner  on  the  remote  side  
(Parametrized,  Spock,  Suites)
©  DataStax,  All  Rights  Reserved. 15
@RunWith(Remote.class)
public class RemoteTest {
@Test
public void foo() {
// test
}
}
Injecting  Faults
• JBoss Byteman (http://byteman.jboss.org)
• Inject  at  runtime
• Exceptions
• Delays
• Arbitrary  side-­effects
• Enables/simplifies  testing  of  edge/uncommon  cases
©  DataStax,  All  Rights  Reserved. 16
Logging
• Logback (http://logback.qos.ch/) based  infrastructure
• Log  file  per  a  test  case
• Send  all  log  messages  to  the  single  logback server  asynchronously  (reactor-­logback adapter)
keeping  DSE  nodes  responsive  
• Route  log  statements  to  the  proper  file  using  SiftingAdapter and  appropriate  discriminator
• Use  JUnit  rules  to  mark  the  beginning  and  the  end  of  a  test  and  
propagate  this  information  to  the  logback discriminator
• Write  thread  dumps  in  case  of  a  failure
• Scan  log  files  for  known  issues  and  fail  tests  if  they  occur  (e.g.  Netty memory  leaks)
• Turn  DEBUG  messages  on  to  help  later  digging  in  a  case  of  failure
©  DataStax,  All  Rights  Reserved. 17
Log  Event  Sender
<appender name="SOCKET" class="com.datastax.bdp.logback.SocketAppender">
<remoteHost>${logbackServer}</remoteHost>
<port>12345</port>
<reconnectionDelay>1 seconds</reconnectionDelay>
<nodeId>${nodeid}</nodeId>
<eventDelayLimit>120 seconds</eventDelayLimit>
</appender>
<appender name="ASYNC" class="reactor.logback.AsyncAppender">
<includeCallerData>true</includeCallerData>
<appender-ref ref="SOCKET"/>
</appender>
<root level="DEBUG">
<appender-ref ref="ASYNC"/>
</root>
©  DataStax,  All  Rights  Reserved. 18
Log  Event  Router
<appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator class="com.datastax.bdp.test.ng.LogFileDiscriminator">
<key>TEST_LOG_FILE</key>
<defaultValue>system.log</defaultValue>
</discriminator>
<sift>
<appender name="FILE-${TEST_LOG_FILE}" class="ch.qos.logback.core.FileAppender">
<filter class="com.datastax.bdp.test.ng.ForbiddenLogEventsDetector">
<logFile>${TEST_LOG_FILE}</logFile>
<detector class="com.datastax.bdp.test.ng.NettyLeakDetector"/>
</filter>
<encoder>
<pattern>%X{nodeid} %5p [%t] %d{ISO8601} %F (line %line) %m%n</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
<file>${LOG_DIR}/${TEST_LOG_FILE}</file>
<append>true</append>
</appender>
</sift>
</appender>
©  DataStax,  All  Rights  Reserved. 19
Test  Start/End  Detection  
@Rule
public TestRule watcher = new TestWatcher() {
private String logFile;
@Override
protected void starting(Description description) {
logFile = description.getClassName()+"/"+description.getMethodName()+".log";
logToFile(logFile);
}
protected void failed(Throwable e, Description description) {
threadDumpLogger.error("Test {}.{} failed, thread dump:n{}n", description.getClassName(),
description.getMethodName(), getThreadDumps());
logToFile(description.getClassName()+"/after.log");
}
protected void finished(Description description) {
logToFile(description.getClassName()+"/after.log");
ForbiddenLogEventsDetector.checkForIssues(logFile);
}
};
©  DataStax,  All  Rights  Reserved. 20
Resources
• Gradle (gradle.org)
• Docker  (docker.com)
• Gradle Dockerized Test  Plugin  (github.com/datastax/gradle-­dockerized-­test-­plugin)
• MobilityRPC (http://github.com/npgall/mobility-­rpc)
• Remote  JUnit  Testrunner (http://github.com/datastax/remote-­junit-­runner)
• JBoss Byteman (http://byteman.jboss.org)
• Logback (http://logback.qos.ch/)
• Project  Reactor  Addons (github.com/reactor/reactor-­addons),  Logback adapter
©  DataStax,  All  Rights  Reserved. 21
Thank  you!
Questions?
©  DataStax,  All  Rights  Reserved.22

More Related Content

What's hot

Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...
Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...
Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...Dmitry Lazarenko
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniZalando Technology
 
Kernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver frameworkKernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver frameworkAnne Nicolas
 
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...DataStax
 
Rally--OpenStack Benchmarking at Scale
Rally--OpenStack Benchmarking at ScaleRally--OpenStack Benchmarking at Scale
Rally--OpenStack Benchmarking at ScaleMirantis
 
Nagios Conference 2012 - Mike Weber - Failover
Nagios Conference 2012 - Mike Weber - FailoverNagios Conference 2012 - Mike Weber - Failover
Nagios Conference 2012 - Mike Weber - FailoverNagios
 
Low latency & mechanical sympathy issues and solutions
Low latency & mechanical sympathy  issues and solutionsLow latency & mechanical sympathy  issues and solutions
Low latency & mechanical sympathy issues and solutionsJean-Philippe BEMPEL
 
OSS Presentation VMWorld 2011 by Andy Bennett & Craig Morgan
OSS Presentation VMWorld 2011 by Andy Bennett & Craig MorganOSS Presentation VMWorld 2011 by Andy Bennett & Craig Morgan
OSS Presentation VMWorld 2011 by Andy Bennett & Craig MorganOpenStorageSummit
 
Introduction to .Net Driver
Introduction to .Net DriverIntroduction to .Net Driver
Introduction to .Net DriverDataStax Academy
 
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxyBo-Yi Wu
 
NetBSD and Linux for Embedded Systems
NetBSD and Linux for Embedded SystemsNetBSD and Linux for Embedded Systems
NetBSD and Linux for Embedded SystemsMahendra M
 
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)Wei Shan Ang
 
On The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL ClusterOn The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL ClusterSrihari Sriraman
 
Oracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingOracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingTanel Poder
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Applicationguest1f2740
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumpsTier1 App
 

What's hot (20)

Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...
Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...
Private PaaS & Container-as-a-Service for ISVs and Enterprise - Use Cases and...
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando Patroni
 
Kernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver frameworkKernel Recipes 2015 - So you want to write a Linux driver framework
Kernel Recipes 2015 - So you want to write a Linux driver framework
 
The Accidental DBA
The Accidental DBAThe Accidental DBA
The Accidental DBA
 
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
 
Presentation
PresentationPresentation
Presentation
 
Rally--OpenStack Benchmarking at Scale
Rally--OpenStack Benchmarking at ScaleRally--OpenStack Benchmarking at Scale
Rally--OpenStack Benchmarking at Scale
 
Nagios Conference 2012 - Mike Weber - Failover
Nagios Conference 2012 - Mike Weber - FailoverNagios Conference 2012 - Mike Weber - Failover
Nagios Conference 2012 - Mike Weber - Failover
 
Low latency & mechanical sympathy issues and solutions
Low latency & mechanical sympathy  issues and solutionsLow latency & mechanical sympathy  issues and solutions
Low latency & mechanical sympathy issues and solutions
 
Atomic CLI scan
Atomic CLI scanAtomic CLI scan
Atomic CLI scan
 
OSS Presentation VMWorld 2011 by Andy Bennett & Craig Morgan
OSS Presentation VMWorld 2011 by Andy Bennett & Craig MorganOSS Presentation VMWorld 2011 by Andy Bennett & Craig Morgan
OSS Presentation VMWorld 2011 by Andy Bennett & Craig Morgan
 
Introduction to .Net Driver
Introduction to .Net DriverIntroduction to .Net Driver
Introduction to .Net Driver
 
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
2014 OSDC Talk: Introduction to Percona XtraDB Cluster and HAProxy
 
NetBSD and Linux for Embedded Systems
NetBSD and Linux for Embedded SystemsNetBSD and Linux for Embedded Systems
NetBSD and Linux for Embedded Systems
 
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
 
On The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL ClusterOn The Building Of A PostgreSQL Cluster
On The Building Of A PostgreSQL Cluster
 
Introduction to clarity
Introduction to clarityIntroduction to clarity
Introduction to clarity
 
Oracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingOracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention Troubleshooting
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Application
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 

Similar to Effective Testing in DSE

Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)
Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)
Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)STePINForum
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherencearagozin
 
Parallelizing CI using Docker Swarm-Mode
Parallelizing CI using Docker Swarm-ModeParallelizing CI using Docker Swarm-Mode
Parallelizing CI using Docker Swarm-ModeAkihiro Suda
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsOrtus Solutions, Corp
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldJignesh Shah
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
PaaSTA: Running applications at Yelp
PaaSTA: Running applications at YelpPaaSTA: Running applications at Yelp
PaaSTA: Running applications at YelpNathan Handler
 
Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Novaclayton_oneill
 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAkshaya Mahapatra
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpikeos890
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang YoonJesang Yoon
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersVMware Tanzu
 
Oracle Workflow Continuous Integration
Oracle Workflow Continuous IntegrationOracle Workflow Continuous Integration
Oracle Workflow Continuous IntegrationRajesh Raheja
 
Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...
Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...
Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...HostedbyConfluent
 
Warden @ Meet magento Romania 2021
Warden @ Meet magento Romania 2021Warden @ Meet magento Romania 2021
Warden @ Meet magento Romania 2021alinalexandru
 
Resilience Testing
Resilience Testing Resilience Testing
Resilience Testing Ran Levy
 
Intro to Azure SQL database
Intro to Azure SQL databaseIntro to Azure SQL database
Intro to Azure SQL databaseSteve Knutson
 
Best practices in Deploying SUSE CaaS Platform v3
Best practices in Deploying SUSE CaaS Platform v3Best practices in Deploying SUSE CaaS Platform v3
Best practices in Deploying SUSE CaaS Platform v3Juan Herrera Utande
 
Prod-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized ApplicationsProd-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized ApplicationsVMware Tanzu
 

Similar to Effective Testing in DSE (20)

Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)
Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)
Docker–Grid (A On demand and Scalable dockerized selenium grid architecture)
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
 
Parallelizing CI using Docker Swarm-Mode
Parallelizing CI using Docker Swarm-ModeParallelizing CI using Docker Swarm-Mode
Parallelizing CI using Docker Swarm-Mode
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applications
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
PaaSTA: Running applications at Yelp
PaaSTA: Running applications at YelpPaaSTA: Running applications at Yelp
PaaSTA: Running applications at Yelp
 
Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Nova
 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps Approach
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With Testcontainers
 
Oracle Workflow Continuous Integration
Oracle Workflow Continuous IntegrationOracle Workflow Continuous Integration
Oracle Workflow Continuous Integration
 
Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...
Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...
Tales from the four-comma club: Managing Kafka as a service at Salesforce | L...
 
Warden @ Meet magento Romania 2021
Warden @ Meet magento Romania 2021Warden @ Meet magento Romania 2021
Warden @ Meet magento Romania 2021
 
Resilience Testing
Resilience Testing Resilience Testing
Resilience Testing
 
Intro to Azure SQL database
Intro to Azure SQL databaseIntro to Azure SQL database
Intro to Azure SQL database
 
Apache cassandra v4.0
Apache cassandra v4.0Apache cassandra v4.0
Apache cassandra v4.0
 
Best practices in Deploying SUSE CaaS Platform v3
Best practices in Deploying SUSE CaaS Platform v3Best practices in Deploying SUSE CaaS Platform v3
Best practices in Deploying SUSE CaaS Platform v3
 
Prod-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized ApplicationsProd-Like Integration Testing for Distributed Containerized Applications
Prod-Like Integration Testing for Distributed Containerized Applications
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 

Effective Testing in DSE

  • 1. Effective  Testing  in  DSE Predrag Knežević predrag.knezevic@datastax.com @pedjakknezevic
  • 2. Why  Taking  Care? • Automated  testing  for  quality  control  of  shipped  product/service • Number  of  tests  and  total  testing  times  increase  over  time • Shorter  delivery  cycles  →  continuous  testing • Run  tests  on  each  pre-­merge  check,  but • Keep  feedback  cycles  short • Ensure  repeatable  test  execution  anywhere ©  DataStax,  All  Rights  Reserved. 2
  • 3. DSE  Build  Facts • Junit  based  test  infrastructure • December  2014  (DSE  4.6) • Ant  based  build  system • ~5h  for  running  all  tests  on  Jenkins,  with  a  rather  complicated  job  layout • July  2016  (DSE  4.7+) • Gradle based  build  system • 40-­60mins  for  running  all  tests  on  Jenkins • 16  hours  of  total  testing  time • The  number  of  tests  doubled! • Repeatable  test  execution  across  all  machines • Simple  setup ©  DataStax,  All  Rights  Reserved. 3
  • 4. Why  Moving  to  Gradle? • Built-­in  support  for  parallel  test  execution • Readable  -­ build  scripts  based  on  Groovy  (easy  learning  for  Java  devs) • Repeatable  builds/environment  setup  across  machines • Powerful  dependency  management • Sane  conventions,  but  configurable  when  needed • Easy  project  modularization • Excellent  Eclipse/IntelliJ  support • Easy  extendable  through  plugins  or  additional  Java/Groovy  code  living  in  the  script  or  project • All  Ant  tasks  still  available ©  DataStax,  All  Rights  Reserved. 4
  • 5. Running  Tests • All:  gradlew test • Single:  gradlew test -Dtest.single=FooTest • By  default  sequential  execution • Low  resources  usage  on  modern  multicore  hardware • Long  test  round  duration ©  DataStax,  All  Rights  Reserved. 5 Main Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4
  • 6. Parallel  Test  Execution ©  DataStax,  All  Rights  Reserved. 6 build.gradle test { maxParallelForks = N } Main Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 . . N
  • 7. Dockerized Test  Execution ©  DataStax,  All  Rights  Reserved. 7 Main . . Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 N github.com/datastax/gradle-dockerized-test-plugin
  • 8. Dockerized Test  Execution  (2) ©  DataStax,  All  Rights  Reserved. 8 build.gradle test { maxParallelForks = N docker { image = ’test-image’ } } • Install  Docker  locally  (native  or  boot2docker) • No  changes  on  production  or  test  code  required • Test  environment • Consistent  across  all  machines  (dev  +  CI) →  no  more  “it  works  on  my  machine” • Managed  as  code  (Dockerfiles)  within  project • Easy  machine  bootstraping • Fully  isolated • Easy  testing  against   several  and/or  appropriate  environment
  • 9. Worker  Starvation ©  DataStax,  All  Rights  Reserved. 9 Main . . Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 Static  queue  allocation!
  • 10. Improved  Queue  Management ©  DataStax,  All  Rights  Reserved. 10 Test Worker Main Test Queue TestClass1 TestClass2 TestClass3 TestClass4 Test Worker
  • 11. Test  Scheduling ©  DataStax,  All  Rights  Reserved. 11 Main . . Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 Test Worker Test Queue TestClass1 TestClass2 TestClass3 TestClass4 • NP-­hard • Longest  Processing  Time  (LPT)   algorithm • History  access  required
  • 12. More  Workers  for  Faster  Feedback • Powerful  multi-­core  machine • Docker  Swarm • Virtual  Docker  engine • Test  workers  run  on   a  Swam  node • Cluster  can  shrink  or  grow • Lower  bound  for  the  test  round  duration   is  equal  to  the  duration  of  slowest  test  class ©  DataStax,  All  Rights  Reserved. 12 Swarm  master Main Swarm  node Swarm  node Test  Worker Test  Worker Test  Worker Test  Worker
  • 13. Split  Slow  Test  Classes for  More  Throughput class FooTest { @Test void bar1() { } @Test void bar2() { } } class Foo1Test { @Test void bar1() { } } class Foo2Test { @Test void bar2() { } } ● Manual ○ Group by common fixture ○ Extreme: one test per class ● Bytecode manipulations (auto split annotated class) ● Grouping tests classes into JUnit suites forces their sequential execution!
  • 14. No  Embedded  DSE  Nodes • Running  cluster  within  single  test  worker  JVM  possible  only  by  using  separate  classpath loaders • Still  requires  a  good  amount  of  hacking  to  make  it  work  decently • Node  shutdowns  might  still  be  problematic • Thread  can  hang  around • Some  objects  cannot  be  garbage  collected  →  memory  leaks • Standalone  nodes  enable  reusage across  test  classes ©  DataStax,  All  Rights  Reserved. 14
  • 15. Remote  Code  Execution • MobilityRPC library  (http://github.com/npgall/mobility-­rpc) • Remote  JUnit  Testrunner (http://github.com/datastax/remote-­junit-­runner) • Useful  for  integration  tests  requiring  application  context,  but   application  cannot  be  easily  embedded  into  test  JVM • Support  any  existing  JUnit  runner  on  the  remote  side   (Parametrized,  Spock,  Suites) ©  DataStax,  All  Rights  Reserved. 15 @RunWith(Remote.class) public class RemoteTest { @Test public void foo() { // test } }
  • 16. Injecting  Faults • JBoss Byteman (http://byteman.jboss.org) • Inject  at  runtime • Exceptions • Delays • Arbitrary  side-­effects • Enables/simplifies  testing  of  edge/uncommon  cases ©  DataStax,  All  Rights  Reserved. 16
  • 17. Logging • Logback (http://logback.qos.ch/) based  infrastructure • Log  file  per  a  test  case • Send  all  log  messages  to  the  single  logback server  asynchronously  (reactor-­logback adapter) keeping  DSE  nodes  responsive   • Route  log  statements  to  the  proper  file  using  SiftingAdapter and  appropriate  discriminator • Use  JUnit  rules  to  mark  the  beginning  and  the  end  of  a  test  and   propagate  this  information  to  the  logback discriminator • Write  thread  dumps  in  case  of  a  failure • Scan  log  files  for  known  issues  and  fail  tests  if  they  occur  (e.g.  Netty memory  leaks) • Turn  DEBUG  messages  on  to  help  later  digging  in  a  case  of  failure ©  DataStax,  All  Rights  Reserved. 17
  • 18. Log  Event  Sender <appender name="SOCKET" class="com.datastax.bdp.logback.SocketAppender"> <remoteHost>${logbackServer}</remoteHost> <port>12345</port> <reconnectionDelay>1 seconds</reconnectionDelay> <nodeId>${nodeid}</nodeId> <eventDelayLimit>120 seconds</eventDelayLimit> </appender> <appender name="ASYNC" class="reactor.logback.AsyncAppender"> <includeCallerData>true</includeCallerData> <appender-ref ref="SOCKET"/> </appender> <root level="DEBUG"> <appender-ref ref="ASYNC"/> </root> ©  DataStax,  All  Rights  Reserved. 18
  • 19. Log  Event  Router <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender"> <discriminator class="com.datastax.bdp.test.ng.LogFileDiscriminator"> <key>TEST_LOG_FILE</key> <defaultValue>system.log</defaultValue> </discriminator> <sift> <appender name="FILE-${TEST_LOG_FILE}" class="ch.qos.logback.core.FileAppender"> <filter class="com.datastax.bdp.test.ng.ForbiddenLogEventsDetector"> <logFile>${TEST_LOG_FILE}</logFile> <detector class="com.datastax.bdp.test.ng.NettyLeakDetector"/> </filter> <encoder> <pattern>%X{nodeid} %5p [%t] %d{ISO8601} %F (line %line) %m%n</pattern> <immediateFlush>false</immediateFlush> </encoder> <file>${LOG_DIR}/${TEST_LOG_FILE}</file> <append>true</append> </appender> </sift> </appender> ©  DataStax,  All  Rights  Reserved. 19
  • 20. Test  Start/End  Detection   @Rule public TestRule watcher = new TestWatcher() { private String logFile; @Override protected void starting(Description description) { logFile = description.getClassName()+"/"+description.getMethodName()+".log"; logToFile(logFile); } protected void failed(Throwable e, Description description) { threadDumpLogger.error("Test {}.{} failed, thread dump:n{}n", description.getClassName(), description.getMethodName(), getThreadDumps()); logToFile(description.getClassName()+"/after.log"); } protected void finished(Description description) { logToFile(description.getClassName()+"/after.log"); ForbiddenLogEventsDetector.checkForIssues(logFile); } }; ©  DataStax,  All  Rights  Reserved. 20
  • 21. Resources • Gradle (gradle.org) • Docker  (docker.com) • Gradle Dockerized Test  Plugin  (github.com/datastax/gradle-­dockerized-­test-­plugin) • MobilityRPC (http://github.com/npgall/mobility-­rpc) • Remote  JUnit  Testrunner (http://github.com/datastax/remote-­junit-­runner) • JBoss Byteman (http://byteman.jboss.org) • Logback (http://logback.qos.ch/) • Project  Reactor  Addons (github.com/reactor/reactor-­addons),  Logback adapter ©  DataStax,  All  Rights  Reserved. 21
  • 22. Thank  you! Questions? ©  DataStax,  All  Rights  Reserved.22