Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Mar 2, 2020
2 parents 82c023f + c9ebeb7 commit 9703c98
Show file tree
Hide file tree
Showing 40 changed files with 527 additions and 4,635 deletions.
13 changes: 13 additions & 0 deletions src/core/server/elasticsearch/retry_call_cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ describe('migrationsRetryCallCluster', () => {
});
});

it('retries ES API calls that rejects with snapshot_in_progress_exception', () => {
expect.assertions(1);
const callEsApi = jest.fn();
let i = 0;
callEsApi.mockImplementation(() => {
return i++ <= 2
? Promise.reject({ body: { error: { type: 'snapshot_in_progress_exception' } } })
: Promise.resolve('success');
});
const retried = migrationsRetryCallCluster(callEsApi, mockLogger.get('mock log'), 1);
return expect(retried('endpoint')).resolves.toMatchInlineSnapshot(`"success"`);
});

it('rejects when ES API calls reject with other errors', async () => {
expect.assertions(3);
const callEsApi = jest.fn();
Expand Down
13 changes: 3 additions & 10 deletions src/core/server/elasticsearch/retry_call_cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export function migrationsRetryCallCluster(
error instanceof esErrors.AuthenticationException ||
error instanceof esErrors.AuthorizationException ||
// @ts-ignore
error instanceof esErrors.Gone
error instanceof esErrors.Gone ||
error?.body?.error?.type === 'snapshot_in_progress_exception'
);
},
timer(delay),
Expand All @@ -85,15 +86,7 @@ export function migrationsRetryCallCluster(
*
* @param apiCaller
*/

// TODO: Replace with APICaller from './scoped_cluster_client' once #46668 is merged
export function retryCallCluster(
apiCaller: (
endpoint: string,
clientParams: Record<string, any>,
options?: CallAPIOptions
) => Promise<any>
) {
export function retryCallCluster(apiCaller: APICaller) {
return (endpoint: string, clientParams: Record<string, any> = {}, options?: CallAPIOptions) => {
return defer(() => apiCaller(endpoint, clientParams, options))
.pipe(
Expand Down
24 changes: 24 additions & 0 deletions src/core/utils/merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

// eslint-disable-next-line max-classes-per-file
import { merge } from './merge';

describe('merge', () => {
Expand Down Expand Up @@ -62,6 +63,29 @@ describe('merge', () => {
expect(merge({ a: 0 }, { a: 1 }, {})).toEqual({ a: 1 });
});

test('does not merge class instances', () => {
class Folder {
constructor(public readonly path: string) {}
getPath() {
return this.path;
}
}
class File {
constructor(public readonly content: string) {}
getContent() {
return this.content;
}
}
const folder = new Folder('/etc');
const file = new File('yolo');

const result = merge({}, { content: folder }, { content: file });
expect(result).toStrictEqual({
content: file,
});
expect(result.content.getContent()).toBe('yolo');
});

test(`doesn't pollute prototypes`, () => {
merge({}, JSON.parse('{ "__proto__": { "foo": "bar" } }'));
merge({}, JSON.parse('{ "constructor": { "prototype": { "foo": "bar" } } }'));
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

import { isPlainObject } from 'lodash';
/**
* Deeply merges two objects, omitting undefined values, and not deeply merging Arrays.
*
Expand Down Expand Up @@ -60,7 +60,7 @@ export function merge<TReturn extends Record<string, any>>(
) as TReturn;
}

const isMergable = (obj: any) => typeof obj === 'object' && obj !== null && !Array.isArray(obj);
const isMergable = (obj: any) => isPlainObject(obj);

const mergeObjects = <T extends Record<string, any>, U extends Record<string, any>>(
baseObj: T,
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/dev_tools/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
This folder is just a left-over of the things that can't be moved to Kibana platform just yet:

* Styling (this can be moved as soon as there is support for styling in Kibana platform)
* Check whether there are no dev tools and hide the link in the nav bar (this can be moved as soon as all dev tools are moved)
3 changes: 0 additions & 3 deletions src/legacy/core_plugins/kibana/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
// vis_type_vislib UI styles
@import 'src/legacy/core_plugins/vis_type_vislib/public/index';

// Dev tools styles
@import './dev_tools/index';

// Discover styles
@import 'discover/index';

Expand Down
15 changes: 14 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,19 @@ export {
export { IRequestTypesMap, IResponseTypesMap } from './search';
export * from './search';

/*
* UI components
*/

export {
SearchBar,
SearchBarProps,
StatefulSearchBarProps,
FilterBar,
QueryStringInput,
IndexPatternSelect,
} from './ui';

/**
* Types to be shared externally
* @public
Expand All @@ -310,7 +323,7 @@ export {
TimefilterContract,
TimeHistoryContract,
} from './query';
export * from './ui';

export {
// kbn field types
castEsToKbnFieldTypeName,
Expand Down
Loading

0 comments on commit 9703c98

Please sign in to comment.