This repository was archived by the owner on Feb 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-deployment.js
More file actions
executable file
·174 lines (144 loc) · 4.75 KB
/
test-deployment.js
File metadata and controls
executable file
·174 lines (144 loc) · 4.75 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
#!/usr/bin/env node
const BASE_URL = 'https://espresense.com';
async function testEndpoint(name, url, expectedStatus, checkRedirect = false, method = 'GET') {
try {
const response = await fetch(url, { redirect: 'manual', method });
const status = response.status;
const passed = status === expectedStatus;
console.log(`${passed ? '✓' : '✗'} ${name}`);
console.log(` URL: ${url}`);
console.log(` Method: ${method}`);
console.log(` Status: ${status} (expected ${expectedStatus})`);
if (checkRedirect && (status === 301 || status === 302 || status === 307 || status === 308)) {
const location = response.headers.get('location');
console.log(` Redirect: ${location}`);
// Verify redirect location is a valid URL
if (location) {
try {
new URL(location);
} catch (e) {
console.log(` WARNING: Invalid redirect URL`);
}
}
}
if (!passed) {
console.log(` FAILED: Expected ${expectedStatus}, got ${status}`);
}
console.log('');
return passed;
} catch (error) {
console.log(`✗ ${name}`);
console.log(` URL: ${url}`);
console.log(` Error: ${error.message}`);
console.log('');
return false;
}
}
async function runTests() {
console.log('='.repeat(60));
console.log('Deployment Test Suite');
console.log('='.repeat(60));
console.log('');
const results = [];
// Artifact Proxy Tests
console.log('Artifact Proxy Tests (espresense.com/artifacts/*)');
console.log('-'.repeat(60));
results.push(await testEndpoint(
'Latest download (master branch - GET)',
`${BASE_URL}/artifacts/latest/download/master/esp32.bin`,
302,
true,
'GET'
));
results.push(await testEndpoint(
'Latest download (master branch - HEAD)',
`${BASE_URL}/artifacts/latest/download/master/esp32.bin`,
302,
true,
'HEAD'
));
// Release Proxy Tests
console.log('Release Proxy Tests (espresense.com/releases/*)');
console.log('-'.repeat(60));
// Critical: Test HEAD request (used by ESP32 firmware for update detection)
results.push(await testEndpoint(
'Latest any download (HEAD - firmware update check)',
`${BASE_URL}/releases/latest-any/download/esp32.bin`,
302,
true,
'HEAD'
));
results.push(await testEndpoint(
'Latest any download (GET)',
`${BASE_URL}/releases/latest-any/download/esp32.bin`,
302,
true,
'GET'
));
results.push(await testEndpoint(
'Latest manifest',
`${BASE_URL}/releases/latest.json`,
200,
false,
'GET'
));
results.push(await testEndpoint(
'Non-existent release asset (404)',
`${BASE_URL}/releases/latest-any/download/nonexistent.bin`,
404,
false,
'GET'
));
// Manifest Validation Tests
console.log('Manifest Validation Tests (verify all manifest URLs are valid)');
console.log('-'.repeat(60));
// Test latest release manifest
try {
const manifestUrl = `${BASE_URL}/releases/latest.json`;
const manifestResponse = await fetch(manifestUrl);
if (manifestResponse.ok) {
const manifest = await manifestResponse.json();
console.log(`Fetched manifest: ${manifest.name}`);
console.log(` Builds: ${manifest.builds.length}`);
// Test each build in the manifest
for (const build of manifest.builds) {
console.log(` Testing ${build.chipFamily} build with ${build.parts.length} parts...`);
// Test each part (bootloader, partition, firmware, etc.)
for (const part of build.parts) {
const partUrl = `${BASE_URL}${part.path}`;
const partResponse = await fetch(partUrl, { method: 'HEAD' });
const passed = partResponse.ok;
results.push(passed);
if (!passed) {
console.log(` ✗ ${part.path} - ${partResponse.status}`);
console.log(` URL: ${partUrl}`);
console.log(` FAILED: File referenced in manifest returns ${partResponse.status}`);
} else {
console.log(` ✓ ${part.path} - ${partResponse.status}`);
}
}
}
} else {
console.log(`✗ Failed to fetch manifest: ${manifestResponse.status}`);
results.push(false);
}
} catch (error) {
console.log(`✗ Manifest validation error: ${error.message}`);
results.push(false);
}
console.log('');
// Summary
console.log('='.repeat(60));
const passed = results.filter(r => r).length;
const total = results.length;
const allPassed = passed === total;
console.log(`Results: ${passed}/${total} tests passed`);
if (allPassed) {
console.log('✓ All deployment tests passed!');
} else {
console.log(`✗ ${total - passed} test(s) failed`);
}
console.log('='.repeat(60));
process.exit(allPassed ? 0 : 1);
}
runTests();