4
0

prometheus.mjs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_action_executions_total', 'type': 'counter', 'desc': 'Total number of finished action executions grouped by result\\.'},
  10. {'name': 'olivetin_action_execution_duration_seconds', 'type': 'histogram', 'desc': 'Action execution duration in seconds from start to finish\\.'},
  11. {'name': 'olivetin_config_action_count', 'type': 'gauge', 'desc': 'The number of actions in the config file'},
  12. {'name': 'olivetin_config_reloaded_count', 'type': 'counter', 'desc': 'The number of times the config has been reloaded'},
  13. ]
  14. describe('config: prometheus', function () {
  15. before(async function () {
  16. await runner.start('prometheus')
  17. })
  18. after(async () => {
  19. await runner.stop()
  20. })
  21. afterEach(function () {
  22. takeScreenshotOnFailure(this.currentTest, webdriver);
  23. });
  24. it('Metrics are available with correct types', async () => {
  25. await webdriver.get(runner.metricsUrl())
  26. const prometheusOutput = await webdriver.findElement(By.tagName('pre')).getText()
  27. expect(prometheusOutput).to.not.be.null
  28. metrics.forEach(({name, type, desc}) => {
  29. const metaLines = `# HELP ${name} ${desc}\n`
  30. + `# TYPE ${name} ${type}\n`
  31. expect(prometheusOutput).to.match(new RegExp(metaLines))
  32. })
  33. })
  34. })