-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '8.10' into backport/8.10/pr-164122
- Loading branch information
Showing
110 changed files
with
1,338 additions
and
269 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
docs/api-generated/connectors/connector-apis-passthru.asciidoc
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,6 @@ | |
}, | ||
{ | ||
"name": "security_detection_engine", | ||
"version": "8.9.3" | ||
"version": "8.9.4" | ||
} | ||
] |
1 change: 1 addition & 0 deletions
1
...rs/core-fatal-errors-browser-internal/src/__snapshots__/fatal_errors_screen.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...logging-server-internal/src/appenders/rolling_file/strategies/numeric/utils.test.mocks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const copyFileMock = jest.fn(); | ||
export const renameMock = jest.fn(); | ||
export const unlinkMock = jest.fn(); | ||
|
||
jest.doMock('fs/promises', () => { | ||
const actual = jest.requireActual('fs/promises'); | ||
return { | ||
...actual, | ||
copyFile: copyFileMock, | ||
rename: renameMock, | ||
unlink: unlinkMock, | ||
}; | ||
}); |
85 changes: 85 additions & 0 deletions
85
.../core-logging-server-internal/src/appenders/rolling_file/strategies/numeric/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { unlinkMock, renameMock, copyFileMock } from './utils.test.mocks'; | ||
import { moveFile } from './utils'; | ||
|
||
describe('moveFile', () => { | ||
beforeEach(() => { | ||
unlinkMock.mockReset(); | ||
renameMock.mockReset(); | ||
copyFileMock.mockReset(); | ||
}); | ||
|
||
it('only calls `rename` when call succeeds', async () => { | ||
await moveFile('from', 'to'); | ||
|
||
expect(renameMock).toHaveBeenCalledTimes(1); | ||
expect(renameMock).toHaveBeenCalledWith('from', 'to'); | ||
|
||
expect(copyFileMock).not.toHaveBeenCalled(); | ||
expect(unlinkMock).not.toHaveBeenCalled(); | ||
}); | ||
|
||
const createError = (code: string) => { | ||
const err = new Error(code); | ||
(err as any).code = code; | ||
return err; | ||
}; | ||
|
||
it('throws error if `rename` throws a non-EXDEV error', async () => { | ||
renameMock.mockRejectedValue(createError('something')); | ||
|
||
await expect(moveFile('from', 'to')).rejects.toThrowError('something'); | ||
|
||
expect(renameMock).toHaveBeenCalledTimes(1); | ||
expect(copyFileMock).not.toHaveBeenCalled(); | ||
expect(unlinkMock).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('fallback to copy+unlink when `rename` throws a EXDEV error', async () => { | ||
renameMock.mockRejectedValue(createError('EXDEV')); | ||
|
||
await moveFile('from', 'to'); | ||
|
||
expect(renameMock).toHaveBeenCalledTimes(1); | ||
expect(renameMock).toHaveBeenCalledWith('from', 'to'); | ||
|
||
expect(copyFileMock).toHaveBeenCalledTimes(1); | ||
expect(copyFileMock).toHaveBeenCalledWith('from', 'to'); | ||
|
||
expect(unlinkMock).toHaveBeenCalledTimes(1); | ||
expect(unlinkMock).toHaveBeenCalledWith('from'); | ||
}); | ||
|
||
it('throws if copyFile call throws', async () => { | ||
renameMock.mockRejectedValue(createError('EXDEV')); | ||
copyFileMock.mockRejectedValue(createError('anything')); | ||
|
||
await expect(moveFile('from', 'to')).rejects.toThrowError('anything'); | ||
|
||
expect(renameMock).toHaveBeenCalledTimes(1); | ||
|
||
expect(copyFileMock).toHaveBeenCalledTimes(1); | ||
|
||
expect(unlinkMock).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('throws if unlink call throws', async () => { | ||
renameMock.mockRejectedValue(createError('EXDEV')); | ||
unlinkMock.mockRejectedValue(createError('something-else')); | ||
|
||
await expect(moveFile('from', 'to')).rejects.toThrowError('something-else'); | ||
|
||
expect(renameMock).toHaveBeenCalledTimes(1); | ||
|
||
expect(copyFileMock).toHaveBeenCalledTimes(1); | ||
|
||
expect(unlinkMock).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
...gging/core-logging-server-internal/src/appenders/rolling_file/strategies/numeric/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { copyFile, rename, unlink } from 'fs/promises'; | ||
|
||
export const moveFile = async (oldPath: string, newPath: string): Promise<void> => { | ||
try { | ||
await rename(oldPath, newPath); | ||
} catch (err) { | ||
// rename isn't supported on some file systems / volumes | ||
// so we fallback to copy+delete | ||
if (err.code === 'EXDEV') { | ||
await copyFile(oldPath, newPath); | ||
await unlink(oldPath); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.