Skip to content

Commit

Permalink
fixing api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Oct 12, 2021
1 parent 1218082 commit 4f0272b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
const commonQuery = { start: new Date(start).toISOString(), end: new Date(end).toISOString() };
const [serviceInventoryAPIResponse, observabilityOverviewAPIResponse] = await Promise.all([
apmApiClient.readUser({
endpoint: 'GET /api/apm/services',
endpoint: 'GET /internal/apm/services',
params: {
query: {
...commonQuery,
Expand All @@ -36,7 +36,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
}),
apmApiClient.readUser({
endpoint: `GET /api/apm/observability_overview`,
endpoint: `GET /internal/apm/observability_overview`,
params: {
query: {
...commonQuery,
Expand Down Expand Up @@ -65,7 +65,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
describe('when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await apmApiClient.readUser({
endpoint: `GET /api/apm/observability_overview`,
endpoint: `GET /internal/apm/observability_overview`,
params: {
query: {
start: new Date(start).toISOString(),
Expand Down
19 changes: 18 additions & 1 deletion x-pack/test/apm_api_integration/tests/services/throughput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
comparisonEnd?: string;
}) {
const response = await apmApiClient.readUser({
endpoint: 'GET /api/apm/services/{serviceName}/throughput',
endpoint: 'GET /internal/apm/services/{serviceName}/throughput',
params: {
path: {
serviceName: 'synth-go',
Expand Down Expand Up @@ -68,12 +68,19 @@ export default function ApiTest({ getService }: FtrProviderContext) {
before(async () => {
const GO_PROD_RATE = 10;
const GO_DEV_RATE = 5;
const JAVA_PROD_RATE = 20;

const serviceGoProdInstance = service(serviceName, 'production', 'go').instance(
'instance-a'
);
const serviceGoDevInstance = service(serviceName, 'development', 'go').instance(
'instance-b'
);

const serviceJavaInstance = service('synth-java', 'development', 'java').instance(
'instance-c'
);

await traceData.index([
...timerange(start, end)
.interval('1s')
Expand All @@ -95,6 +102,16 @@ export default function ApiTest({ getService }: FtrProviderContext) {
.timestamp(timestamp)
.serialize()
),
...timerange(start, end)
.interval('1s')
.rate(JAVA_PROD_RATE)
.flatMap((timestamp) =>
serviceJavaInstance
.transaction('POST /api/product/buy')
.duration(1000)
.timestamp(timestamp)
.serialize()
),
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
backendThroughputChartAPIResponse,
] = await Promise.all([
apmApiClient.readUser({
endpoint: `GET /api/apm/services/{serviceName}/dependencies`,
endpoint: `GET /internal/apm/services/{serviceName}/dependencies`,
params: {
path: { serviceName },
query: {
Expand All @@ -43,7 +43,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
}),
apmApiClient.readUser({
endpoint: `GET /api/apm/backends/top_backends`,
endpoint: `GET /internal/apm/backends/top_backends`,
params: {
query: {
...commonQuery,
Expand All @@ -53,7 +53,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
}),
apmApiClient.readUser({
endpoint: `GET /api/apm/backends/{backendName}/charts/throughput`,
endpoint: `GET /internal/apm/backends/{backendName}/charts/throughput`,
params: {
path: { backendName: 'elasticsearch' },
query: {
Expand Down
10 changes: 5 additions & 5 deletions x-pack/test/apm_api_integration/tests/throughput/service_apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
serviceInstancesAPIResponse,
] = await Promise.all([
apmApiClient.readUser({
endpoint: 'GET /api/apm/services',
endpoint: 'GET /internal/apm/services',
params: {
query: {
...commonQuery,
Expand All @@ -43,7 +43,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
}),
apmApiClient.readUser({
endpoint: 'GET /api/apm/services/{serviceName}/throughput',
endpoint: 'GET /internal/apm/services/{serviceName}/throughput',
params: {
path: { serviceName },
query: {
Expand All @@ -54,7 +54,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
}),
apmApiClient.readUser({
endpoint: `GET /api/apm/services/{serviceName}/transactions/groups/main_statistics`,
endpoint: `GET /internal/apm/services/{serviceName}/transactions/groups/main_statistics`,
params: {
path: { serviceName },
query: {
Expand All @@ -66,7 +66,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
}),
apmApiClient.readUser({
endpoint: `GET /api/apm/services/{serviceName}/service_overview_instances/main_statistics`,
endpoint: `GET /internal/apm/services/{serviceName}/service_overview_instances/main_statistics`,
params: {
path: { serviceName },
query: {
Expand All @@ -79,7 +79,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
}),
// TODO: not using it for now since the instance name is empty for metric documents
// apmApiClient.readUser({
// endpoint: `GET /api/apm/services/{serviceName}/service_overview_instances/detailed_statistics`,
// endpoint: `GET /internal/apm/services/{serviceName}/service_overview_instances/detailed_statistics`,
// params: {
// path: { serviceName },
// query: {
Expand Down

0 comments on commit 4f0272b

Please sign in to comment.