-
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
[Ingest Manager] Allow prerelease in package version #74452
Changes from 2 commits
22c86c8
d7aa024
c1f6919
0086f08
a108028
2385cc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import semver from 'semver'; | ||
import { Response } from 'node-fetch'; | ||
import { URL } from 'url'; | ||
import { | ||
|
@@ -35,6 +36,26 @@ export interface CategoriesParams { | |
experimental?: boolean; | ||
} | ||
|
||
/** | ||
* Extract the package name and package version from a string. | ||
* | ||
* @param pkgkey a string containing the package name delimited by the package version | ||
*/ | ||
export function splitPkgKey(pkgkey: string): { pkgName: string; pkgVersion: string } { | ||
// this will return an empty string if `indexOf` returns -1 | ||
const pkgName = pkgkey.substr(0, pkgkey.indexOf('-')); | ||
if (pkgName === '') { | ||
throw new Error('Package key parsing failed: package name was empty'); | ||
} | ||
|
||
// this will return the entire string if `indexOf` return -1 | ||
const pkgVersion = pkgkey.substr(pkgkey.indexOf('-') + 1); | ||
if (!semver.valid(pkgVersion)) { | ||
throw new Error('Package key parsing failed: package version was not a valid semver'); | ||
} | ||
return { pkgName, pkgVersion }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it should accept an empty name or version. I also think we should ensure the version is valid semver https://github.com/npm/node-semver#usage There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the comment @jfsiii, how about if I check if the For the |
||
} | ||
|
||
export const pkgToPkgKey = ({ name, version }: { name: string; version: string }) => | ||
`${name}-${version}`; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; | ||
import { warnAndSkipTest } from '../../helpers'; | ||
import { deletePackage } from './install_overrides'; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
const dockerServers = getService('dockerServers'); | ||
const log = getService('log'); | ||
|
||
const pkgkey = 'prerelease-0.1.0-dev.0+abc'; | ||
const server = dockerServers.get('registry'); | ||
|
||
describe('installs package that has a prerelease version', async () => { | ||
after(async () => { | ||
if (server.enabled) { | ||
// remove the package just in case it being installed will affect other tests | ||
await deletePackage(supertest, pkgkey); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to call the delete API here rather than coupling the tests to one another, but it's not a blocker There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, I'll switch it back 👍 |
||
} | ||
}); | ||
|
||
it('should install the package correctly', async function () { | ||
if (server.enabled) { | ||
await supertest | ||
.post(`/api/ingest_manager/epm/packages/${pkgkey}`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.expect(200); | ||
} else { | ||
warnAndSkipTest(this, log); | ||
} | ||
}); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- name: data_stream.type | ||
type: constant_keyword | ||
description: > | ||
Data stream type. | ||
- name: data_stream.dataset | ||
type: constant_keyword | ||
description: > | ||
Data stream dataset. | ||
- name: data_stream.namespace | ||
type: constant_keyword | ||
description: > | ||
Data stream namespace. | ||
- name: '@timestamp' | ||
type: date | ||
description: > | ||
Event timestamp. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
title: Test Dataset | ||
|
||
type: logs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Test package | ||
|
||
For testing a prerelease package |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
format_version: 1.0.0 | ||
name: prerelease | ||
title: Prerelease package | ||
description: This is a test package for testing that parsing a prerelease version works | ||
version: 0.1.0-dev.0+abc | ||
categories: ['security'] | ||
release: beta | ||
type: integration | ||
license: basic | ||
|
||
requirement: | ||
elasticsearch: | ||
versions: '>7.7.0' | ||
kibana: | ||
versions: '>7.7.0' | ||
|
||
icons: | ||
- src: '/img/logo_prerelease_64_color.svg' | ||
size: '16x16' | ||
type: 'image/svg+xml' |
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.
@jfsiii @skh @neptunian @nchaulet this is so we can have a valid semver as the package directory name with a dash in it. Should this only cover the packages directory? Or would it be useful if it was higher up like:
'x-pack/test/ingest_manager_api_integration/apis/fixtures/**/*
?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.
let's start here and lift it up later if we need to