-
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.
Browse files
Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 12e63dd)
- Loading branch information
Spencer
authored
Jan 20, 2022
1 parent
f0c868c
commit 581cfb4
Showing
22 changed files
with
349 additions
and
75 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
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
55 changes: 55 additions & 0 deletions
55
packages/kbn-test/src/functional_test_runner/lib/es_version.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,55 @@ | ||
/* | ||
* 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 semver from 'semver'; | ||
import { kibanaPackageJson } from '@kbn/utils'; | ||
|
||
export class EsVersion { | ||
static getDefault() { | ||
// example: https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.0.0/manifest-latest-verified.json | ||
const manifestUrl = process.env.ES_SNAPSHOT_MANIFEST; | ||
if (manifestUrl) { | ||
const match = manifestUrl.match(/\d+\.\d+\.\d+/); | ||
if (!match) { | ||
throw new Error('unable to extract es version from ES_SNAPSHOT_MANIFEST_URL'); | ||
} | ||
return new EsVersion(match[0]); | ||
} | ||
|
||
return new EsVersion(process.env.TEST_ES_BRANCH || kibanaPackageJson.version); | ||
} | ||
|
||
public readonly parsed: semver.SemVer; | ||
|
||
constructor(version: string) { | ||
const parsed = semver.coerce(version); | ||
if (!parsed) { | ||
throw new Error(`unable to parse es version [${version}]`); | ||
} | ||
this.parsed = parsed; | ||
} | ||
|
||
toString() { | ||
return this.parsed.version; | ||
} | ||
|
||
/** | ||
* Determine if the ES version matches a semver range, like >=7 or ^8.1.0 | ||
*/ | ||
matchRange(range: string) { | ||
return semver.satisfies(this.parsed, range); | ||
} | ||
|
||
/** | ||
* Determine if the ES version matches a specific version, ignores things like -SNAPSHOT | ||
*/ | ||
eql(version: string) { | ||
const other = semver.coerce(version); | ||
return other && semver.compareLoose(this.parsed, other) === 0; | ||
} | ||
} |
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.