Skip to content

Commit f885e50

Browse files
committed
tests "work" - what did the 2nd test test?
1 parent 3e53c7f commit f885e50

File tree

2 files changed

+40
-160
lines changed

2 files changed

+40
-160
lines changed

src/shadowbox/Taskfile.yml

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ tasks:
6060
SB_PUBLIC_IP: localhost
6161
SB_CERTIFICATE_FILE: '{{joinPath .RUN_DIR "/shadowbox-selfsigned-dev.crt"}}'
6262
SB_PRIVATE_KEY_FILE: '{{joinPath .RUN_DIR "/shadowbox-selfsigned-dev.key"}}'
63+
LOG_LEVEL: '{{.LOG_LEVEL}}'
6364
cmds:
6465
- echo Target platform is {{.TARGET_OS}}/{{.TARGET_ARCH}}
6566
- echo "Using directory {{.RUN_DIR}}"

src/shadowbox/server/manager_metrics.spec.ts

+39-160
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,7 @@ describe('PrometheusManagerMetrics', () => {
4141
const managerMetrics = new PrometheusManagerMetrics(
4242
new QueryMapPrometheusClient(
4343
{
44-
'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))': {
45-
resultType: 'vector',
46-
result: [
47-
{
48-
metric: {
49-
location: 'US',
50-
asn: '49490',
51-
asorg: 'Test AS Org',
52-
},
53-
value: [1739284734, '1234'],
54-
},
55-
],
56-
},
57-
'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[0s])) by (location, asn, asorg)':
44+
'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)':
5845
{
5946
resultType: 'vector',
6047
result: [
@@ -68,60 +55,25 @@ describe('PrometheusManagerMetrics', () => {
6855
},
6956
],
7057
},
71-
'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)':
58+
},
59+
{
60+
'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s])) by (location, asn, asorg)':
7261
{
73-
resultType: 'vector',
62+
resultType: 'matrix',
7463
result: [
7564
{
7665
metric: {
7766
location: 'US',
7867
asn: '49490',
7968
asorg: 'Test AS Org',
8069
},
81-
value: [1738959398, '1000'],
70+
values: [
71+
[1738959398, '9000'],
72+
[1739284734, '3000'],
73+
],
8274
},
8375
],
8476
},
85-
'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[0s])) by (access_key)': {
86-
resultType: 'vector',
87-
result: [
88-
{
89-
metric: {
90-
access_key: '0',
91-
},
92-
value: [1738959398, '1000'],
93-
},
94-
],
95-
},
96-
'sum(increase(shadowsocks_tunnel_time_seconds[0s])) by (access_key)': {
97-
resultType: 'vector',
98-
result: [
99-
{
100-
metric: {
101-
access_key: '0',
102-
},
103-
value: [1738959398, '1000'],
104-
},
105-
],
106-
},
107-
},
108-
{
109-
'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))': {
110-
resultType: 'matrix',
111-
result: [
112-
{
113-
metric: {
114-
location: 'US',
115-
asn: '49490',
116-
asorg: 'Test AS Org',
117-
},
118-
values: [
119-
[1738959398, '5678'],
120-
[1739284734, '1234'],
121-
],
122-
},
123-
],
124-
},
12577
'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[300s])) by (access_key)': {
12678
resultType: 'matrix',
12779
result: [
@@ -130,8 +82,8 @@ describe('PrometheusManagerMetrics', () => {
13082
access_key: '0',
13183
},
13284
values: [
133-
[1738959398, '1000'],
134-
[1739284734, '2000'],
85+
[1738959398, '9000'],
86+
[1739284734, '3000'],
13587
],
13688
},
13789
],
@@ -145,7 +97,7 @@ describe('PrometheusManagerMetrics', () => {
14597
},
14698
values: [
14799
[1738959398, '1000'],
148-
[1739284734, '0'],
100+
[1738959398, '0'],
149101
],
150102
},
151103
],
@@ -162,18 +114,18 @@ describe('PrometheusManagerMetrics', () => {
162114
"seconds": 1000
163115
},
164116
"dataTransferred": {
165-
"bytes": 1000
117+
"bytes": 12000
166118
},
167119
"bandwidth": {
168120
"current": {
169121
"data": {
170-
"bytes": 1234
122+
"bytes": 10
171123
},
172124
"timestamp": 1739284734
173125
},
174126
"peak": {
175127
"data": {
176-
"bytes": 5678
128+
"bytes": 30
177129
},
178130
"timestamp": 1738959398
179131
}
@@ -184,7 +136,7 @@ describe('PrometheusManagerMetrics', () => {
184136
"asn": 49490,
185137
"asOrg": "Test AS Org",
186138
"dataTransferred": {
187-
"bytes": 1000
139+
"bytes": 12000
188140
},
189141
"tunnelTime": {
190142
"seconds": 1000
@@ -196,7 +148,7 @@ describe('PrometheusManagerMetrics', () => {
196148
{
197149
"accessKeyId": 0,
198150
"dataTransferred": {
199-
"bytes": 1000
151+
"bytes": 12000
200152
},
201153
"tunnelTime": {
202154
"seconds": 1000
@@ -218,20 +170,7 @@ describe('PrometheusManagerMetrics', () => {
218170
const managerMetrics = new PrometheusManagerMetrics(
219171
new QueryMapPrometheusClient(
220172
{
221-
'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))': {
222-
resultType: 'vector',
223-
result: [
224-
{
225-
metric: {
226-
location: 'US',
227-
asn: '49490',
228-
asorg: 'Test AS Org',
229-
},
230-
value: [1739284734, '1234'],
231-
},
232-
],
233-
},
234-
'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[0s])) by (location, asn, asorg)':
173+
'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)':
235174
{
236175
resultType: 'vector',
237176
result: [
@@ -245,58 +184,25 @@ describe('PrometheusManagerMetrics', () => {
245184
},
246185
],
247186
},
248-
'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)':
187+
},
188+
{
189+
'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s])) by (location, asn, asorg)':
249190
{
250-
resultType: 'vector',
191+
resultType: 'matrix',
251192
result: [
252193
{
253194
metric: {
254-
location: 'CA',
195+
location: 'US',
196+
asn: '49490',
197+
asorg: 'Test AS Org',
255198
},
256-
value: [1738959398, '1000'],
199+
values: [
200+
[1738959398, '9000'],
201+
[1739284734, '3000'],
202+
],
257203
},
258204
],
259205
},
260-
'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[0s])) by (access_key)': {
261-
resultType: 'vector',
262-
result: [
263-
{
264-
metric: {
265-
access_key: '0',
266-
},
267-
value: [1738959398, '1000'],
268-
},
269-
],
270-
},
271-
'sum(increase(shadowsocks_tunnel_time_seconds[0s])) by (access_key)': {
272-
resultType: 'vector',
273-
result: [
274-
{
275-
metric: {
276-
access_key: '1',
277-
},
278-
value: [1738959398, '1000'],
279-
},
280-
],
281-
},
282-
},
283-
{
284-
'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))': {
285-
resultType: 'matrix',
286-
result: [
287-
{
288-
metric: {
289-
location: 'US',
290-
asn: '49490',
291-
asorg: 'Test AS Org',
292-
},
293-
values: [
294-
[1738959398, '5678'],
295-
[1739284734, '1234'],
296-
],
297-
},
298-
],
299-
},
300206
'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[300s])) by (access_key)': {
301207
resultType: 'matrix',
302208
result: [
@@ -305,8 +211,8 @@ describe('PrometheusManagerMetrics', () => {
305211
access_key: '0',
306212
},
307213
values: [
308-
[1738959398, '1000'],
309-
[1738959398, '2000'],
214+
[1738959398, '9000'],
215+
[1739284734, '3000'],
310216
],
311217
},
312218
],
@@ -337,74 +243,47 @@ describe('PrometheusManagerMetrics', () => {
337243
"seconds": 1000
338244
},
339245
"dataTransferred": {
340-
"bytes": 1000
246+
"bytes": 12000
341247
},
342248
"bandwidth": {
343249
"current": {
344250
"data": {
345-
"bytes": 1234
251+
"bytes": 10
346252
},
347253
"timestamp": 1739284734
348254
},
349255
"peak": {
350256
"data": {
351-
"bytes": 5678
257+
"bytes": 30
352258
},
353259
"timestamp": 1738959398
354260
}
355261
},
356262
"locations": [
357-
{
358-
"location": "CA",
359-
"asn": null,
360-
"asOrg": null,
361-
"dataTransferred": {
362-
"bytes": 0
363-
},
364-
"tunnelTime": {
365-
"seconds": 1000
366-
}
367-
},
368263
{
369264
"location": "US",
370265
"asn": 49490,
371266
"asOrg": "Test AS Org",
372267
"dataTransferred": {
373-
"bytes": 1000
268+
"bytes": 12000
374269
},
375270
"tunnelTime": {
376-
"seconds": 0
271+
"seconds": 1000
377272
}
378273
}
379274
]
380275
},
381276
"accessKeys": [
382-
{
383-
"accessKeyId": 1,
384-
"dataTransferred": {
385-
"bytes": 0
386-
},
387-
"tunnelTime": {
388-
"seconds": 1000
389-
},
390-
"connection": {
391-
"lastTrafficSeen": null,
392-
"peakDeviceCount": {
393-
"data": 0,
394-
"timestamp": null
395-
}
396-
}
397-
},
398277
{
399278
"accessKeyId": 0,
400279
"dataTransferred": {
401-
"bytes": 1000
280+
"bytes": 12000
402281
},
403282
"tunnelTime": {
404-
"seconds": 0
283+
"seconds": 1000
405284
},
406285
"connection": {
407-
"lastTrafficSeen": 1738959398,
286+
"lastTrafficSeen": 1739284734,
408287
"peakDeviceCount": {
409288
"data": 4,
410289
"timestamp": 1738959398

0 commit comments

Comments
 (0)