smoke tests
Some checks failed
Build & Deploy KLZ Cables / build-and-deploy (push) Failing after 4m17s
Some checks failed
Build & Deploy KLZ Cables / build-and-deploy (push) Failing after 4m17s
This commit is contained in:
36
scripts/smoke-test.ts
Normal file
36
scripts/smoke-test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import * as http from 'http';
|
||||
|
||||
/**
|
||||
* Simple smoke test to verify the application is running and healthy.
|
||||
* This script is intended to be run against a local or remote instance.
|
||||
*/
|
||||
|
||||
const url = process.argv[2] || 'http://localhost:3000/health';
|
||||
const timeout = 10000; // 10 seconds
|
||||
|
||||
console.log(`🔍 Running smoke test against: ${url}`);
|
||||
|
||||
const request = http.get(url, (res) => {
|
||||
const { statusCode } = res;
|
||||
|
||||
if (statusCode === 200) {
|
||||
console.log('✅ Smoke test passed: Application is healthy.');
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.error(`❌ Smoke test failed: Received status code ${statusCode}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
request.on('error', (err) => {
|
||||
console.error(`❌ Smoke test failed: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
request.on('timeout', () => {
|
||||
console.error('❌ Smoke test failed: Request timed out');
|
||||
request.destroy();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
request.setTimeout(timeout);
|
||||
Reference in New Issue
Block a user