Skip to content

Commit 143a5ab

Browse files
committed
Add data type DataType enum and usage in EntryHeader data structure
Added also unit test for that. Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
1 parent 9b23dfe commit 143a5ab

File tree

4 files changed

+94
-30
lines changed

4 files changed

+94
-30
lines changed

tsp-typescript-client/fixtures/tsp-client/fetch-data-tree-0.json

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
"style": null,
88
"labels": [
99
"kernel",
10-
"221 ns",
11-
"13.583 s",
12-
"117.405 ms",
13-
"743.411 ms",
14-
"4364",
15-
"512.353 s"
16-
],
10+
"266 ns",
11+
"1.022 s",
12+
"18.768 ms",
13+
"85.527 ms",
14+
"2607",
15+
"48.929 s",
16+
"[1571171542725521079,1571171542725521345]",
17+
"[1571171542231247219,1571171543252848866]"
18+
],
1719
"hasData": true
1820
},
1921
{
@@ -22,13 +24,15 @@
2224
"style": null,
2325
"labels": [
2426
"Total",
25-
"221 ns",
26-
"13.583 s",
27-
"117.405 ms",
28-
"743.411 ms",
29-
"4364",
30-
"512.353 s"
31-
],
27+
"266 ns",
28+
"1.022 s",
29+
"18.768 ms",
30+
"85.527 ms",
31+
"2607",
32+
"48.929 s",
33+
"[1571171542725521079,1571171542725521345]",
34+
"[1571171542231247219,1571171543252848866]"
35+
],
3236
"hasData": true
3337
},
3438
{
@@ -37,13 +41,15 @@
3741
"style": null,
3842
"labels": [
3943
"WAKE",
40-
"221 ns",
41-
"55.137 µs",
42-
"3.707 µs",
43-
"5.214 µs",
44-
"3010",
45-
"11.158 ms"
46-
],
44+
"266 ns",
45+
"65.302 µs",
46+
"3.087 µs",
47+
"3.961 µs",
48+
"1756",
49+
"5.421 ms",
50+
"[1571171542725521079,1571171542725521345]",
51+
"[1571171542574454113,1571171542574519415]"
52+
],
4753
"hasData": true
4854
},
4955
{
@@ -52,13 +58,15 @@
5258
"style": null,
5359
"labels": [
5460
"WAIT",
55-
"319 ns",
56-
"13.583 s",
57-
"378.392 ms",
58-
"1.297 s",
59-
"1354",
60-
"512.342 s"
61-
],
61+
"622 ns",
62+
"1.022 s",
63+
"57.489 ms",
64+
"142.119 ms",
65+
"851",
66+
"48.923 s",
67+
"[1571171542693294749,1571171542693295371]",
68+
"[1571171542231247219,1571171543252848866]"
69+
],
6270
"hasData": true
6371
}
6472
],
@@ -90,6 +98,16 @@
9098
{
9199
"name": "Total",
92100
"tooltip": ""
101+
},
102+
{
103+
"name": "Min Time Range",
104+
"tooltip": "",
105+
"dataType": "TIME_RANGE"
106+
},
107+
{
108+
"name": "Max Time Range",
109+
"tooltip": "",
110+
"dataType": "TIME_RANGE"
93111
}
94112
]
95113
},
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export enum DataType {
2+
/** Data represent a decimal number */
3+
NUMBER = 'NUMBER',
4+
/** Binary data, where the size orders are powers of 2 */
5+
BINARY_NUMBER = 'NUMBER',
6+
/** Data represent a timestamp in nanoseconds, can be negative */
7+
TIMESTAMP = "TIMESTAMP",
8+
/** Data represents a duration in nanoseconds */
9+
DURATION = "DURATION",
10+
/** Data is textual data */
11+
STRING = "STRING",
12+
/**
13+
* Data representing a time range of string: [start,end],
14+
* where `start` and `end` are timestamps in nanoseconds
15+
*/
16+
TIME_RANGE = "TIME_RANGE"
17+
}

tsp-typescript-client/src/models/entry.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ export interface EntryHeader {
5858
* The description of this header field
5959
*/
6060
tooltip: string
61+
62+
/**
63+
* The data type of the column. If undefined, default is DATA_TYPE.STRING.
64+
*/
65+
dataType?: string
6166
}
6267

6368
export function EntryModel<T extends Entry>(normalizer: Normalizer<T>): Normalizer<EntryModel<T>> {

tsp-typescript-client/src/protocol/tsp-client.test.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// tslint:disable: no-unused-expression
22

3+
import { Headers } from 'node-fetch';
34
import { Query } from '../models/query/query';
45
import { HttpRequest, HttpResponse, RestClient } from './rest-client';
5-
import { Headers } from 'node-fetch';
66
import { FixtureSet } from './test-utils';
77
import { TspClient } from './tsp-client';
8+
import { DataType } from '../models/data-type';
89

910
describe('TspClient Deserialization', () => {
1011

@@ -333,11 +334,34 @@ describe('TspClient Deserialization', () => {
333334
const genericResponse = response.getModel()!;
334335
const model = genericResponse.model;
335336

337+
const EXPECTED_TRACE_MAX_RANGE = "[1571171542231247219,1571171543252848866]";
338+
const EXPECTED_HEADERS = [ { name: 'Label', tooltip: '' },
339+
{ name: 'Minimum', tooltip: '' },
340+
{ name: 'Maximum', tooltip: '' },
341+
{ name: 'Average', tooltip: '' },
342+
{ name: 'Std Dev', tooltip: '' },
343+
{ name: 'Count', tooltip: '', },
344+
{ name: 'Total', tooltip: '', },
345+
{ name: 'Min Time Range', tooltip: '', dataType: DataType.TIME_RANGE },
346+
{ name: 'Max Time Range', tooltip: '', dataType: DataType.TIME_RANGE }];
347+
336348
expect(model.entries).toHaveLength(4);
337-
expect(model.headers).toHaveLength(7);
349+
expect(model.headers).toHaveLength(9);
350+
351+
let i = 0;
352+
for (const header of model.headers) {
353+
expect(header.name).toEqual(EXPECTED_HEADERS[i].name);
354+
expect(header.tooltip).toEqual(EXPECTED_HEADERS[i].tooltip);
355+
if (EXPECTED_HEADERS[i].dataType) {
356+
expect(header.dataType).toEqual(EXPECTED_HEADERS[i].dataType);
357+
}
358+
i++;
359+
}
338360
for (const entry of model.entries) {
339361
expect(typeof entry.id).toEqual('number');
340362
}
363+
const len = model.entries[0].labels.length;
364+
expect(model.entries[0].labels[len - 1]).toEqual(EXPECTED_TRACE_MAX_RANGE);
341365
});
342366

343367
it('fetchXYTree', async () => {

0 commit comments

Comments
 (0)