Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# ToolJet Instance Configuration
BASE_URL=http://localhost:80
# Update BASE_URL to match your ToolJet instance host

# Workspace/Organization Configuration
# Get this from your ToolJet instance after logging in
WORKSPACE_ID=f078c38d-736b-442f-980d-5baac530ebc7

# Test User Credentials
# Builder/Admin user for most tests
EMAIL=builder1@testmail.com
PASSWORD=test123

# End user credentials (for end-user tests)
END_USER_EMAIL=enduser@testmail.com
END_USER_PASSWORD=test123

# Load Testing Configuration
# Sleep multiplier: Higher = longer sleeps = lower RPS = lower failure rate
# 2.5 is conservative for 0%-0.1% failure rate
# 2.0 for slightly higher RPS
# 3.0+ for even more conservative testing
SLEEP_MULTIPLIER=2.5

# Test Duration Configuration (optional overrides)
# WARMUP_DURATION=2m
# RAMPUP_DURATION=2m
# HOLD_DURATION=8m
# RAMPDOWN_DURATION=2m

# VU Configuration (optional overrides)
# VUS_AUTH=500
# VUS_BUILDER=500
# VUS_DATASOURCE=500
# VUS_WORKSPACE=500
# VUS_ENDUSER=1000
# VUS_ENTERPRISE=500

# Data Source Configuration (for data source tests)
# PostgreSQL
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=tooljet_test
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

# MySQL
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DB=tooljet_test
MYSQL_USER=root
MYSQL_PASSWORD=mysql

# REST API (for testing)
REST_API_URL=https://jsonplaceholder.typicode.com

# GraphQL (for testing)
GRAPHQL_URL=https://countries.trevorblades.com

# Advanced Configuration
# Set to true to enable verbose logging
DEBUG=false

# Set to true to save detailed request/response logs
SAVE_DETAILED_LOGS=false

# Result output format (json, csv, influxdb)
OUTPUT_FORMAT=json
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Test Results
results/
*.log
*.json
!package.json

# Environment Files
.env
.env.local
.env.production

# OS Files
.DS_Store
Thumbs.db

# IDE Files
.vscode/
.idea/
*.swp
*.swo
*~

# Node modules (if using npm for k6 extensions)
node_modules/
package-lock.json
yarn.lock

# Temporary files
*.tmp
*.temp
.cache/

# K6 Cloud results
k6-cloud-*
208 changes: 201 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,207 @@
# Generated k6 script
# ToolJet K6 Load Test Suite

The `script.js` file contains most of the Swagger/OpenAPI specification and you can customize it to your needs.
Comprehensive k6 load testing suite for ToolJet, covering all major user journeys and operations based on the Cypress test suite.

Global header variables are defined at the top of the file, like `api_key`. Each path in the specification is converted into a [group](https://docs.k6.io/docs/tags-and-groups) in k6 and each group contains all the request methods related to that path. Path and query parameters are extracted from the specification and put at the start of the group. The URL is constructed from the base URL plus path and query.
## Overview

k6 specific parameters are in the [`params`](https://docs.k6.io/docs/params-k6http) object, and `body` contains the [request](https://docs.k6.io/docs/http-requests) body which is in the form of `identifier: type`, which the `type` should be substituted by a proper value. Then goes the request and the check.
This repository contains **complete user journey tests** (not isolated endpoint tests) organized to match the ToolJet Cypress test structure. All tests target **500-1000 VUs** with **0%-0.1% failure rate** for production-ready performance validation.

[Check](https://docs.k6.io/docs/checks) are like asserts but differ in that they don't halt execution, instead they just store the result of the check, pass or fail, and let the script execution continue.
## Repository Structure

Each request is always followed by a 0.1 second [sleep](https://docs.k6.io/docs/sleep-t-1) to prevent the script execution from flooding the system with too many requests simultaneously.
```
ToolJet-k6-tests/
β”œβ”€β”€ common/ # Shared utilities and helpers
β”‚ β”œβ”€β”€ config.js # Environment configuration
β”‚ β”œβ”€β”€ auth.js # Authentication helpers
β”‚ └── helpers.js # Common functions
β”‚
β”œβ”€β”€ tests/ # Test scripts (mirrors Cypress structure)
β”‚ β”œβ”€β”€ authentication/ # Login, logout, user management
β”‚ β”œβ”€β”€ appBuilder/ # App lifecycle, components
β”‚ β”œβ”€β”€ dataSources/ # Data source operations
β”‚ β”œβ”€β”€ workspace/ # Workspace and folder management
β”‚ β”œβ”€β”€ endUser/ # Public/private app viewing
β”‚ └── enterprise/ # Multi-env, SSO, workflows
β”‚
β”œβ”€β”€ runners/ # Test suite runners
β”‚ β”œβ”€β”€ run_all_tests.sh # Run all test suites
β”‚ └── run_*_suite.sh # Category-specific runners
β”‚
β”œβ”€β”€ results/ # Test results (gitignored)
└── docs/ # Documentation
```

Note that the default iteration count and VU count is 1. So each request in each group will be executed once. For more information, see the [k6 options](https://docs.k6.io/docs/options).
## Quick Start

### 1. Prerequisites

```bash
# Install k6
brew install k6 # macOS
# OR
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6 # Debian/Ubuntu
```

### 2. Configure Environment

```bash
# Copy example environment file
cp .env.example .env

# Edit .env with your ToolJet instance details
nano .env
```

### 3. Run Tests

```bash
# Run a single test
k6 run tests/authentication/login_logout_journey_500vus.js

# Run an entire test suite
./runners/run_authentication_suite.sh

# Run all tests
./runners/run_all_tests.sh
```

## Test Categories

### Authentication & User Management
- **Login/Logout Journey** (500 VUs, 8-10 RPS)
- **User Invite & Onboarding** (500 VUs, 5-8 RPS)
- **Password Reset** (500 VUs, 5-8 RPS)

### App Builder Workflows
- **App Lifecycle** (500 VUs, 8-10 RPS) - Create β†’ Edit β†’ Release β†’ Delete
- **Component Workflow** (500 VUs, 6-8 RPS) - Add components β†’ Configure
- **Multi-page Apps** (500 VUs, 5-8 RPS) - Multi-page creation and navigation

### Data Sources
- **PostgreSQL Full Journey** (500 VUs, 8-10 RPS)
- **MySQL Full Journey** (500 VUs, 8-10 RPS)
- **REST API Journey** (500 VUs, 10-12 RPS)
- **Mixed Data Sources** (1000 VUs, 15-18 RPS)

### Workspace Management
- **Workspace Setup** (500 VUs, 6-8 RPS) - Folders, apps, organization
- **User Management** (500 VUs, 5-8 RPS) - Roles, permissions

### End User Scenarios
- **Public App Viewing** (1000 VUs, 15-18 RPS) - No authentication
- **Private App Viewing** (500 VUs, 8-10 RPS) - Authenticated access

### Enterprise Features
- **Multi-Environment Promotion** (500 VUs, 5-8 RPS)
- **SSO Login** (500 VUs, 5-8 RPS)
- **Workflows** (500 VUs, 5-8 RPS)

## Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `BASE_URL` | ToolJet instance URL | `http://localhost:3000` |
| `WORKSPACE_ID` | Workspace/Organization ID | Required |
| `EMAIL` | Test user email | `admin@example.com` |
| `PASSWORD` | Test user password | `password` |
| `SLEEP_MULTIPLIER` | Sleep duration multiplier | `2.5` |

## Test Configuration

All tests follow this pattern for 0%-0.1% failure rate:

```javascript
export const options = {
stages: [
{ duration: '2m', target: 100 }, // Warm up
{ duration: '2m', target: 500 }, // Ramp to target
{ duration: '8m', target: 500 }, // Hold and measure
{ duration: '2m', target: 0 }, // Cool down
],
thresholds: {
http_req_duration: ['p(95)<2000'], // 95% under 2s
http_req_failed: ['rate<0.001'], // 0.1% failure rate
},
};
```

## Running Specific Suites

```bash
# Authentication tests
./runners/run_authentication_suite.sh

# App builder tests
./runners/run_builder_suite.sh

# Data source tests
./runners/run_datasource_suite.sh

# Workspace tests
./runners/run_workspace_suite.sh

# End user tests
./runners/run_enduser_suite.sh

# Enterprise tests
./runners/run_enterprise_suite.sh
```

## Results

Test results are saved to the `results/` directory with timestamps:

```
results/
β”œβ”€β”€ authentication_20250124_143022/
β”‚ β”œβ”€β”€ summary.json
β”‚ └── test_output.log
β”œβ”€β”€ builder_20250124_144530/
└── ...
```

## Success Criteria

βœ… HTTP request failure rate < 0.1%
βœ… 95th percentile response time < 2s
βœ… All user journeys complete successfully
βœ… RPS targets met for each test category

## Documentation

- [Running Tests](docs/RUNNING_TESTS.md) - Detailed execution guide
- [API Reference](docs/API_REFERENCE.md) - ToolJet API endpoints
- [Cypress Mapping](docs/CYPRESS_MAPPING.md) - Cypress to k6 test mapping
- [Troubleshooting](docs/TROUBLESHOOTING.md) - Common issues and solutions

## Contributing

When adding new tests:
1. Follow the existing directory structure
2. Use common utilities from `/common`
3. Target 500-1000 VUs with 0%-0.1% failure rate
4. Use complete user journeys (not isolated endpoints)
5. Add runner scripts for new test categories
6. Update documentation

## Test Coverage

Based on ToolJet Cypress test suite:
- 93+ test scenarios identified
- 15+ core journeys implemented (Phase 1)
- Covers authentication, app building, data sources, workspace management, and end-user scenarios

## License

Same as ToolJet project

## Support

For issues or questions:
- Check [Troubleshooting Guide](docs/TROUBLESHOOTING.md)
- Review [ToolJet Documentation](https://docs.tooljet.com)
- Open an issue in this repository
Loading