https://github.com/dream-horizon-org/testlab
https://github.com/dream-horizon-org/testlab
experimentation
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dream-horizon-org/testlab
- Owner: dream-horizon-org
- License: mit
- Created: 2025-10-06T14:13:37.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-01-22T10:56:33.000Z (4 months ago)
- Last Synced: 2026-01-23T01:12:58.721Z (4 months ago)
- Topics: experimentation
- Language: Java
- Homepage:
- Size: 840 KB
- Stars: 19
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
TestLab
Enterprise-grade A/B Testing & Feature Experimentation Platform
## ๐ Overview
TestLab is a robust, high-performance experimentation platform designed for modern applications. It provides comprehensive A/B testing capabilities with flexible targeting rules, real-time user allocation, and variant management - giving you complete control over your feature experiments.
## Why TestLab?
* ๐งช **Powerful Experimentation**: Full A/B testing with multi-variant support and statistical rigor
* ๐ฏ **Flexible Targeting**: Rule-based targeting with cohorts, attributes, and custom conditions
* ๐ข **Multi-Tenant Ready**: Supports multiple projects with logical isolation
* ๐ **Quick Implementation**: Get experiments running in minutes
* โก **High Performance**: Built on Vert.x for reactive, non-blocking I/O with Aerospike for lightning-fast allocations
* ๐ **Real-time Allocation**: Instant user assignment with consistent bucketing
* ๐ **Lifecycle Management**: Full experiment lifecycle from DRAFT to CONCLUDED
## ๐ Table of Contents
* [Features](#-features)
* [Architecture](#-architecture)
* [Getting Started](#-getting-started)
* [Configuration](#-configuration)
* [API Reference](#-api-reference)
* [Deployment](#-deployment)
* [Contributing](#-contributing)
* [License](#-license)
## โจ Features
### Experiment Management
* **๐ Create Experiments**: Define A/B tests with multiple variants
* **๐ Lifecycle States**: DRAFT โ LIVE โ PAUSED โ CONCLUDED/TERMINATED
* **๐ Variant Weights**: Configure traffic distribution across variants
* **๐ท๏ธ Tags & Owners**: Organize experiments with tags and assign ownership
* **๐ Metrics Tracking**: Define primary and secondary metrics for analysis
### Targeting & Allocation
* **๐ฅ Cohort-based Targeting**: Target specific user cohorts
* **๐ Rule-based Targeting**: Define complex targeting rules with conditions
* Attribute-based conditions (operand, operator, value)
* Multiple data types: STRING, INTEGER, DOUBLE, BOOLEAN, LIST, SEMVER
* Rich operators: EQUALS, NOT_EQUALS, GREATER_THAN, LESS_THAN, CONTAINS, IN, etc.
* **๐ฒ Distribution Strategies**: RANDOM allocation with configurable exposure
* **๐ Threshold Limits**: Control maximum experiment participation
### Real-time Allocation
* **๐ Fast User Assignment**: Sub-millisecond allocation decisions
* **๐ Consistent Bucketing**: Users always see the same variant
* **๐ฑ Multi-experiment Support**: Allocate users to multiple experiments simultaneously
* **๐ Reallocation Support**: Move users between variants when needed
### Administration
* **๐ Experiment History**: Track all changes with audit logs
* **๐ Filter & Search**: Find experiments by status, type, name, tags, or owners
* **โ
Key Availability**: Check experiment key uniqueness before creation
## ๐๏ธ Architecture
TestLab is built with a modern, scalable architecture:
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TestLab API โ
โ (Vert.x REST API) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Experiment โ โ Allocation โ โ Admin Service โ โ
โ โ Service โ โ Service โ โ (History, Tags) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Data Layer โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ PostgreSQL โ โ Aerospike โโ
โ โ (Experiment Data) โ โ (User Allocations/Counts) โโ
โ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## ๐ Getting Started
### Prerequisites
* **Docker** โฅ 20.10 ([Download Docker Desktop](https://www.docker.com/products/docker-desktop/))
* **Docker Compose** โฅ 2.0 ([Install instructions](https://docs.docker.com/compose/install/))
* **Maven** โฅ 3.6 ([Download Maven](https://maven.apache.org/download.cgi))
* **Java 17** (JDK) ([Download Java 17](https://www.oracle.com/java/technologies/downloads/#java17))
### Verify Installations
```bash
docker --version
mvn --version
java -version
```
**Important**: Ensure that Java 17 is the active version. Maven should also be configured to use Java 17 - verify with `mvn --version`.
### Port Requirements
Ensure the following ports are available:
* `8142` โ PostgreSQL database
* `8130` โ Aerospike
* `8100` โ TestLab application server
### Quick Start
1. **Clone the repository**:
```bash
git clone https://github.com/dream-horizon-org/testlab.git
cd testlab
```
2. **Start infrastructure services**:
```bash
# With default project key
docker-compose up -d
# Or with a custom project key
PROJECT_KEY=your-project-key-here docker-compose up -d
```
> **Note**: The `PROJECT_KEY` environment variable is used to create PostgreSQL partitions and seed data for your project. If not specified, it defaults to `550e8400-e29b-41d4-a716-446655440001`.
3. **Build and run TestLab**:
```bash
mvn clean package -DskipTests
cd target/testlab
PG_USER=postgres PG_PASSWORD=postgres java -Dapp.environment=local -Dlogback.configurationFile=./resources/logback/logback.xml -jar testlab-1.0-fat.jar
```
## โ๏ธ Configuration
### Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| `PG_USER` | PostgreSQL username | - |
| `PG_PASSWORD` | PostgreSQL password | - |
| `PROJECT_KEY` | Project identifier for multi-tenant partitioning | `550e8400-e29b-41d4-a716-446655440001` |
| `app.environment` | Environment type (local, test, prod) | - |
### Configuration Files
Configuration files are located in `src/main/resources/config/`:
* `application/default.conf` - Application settings
* `postgresql/default.conf` - Database configuration
* `aerospike/default.conf` - Aerospike cache settings
* `http-server/default.conf` - HTTP server settings
* `circuit-breaker/default.conf` - Resilience settings
### Multi-Tenant Setup (Project Key)
TestLab uses PostgreSQL partitioning for multi-tenant isolation. Each project has its own partition:
```bash
# Start with a specific project
PROJECT_KEY=my-project-key docker-compose up -d
# Or set it in a .env file
echo "PROJECT_KEY=my-project-uuid" > .env
docker-compose up -d
```
When making API calls, include the project key in the header:
```bash
curl -X GET http://localhost:8100/v1/experiments \
-H "x-project-key: my-project-key"
```
> **Note**: If you try to access a project that doesn't have a partition, you'll receive a `PARTITION_NOT_FOUND` error. Ensure partitions are created before making API calls.
## ๐ API Reference
### Swagger Specification
The complete API specification is available at:
* [Swagger File](./src/main/resources/webroot/swagger/swagger.yaml)
### Database Schema
* [DB Schema](./src/main/resources/db/postgresql/schema.sql)
## ๐ Deployment
### Running with Docker
```bash
# Default project key
docker-compose up -d
# Custom project key (creates partitions for your project)
PROJECT_KEY=my-custom-project-id docker-compose up -d
```
The `PROJECT_KEY` variable:
- Creates PostgreSQL partitions for the specified project
- Seeds initial experiment data associated with that project
- Enables multi-tenant isolation per project
### Running the JAR
```bash
mvn clean package
cd target/testlab
PG_USER= \
PG_PASSWORD= \
java -Dapp.environment= \
-Dlogback.configurationFile=./resources/logback/logback.xml \
-jar testlab-1.0-fat.jar
```
### IntelliJ Run Configuration
1. Create IntelliJ Run Configuration of type `Application`
2. Add VM options:
* `-Dapp.environment=`
* `-Dlogback.configurationFile=logback/logback-local.xml`
3. Set program arguments: `run verticle.com.ascend.testlab.MainVerticle`
4. Set environment variables:
```
ENV=
PG_USER=
PG_PASSWORD=
```
## ๐ ๏ธ Development
### Code Formatting
Auto-format code using Spotify's fmt plugin:
```bash
mvn com.spotify.fmt:fmt-maven-plugin:format
```
### Running Tests
```bash
# Unit tests
mvn test
# All tests including integration
mvn verify
```
### Generate API Documentation
```bash
mvn javadoc:javadoc
```
Documentation will be generated in `docs/api-v1.0/`.
## ๐ค Contributing
We welcome contributions! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests: `mvn verify`
5. Submit a pull request
### Coding Standards
* Follow existing code style
* Add tests for new functionality
* Update documentation as needed
## ๐ License
TestLab is licensed under the [MIT License](./LICENSE).
---
Built with โค๏ธ by the TestLab team and contributors