Skip to content

Commit 7971f01

Browse files
committed
add ci e2e
1 parent 3923484 commit 7971f01

File tree

3 files changed

+113
-6
lines changed

3 files changed

+113
-6
lines changed

.github/workflows/test-e2e.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [master, v9, 'v9.*']
6+
pull_request:
7+
branches: [master, v9, v9.7, v9.8, 'ndyakov/**', 'ofekshenawa/**', 'ce/**']
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test-e2e-mock:
14+
name: E2E Tests (Mock Proxy)
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
go-version:
20+
- "1.23.x"
21+
- stable
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
27+
- name: Set up Go ${{ matrix.go-version }}
28+
uses: actions/setup-go@v6
29+
with:
30+
go-version: ${{ matrix.go-version }}
31+
32+
- name: Start Docker services for E2E tests
33+
run: make docker.e2e.start
34+
35+
- name: Wait for services to be ready
36+
run: |
37+
echo "Waiting for Redis to be ready..."
38+
timeout 30 bash -c 'until docker exec redis-stack redis-cli ping 2>/dev/null; do sleep 1; done'
39+
echo "Waiting for cae-resp-proxy to be ready..."
40+
timeout 30 bash -c 'until curl -s http://localhost:18100/stats > /dev/null; do sleep 1; done'
41+
echo "All services are ready!"
42+
43+
- name: Run E2E tests with mock proxy
44+
env:
45+
E2E_SCENARIO_TESTS: "true"
46+
run: |
47+
go test -v ./maintnotifications/e2e/ -timeout 30m -race
48+
continue-on-error: false
49+
50+
- name: Stop Docker services
51+
if: always()
52+
run: make docker.e2e.stop
53+
54+
- name: Show Docker logs on failure
55+
if: failure()
56+
run: |
57+
echo "=== Redis logs ==="
58+
docker logs redis-stack 2>&1 | tail -100
59+
echo "=== cae-resp-proxy logs ==="
60+
docker logs cae-resp-proxy 2>&1 | tail -100
61+
echo "=== proxy-fault-injector logs ==="
62+
docker logs proxy-fault-injector 2>&1 | tail -100
63+

maintnotifications/e2e/README_SCENARIOS.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,36 @@ This directory contains comprehensive end-to-end test scenarios for Redis push n
77

88
## Introduction
99

10-
To run those tests you would need a fault injector service, please review the client and feel free to implement your
11-
fault injector of choice. Those tests are tailored for Redis Enterprise, but can be adapted to other Redis distributions where
12-
a fault injector is available.
10+
These tests support two modes:
1311

14-
Once you have fault injector service up and running, you can execute the tests by running the `run-e2e-tests.sh` script.
15-
there are three environment variables that need to be set before running the tests:
12+
### 1. Mock Proxy Mode (Default)
13+
Uses a local Docker-based proxy ([cae-resp-proxy](https://github.com/redis-developer/cae-resp-proxy)) to simulate Redis Enterprise behavior. This mode:
14+
- Runs entirely locally without external dependencies
15+
- Provides fast feedback for development
16+
- Simulates cluster topology changes
17+
- Supports SMIGRATING and SMIGRATED notifications
1618

19+
To run in mock proxy mode:
20+
```bash
21+
make test.e2e
22+
```
23+
24+
### 2. Real Fault Injector Mode
25+
Uses a real Redis Enterprise fault injector service for comprehensive testing. This mode:
26+
- Tests against actual Redis Enterprise clusters
27+
- Validates real-world scenarios
28+
- Requires external fault injector setup
29+
30+
To run with a real fault injector, set these environment variables:
1731
- `REDIS_ENDPOINTS_CONFIG_PATH`: Path to Redis endpoints configuration
1832
- `FAULT_INJECTION_API_URL`: URL of the fault injector server
1933
- `E2E_SCENARIO_TESTS`: Set to `true` to enable scenario tests
2034

35+
Then run:
36+
```bash
37+
./scripts/run-e2e-tests.sh
38+
```
39+
2140
## Test Scenarios Overview
2241

2342
### 1. Basic Push Notifications (`scenario_push_notifications_test.go`)
@@ -44,7 +63,28 @@ there are three environment variables that need to be set before running the tes
4463
- Notification delivery consistency
4564
- Handoff behavior per endpoint type
4665

47-
### 3. Database Management Scenario (`scenario_database_management_test.go`)
66+
### 3. Unified Injector Scenarios (`scenario_unified_injector_test.go`)
67+
**Mock proxy-based notification testing**
68+
- **Purpose**: Test SMIGRATING and SMIGRATED notifications with simulated cluster topology changes
69+
- **Features Tested**:
70+
- SMIGRATING notifications (slot migration in progress)
71+
- SMIGRATED notifications (slot migration completed)
72+
- Cluster topology changes (node swap simulation)
73+
- Complex multi-step migration scenarios
74+
- **Configuration**: Uses local Docker proxy (cae-resp-proxy) with 4 nodes
75+
- **Duration**: ~10 seconds
76+
- **Key Validations**:
77+
- Notification delivery and parsing
78+
- Cluster state reload callbacks
79+
- Client resilience during migrations
80+
- Topology change handling
81+
- **Topology Simulation**:
82+
- Starts with 4 proxy nodes (17000-17003)
83+
- Initially exposes 3 nodes in CLUSTER SLOTS (17000, 17001, 17002)
84+
- On SMIGRATED, swaps node 2 for node 3 (simulates node replacement)
85+
- Verifies client continues to function after topology change
86+
87+
### 4. Database Management Scenario (`scenario_database_management_test.go`)
4888
**Dynamic database creation and deletion**
4989
- **Purpose**: Test database lifecycle management via fault injector
5090
- **Features Tested**: CREATE_DATABASE, DELETE_DATABASE endpoints

maintnotifications/e2e/notiftracker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ func (a *DiagnosticsAnalysis) Print(t *testing.T) {
366366
}
367367

368368
// setupNotificationHook adds a notification hook to a cluster client
369+
//
370+
//nolint:unused // Used in test files
369371
func setupNotificationHook(client *redis.ClusterClient, hook maintnotifications.NotificationHook) {
370372
_ = client.ForEachShard(context.Background(), func(ctx context.Context, nodeClient *redis.Client) error {
371373
manager := nodeClient.GetMaintNotificationsManager()
@@ -385,6 +387,8 @@ func setupNotificationHook(client *redis.ClusterClient, hook maintnotifications.
385387
}
386388

387389
// setupNotificationHooks adds multiple notification hooks to a regular client
390+
//
391+
//nolint:unused // Used in test files
388392
func setupNotificationHooks(client redis.UniversalClient, hooks ...maintnotifications.NotificationHook) {
389393
// Try to get manager from the client
390394
var manager *maintnotifications.Manager

0 commit comments

Comments
 (0)