Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
Tyler Smalley committed Jan 20, 2021
1 parent c272d35 commit cbc8164
Show file tree
Hide file tree
Showing 26 changed files with 103 additions and 80 deletions.
1 change: 0 additions & 1 deletion .ci/packer_cache_for_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ source src/dev/ci_setup/setup.sh;

# download es snapshots
node scripts/es snapshot --download-only;
node scripts/es snapshot --license=oss --download-only;

# download reporting browsers
(cd "x-pack" && node ../node_modules/.bin/gulp downloadChromium);
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-es/src/artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function fetchSnapshotManifest(url, log) {

async function getArtifactSpecForSnapshot(urlVersion, license, log) {
const desiredVersion = urlVersion.replace('-SNAPSHOT', '');
const desiredLicense = license === 'oss' ? 'oss' : 'default';
const desiredLicense = 'basic';

const customManifestUrl = process.env.ES_SNAPSHOT_MANIFEST;
const primaryManifestUrl = `${DAILY_SNAPSHOTS_BASE_URL}/${desiredVersion}/manifest-latest${
Expand Down Expand Up @@ -144,14 +144,14 @@ async function getArtifactSpecForSnapshot(urlVersion, license, log) {
exports.Artifact = class Artifact {
/**
* Fetch an Artifact from the Artifact API for a license level and version
* @param {('oss'|'basic'|'trial')} license
* @param {('basic'|'trial')} license
* @param {string} version
* @param {ToolingLog} log
*/
static async getSnapshot(license, version, log) {
const urlVersion = `${encodeURIComponent(version)}-SNAPSHOT`;

const customSnapshotArtifactSpec = resolveCustomSnapshotUrl(urlVersion, license);
const customSnapshotArtifactSpec = resolveCustomSnapshotUrl(urlVersion);
if (customSnapshotArtifactSpec) {
return new Artifact(customSnapshotArtifactSpec, log);
}
Expand Down
51 changes: 24 additions & 27 deletions packages/kbn-es/src/cli_commands/build_snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,32 @@ exports.run = async (defaults = {}) => {
del.sync(outputDir);
Fs.mkdirSync(outputDir, { recursive: true });

for (const license of ['oss', 'trial']) {
for (const platform of ['darwin', 'win32', 'linux']) {
log.info('Building', platform, license === 'trial' ? 'default' : 'oss', 'snapshot');
log.indent(4);
for (const platform of ['darwin', 'win32', 'linux']) {
log.info('Building', platform, 'snapshot');
log.indent(4);

const snapshotPath = await buildSnapshot({
license,
sourcePath: options.sourcePath,
log,
platform,
});
const snapshotPath = await buildSnapshot({
sourcePath: options.sourcePath,
log,
platform,
});

const filename = basename(snapshotPath);
const outputPath = resolve(outputDir, filename);
const hash = createHash('sha512');
await pipelineAsync(
Fs.createReadStream(snapshotPath),
new Transform({
transform(chunk, _, cb) {
hash.update(chunk);
cb(undefined, chunk);
},
}),
Fs.createWriteStream(outputPath)
);
const filename = basename(snapshotPath);
const outputPath = resolve(outputDir, filename);
const hash = createHash('sha512');
await pipelineAsync(
Fs.createReadStream(snapshotPath),
new Transform({
transform(chunk, _, cb) {
hash.update(chunk);
cb(undefined, chunk);
},
}),
Fs.createWriteStream(outputPath)
);

Fs.writeFileSync(`${outputPath}.sha512`, `${hash.digest('hex')} ${filename}`);
log.success('snapshot and shasum written to', outputPath);
log.indent(-4);
}
Fs.writeFileSync(`${outputPath}.sha512`, `${hash.digest('hex')} ${filename}`);
log.success('snapshot and shasum written to', outputPath);
log.indent(-4);
}
};
2 changes: 1 addition & 1 deletion packages/kbn-es/src/cli_commands/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports.help = (defaults = {}) => {
return dedent`
Options:
--license Run with a 'oss', 'basic', or 'trial' license [default: ${license}]
--license Run with a 'basic', or 'trial' license [default: ${license}]
--version Version of ES to download [default: ${defaults.version}]
--base-path Path containing cache/installations [default: ${basePath}]
--install-path Installation path, defaults to 'source' within base-path
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es/src/cli_commands/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports.help = (defaults = {}) => {
return dedent`
Options:
--license Run with a 'oss', 'basic', or 'trial' license [default: ${license}]
--license Run with a 'basic', or 'trial' license [default: ${license}]
--source-path Path to ES source [default: ${defaults['source-path']}]
--base-path Path containing cache/installations [default: ${basePath}]
--install-path Installation path, defaults to 'source' within base-path
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-es/src/custom_snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getCustomSnapshotUrl() {
}
}

function resolveCustomSnapshotUrl(urlVersion, license) {
function resolveCustomSnapshotUrl(urlVersion) {
const customSnapshotUrl = getCustomSnapshotUrl();

if (!customSnapshotUrl) {
Expand All @@ -48,7 +48,7 @@ function resolveCustomSnapshotUrl(urlVersion, license) {

const ext = process.platform === 'win32' ? 'zip' : 'tar.gz';
const os = process.platform === 'win32' ? 'windows' : process.platform;
const name = license === 'oss' ? 'elasticsearch-oss' : 'elasticsearch';
const name = 'elasticsearch';
const overrideUrl = customSnapshotUrl
.replace('{name}', name)
.replace('{ext}', ext)
Expand Down
25 changes: 14 additions & 11 deletions packages/kbn-es/src/install/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const { parseSettings, SettingsFilter } = require('../settings');
*
* @param {String} archive - path to tar
* @param {Object} options
* @property {('oss'|'basic'|'trial')} options.license
* @property {('basic'|'trial')} options.license
* @property {String} options.basePath
* @property {String} options.installPath
* @property {ToolingLog} options.log
Expand All @@ -50,6 +50,11 @@ exports.installArchive = async function installArchive(archive, options = {}) {
} = options;

let dest = archive;

if (license === 'oss') {
throw new Error('Elasticsearch no longer produces an oss build');
}

if (['http:', 'https:'].includes(url.parse(archive).protocol)) {
const artifact = await Artifact.getArchive(archive, log);
dest = path.resolve(basePath, 'cache', artifact.getFilename());
Expand All @@ -69,17 +74,15 @@ exports.installArchive = async function installArchive(archive, options = {}) {
fs.mkdirSync(tmpdir, { recursive: true });
log.info('created %s', chalk.bold(tmpdir));

if (license !== 'oss') {
// starting in 6.3, security is disabled by default. Since we bootstrap
// the keystore, we can enable security ourselves.
await appendToConfig(installPath, 'xpack.security.enabled', 'true');
// starting in 6.3, security is disabled by default. Since we bootstrap
// the keystore, we can enable security ourselves.
await appendToConfig(installPath, 'xpack.security.enabled', 'true');

await appendToConfig(installPath, 'xpack.license.self_generated.type', license);
await configureKeystore(installPath, log, bundledJDK, [
['bootstrap.password', password],
...parseSettings(esArgs, { filter: SettingsFilter.SecureOnly }),
]);
}
await appendToConfig(installPath, 'xpack.license.self_generated.type', license);
await configureKeystore(installPath, log, bundledJDK, [
['bootstrap.password', password],
...parseSettings(esArgs, { filter: SettingsFilter.SecureOnly }),
]);

return { installPath };
};
Expand Down
8 changes: 6 additions & 2 deletions packages/kbn-es/src/install/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { Artifact } = require('../artifact');
* Download an ES snapshot
*
* @param {Object} options
* @property {('oss'|'basic'|'trial')} options.license
* @property {('basic'|'trial')} options.license
* @property {String} options.version
* @property {String} options.basePath
* @property {String} options.installPath
Expand All @@ -45,6 +45,10 @@ exports.downloadSnapshot = async function installSnapshot({
log.info('install path: %s', chalk.bold(installPath));
log.info('license: %s', chalk.bold(license));

if (license === 'oss') {
throw new Error('Elasticsearch no longer produces an oss build');
}

const artifact = await Artifact.getSnapshot(license, version, log);
const dest = path.resolve(basePath, 'cache', artifact.getFilename());
await artifact.download(dest);
Expand All @@ -58,7 +62,7 @@ exports.downloadSnapshot = async function installSnapshot({
* Installs ES from snapshot
*
* @param {Object} options
* @property {('oss'|'basic'|'trial')} options.license
* @property {('basic'|'trial')} options.license
* @property {String} options.password
* @property {String} options.version
* @property {String} options.basePath
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-es/src/install/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const { BASE_PATH } = require('../paths');
* Installs ES from source
*
* @param {Object} options
* @property {('oss'|'basic'|'trial')} options.license
* @property {('basic'|'trial')} options.license
* @property {String} options.password
* @property {String} options.sourcePath
* @property {String} options.basePath
Expand Down Expand Up @@ -87,7 +87,7 @@ async function sourceInfo(cwd, license, log = defaultLog) {

const git = simpleGit(cwd);

const { task, ext } = archiveForPlatform(os.platform(), license);
const { task, ext } = archiveForPlatform(os.platform());
const status = await git.status();
const branch = status.current;
const sha = (await git.revparse(['HEAD'])).trim();
Expand Down
16 changes: 7 additions & 9 deletions packages/kbn-es/src/utils/build_snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const onceEvent = (emitter, event) => new Promise((resolve) => emitter.once(even
* Creates archive from source
*
* @param {Object} options
* @property {('oss'|'basic'|'trial')} options.license
* @property {('basic'|'trial')} options.license
* @property {String} options.sourcePath
* @property {ToolingLog} options.log
* @returns {Object} containing archive and optional plugins
Expand All @@ -44,8 +44,8 @@ const onceEvent = (emitter, event) => new Promise((resolve) => emitter.once(even
* :distribution:archives:oss-linux-tar:assemble
* :distribution:archives:oss-windows-zip:assemble
*/
exports.buildSnapshot = async ({ license, sourcePath, log, platform = os.platform() }) => {
const { task, ext } = exports.archiveForPlatform(platform, license);
exports.buildSnapshot = async ({ sourcePath, log, platform = os.platform() }) => {
const { task, ext } = exports.archiveForPlatform(platform);
const buildArgs = [`:distribution:archives:${task}:assemble`];

log.info('%s %s', GRADLE_BIN, buildArgs.join(' '));
Expand Down Expand Up @@ -87,16 +87,14 @@ exports.buildSnapshot = async ({ license, sourcePath, log, platform = os.platfor
return esArchivePath;
};

exports.archiveForPlatform = (platform, license) => {
const taskPrefix = license === 'oss' ? 'oss-' : '';

exports.archiveForPlatform = (platform) => {
switch (platform) {
case 'darwin':
return { format: 'tar', ext: 'tar.gz', task: `${taskPrefix}darwin-tar`, platform: 'darwin' };
return { format: 'tar', ext: 'tar.gz', task: 'darwin-tar', platform: 'darwin' };
case 'win32':
return { format: 'zip', ext: 'zip', task: `${taskPrefix}windows-zip`, platform: 'windows' };
return { format: 'zip', ext: 'zip', task: 'windows-zip', platform: 'windows' };
case 'linux':
return { format: 'tar', ext: 'tar.gz', task: `${taskPrefix}linux-tar`, platform: 'linux' };
return { format: 'tar', ext: 'tar.gz', task: 'linux-tar', platform: 'linux' };
default:
throw new Error(`unknown platform: ${platform}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const schema = Joi.object()

esTestCluster: Joi.object()
.keys({
license: Joi.string().default('oss'),
license: Joi.string().default('basic'),
from: Joi.string().default('snapshot'),
serverArgs: Joi.array(),
serverEnvVars: Joi.object(),
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test/src/legacy_es/legacy_es_test_cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function createLegacyEsTestCluster(options = {}) {
const {
port = esTestConfig.getPort(),
password = 'changeme',
license = 'oss',
license = 'basic',
log,
basePath = resolve(KIBANA_ROOT, '.es'),
esFrom = esTestConfig.getBuildFrom(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('migration v2', () => {
adjustTimeout: (t: number) => jest.setTimeout(t),
settings: {
es: {
license: oss ? 'oss' : 'trial',
license: oss ? 'basic' : 'trial',
dataArchive,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe.skip('migration from 7.7.2-xpack with 100k objects', () => {
adjustTimeout: (t: number) => jest.setTimeout(600000),
settings: {
es: {
license: oss ? 'oss' : 'trial',
license: oss ? 'basic' : 'trial',
dataArchive,
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/core/test_helpers/kbn_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export function createTestServers({
adjustTimeout: (timeout: number) => void;
settings?: {
es?: {
license: 'oss' | 'basic' | 'gold' | 'trial';
license: 'basic' | 'gold' | 'trial';
[key: string]: any;
};
kbn?: {
Expand All @@ -218,7 +218,7 @@ export function createTestServers({
if (!adjustTimeout) {
throw new Error('adjustTimeout is required in order to avoid flaky tests');
}
const license = get(settings, 'es.license', 'oss');
const license = get(settings, 'es.license', 'basic');
const usersToBeAdded = get(settings, 'users', []);
if (usersToBeAdded.length > 0) {
if (license !== 'trial') {
Expand Down
2 changes: 0 additions & 2 deletions src/dev/ci_setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ yarn kbn bootstrap
###
echo " -- downloading es snapshot"
node scripts/es snapshot --download-only;
node scripts/es snapshot --license=oss --download-only;


###
### verify no git modifications
Expand Down
5 changes: 4 additions & 1 deletion test/api_integration/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default async function ({ readConfigFile }) {
junit: {
reportName: 'API Integration Tests',
},
esTestCluster: commonConfig.get('esTestCluster'),
esTestCluster: {
...functionalConfig.get('esTestCluster'),
serverArgs: ['xpack.security.enabled=false'],
},
kbnTestServer: {
...functionalConfig.get('kbnTestServer'),
serverArgs: [
Expand Down
4 changes: 1 addition & 3 deletions test/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export default function () {
servers,

esTestCluster: {
license: 'oss',
from: 'snapshot',
serverArgs: [],
serverArgs: ['xpack.security.enabled=false'],
},

kbnTestServer: {
Expand Down
5 changes: 4 additions & 1 deletion test/examples/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export default async function ({ readConfigFile }) {
},
pageObjects: functionalConfig.get('pageObjects'),
servers: functionalConfig.get('servers'),
esTestCluster: functionalConfig.get('esTestCluster'),
esTestCluster: {
...functionalConfig.get('esTestCluster'),
serverArgs: ['xpack.security.enabled=false'],
},
apps: functionalConfig.get('apps'),
esArchiver: {
directory: path.resolve(__dirname, '../es_archives'),
Expand Down
6 changes: 4 additions & 2 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ export default async function ({ readConfigFile }) {

servers: commonConfig.get('servers'),

esTestCluster: commonConfig.get('esTestCluster'),

esTestCluster: {
...commonConfig.get('esTestCluster'),
serverArgs: ['xpack.security.enabled=false'],
},
kbnTestServer: {
...commonConfig.get('kbnTestServer'),
serverArgs: [
Expand Down
5 changes: 4 additions & 1 deletion test/plugin_functional/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
},
pageObjects: functionalConfig.get('pageObjects'),
servers: functionalConfig.get('servers'),
esTestCluster: functionalConfig.get('esTestCluster'),
esTestCluster: {
...functionalConfig.get('esTestCluster'),
serverArgs: ['xpack.security.enabled=false'],
},
apps: functionalConfig.get('apps'),
esArchiver: {
directory: path.resolve(__dirname, '../es_archives'),
Expand Down
5 changes: 4 additions & 1 deletion test/server_integration/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default async function ({ readConfigFile }) {
junit: {
reportName: 'Integration Tests',
},
esTestCluster: commonConfig.get('esTestCluster'),
esTestCluster: {
...functionalConfig.get('esTestCluster'),
serverArgs: ['xpack.security.enabled=false'],
},
kbnTestServer: {
...functionalConfig.get('kbnTestServer'),
serverArgs: [
Expand Down
Loading

0 comments on commit cbc8164

Please sign in to comment.