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

What's hot (20)

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

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

PDF
Learning on Deep Learning
Shelley Lambert
 
PDF
TestNG - The Next Generation of Unit Testing
Bethmi Gunasekara
 
PPTX
Techorama 2017 - Testing the unit, and beyond.
Bert Brouns
 
DOCX
Diversified AT Framework - Initial Version
Yu Tao Zhang
 
PDF
Efficient Dependency Detection for Safe Java Test Acceleration
jon_bell
 
PDF
Create an architecture for web test automation
Elias Nogueira
 
PDF
Testcontainers - Geekout EE 2017 presentation
Richard North
 
PDF
Test strategies for data processing pipelines
Lars Albertsson
 
PDF
Devoxx 2014 [incomplete] summary
Artem Oboturov
 
PPTX
Profiling & Testing with Spark
Roger Rafanell Mas
 
PDF
A Declarative Approach for Performance Tests Execution in Continuous Software...
Vincenzo Ferme
 
PPT
Strider_InMobi_HadoopSummit_2015_Brussels
Swamynathan S
 
PDF
Andrey Adamovich and Luciano Fiandesio - Groovy dev ops in the cloud
DevConFu
 
PPTX
Test NG Framework Complete Walk Through
Narendran Solai Sridharan
 
PDF
QA Fest 2019. Антон Молдован. Load testing which you always wanted
QAFest
 
PPTX
GeeCon.cz - Integration Testing from the Trenches Rebooted
Nicolas Fränkel
 
PDF
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Kevin Brockhoff
 
PDF
Test Dependencies and the Future of Build Acceleration
New York City College of Technology Computer Systems Technology Colloquium
 
PDF
Testing Spark and Scala
datamantra
 
PPT
XML2Selenium Technical Presentation
jazzteam
 
Learning on Deep Learning
Shelley Lambert
 
TestNG - The Next Generation of Unit Testing
Bethmi Gunasekara
 
Techorama 2017 - Testing the unit, and beyond.
Bert Brouns
 
Diversified AT Framework - Initial Version
Yu Tao Zhang
 
Efficient Dependency Detection for Safe Java Test Acceleration
jon_bell
 
Create an architecture for web test automation
Elias Nogueira
 
Testcontainers - Geekout EE 2017 presentation
Richard North
 
Test strategies for data processing pipelines
Lars Albertsson
 
Devoxx 2014 [incomplete] summary
Artem Oboturov
 
Profiling & Testing with Spark
Roger Rafanell Mas
 
A Declarative Approach for Performance Tests Execution in Continuous Software...
Vincenzo Ferme
 
Strider_InMobi_HadoopSummit_2015_Brussels
Swamynathan S
 
Andrey Adamovich and Luciano Fiandesio - Groovy dev ops in the cloud
DevConFu
 
Test NG Framework Complete Walk Through
Narendran Solai Sridharan
 
QA Fest 2019. Антон Молдован. Load testing which you always wanted
QAFest
 
GeeCon.cz - Integration Testing from the Trenches Rebooted
Nicolas Fränkel
 
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Kevin Brockhoff
 
Test Dependencies and the Future of Build Acceleration
New York City College of Technology Computer Systems Technology Colloquium
 
Testing Spark and Scala
datamantra
 
XML2Selenium Technical Presentation
jazzteam
 
Ad

More from DataStax (20)

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

Recently uploaded (20)

PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

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

  • 1. Effective  Testing  in  DSE Predrag Knežević [email protected] @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