[Reporting] Use google headless binary for reporting (#216688)

## Summary

This PR switches the chromium binary used for reporting to new
headless-shell binary provided by google, we only use said binaries for
Mac and Windows, and will keep the same our current approach for linux
because there's no support for ARM linux.

The current installed version of puppeteer is `24.4.0`, with an
expectation for chromium of revision `1415337` and version
`134.0.6998.35`, which has been selected.


## How to verify this change;

- Attempt generating exports of PDFs and PNG, with print option enabled
and disabled
- Verify that we are able to generate a report, and the reports match
previous ones.

### Binary Verification

- Mac Arm
<img width="864" alt="Screenshot 2025-04-04 at 12 15 31"
src="https://github.com/user-attachments/assets/00b22c69-6839-4056-ac67-c6001e16413d"
/>

- Windows
<img width="1395" alt="Screenshot 2025-04-19 at 14 51 09"
src="https://github.com/user-attachments/assets/499b67ff-ab6a-41bb-ae4e-598c15e1bef4"
/>

P.S. This PR is a prerequisite for
https://github.com/elastic/kibana/pull/212674

<!-- 
### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

-->

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Eyo O. Eyo 2025-04-20 16:41:36 +02:00 committed by GitHub
parent 7eb727410a
commit 1c74e0fb95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 39 deletions

View file

@ -17,53 +17,55 @@ export interface PackageInfo {
binaryChecksum: string;
binaryRelativePath: string;
isPreInstalled: boolean;
location: 'custom' | 'common';
revision: number;
location: 'custom' | 'chromeForTesting';
}
enum BaseUrl {
// see https://www.chromium.org/getting-involved/download-chromium
common = 'https://commondatastorage.googleapis.com/chromium-browser-snapshots',
// A GCS bucket under the Kibana team
custom = 'https://storage.googleapis.com/headless_shell',
// GCS bucket for headless chrome provided by the chrome team, see
// https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
chromeForTesting = 'https://storage.googleapis.com/chrome-for-testing-public',
}
interface CustomPackageInfo extends PackageInfo {
location: 'custom';
}
interface CommonPackageInfo extends PackageInfo {
location: 'common';
interface ChromeForTestingPackageInfo extends PackageInfo {
version: string;
location: 'chromeForTesting';
archivePath: string;
}
function isCommonPackage(p: PackageInfo): p is CommonPackageInfo {
return p.location === 'common';
function isChromeForTestingPackage(p: PackageInfo): p is ChromeForTestingPackageInfo {
return p.location === 'chromeForTesting';
}
export class ChromiumArchivePaths {
public readonly packages: Array<CustomPackageInfo | CommonPackageInfo> = [
public readonly packages: Array<CustomPackageInfo | ChromeForTestingPackageInfo> = [
{
platform: 'darwin',
architecture: 'x64',
archiveFilename: 'chrome-mac.zip',
archiveChecksum: '481e48cbe90b1f904594a4658bcd5152e54cb11108cec8e2df08f959f75bdf5d',
binaryChecksum: 'a634013f8596f8a35e324acfc48ba7a986b328a5f58ee925d47fa9aee1195ce4',
binaryRelativePath: 'chrome-mac/Chromium.app/Contents/MacOS/Chromium',
revision: 1415334,
location: 'common',
archivePath: 'Mac',
archiveFilename: 'chrome-headless-shell-mac-x64.zip',
archiveChecksum: 'e09bd8cc7b381a20d7738c3026a359e5ddd6a587ecb33f8326c0818f243f50e2',
binaryChecksum: '7bef5a84fe90d2a243e1e9c45e86f53525b1a3adec598c0b6ce009792abd5f34',
binaryRelativePath: 'chrome-headless-shell-mac-x64/chrome-headless-shell',
version: '134.0.6998.35',
location: 'chromeForTesting',
archivePath: 'mac-x64',
isPreInstalled: false,
},
{
platform: 'darwin',
architecture: 'arm64',
archiveFilename: 'chrome-mac.zip',
archiveChecksum: '37d77b21dd0085c845d610d1a63c2bf0e7b07aa75c8cef5bd1a251a6d86411df',
binaryChecksum: '35a2b8a456e71f6d1df58a324d983b86944ce60443a1fe24d460a18f88c53216',
binaryRelativePath: 'chrome-mac/Chromium.app/Contents/MacOS/Chromium',
revision: 1415336,
location: 'common',
archivePath: 'Mac_Arm',
archiveFilename: 'chrome-headless-shell-mac-arm64.zip',
archiveChecksum: 'ead60a22ae13e93a74b88fe43df3aa547ca599d9f9b7fd4b060e5c595fd890cb',
binaryChecksum: '8f60afb3cabee80b3e7efa6898d589997d5f6e3669b1bdc1bca4b8685e500e7f',
binaryRelativePath: 'chrome-headless-shell-mac-arm64/chrome-headless-shell',
version: '134.0.6998.35',
location: 'chromeForTesting',
archivePath: 'mac-arm64',
isPreInstalled: false,
},
{
@ -73,7 +75,6 @@ export class ChromiumArchivePaths {
archiveChecksum: '98db5f4ae704a0cf4d1612721334b0466908bf642ac547798aa303d17105e782',
binaryChecksum: '2ed0cbce8358e86b5c44719d1ccd50f711b879088946b6ffdeed22b4ce2e47ea',
binaryRelativePath: 'headless_shell-linux_x64/headless_shell',
revision: 1415337,
location: 'custom',
isPreInstalled: true,
},
@ -84,20 +85,19 @@ export class ChromiumArchivePaths {
archiveChecksum: '9b3bf295794f0d4fe5e52813aa31a5ed4ca4389384f7fff2a8465777709174ea',
binaryChecksum: '382c7f30a57b1096c7567d3a2cba0353aae80ec11790cd271601fb1b2ebb85cd',
binaryRelativePath: 'headless_shell-linux_arm64/headless_shell',
revision: 1415337,
location: 'custom',
isPreInstalled: true,
},
{
platform: 'win32',
architecture: 'x64',
archiveFilename: 'chrome-win.zip',
archiveChecksum: 'b76935f051c3f386372a0dbb79b657f5179430fea3e8014cc054cb44a5c138e0',
binaryChecksum: '78d4e3a27130a3589e8bd51f3dc6cce061ccd80ab5bcfc77430ac014f17a9be9',
binaryRelativePath: path.join('chrome-win', 'chrome.exe'),
revision: 1415337,
location: 'common',
archivePath: 'Win',
archiveFilename: 'chrome-headless-shell-win64.zip',
archiveChecksum: '3bda1b7b1dc59fe4d79d68c5ca2384f8e7a743253e041eb731664b05a1e73343',
binaryChecksum: 'fffdc5e77fae67391e154d92f2084f84fec410632a48211ae0ab652dc64aeacf',
binaryRelativePath: path.join('chrome-headless-shell-win64', 'chrome-headless-shell.exe'),
version: '134.0.6998.35',
location: 'chromeForTesting',
archivePath: 'win64',
isPreInstalled: true,
},
];
@ -119,11 +119,14 @@ export class ChromiumArchivePaths {
}
public getDownloadUrl(p: PackageInfo) {
if (isCommonPackage(p)) {
const { common } = BaseUrl;
const { archivePath, revision, archiveFilename } = p;
return `${common}/${archivePath}/${revision}/${archiveFilename}`;
if (isChromeForTestingPackage(p)) {
const { chromeForTesting } = BaseUrl;
const { archivePath, version, archiveFilename } = p;
// returned string matches download value found at the following endpoint;
// https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
return `${chromeForTesting}/${version}/${archivePath}/${archiveFilename}`;
}
return BaseUrl.custom + '/' + p.archiveFilename; // revision is not used for URL if package is a custom build
}

View file

@ -86,14 +86,14 @@ describe('ensureDownloaded', () => {
expect(fetch).not.toHaveBeenCalled();
await expect(readdir(path.resolve(`${paths.archivesPath}/x64`))).resolves.toEqual(
expect.arrayContaining([
'chrome-mac.zip',
'chrome-win.zip',
'chrome-headless-shell-mac-x64.zip',
'chrome-headless-shell-win64.zip',
expect.stringMatching(/^chromium-[0-9a-f]{7}-locales-linux_x64\.zip$/),
])
);
await expect(readdir(path.resolve(`${paths.archivesPath}/arm64`))).resolves.toEqual(
expect.arrayContaining([
'chrome-mac.zip',
'chrome-headless-shell-mac-arm64.zip',
expect.stringMatching(/^chromium-[0-9a-f]{7}-locales-linux_arm64\.zip$/),
])
);