prometheus.mjs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect } from 'chai'
  3. import { By } from 'selenium-webdriver'
  4. let metrics = [
  5. {'name': 'olivetin_actions_requested_count', 'type': 'counter', 'desc': 'The actions requested count'},
  6. {'name': 'olivetin_config_action_count', 'type': 'gauge', 'desc': 'The number of actions in the config file'},
  7. {'name': 'olivetin_config_reloaded_count', 'type': 'counter', 'desc': 'The number of times the config has been reloaded'},
  8. {'name': 'olivetin_sv_count', 'type': 'gauge', 'desc': 'The number entries in the sv map'},
  9. ]
  10. describe('config: prometheus', function () {
  11. before(async function () {
  12. await runner.start('prometheus')
  13. })
  14. after(async () => {
  15. await runner.stop()
  16. })
  17. it('Metrics are available with correct types', async () => {
  18. webdriver.get(runner.metricsUrl())
  19. const prometheusOutput = await webdriver.findElement(By.tagName('pre')).getText()
  20. expect(prometheusOutput).to.not.be.null
  21. metrics.forEach(({name, type, desc}) => {
  22. const metaLines = `# HELP ${name} ${desc}\n`
  23. + `# TYPE ${name} ${type}\n`
  24. expect(prometheusOutput).to.match(new RegExp(metaLines))
  25. })
  26. })
  27. })