Skip to content

Commit dedbb9e

Browse files
committed
add tests for server
1 parent 252160a commit dedbb9e

File tree

1 file changed

+58
-4
lines changed
  • x-pack/platform/test/functional_execution_context/tests

1 file changed

+58
-4
lines changed

x-pack/platform/test/functional_execution_context/tests/server.ts

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function ({ getService }: FtrProviderContext) {
7070
await waitForStatus(alertId, new Set(['ok']), 90_000);
7171
const logs = await readLogFile();
7272

73-
await assertLogContains({
73+
assertLogContains({
7474
description:
7575
'task manager execution context propagates to Elasticsearch via "x-opaque-id" header',
7676
predicate: (record) =>
@@ -83,7 +83,7 @@ export default function ({ getService }: FtrProviderContext) {
8383
logs,
8484
});
8585

86-
await assertLogContains({
86+
assertLogContains({
8787
description:
8888
'alerting execution context propagates to Elasticsearch via "x-opaque-id" header',
8989
predicate: (record) =>
@@ -93,7 +93,7 @@ export default function ({ getService }: FtrProviderContext) {
9393
logs,
9494
});
9595

96-
await assertLogContains({
96+
assertLogContains({
9797
description: 'execution context propagates to Kibana logs',
9898
predicate: (record) =>
9999
isExecutionContextLog(record, {
@@ -137,7 +137,7 @@ export default function ({ getService }: FtrProviderContext) {
137137
logs,
138138
});
139139

140-
await assertLogContains({
140+
assertLogContains({
141141
description: 'execution context propagates to Kibana logs',
142142
predicate: (record) =>
143143
isExecutionContextLog(record, {
@@ -149,5 +149,59 @@ export default function ({ getService }: FtrProviderContext) {
149149
logs,
150150
});
151151
});
152+
153+
it('adds space id (default) to execution context from x-kbn-context header', async () => {
154+
const executionContext = {
155+
type: 'test',
156+
name: 'status check',
157+
id: 'test-123',
158+
};
159+
160+
await supertest
161+
.get('/api/status')
162+
.set('x-kbn-context', encodeURIComponent(JSON.stringify(executionContext)))
163+
.expect(200);
164+
165+
const logs = await readLogFile();
166+
167+
assertLogContains({
168+
description: 'execution context includes space id in Kibana logs',
169+
predicate: (record) =>
170+
isExecutionContextLog(record, {
171+
type: 'test',
172+
name: 'status check',
173+
id: 'test-123',
174+
space: 'default',
175+
}),
176+
logs,
177+
});
178+
});
179+
180+
it('adds space id (myspace) to execution context from x-kbn-context header', async () => {
181+
const executionContext = {
182+
type: 'test',
183+
name: 'api call',
184+
id: 'test-456',
185+
};
186+
187+
await supertest
188+
.get('/s/myspace/emit_log_with_trace_id')
189+
.set('x-kbn-context', encodeURIComponent(JSON.stringify(executionContext)))
190+
.expect(200);
191+
192+
const logs = await readLogFile();
193+
194+
assertLogContains({
195+
description: 'execution context includes space id in Kibana logs',
196+
predicate: (record) =>
197+
isExecutionContextLog(record, {
198+
type: 'test',
199+
name: 'api call',
200+
id: 'test-456',
201+
space: 'myspace',
202+
}),
203+
logs,
204+
});
205+
});
152206
});
153207
}

0 commit comments

Comments
 (0)