diff --git a/packages/health-check/package.json b/packages/health-check/package.json index 45dd3006..89b478de 100644 --- a/packages/health-check/package.json +++ b/packages/health-check/package.json @@ -12,6 +12,7 @@ "lowdb": "^1.0.0", "object-hash": "^2.1.1", "superagent": "^6.0.0", + "tmp": "^0.2.1", "yargs": "^16.2.0" }, "devDependencies": { diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 8e04c0c3..4fded35a 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -1,15 +1,22 @@ +const fs = require("fs"); const superagent = require("superagent"); +const tmp = require('tmp'); const { StatusCodes } = require("http-status-codes"); const { calculateElapsedTime, getResponseContent } = require("../utils"); // uploadCheck returns the result of uploading a sample file async function uploadCheck(done) { const time = process.hrtime(); + const file = tmp.fileSync(); + + fs.writeSync(file.fd, Buffer.from(new Date())); // write current date to temp file superagent .post(`${process.env.PORTAL_URL}/skynet/skyfile`) - .attach("file", "package.json", "package.json") + .attach("file", file.name, file.name) .end((error, response) => { + file.removeCallback(); + const statusCode = (response && response.statusCode) || (error && error.statusCode) || null; done({