-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e.test.js
68 lines (65 loc) · 1.84 KB
/
e2e.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const axios = require('axios')
const yaml = require('yaml')
const {clokiWriteUrl, clokiExtUrl, axiosGet } = require('./common')
it('qryn should work', async () => {
let retries = 0
while (true) {
try {
await axiosGet(`http://${clokiWriteUrl}/ready`)
await axiosGet(`http://${clokiExtUrl}/ready`)
return
} catch (e) {
if (retries >= 10) {
throw e;
}
retries++
await new Promise(f => setTimeout(f, 1000))
}
}
})
require('./e2e.writer')
require('./e2e.logql.reader')
require('./e2e.tempo.reader')
require('./e2e.prom.reader')
require('./e2e.misc')
require('./e2e.alert.config')
require('./e2e.traceql')
require('./e2e.pprof')
const checkAlertConfig = async () => {
try {
expect(await axios({
method: 'POST',
url: 'http://localhost:3100/api/prom/rules/test_ns',
data: yaml.stringify({
name: 'test_group',
interval: '1s',
rules: [{
alert: 'test_rul',
for: '1m',
annotations: { summary: 'ssssss' },
labels: { lllll: 'vvvvv' },
expr: '{test_id="alert_test"}'
}]
}),
headers: {
'Content-Type': 'application/yaml'
}
})).toHaveProperty('data', { msg: 'ok' })
expect(yaml.parse((await axios.get('http://localhost:3100/api/prom/rules')).data))
.toHaveProperty('test_ns', [{
name: 'test_group',
interval: '1s',
rules: [{
alert: 'test_rul',
for: '1m',
annotations: { summary: 'ssssss' },
labels: { lllll: 'vvvvv' },
expr: '{test_id="alert_test"}'
}]
}])
await axios.delete('http://localhost:3100/api/prom/rules/test_ns').catch(console.log)
} catch (e) {
await axios.delete('http://localhost:3100/api/prom/rules/test_ns').catch(console.log)
throw e
}
}