Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an endpoint for closing an experiment #90

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tsp-typescript-client/fixtures/tsp-client/close-experiment-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "kernel",
"UUID": "22222222-2222-2222-2222-222222222222",
"nbEvents": 0,
"start": 0,
"end": 0,
"indexingStatus": "CLOSED",
"traces": [
{
"name": "kernel",
"path": "/path/kernel",
"UUID": "11111111-1111-1111-1111-111111111111",
"nbEvents": 0,
"start": 0,
"end": 0,
"indexingStatus": "CLOSED"
}
]
}
12 changes: 12 additions & 0 deletions tsp-typescript-client/src/protocol/http-tsp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ export class HttpTspClient implements ITspClient {
return RestClient.put(url, parameters, Experiment);
}

/**
* Close an experiment
* @param expUUID Experiment UUID to close
* @returns The closed experiment
*/
closeExperiment(
expUUID: string
): Promise<TspClientResponse<Experiment>> {
const url = this.baseUrl + "/experiments/" + expUUID + ":close";
return RestClient.put(url, new Query({}), Experiment);
}

/**
* Delete an experiment on the server
* @param expUUID Experiment UUID to delete
Expand Down
8 changes: 8 additions & 0 deletions tsp-typescript-client/src/protocol/tsp-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ describe('HttpTspClient Deserialization', () => {
expect(typeof experiment.nbEvents).toEqual('number');
});

it('deleteExperiment', async () => {
httpRequestMock.mockReturnValueOnce(fixtures.asResponse('close-experiment-0.json'));
const response = await client.closeExperiment('not-relevant');
const experiment = response.getModel()!;

expect(experiment.indexingStatus).toEqual('CLOSED');
});

it('deleteTrace', async () => {
httpRequestMock.mockReturnValueOnce(fixtures.asResponse('delete-trace-0.json'));
const response = await client.deleteTrace('not-relevant');
Expand Down
9 changes: 9 additions & 0 deletions tsp-typescript-client/src/protocol/tsp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ export interface ITspClient {
parameters: Query
): Promise<TspClientResponse<Experiment>>;

/**
* Close an experiment
* @param expUUID Experiment UUID to close
* @returns The closed experiment
*/
closeExperiment(
expUUID: string
): Promise<TspClientResponse<Experiment>>;

/**
* Delete an experiment on the server
* @param expUUID Experiment UUID to delete
Expand Down
Loading