Skip to content

Commit 71b8575

Browse files
committed
Add an endpoint for closing an experiment
With this it's possible to close an experiment on the server. Upon reception of the command the server can dispose allocated resources hence the client doesn't need them anymore. This change follows the TSP update provided by: eclipse-cdt-cloud/trace-server-protocol#95 Signed-off-by: Bernd Hufmann <[email protected]>
1 parent e23c508 commit 71b8575

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "kernel",
3+
"UUID": "22222222-2222-2222-2222-222222222222",
4+
"nbEvents": 0,
5+
"start": 0,
6+
"end": 0,
7+
"indexingStatus": "CLOSED",
8+
"traces": [
9+
{
10+
"name": "kernel",
11+
"path": "/path/kernel",
12+
"UUID": "11111111-1111-1111-1111-111111111111",
13+
"nbEvents": 0,
14+
"start": 0,
15+
"end": 0,
16+
"indexingStatus": "CLOSED"
17+
}
18+
]
19+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ export class HttpTspClient implements ITspClient {
142142
return RestClient.put(url, parameters, Experiment);
143143
}
144144

145+
/**
146+
* Close an experiment
147+
* @param expUUID Experiment UUID to close
148+
* @returns The closed experiment
149+
*/
150+
closeExperiment(
151+
expUUID: string
152+
): Promise<TspClientResponse<Experiment>> {
153+
const url = this.baseUrl + "/experiments/" + expUUID + ":close";
154+
return RestClient.put(url, new Query({}), Experiment);
155+
}
156+
145157
/**
146158
* Delete an experiment on the server
147159
* @param expUUID Experiment UUID to delete

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ describe('HttpTspClient Deserialization', () => {
108108
expect(typeof experiment.nbEvents).toEqual('number');
109109
});
110110

111+
it('deleteExperiment', async () => {
112+
httpRequestMock.mockReturnValueOnce(fixtures.asResponse('close-experiment-0.json'));
113+
const response = await client.closeExperiment('not-relevant');
114+
const experiment = response.getModel()!;
115+
116+
expect(experiment.indexingStatus).toEqual('CLOSED');
117+
});
118+
111119
it('deleteTrace', async () => {
112120
httpRequestMock.mockReturnValueOnce(fixtures.asResponse('delete-trace-0.json'));
113121
const response = await client.deleteTrace('not-relevant');

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ export interface ITspClient {
9494
parameters: Query
9595
): Promise<TspClientResponse<Experiment>>;
9696

97+
/**
98+
* Close an experiment
99+
* @param expUUID Experiment UUID to close
100+
* @returns The closed experiment
101+
*/
102+
closeExperiment(
103+
expUUID: string
104+
): Promise<TspClientResponse<Experiment>>;
105+
97106
/**
98107
* Delete an experiment on the server
99108
* @param expUUID Experiment UUID to delete

0 commit comments

Comments
 (0)