-
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.
[Fleet] Make upload and registry package info consistent (#126915)
* Update docker image + set up initial validation test * Get validation test passing * Remove erroneous test load call * Address PR review + improve comments + rename validation.ts -> parse.ts * Replace packages in fleet_packages.json * Add temp debug log to debug CI failures * Use a non-colliding package in bundled package tests * (debug) Add logging output * (debug) More logging * (debug) Log bundled package dir in module * Use absolute path for bundled packages * Remove debug logs + use KIBANA_BUILD_LOCATION if it exists * Add support for developer.bundledPackageLocation config value * (debug) Try some more logs * (debug) Try some more logs * Fix test hopefully 🤞 * Fix other failing tests * Move default for bundled package dir to schema definition * Fix schema default value for bundledPackageLocation * Fix snapshot * Fix regression in bundled packages fetch Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
714f3b2
commit 88f12fd
Showing
26 changed files
with
312 additions
and
80 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -70,4 +70,5 @@ export interface PackageSpecScreenshot { | |
title: string; | ||
size?: string; | ||
type?: string; | ||
path?: string; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
.../plugins/fleet/server/integration_tests/__snapshots__/cloud_preconfiguration.test.ts.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
77 changes: 77 additions & 0 deletions
77
x-pack/plugins/fleet/server/integration_tests/validate_bundled_packages.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,77 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import path from 'path'; | ||
import fs from 'fs/promises'; | ||
|
||
import JSON5 from 'json5'; | ||
import { REPO_ROOT } from '@kbn/utils'; | ||
|
||
import * as Registry from '../services/epm/registry'; | ||
import { generatePackageInfoFromArchiveBuffer } from '../services/epm/archive'; | ||
|
||
import { createAppContextStartContractMock } from '../mocks'; | ||
import { appContextService } from '../services'; | ||
|
||
import { useDockerRegistry } from './helpers'; | ||
|
||
describe('validate bundled packages', () => { | ||
const registryUrl = useDockerRegistry(); | ||
let mockContract: ReturnType<typeof createAppContextStartContractMock>; | ||
|
||
beforeEach(() => { | ||
mockContract = createAppContextStartContractMock({ registryUrl }); | ||
appContextService.start(mockContract); | ||
}); | ||
|
||
async function getBundledPackageEntries() { | ||
const configFilePath = path.resolve(REPO_ROOT, 'fleet_packages.json'); | ||
const configFile = await fs.readFile(configFilePath, 'utf8'); | ||
const bundledPackages = JSON5.parse(configFile); | ||
|
||
return bundledPackages as Array<{ name: string; version: string }>; | ||
} | ||
|
||
async function setupPackageObjects() { | ||
const bundledPackages = await getBundledPackageEntries(); | ||
|
||
const packageObjects = await Promise.all( | ||
bundledPackages.map(async (bundledPackage) => { | ||
const registryPackage = await Registry.getRegistryPackage( | ||
bundledPackage.name, | ||
bundledPackage.version | ||
); | ||
|
||
const packageArchive = await Registry.fetchArchiveBuffer( | ||
bundledPackage.name, | ||
bundledPackage.version | ||
); | ||
|
||
return { registryPackage, packageArchive }; | ||
}) | ||
); | ||
|
||
return packageObjects; | ||
} | ||
|
||
it('generates matching package info objects for uploaded and registry packages', async () => { | ||
const packageObjects = await setupPackageObjects(); | ||
|
||
for (const packageObject of packageObjects) { | ||
const { registryPackage, packageArchive } = packageObject; | ||
|
||
const archivePackageInfo = await generatePackageInfoFromArchiveBuffer( | ||
packageArchive.archiveBuffer, | ||
'application/zip' | ||
); | ||
|
||
expect(archivePackageInfo.packageInfo.data_streams).toEqual( | ||
registryPackage.packageInfo.data_streams | ||
); | ||
} | ||
}); | ||
}); |
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.