-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fleet] Make upload and registry package info consistent #126915
Merged
kpollich
merged 28 commits into
elastic:main
from
kpollich:126695-make-upload-and-registry-package-info-consistent
Mar 10, 2022
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
cf96755
Update docker image + set up initial validation test
kpollich 625f582
Get validation test passing
kpollich 5ff6ee6
Merge branch 'main' into 126695-make-upload-and-registry-package-info…
kibanamachine c564592
Remove erroneous test load call
kpollich 586c08c
Address PR review + improve comments + rename validation.ts -> parse.ts
kpollich 6a9c1e9
Merge branch 'main' into 126695-make-upload-and-registry-package-info…
kibanamachine 62a45cc
Replace packages in fleet_packages.json
kpollich cae823e
Add temp debug log to debug CI failures
kpollich 37f60f3
Use a non-colliding package in bundled package tests
kpollich 4212c27
(debug) Add logging output
kpollich 0f779d9
(debug) More logging
kpollich 000f3a1
(debug) Log bundled package dir in module
kpollich 6fdfd1f
Use absolute path for bundled packages
kpollich 8656915
Remove debug logs + use KIBANA_BUILD_LOCATION if it exists
kpollich 29d903c
Add support for developer.bundledPackageLocation config value
kpollich a316ab1
(debug) Try some more logs
kpollich 0ba1902
(debug) Try some more logs
kpollich 14e7b87
Fix test hopefully 🤞
kpollich eadab35
Fix other failing tests
kpollich 1da1eba
Merge branch 'main' into 126695-make-upload-and-registry-package-info…
kibanamachine a1254e7
Merge branch 'main' into 126695-make-upload-and-registry-package-info…
kibanamachine dadfe20
Move default for bundled package dir to schema definition
kpollich 5d97961
Merge branch 'main' into 126695-make-upload-and-registry-package-info…
kibanamachine 9122a63
Merge branch 'main' into 126695-make-upload-and-registry-package-info…
kibanamachine bd2e6c2
Fix schema default value for bundledPackageLocation
kpollich bfffa79
Merge branch '126695-make-upload-and-registry-package-info-consistent…
kpollich f0e9da1
Fix snapshot
kpollich 29a30e4
Fix regression in bundled packages fetch
kpollich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we test more things than the
data_streams
property here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am taking a look at other properties to place under test here and there don't seem to be any good candidates.
policy_templates
andvars
were my first thoughts, but the current registry logic "fills out" variable values that we infer default for in Fleet, so these fields are unlikely to match for now. I am going to merge this PR for now, and these tests will likely change in #115032