mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-10-22 04:21:00 +00:00
test: cover lossless custom metrics IDs
This commit is contained in:
parent
0f77081123
commit
b56c021013
1 changed files with 30 additions and 0 deletions
|
|
@ -427,4 +427,34 @@ describe('PrometheusManagerMetrics', () => {
|
|||
expect(bytesTransferredByUserId['access-key-2']).toEqual(10000);
|
||||
done();
|
||||
});
|
||||
|
||||
it('preserves custom access key IDs in server metrics', async () => {
|
||||
const accessKeyIds = ['custom-id', '001', '9007199254740993'];
|
||||
const prometheusClient = {
|
||||
query: async (query: string): Promise<QueryResultData> => {
|
||||
if (query.includes('shadowsocks_data_bytes{')) {
|
||||
return {
|
||||
resultType: 'vector',
|
||||
result: accessKeyIds.map((accessKey, index) => ({
|
||||
metric: {access_key: accessKey},
|
||||
value: [1, String(index + 1)],
|
||||
})),
|
||||
};
|
||||
}
|
||||
return {resultType: 'vector', result: []};
|
||||
},
|
||||
queryRange: async (query: string): Promise<QueryResultData> => {
|
||||
if (query.includes('shadowsocks_data_bytes_per_location')) {
|
||||
return {resultType: 'matrix', result: [{metric: {}, values: []}]};
|
||||
}
|
||||
return {resultType: 'matrix', result: []};
|
||||
},
|
||||
} as PrometheusClient;
|
||||
const managerMetrics = new PrometheusManagerMetrics(prometheusClient);
|
||||
|
||||
const serverMetrics = await managerMetrics.getServerMetrics({seconds: 0});
|
||||
|
||||
expect(serverMetrics.accessKeys.map((entry) => entry.accessKeyId)).toEqual(accessKeyIds);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue