prometheus.mjs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. ]
  12. describe('config: prometheus', function () {
  13. before(async function () {
  14. await runner.start('prometheus')
  15. })
  16. after(async () => {
  17. await runner.stop()
  18. })
  19. afterEach(function () {
  20. takeScreenshotOnFailure(this.currentTest, webdriver);
  21. });
  22. it('Metrics are available with correct types', async () => {
  23. await webdriver.get(runner.metricsUrl())
  24. const prometheusOutput = await webdriver.findElement(By.tagName('pre')).getText()
  25. expect(prometheusOutput).to.not.be.null
  26. metrics.forEach(({name, type, desc}) => {
  27. const metaLines = `# HELP ${name} ${desc}\n`
  28. + `# TYPE ${name} ${type}\n`
  29. expect(prometheusOutput).to.match(new RegExp(metaLines))
  30. })
  31. })
  32. })