prometheus.mjs 1.3 KB

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