-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
So far, I have only found that we can periodically fetch the health of our system under test (SUT) to send a message but not be able to report any errors throughout mokapi testing.
import { cron } from 'mokapi'
// Run every 2 minutes
cron('*/2 * * * *', function() {
const sutUrl = 'http://system-under-test.com/api/health'
try {
const response = fetch(sutUrl)
if (response.status !== 200) {
sendTelegram(`Smoke Test Failed! SUT returned ${response.status}`);
}
} catch (err) {
sendTelegram(`Smoke Test Error: Could not reach SUT at ${sutUrl}`);
}
})
function sendTelegram(message) {
const token = 'YOUR_BOT_TOKEN'
const chatId = 'YOUR_CHAT_ID'
fetch(`api.telegram.org{token}/sendMessage`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ chat_id: chatId, text: message })
})
}Active external reporting to e.g. a Telegram bot is helpful for GitOps deployments that can change upon push.
Metadata
Metadata
Assignees
Labels
No labels