-
Notifications
You must be signed in to change notification settings - Fork 35
319 lines (265 loc) · 10.8 KB
/
Copy pathe2e-tests.yml
File metadata and controls
319 lines (265 loc) · 10.8 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
name: E2E Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
e2e-tests:
name: End-to-End Tests
runs-on: ${{ matrix.os }}
env:
GO111MODULE: "on"
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ["1.21", "1.22", "1.23.10"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/AppData/Local/go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run unit tests
run: go test -v -race -timeout 30s ./internal/...
- name: Run E2E tests
run: go test -v -race -timeout 5m ./internal/server -run TestE2E
env:
GO_TEST_TIMEOUT: 300s
- name: Run Logging E2E tests
run: go test -v -race -timeout 5m ./internal/logs -run TestE2E
env:
GO_TEST_TIMEOUT: 300s
- name: Run E2E tests with race detector
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23.10'
run: go test -v -race -timeout 10m ./internal/server -run TestE2E
env:
GO_TEST_TIMEOUT: 600s
- name: Run Logging E2E tests with race detector
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23.10'
run: go test -v -race -timeout 10m ./internal/logs -run TestE2E
env:
GO_TEST_TIMEOUT: 600s
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: e2e-tests
env:
GO111MODULE: "on"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23.10"
- name: Build mcpproxy
env:
CGO_ENABLED: "0"
run: go build -tags nogui -o mcpproxy ./cmd/mcpproxy
- name: Test mcpproxy binary
run: |
# Test version command
./mcpproxy --version
# Test help command
./mcpproxy --help
# Test logging functionality
timeout 10s ./mcpproxy --log-to-file --log-level debug --listen :0 --tray=false || true
# Verify log file was created in standard OS location
if [ "$(uname)" = "Linux" ]; then
if [ -f "$HOME/.local/state/mcpproxy/logs/mcpproxy.log" ]; then
echo "✓ Log file created in Linux standard location"
head -5 "$HOME/.local/state/mcpproxy/logs/mcpproxy.log"
else
echo "⚠ Log file not found in expected location"
fi
fi
- name: Run tests with coverage (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
go test -v -race '-coverprofile=coverage.out' -covermode=atomic ./internal/server -run TestE2E
go test -v -race '-coverprofile=coverage-logs.out' -covermode=atomic ./internal/logs -run TestE2E
go tool cover '-html=coverage.out' -o coverage.html
go tool cover '-html=coverage-logs.out' -o coverage-logs.html
- name: Run tests with coverage (Unix)
if: matrix.os != 'windows-latest'
run: |
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/server -run TestE2E
go test -v -race -coverprofile=coverage-logs.out -covermode=atomic ./internal/logs -run TestE2E
go tool cover -html=coverage.out -o coverage.html
go tool cover -html=coverage-logs.out -o coverage-logs.html
- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
file: ./coverage.out
flags: e2e-tests
name: e2e-coverage
fail_ci_if_error: false
logging-tests:
name: Cross-Platform Logging Tests
runs-on: ${{ matrix.os }}
env:
GO111MODULE: "on"
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
log_path_check: "$HOME/.local/state/mcpproxy/logs"
log_standard: "XDG Base Directory Specification"
- os: macos-latest
log_path_check: "$HOME/Library/Logs/mcpproxy"
log_standard: "macOS File System Programming Guide"
- os: windows-latest
log_path_check: "$env:LOCALAPPDATA\\mcpproxy\\logs"
log_standard: "Windows Application Data Guidelines"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23.10"
- name: Run logging unit tests
run: go test -v -race -timeout 2m ./internal/logs
- name: Run logging E2E tests
run: go test -v -race -timeout 5m ./internal/logs -run TestE2E
- name: Build mcpproxy for logging test (Windows)
if: matrix.os == 'windows-latest'
env:
CGO_ENABLED: "0"
run: go build -tags nogui -o mcpproxy.exe ./cmd/mcpproxy
- name: Build mcpproxy for logging test (Unix)
if: matrix.os != 'windows-latest'
env:
CGO_ENABLED: "0"
run: go build -tags nogui -o mcpproxy ./cmd/mcpproxy
- name: Test OS-specific log directory creation (Unix)
if: matrix.os != 'windows-latest'
run: |
echo "Testing logging on ${{ matrix.os }}"
echo "Expected log path: ${{ matrix.log_path_check }}"
echo "OS Standard: ${{ matrix.log_standard }}"
# Run mcpproxy briefly to create log files
timeout 5s ./mcpproxy --log-to-file --log-level info --listen :0 --tray=false || true
# Check if log directory was created
if [ -d "${{ matrix.log_path_check }}" ]; then
echo "✓ Log directory created successfully"
ls -la "${{ matrix.log_path_check }}"
# Check if log file exists and has content
if [ -f "${{ matrix.log_path_check }}/mcpproxy.log" ]; then
echo "✓ Log file created successfully"
echo "Log file size: $(wc -c < "${{ matrix.log_path_check }}/mcpproxy.log") bytes"
echo "First few lines:"
head -3 "${{ matrix.log_path_check }}/mcpproxy.log"
# Verify log contains expected content
if grep -q "Log directory configured" "${{ matrix.log_path_check }}/mcpproxy.log"; then
echo "✓ Log contains expected startup messages"
else
echo "⚠ Log missing expected startup messages"
fi
if grep -q "${{ matrix.log_standard }}" "${{ matrix.log_path_check }}/mcpproxy.log"; then
echo "✓ Log contains OS standard compliance information"
else
echo "⚠ Log missing OS standard compliance information"
fi
else
echo "✗ Log file not created"
exit 1
fi
else
echo "✗ Log directory not created"
exit 1
fi
- name: Test OS-specific log directory creation (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
Write-Host "Testing logging on Windows"
Write-Host "Expected log path: ${{ matrix.log_path_check }}"
Write-Host "OS Standard: ${{ matrix.log_standard }}"
# Run mcpproxy briefly to create log files
Start-Process -FilePath "./mcpproxy.exe" -ArgumentList "--log-to-file", "--log-level", "info", "--listen", ":0", "--tray=false" -NoNewWindow -PassThru | ForEach-Object { Start-Sleep -Seconds 5; $_ | Stop-Process -Force }
# Check if log directory was created
$logPath = "${{ matrix.log_path_check }}"
if (Test-Path $logPath) {
Write-Host "✓ Log directory created successfully"
Get-ChildItem $logPath
# Check if log file exists and has content
$logFile = Join-Path $logPath "mcpproxy.log"
if (Test-Path $logFile) {
Write-Host "✓ Log file created successfully"
$fileSize = (Get-Item $logFile).Length
Write-Host "Log file size: $fileSize bytes"
Write-Host "First few lines:"
Get-Content $logFile -Head 3
# Verify log contains expected content
$content = Get-Content $logFile -Raw
if ($content -match "Log directory configured") {
Write-Host "✓ Log contains expected startup messages"
} else {
Write-Host "⚠ Log missing expected startup messages"
}
if ($content -match "${{ matrix.log_standard }}") {
Write-Host "✓ Log contains OS standard compliance information"
} else {
Write-Host "⚠ Log missing OS standard compliance information"
}
} else {
Write-Host "✗ Log file not created"
exit 1
}
} else {
Write-Host "✗ Log directory not created"
exit 1
}
- name: Test log rotation
if: matrix.os == 'ubuntu-latest'
run: |
echo "Testing log rotation functionality"
go test -v -timeout 2m ./internal/logs -run TestE2E_LogRotation
- name: Test concurrent logging
if: matrix.os == 'ubuntu-latest'
run: |
echo "Testing concurrent logging functionality"
go test -v -race -timeout 3m ./internal/logs -run TestE2E_ConcurrentLogging
stress-tests:
name: Stress Tests
runs-on: ubuntu-latest
needs: e2e-tests
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23.10"
- name: Run concurrent stress tests
run: |
# Run the concurrent test multiple times to catch race conditions
for i in {1..5}; do
echo "Stress test iteration $i"
go test -v -race -timeout 10m ./internal/server -run TestE2E_ConcurrentOperations
done
- name: Run memory stress test
run: |
# Run tests with memory limit
GOMAXPROCS=1 GOMEMLIMIT=100MiB go test -v -timeout 15m ./internal/server -run TestE2E