Skip to content

Commit

Permalink
Make the tests less flaky (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm authored Dec 27, 2024
1 parent c3df3ca commit 9064f59
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/mainLoop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ var port = 25212
var lastReq
var smallestInterval
const server = http.createServer(function (req, res) {
if (counter % 4 === 0) {
counter++
res.writeHead(404)
res.end()
return
}
if (req.url === "/http-queue/get-a-job") {
if (!lastReq) {
lastReq = Date.now()
Expand Down Expand Up @@ -114,8 +120,9 @@ describe('Main cloud loop', () => {
}
stopIt()
server.close()
if (smallestInterval < sleepTime) {
throw new Error('Smallest interval (' + smallestInterval + ') was smaller than the smallest pause (' + sleepTime + ')')
// Allow a small offset. Seems tests are failing with 99ms flakily.
if (smallestInterval < (sleepTime - 20)) {
throw new Error('Smallest interval (' + smallestInterval + ') was smaller than the smallest pause (' + sleepTime + ') well minus the offset')
}
resolve(null)
})
Expand Down

0 comments on commit 9064f59

Please sign in to comment.