Skip to content

Commit 99277ee

Browse files
Merge branch 'master' into autocompleteOptions
2 parents a9af003 + ce45647 commit 99277ee

File tree

361 files changed

+806
-983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

361 files changed

+806
-983
lines changed

docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export interface SavedObjectsServiceSetup
1616

1717
When plugins access the Saved Objects client, a new client is created using the factory provided to `setClientFactory` and wrapped by all wrappers registered through `addClientWrapper`<!-- -->.
1818

19+
All the setup APIs will throw if called after the service has started, and therefor cannot be used from legacy plugin code. Legacy plugins should use the legacy savedObject service until migrated.
20+
1921
## Example 1
2022

2123

src/core/MIGRATION_EXAMPLES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,4 +917,10 @@ Would be converted to:
917917
918918
```typescript
919919
const migration: SavedObjectMigrationFn = (doc, { log }) => {...}
920-
```
920+
```
921+
922+
### Remarks
923+
924+
The `registerType` API will throw if called after the service has started, and therefor cannot be used from
925+
legacy plugin code. Legacy plugins should use the legacy savedObjects service and the legacy way to register
926+
saved object types until migrated.

src/core/server/saved_objects/saved_objects_service.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,36 @@ describe('SavedObjectsService', () => {
232232
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(1);
233233
});
234234

235+
it('throws when calling setup APIs once started', async () => {
236+
const coreContext = createCoreContext({ skipMigration: false });
237+
const soService = new SavedObjectsService(coreContext);
238+
const setup = await soService.setup(createSetupDeps());
239+
await soService.start({});
240+
241+
expect(() => {
242+
setup.setClientFactoryProvider(jest.fn());
243+
}).toThrowErrorMatchingInlineSnapshot(
244+
`"cannot call \`setClientFactoryProvider\` after service startup."`
245+
);
246+
247+
expect(() => {
248+
setup.addClientWrapper(0, 'dummy', jest.fn());
249+
}).toThrowErrorMatchingInlineSnapshot(
250+
`"cannot call \`addClientWrapper\` after service startup."`
251+
);
252+
253+
expect(() => {
254+
setup.registerType({
255+
name: 'someType',
256+
hidden: false,
257+
namespaceAgnostic: false,
258+
mappings: { properties: {} },
259+
});
260+
}).toThrowErrorMatchingInlineSnapshot(
261+
`"cannot call \`registerType\` after service startup."`
262+
);
263+
});
264+
235265
describe('#getTypeRegistry', () => {
236266
it('returns the internal type registry of the service', async () => {
237267
const coreContext = createCoreContext({ skipMigration: false });

src/core/server/saved_objects/saved_objects_service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ import { registerRoutes } from './routes';
6161
* the factory provided to `setClientFactory` and wrapped by all wrappers
6262
* registered through `addClientWrapper`.
6363
*
64+
* All the setup APIs will throw if called after the service has started, and therefor cannot be used
65+
* from legacy plugin code. Legacy plugins should use the legacy savedObject service until migrated.
66+
*
6467
* @example
6568
* ```ts
6669
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
@@ -275,6 +278,7 @@ export class SavedObjectsService
275278
private migrator$ = new Subject<KibanaMigrator>();
276279
private typeRegistry = new SavedObjectTypeRegistry();
277280
private validations: PropertyValidators = {};
281+
private started = false;
278282

279283
constructor(private readonly coreContext: CoreContext) {
280284
this.logger = coreContext.logger.get('savedobjects-service');
@@ -316,19 +320,28 @@ export class SavedObjectsService
316320

317321
return {
318322
setClientFactoryProvider: provider => {
323+
if (this.started) {
324+
throw new Error('cannot call `setClientFactoryProvider` after service startup.');
325+
}
319326
if (this.clientFactoryProvider) {
320327
throw new Error('custom client factory is already set, and can only be set once');
321328
}
322329
this.clientFactoryProvider = provider;
323330
},
324331
addClientWrapper: (priority, id, factory) => {
332+
if (this.started) {
333+
throw new Error('cannot call `addClientWrapper` after service startup.');
334+
}
325335
this.clientFactoryWrappers.push({
326336
priority,
327337
id,
328338
factory,
329339
});
330340
},
331341
registerType: type => {
342+
if (this.started) {
343+
throw new Error('cannot call `registerType` after service startup.');
344+
}
332345
this.typeRegistry.registerType(type);
333346
},
334347
};
@@ -415,6 +428,8 @@ export class SavedObjectsService
415428
clientProvider.addClientWrapperFactory(priority, id, factory);
416429
});
417430

431+
this.started = true;
432+
418433
return {
419434
migrator,
420435
clientProvider,

src/plugins/bfetch/common/buffer/tests/timed_item_buffer.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import { TimedItemBuffer } from '../timed_item_buffer';
2121
import { runItemBufferTests } from './run_item_buffer_tests';
2222

23-
describe('TimedItemBuffer', () => {
23+
// FLAKY: https://github.com/elastic/kibana/issues/58662
24+
describe.skip('TimedItemBuffer', () => {
2425
runItemBufferTests(TimedItemBuffer);
2526

2627
test('does not do unnecessary flushes', async () => {

test/functional/apps/context/_filters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function({ getService, getPageObjects }) {
6464
await filterBar.toggleFilterEnabled(TEST_ANCHOR_FILTER_FIELD);
6565
await PageObjects.context.waitUntilContextLoadingHasFinished();
6666

67-
retry.try(async () => {
67+
await retry.try(async () => {
6868
expect(
6969
await filterBar.hasFilter(TEST_ANCHOR_FILTER_FIELD, TEST_ANCHOR_FILTER_VALUE, false)
7070
).to.be(true);

test/functional/apps/dashboard/panel_expand_toggle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function({ getService, getPageObjects }) {
5656

5757
// Add a retry to fix https://github.com/elastic/kibana/issues/14574. Perhaps the recent changes to this
5858
// being a CSS update is causing the UI to change slower than grabbing the panels?
59-
retry.try(async () => {
59+
await retry.try(async () => {
6060
const panelCountAfterMaxThenMinimize = await PageObjects.dashboard.getPanelCount();
6161
expect(panelCountAfterMaxThenMinimize).to.be(panelCount);
6262
});

test/functional/apps/visualize/_tsvb_markdown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
121121
await visualBuilder.markdownSwitchSubTab('data');
122122
await visualBuilder.cloneSeries();
123123

124-
retry.try(async function seriesCountCheck() {
124+
await retry.try(async function seriesCountCheck() {
125125
const seriesLength = (await visualBuilder.getSeries()).length;
126126
expect(seriesLength).to.be.equal(2);
127127
});
@@ -131,7 +131,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
131131
await visualBuilder.markdownSwitchSubTab('data');
132132
await visualBuilder.createNewAgg();
133133

134-
retry.try(async function aggregationCountCheck() {
134+
await retry.try(async function aggregationCountCheck() {
135135
const aggregationLength = await visualBuilder.getAggregationCount();
136136
expect(aggregationLength).to.be.equal(2);
137137
});

x-pack/.i18nrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"xpack.logstash": "legacy/plugins/logstash",
2727
"xpack.main": "legacy/plugins/xpack_main",
2828
"xpack.maps": "legacy/plugins/maps",
29-
"xpack.ml": "legacy/plugins/ml",
29+
"xpack.ml": ["plugins/ml", "legacy/plugins/ml"],
3030
"xpack.monitoring": "legacy/plugins/monitoring",
3131
"xpack.remoteClusters": "plugins/remote_clusters",
3232
"xpack.reporting": ["plugins/reporting", "legacy/plugins/reporting"],

x-pack/legacy/plugins/apm/readme.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,29 @@ node scripts/jest.js plugins/apm --updateSnapshot
7474
### Functional tests
7575

7676
**Start server**
77-
`node scripts/functional_tests_server --config x-pack/test/functional/config.js`
77+
```
78+
node scripts/functional_tests_server --config x-pack/test/functional/config.js
79+
```
7880

7981
**Run tests**
80-
`node scripts/functional_test_runner --config x-pack/test/functional/config.js --grep='APM specs'`
82+
```
83+
node scripts/functional_test_runner --config x-pack/test/functional/config.js --grep='APM specs'
84+
```
8185

8286
APM tests are located in `x-pack/test/functional/apps/apm`.
8387
For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)
8488

8589
### API integration tests
8690

8791
**Start server**
88-
`node scripts/functional_tests_server --config x-pack/test/api_integration/config.js`
92+
```
93+
node scripts/functional_tests_server --config x-pack/test/api_integration/config.js
94+
```
8995

9096
**Run tests**
91-
`node scripts/functional_test_runner --config x-pack/test/api_integration/config.js --grep='APM specs'`
97+
```
98+
node scripts/functional_test_runner --config x-pack/test/api_integration/config.js --grep='APM specs'
99+
```
92100

93101
APM tests are located in `x-pack/test/api_integration/apis/apm`.
94102
For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)

0 commit comments

Comments
 (0)