SlideShare a Scribd company logo
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

PPTX
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
PPTX
DataStax | DSE: Bring Your Own Spark (with Enterprise Security) (Artem Aliev)...
PDF
DataStax | Building a Spark Streaming App with DSE File System (Rocco Varela)...
PPTX
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
PDF
DataStax | Advanced DSE Analytics Client Configuration (Jacek Lewandowski) | ...
PDF
DataStax | DataStax Tools for Developers (Alex Popescu) | Cassandra Summit 2016
PPTX
Everyday I’m scaling... Cassandra
PPTX
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
DataStax | DSE: Bring Your Own Spark (with Enterprise Security) (Artem Aliev)...
DataStax | Building a Spark Streaming App with DSE File System (Rocco Varela)...
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
DataStax | Advanced DSE Analytics Client Configuration (Jacek Lewandowski) | ...
DataStax | DataStax Tools for Developers (Alex Popescu) | Cassandra Summit 2016
Everyday I’m scaling... Cassandra
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...

What's hot (20)

PPTX
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
PDF
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016
PPTX
Building a Multi-Region Cluster at Target (Aaron Ploetz, Target) | Cassandra ...
PPTX
Processing 50,000 events per second with Cassandra and Spark
PPTX
DataStax | Deploy DataStax Enterprise Clusters with OpsCenter (LCM) (Manikand...
PPTX
Cassandra Tuning - above and beyond
PDF
Advanced Cassandra
PPTX
DataStax | DSE Search 5.0 and Beyond (Nick Panahi & Ariel Weisberg) | Cassand...
PDF
Maximum Overdrive: Tuning the Spark Cassandra Connector (Russell Spitzer, Dat...
PPTX
Using Spark to Load Oracle Data into Cassandra
PPT
Clustering van IT-componenten
PDF
Managing Cassandra at Scale by Al Tobey
PPTX
Oracle: Let My People Go! (Shu Zhang, Ilya Sokolov, Symantec) | Cassandra Sum...
PDF
Elassandra: Elasticsearch as a Cassandra Secondary Index (Rémi Trouville, Vin...
PPTX
Understanding DSE Search by Matt Stump
PDF
Advanced Operations
PDF
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
PPTX
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
PPTX
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016
PDF
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016
Building a Multi-Region Cluster at Target (Aaron Ploetz, Target) | Cassandra ...
Processing 50,000 events per second with Cassandra and Spark
DataStax | Deploy DataStax Enterprise Clusters with OpsCenter (LCM) (Manikand...
Cassandra Tuning - above and beyond
Advanced Cassandra
DataStax | DSE Search 5.0 and Beyond (Nick Panahi & Ariel Weisberg) | Cassand...
Maximum Overdrive: Tuning the Spark Cassandra Connector (Russell Spitzer, Dat...
Using Spark to Load Oracle Data into Cassandra
Clustering van IT-componenten
Managing Cassandra at Scale by Al Tobey
Oracle: Let My People Go! (Shu Zhang, Ilya Sokolov, Symantec) | Cassandra Sum...
Elassandra: Elasticsearch as a Cassandra Secondary Index (Rémi Trouville, Vin...
Understanding DSE Search by Matt Stump
Advanced Operations
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Ad

Similar to DataStax | Effective Testing in DSE (Lessons Learned) (Predrag Knezevic) | Cassandra Summit 2016 (20)

PDF
Learning on Deep Learning
PDF
TestNG - The Next Generation of Unit Testing
PPTX
Techorama 2017 - Testing the unit, and beyond.
DOCX
Diversified AT Framework - Initial Version
PDF
Efficient Dependency Detection for Safe Java Test Acceleration
PDF
Create an architecture for web test automation
PDF
Testcontainers - Geekout EE 2017 presentation
PDF
Test strategies for data processing pipelines
PDF
Devoxx 2014 [incomplete] summary
PPTX
Profiling & Testing with Spark
PDF
A Declarative Approach for Performance Tests Execution in Continuous Software...
PPT
Strider_InMobi_HadoopSummit_2015_Brussels
PDF
Andrey Adamovich and Luciano Fiandesio - Groovy dev ops in the cloud
PPTX
Test NG Framework Complete Walk Through
PDF
QA Fest 2019. Антон Молдован. Load testing which you always wanted
PPTX
GeeCon.cz - Integration Testing from the Trenches Rebooted
PDF
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
PDF
Test Dependencies and the Future of Build Acceleration
PDF
Testing Spark and Scala
PPT
XML2Selenium Technical Presentation
Learning on Deep Learning
TestNG - The Next Generation of Unit Testing
Techorama 2017 - Testing the unit, and beyond.
Diversified AT Framework - Initial Version
Efficient Dependency Detection for Safe Java Test Acceleration
Create an architecture for web test automation
Testcontainers - Geekout EE 2017 presentation
Test strategies for data processing pipelines
Devoxx 2014 [incomplete] summary
Profiling & Testing with Spark
A Declarative Approach for Performance Tests Execution in Continuous Software...
Strider_InMobi_HadoopSummit_2015_Brussels
Andrey Adamovich and Luciano Fiandesio - Groovy dev ops in the cloud
Test NG Framework Complete Walk Through
QA Fest 2019. Антон Молдован. Load testing which you always wanted
GeeCon.cz - Integration Testing from the Trenches Rebooted
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Test Dependencies and the Future of Build Acceleration
Testing Spark and Scala
XML2Selenium Technical Presentation
Ad

More from DataStax (20)

PPTX
Is Your Enterprise Ready to Shine This Holiday Season?
PPTX
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
PPTX
Running DataStax Enterprise in VMware Cloud and Hybrid Environments
PPTX
Best Practices for Getting to Production with DataStax Enterprise Graph
PPTX
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
PPTX
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...
PDF
Webinar | Better Together: Apache Cassandra and Apache Kafka
PDF
Top 10 Best Practices for Apache Cassandra and DataStax Enterprise
PDF
Introduction to Apache Cassandra™ + What’s New in 4.0
PPTX
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
PPTX
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
PDF
Designing a Distributed Cloud Database for Dummies
PDF
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
PDF
How to Evaluate Cloud Databases for eCommerce
PPTX
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
PPTX
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
PPTX
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
PPTX
Datastax - The Architect's guide to customer experience (CX)
PPTX
An Operational Data Layer is Critical for Transformative Banking Applications
PPTX
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Is Your Enterprise Ready to Shine This Holiday Season?
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
Running DataStax Enterprise in VMware Cloud and Hybrid Environments
Best Practices for Getting to Production with DataStax Enterprise Graph
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...
Webinar | Better Together: Apache Cassandra and Apache Kafka
Top 10 Best Practices for Apache Cassandra and DataStax Enterprise
Introduction to Apache Cassandra™ + What’s New in 4.0
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Designing a Distributed Cloud Database for Dummies
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Evaluate Cloud Databases for eCommerce
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Datastax - The Architect's guide to customer experience (CX)
An Operational Data Layer is Critical for Transformative Banking Applications
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking

Recently uploaded (20)

PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
AI in Product Development-omnex systems
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Essential Infomation Tech presentation.pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Nekopoi APK 2025 free lastest update
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Transform Your Business with a Software ERP System
PDF
System and Network Administraation Chapter 3
PTS Company Brochure 2025 (1).pdf.......
How to Choose the Right IT Partner for Your Business in Malaysia
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
AI in Product Development-omnex systems
Odoo Companies in India – Driving Business Transformation.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Essential Infomation Tech presentation.pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
L1 - Introduction to python Backend.pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Odoo POS Development Services by CandidRoot Solutions
Nekopoi APK 2025 free lastest update
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Transform Your Business with a Software ERP System
System and Network Administraation Chapter 3

DataStax | Effective Testing in DSE (Lessons Learned) (Predrag Knezevic) | Cassandra Summit 2016

  • 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