Skip to content

Commit

Permalink
implement identifier service
Browse files Browse the repository at this point in the history
Signed-off-by: Vlad Arama <[email protected]>
  • Loading branch information
vladarama authored and bhufmann committed Aug 12, 2024
1 parent 039612e commit 62e8d39
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tsp-typescript-client/fixtures/tsp-client/fetch-identifier-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.9.1",
"buildTime": "202408051810",
"os": "Windows 10",
"osArch": "amd64",
"osVersion": "10.0",
"cpuCount": 8,
"maxMemory": 8552185856,
"launcherName": "Tracecompass-serverc",
"productId": "org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.id"
}
49 changes: 49 additions & 0 deletions tsp-typescript-client/src/models/identifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Model of the identifier
*/
export interface Identifier {
/**
* Version in the format Major.Minor.Micro
*/
version: string;

/**
* Build time or qualifier of the server version, if available
*/
buildTime: string;

/**
* Operating system name
*/
os: string;

/**
* Architecture of the operating system
*/
osArch: string;

/**
* Operating system version
*/
osVersion: string;

/**
* Number of CPUs available
*/
cpuCount: string;

/**
* Maximum memory available to the JVM in bytes
*/
maxMemory: string;

/**
* Name of the launcher used, if available
*/
launcherName: string;

/**
* Product identifier
*/
productId: string;
}
10 changes: 10 additions & 0 deletions tsp-typescript-client/src/protocol/http-tsp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DataTreeEntry } from "../models/data-tree";
import { Entry, EntryModel } from "../models/entry";
import { Experiment } from "../models/experiment";
import { HealthStatus } from "../models/health";
import { Identifier } from "../models/identifier";
import { MarkerSet } from "../models/markerset";
import { OutputDescriptor } from "../models/output-descriptor";
import { Query } from "../models/query/query";
Expand Down Expand Up @@ -519,6 +520,15 @@ export class HttpTspClient implements ITspClient {
return RestClient.get(url);
}

/**
* Fetch the identifier service
* @returns Important information regarding the trace server and the system it is running on
*/
public async fetchIdentifier(): Promise<TspClientResponse<Identifier>> {
const url = this.baseUrl + "/identifier";
return RestClient.get(url);
}

/**
* Fetch all configuration source types
* @returns Generic response with the model
Expand Down
15 changes: 15 additions & 0 deletions tsp-typescript-client/src/protocol/tsp-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ describe('HttpTspClient Deserialization', () => {
}
});

it('fetchIdentifier' , async () => {
httpRequestMock.mockReturnValueOnce(fixtures.asResponse('fetch-identifier-0.json'));
const response = await client.fetchIdentifier();
const identifier = response.getModel()!;

expect(response.getStatusCode()).toEqual(200);
expect(identifier.version).toBeDefined();
expect(identifier.os).toBeDefined();
expect(identifier.osArch).toBeDefined();
expect(identifier.osVersion).toBeDefined();
expect(identifier.cpuCount).toBeDefined();
expect(identifier.maxMemory).toBeDefined();
expect(identifier.productId).toBeDefined();
});

it('fetchMarkerSets', async () => {
httpRequestMock.mockReturnValueOnce(fixtures.asResponse('fetch-marker-sets-0.json'));
const response = await client.fetchMarkerSets('not-relevant');
Expand Down
7 changes: 7 additions & 0 deletions tsp-typescript-client/src/protocol/tsp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { MarkerSet } from "../models/markerset";
import { DataTreeEntry } from "../models/data-tree";
import { ConfigurationSourceType } from "../models/configuration-source";
import { Configuration } from "../models/configuration";
import { Identifier } from "../models/identifier";

export {
/** @deprecated */ HttpTspClient as TspClient,
Expand Down Expand Up @@ -297,6 +298,12 @@ export interface ITspClient {
*/
checkHealth(): Promise<TspClientResponse<HealthStatus>>;

/**
* Fetch the identifier service
* @returns Important information regarding the trace server and the system it is running on
*/
fetchIdentifier(): Promise<TspClientResponse<Identifier>>;

/**
* Fetch all configuration source types
* @returns Generic response with the model
Expand Down

0 comments on commit 62e8d39

Please sign in to comment.