Test Strategy for Samza/Kafka Services

Devi Sridharan
5 min readintermediate
--
View Original

Overview

The article discusses the evolution of testing strategies for backend services at LinkedIn, specifically focusing on the transition from UI-driven tests to a more efficient testing framework using Apache Kafka and Apache Samza. It highlights the improvements in release velocity and quality achieved through this new approach.

What You'll Learn

1

How to decouple UI-based tests from backend testing to improve release cycles

2

Why adopting a fast-fail approach can enhance testing efficiency

3

How to implement scenario tests using Mockito for backend services

Prerequisites & Requirements

  • Understanding of backend service architecture and testing methodologies
  • Familiarity with Apache Kafka and Apache Samza(optional)

Key Questions Answered

How did LinkedIn improve its testing strategy for backend services?
LinkedIn improved its testing strategy by moving away from UI-driven tests to dedicated non-UI-based test strategies for backend services. This change allowed for faster release cycles, reducing commit-to-release time from weeks to less than two hours while maintaining high quality.
What are the phases of scenario tests in the new testing framework?
The scenario tests consist of three phases: Setup and configuration, where mock event topics are primed; Mocking and stubbing, using Mockito to simulate downstream calls; and Validation, where the produced Kafka events are consumed and validated against expected values.
What metrics indicate the success of the new testing strategy at LinkedIn?
The new testing strategy has resulted in the entire test suite completing in 2-3 minutes, backend services being tested in isolation without UI tests, and tests acting as a reliable safety net to catch defects early in the development cycle.

Key Statistics & Figures

Commit-to-release time
Less than two hours
This significant reduction was achieved by transforming the testing strategy.
Test suite execution time
2-3 minutes
This time is taken for the entire test suite to complete as a sanity check against every commit.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Backend
Apache Kafka
Used for processing real-time events in the Content Analytics platform.
Backend
Apache Samza
Utilized for stream processing in real-time event handling.
Testing
Mockito
Employed for mocking dependencies in scenario tests.

Key Actionable Insights

1
Implement a fast-fail approach in your testing strategy to identify issues earlier in the release cycle.
This approach allows teams to catch defects sooner, reducing the time spent on debugging and enhancing overall efficiency.
2
Utilize the Test Pyramid to ensure a proper distribution of tests across unit, scenario, and end-to-end tests.
This strategy helps maintain a balance between different types of tests, ensuring that the most critical aspects of the application are validated efficiently.
3
Consider using Mockito for mocking dependencies in your scenario tests.
Mocking allows you to isolate the system under test, ensuring that tests are reliable and do not depend on external systems.

Common Pitfalls

1
Relying too heavily on UI-driven tests can lead to fragile test suites that require frequent modifications.
This often results in longer release cycles due to the unpredictability of UI tests, making it essential to decouple backend testing from UI dependencies.

Related Concepts

Testing Methodologies
Backend Service Architecture
Real-time Data Processing