-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.toml
247 lines (212 loc) · 7.72 KB
/
Makefile.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
[config]
default_to_workspace = false
reduce_output = true
skip_core_tasks = true
[env]
WASM_TARGET = "wasm32-wasip1"
RUST_VERSION = "1.82"
MIDDLEWARE = { value = "axum", condition = { env_not_set = [
"MIDDLEWARE",
] } }
DURATION = { value = "60", condition = { env_not_set = ["DURATION"] } }
VUS = { value = "10", condition = { env_not_set = ["VUS"] } }
# Core development tasks
[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--all", "--", "--emit=files"]
[tasks.lint]
install_crate = "clippy"
command = "cargo"
args = ["clippy", "--all-targets", "--all-features"]
[tasks.fmtclip]
dependencies = ["format", "lint"]
# Unit tests tasks
[tasks.test-core]
command = "cargo"
args = ["nextest", "run", "-p", "treblle-core"]
[tasks.test-axum]
command = "cargo"
args = ["nextest", "run", "-p", "treblle-axum"]
[tasks.test-actix]
command = "cargo"
args = ["nextest", "run", "-p", "treblle-actix"]
[tasks.test-rocket]
command = "cargo"
args = ["nextest", "run", "-p", "treblle-rocket"]
[tasks.test-traefik]
command = "cargo"
args = ["nextest", "run", "-p", "treblle-traefik-wasm"]
dependencies = ["wasm-test-unit"]
[tasks.test-all-unit]
dependencies = [
"test-core",
"test-axum",
"test-actix",
"test-rocket",
"test-traefik",
]
# Integration tests tasks
[tasks.setup-monitoring]
description = "Set up monitoring stack"
script = '''
#!/usr/bin/env bash
PROJECT_ROOT=$(dirname ${CARGO_MAKE_MAKEFILE_PATH})
echo "Setting up monitoring stack..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.monitoring.yml up -d prometheus grafana
echo "Waiting for monitoring stack to be ready..."
sleep 5
'''
[tasks.integration-test-axum]
description = "Run integration tests for Axum middleware"
dependencies = ["setup-monitoring"]
script = '''
#!/usr/bin/env bash
export PROJECT_ROOT=$(dirname ${CARGO_MAKE_MAKEFILE_PATH})
echo "Testing Axum middleware..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml up -d axum-test-service mock-treblle-api
echo "Waiting for services to be ready..."
sleep 10
echo "Running k6 tests..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml --profile axum run \
--rm \
-e MIDDLEWARE_TYPE=axum \
-e K6_OUT=experimental-prometheus-rw \
-e K6_PROMETHEUS_RW_SERVER_URL=http://prometheus:9090/api/v1/write \
-e K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true \
-e K6_PROMETHEUS_RW_TREND_STATS="avg,min,max,p(90),p(95)" \
-e K6_PROMETHEUS_RW_STALE_MARKERS=false \
k6 run /scripts/load-test.js
'''
[tasks.integration-test-actix]
description = "Run integration tests for Actix middleware"
dependencies = ["setup-monitoring"]
script = '''
#!/usr/bin/env bash
export PROJECT_ROOT=$(dirname ${CARGO_MAKE_MAKEFILE_PATH})
echo "Testing Actix middleware..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml up -d actix-test-service mock-treblle-api
echo "Waiting for services to be ready..."
sleep 10
echo "Running k6 tests..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml --profile actix run \
--rm \
-e MIDDLEWARE_TYPE=actix \
-e K6_OUT=experimental-prometheus-rw \
-e K6_PROMETHEUS_RW_SERVER_URL=http://prometheus:9090/api/v1/write \
-e K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true \
-e K6_PROMETHEUS_RW_TREND_STATS="avg,min,max,p(90),p(95)" \
-e K6_PROMETHEUS_RW_STALE_MARKERS=false \
k6 run /scripts/load-test.js
'''
[tasks.integration-test-rocket]
description = "Run integration tests for Rocket middleware"
dependencies = ["setup-monitoring"]
script = '''
#!/usr/bin/env bash
export PROJECT_ROOT=$(dirname ${CARGO_MAKE_MAKEFILE_PATH})
echo "Testing Rocket middleware..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml up -d rocket-test-service mock-treblle-api
echo "Waiting for services to be ready..."
sleep 10
echo "Running k6 tests..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml --profile rocket run \
--rm \
-e MIDDLEWARE_TYPE=rocket \
-e K6_OUT=experimental-prometheus-rw \
-e K6_PROMETHEUS_RW_SERVER_URL=http://prometheus:9090/api/v1/write \
-e K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true \
-e K6_PROMETHEUS_RW_TREND_STATS="avg,min,max,p(90),p(95)" \
-e K6_PROMETHEUS_RW_STALE_MARKERS=false \
k6 run /scripts/load-test.js
'''
[tasks.integration-test-all]
description = "Run all integration tests"
dependencies = ["setup-monitoring"]
script = '''
#!/usr/bin/env bash
PROJECT_ROOT=$(dirname ${CARGO_MAKE_MAKEFILE_PATH})
echo "Testing all middleware implementations..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml up -d
echo "Waiting for all services to be healthy..."
sleep 15
for middleware in axum actix rocket; do
echo "Running tests for $middleware..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml run --rm k6 run \
-e MIDDLEWARE_TYPE=$middleware \
-e K6_OUT=experimental-prometheus-rw \
-e K6_PROMETHEUS_RW_SERVER_URL=http://prometheus:9090/api/v1/write \
-e K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true \
-e K6_PROMETHEUS_RW_TREND_STATS="avg,min,max,p(90),p(95)" \
-e K6_PROMETHEUS_RW_STALE_MARKERS=false \
/scripts/load-test.js
done
'''
[tasks.clean]
description = "Clean up test environment"
category = "Cleanup"
script = '''
#!/usr/bin/env bash
echo "🧹 Cleaning up..."
export PROJECT_ROOT=$(dirname ${CARGO_MAKE_MAKEFILE_PATH})
echo "→ Removing test containers..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.test.yml down -v --remove-orphans
echo "→ Removing monitoring stack..."
docker compose -f ${PROJECT_ROOT}/tests/docker-compose.monitoring.yml down -v --remove-orphans
echo "→ Cleaning Cargo artifacts..."
cargo clean
echo "✨ Done"
'''
# Setup and validation tasks
[tasks.check-prereqs]
description = "Check if required tools are installed"
script = '''
#!/usr/bin/env bash
function check_command() {
if ! command -v $1 &> /dev/null; then
echo "❌ $1 is not installed"
exit 1
fi
echo "✅ $1 is installed"
}
check_command docker
check_command curl
'''
[tasks.setup]
description = "Setup complete test environment"
dependencies = ["check-prereqs", "setup-monitoring"]
[tasks.help]
description = "Display available tasks"
script = '''
#!/usr/bin/env bash
echo "Available tasks:"
echo "Development:"
echo " cargo make format - Format code"
echo " cargo make lint - Run clippy"
echo " cargo make fmtclip - Run format and lint"
echo ""
echo "Unit Tests:"
echo " cargo make test-all-unit - Run all unit tests"
echo " cargo make test-core - Test core crate"
echo " cargo make test-axum - Test Axum crate"
echo " cargo make test-actix - Test Actix crate"
echo " cargo make test-rocket - Test Rocket crate"
echo " cargo make test-traefik - Test Traefik crate"
echo ""
echo "Integration Tests:"
echo " cargo make setup - Set up test environment"
echo " cargo make integration-test-axum - Test Axum middleware"
echo " cargo make integration-test-actix - Test Actix middleware"
echo " cargo make integration-test-rocket - Test Rocket middleware"
echo " cargo make integration-test-all - Test all implementations"
echo ""
echo "Cleanup:"
echo " cargo make clean - Clean up test environment"
echo ""
echo "Environment variables:"
echo " MIDDLEWARE - Middleware to test (default: axum)"
echo " DURATION - Test duration in seconds (default: 60)"
echo " VUS - Number of virtual users (default: 10)"
'''
[tasks.default]
alias = "help"