Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Adding license and PROMtext test
Browse files Browse the repository at this point in the history
  • Loading branch information
axelssonHakan committed Mar 18, 2020
1 parent 1e02a51 commit b95f7b8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bundled/parse-prometheus-text-format.js
@@ -1,6 +1,6 @@
// LICENSE - Apache License 2.0 (https://github.com/yunyu/parse-prometheus-text-format/blob/master/LICENSE)
// parse-prometheus-text-format is bundled from https://github.com/yunyu/parse-prometheus-text-format awaiting a fix (https://github.com/yunyu/parse-prometheus-text-format/pull/9)


const shallowEqual = require('shallow-equal');

function _classCallCheck(instance, Constructor) {
Expand Down
36 changes: 35 additions & 1 deletion test/unit/EngineStatusFetcher.spec.js
Expand Up @@ -17,13 +17,47 @@ describe('EngineStatusFetcher', () => {
});

describe('#fetch()', () => {
it('should resolve and receive health status properly on success', async () => {
it('should resolve and receive health status properly on success - JSON', async () => {
nock('http://10.0.0.1:7777').get('/healthz').reply(200, { healthy: true });
const statusFetcher = new EngineStatusFetcher(myHttp);
const health = await statusFetcher.fetch('10.0.0.1', 7777, '/healthz');
expect(health.healthy).to.be.true;
});

it('should resolve and receive health status properly on success- PROM', async () => {
const promText = `# HELP qix_build_info Engine version info
# TYPE qix_build_info counter
qix_build_info{revision="12.612.0"} 1.000000
qix_build_info{version="12.612.0.0"} 1.000000
qix_build_info{os="linux"} 1.000000`;
const promJSON = [
{
name: 'qix_build_info',
help: 'Engine version info',
type: 'COUNTER',
metrics: [
{
value: '1.000000',
labels: {
revision: '12.612.0',
},
},
{
value: '1.000000',
labels: {
version: '12.612.0.0',
},
},
],
},
];
nock('http://10.0.0.1:7777').get('/metrics').reply(200, promText);
const statusFetcher = new EngineStatusFetcher(myHttp);
const metrics = await statusFetcher.fetch('10.0.0.1', 7777, '/metrics');
console.log(JSON.stringify(metrics));
expect(metrics).to.deep.equal(promJSON);
});

it('should be rejected when health check returns error response', () => {
nock('http://10.0.0.1:7777').get('/healthz').replyWithError('I am failing!');
const statusFetcher = new EngineStatusFetcher(myHttp);
Expand Down

0 comments on commit b95f7b8

Please sign in to comment.