Skip to content

Commit

Permalink
Merge branch 'master' into reporting/csv-scroll-id-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jun 30, 2021
2 parents 7a35363 + 1ff2407 commit 1829558
Show file tree
Hide file tree
Showing 54 changed files with 852 additions and 613 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pip3 install --user ansible

```
# Build distributions
node scripts/build --all-platforms --debug --no-oss
node scripts/build --all-platforms --debug

cd test/package

Expand Down
4 changes: 2 additions & 2 deletions src/dev/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ node scripts/build --help
# build a release version
node scripts/build --release

# reuse already downloaded node executables, turn on debug logging, and only build the default distributable
node scripts/build --skip-node-download --debug --no-oss
# reuse already downloaded node executables, turn on debug logging
node scripts/build --skip-node-download --debug
```

# Fixing out of memory issues
Expand Down
14 changes: 0 additions & 14 deletions src/dev/build/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ it('build default and oss dist for current platform, without packages, by defaul
expect(readCliArgs(['node', 'scripts/build'])).toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": false,
Expand All @@ -53,8 +51,6 @@ it('builds packages if --all-platforms is passed', () => {
expect(readCliArgs(['node', 'scripts/build', '--all-platforms'])).toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": true,
Expand All @@ -80,8 +76,6 @@ it('limits packages if --rpm passed with --all-platforms', () => {
expect(readCliArgs(['node', 'scripts/build', '--all-platforms', '--rpm'])).toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": false,
Expand All @@ -107,8 +101,6 @@ it('limits packages if --deb passed with --all-platforms', () => {
expect(readCliArgs(['node', 'scripts/build', '--all-platforms', '--deb'])).toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": false,
Expand All @@ -135,8 +127,6 @@ it('limits packages if --docker passed with --all-platforms', () => {
.toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": true,
Expand Down Expand Up @@ -170,8 +160,6 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
).toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": true,
Expand All @@ -198,8 +186,6 @@ it('limits packages if --all-platforms passed with --skip-docker-centos', () =>
.toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": false,
Expand Down
5 changes: 0 additions & 5 deletions src/dev/build/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export function readCliArgs(argv: string[]) {
const unknownFlags: string[] = [];
const flags = getopts(argv, {
boolean: [
'oss',
'no-oss',
'skip-archives',
'skip-initialize',
'skip-generic-folders',
Expand Down Expand Up @@ -48,7 +46,6 @@ export function readCliArgs(argv: string[]) {
rpm: null,
deb: null,
'docker-images': null,
oss: null,
'version-qualifier': '',
},
unknown: (flag) => {
Expand Down Expand Up @@ -94,8 +91,6 @@ export function readCliArgs(argv: string[]) {
const buildOptions: BuildOptions = {
isRelease: Boolean(flags.release),
versionQualifier: flags['version-qualifier'],
buildOssDist: flags.oss !== false,
buildDefaultDist: !flags.oss,
initialize: !Boolean(flags['skip-initialize']),
downloadFreshNode: !Boolean(flags['skip-node-download']),
createGenericFolders: !Boolean(flags['skip-generic-folders']),
Expand Down
4 changes: 0 additions & 4 deletions src/dev/build/build_distributables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import * as Tasks from './tasks';

export interface BuildOptions {
isRelease: boolean;
buildOssDist: boolean;
buildDefaultDist: boolean;
downloadFreshNode: boolean;
initialize: boolean;
createGenericFolders: boolean;
Expand All @@ -37,8 +35,6 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
const run = createRunner({
config,
log,
buildDefaultDist: options.buildDefaultDist,
buildOssDist: options.buildOssDist,
});

/**
Expand Down
2 changes: 0 additions & 2 deletions src/dev/build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ if (showHelp) {
build the Kibana distributable
options:
--oss {dim Only produce the OSS distributable of Kibana}
--no-oss {dim Only produce the default distributable of Kibana}
--skip-archives {dim Don't produce tar/zip archives}
--skip-os-packages {dim Don't produce rpm/deb/docker packages}
--all-platforms {dim Produce archives for all platforms, not just this one}
Expand Down
39 changes: 11 additions & 28 deletions src/dev/build/lib/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,24 @@ beforeEach(() => {
jest.clearAllMocks();
});

const ossBuild = new Build(config, true);
const defaultBuild = new Build(config, false);

describe('#isOss()', () => {
it('returns true for oss', () => {
expect(ossBuild.isOss()).toBe(true);
});

it('returns false for default build', () => {
expect(defaultBuild.isOss()).toBe(false);
});
});
const defaultBuild = new Build(config);

describe('#getName()', () => {
it('returns kibana for default build', () => {
expect(defaultBuild.getName()).toBe('kibana');
});

it('returns kibana-oss for oss', () => {
expect(ossBuild.getName()).toBe('kibana-oss');
});
});

describe('#getLogTag()', () => {
it('returns string with build name in it', () => {
expect(defaultBuild.getLogTag()).toContain(defaultBuild.getName());
expect(ossBuild.getLogTag()).toContain(ossBuild.getName());
});
});

describe('#resolvePath()', () => {
it('uses passed config to resolve a path relative to the repo', () => {
expect(ossBuild.resolvePath('bar')).toMatchInlineSnapshot(
`<absolute path>/build/kibana-oss/bar`
expect(defaultBuild.resolvePath('bar')).toMatchInlineSnapshot(
`<absolute path>/build/kibana/bar`
);
});

Expand All @@ -89,28 +73,27 @@ describe('#resolvePath()', () => {

describe('#resolvePathForPlatform()', () => {
it('uses config.resolveFromRepo(), config.getBuildVersion(), and platform.getBuildName() to create path', () => {
expect(ossBuild.resolvePathForPlatform(linuxPlatform, 'foo', 'bar')).toMatchInlineSnapshot(
`<absolute path>/build/oss/kibana-8.0.0-linux-x86_64/foo/bar`
expect(defaultBuild.resolvePathForPlatform(linuxPlatform, 'foo', 'bar')).toMatchInlineSnapshot(
`<absolute path>/build/default/kibana-8.0.0-linux-x86_64/foo/bar`
);
});
});

describe('#getPlatformArchivePath()', () => {
it('creates correct path for different platforms', () => {
expect(ossBuild.getPlatformArchivePath(linuxPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-oss-8.0.0-linux-x86_64.tar.gz`
expect(defaultBuild.getPlatformArchivePath(linuxPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-8.0.0-linux-x86_64.tar.gz`
);
expect(ossBuild.getPlatformArchivePath(linuxArmPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-oss-8.0.0-linux-aarch64.tar.gz`
expect(defaultBuild.getPlatformArchivePath(linuxArmPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-8.0.0-linux-aarch64.tar.gz`
);
expect(ossBuild.getPlatformArchivePath(windowsPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-oss-8.0.0-windows-x86_64.zip`
expect(defaultBuild.getPlatformArchivePath(windowsPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-8.0.0-windows-x86_64.zip`
);
});

describe('#getRootDirectory()', () => {
it('creates correct root directory name', () => {
expect(ossBuild.getRootDirectory()).toMatchInlineSnapshot(`"kibana-oss-8.0.0"`);
expect(defaultBuild.getRootDirectory()).toMatchInlineSnapshot(`"kibana-8.0.0"`);
});
});
Expand Down
12 changes: 4 additions & 8 deletions src/dev/build/lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ import { Config } from './config';
import { Platform } from './platform';

export class Build {
private name = this.oss ? 'kibana-oss' : 'kibana';
private logTag = this.oss ? chalk`{magenta [kibana-oss]}` : chalk`{cyan [ kibana ]}`;
private name = 'kibana';
private logTag = chalk`{cyan [ kibana ]}`;

constructor(private config: Config, private oss: boolean) {}

isOss() {
return !!this.oss;
}
constructor(private config: Config) {}

resolvePath(...args: string[]) {
return this.config.resolveFromRepo('build', this.name, ...args);
Expand All @@ -28,7 +24,7 @@ export class Build {
resolvePathForPlatform(platform: Platform, ...args: string[]) {
return this.config.resolveFromRepo(
'build',
this.oss ? 'oss' : 'default',
'default',
`kibana-${this.config.getBuildVersion()}-${platform.getBuildName()}`,
...args
);
Expand Down
109 changes: 6 additions & 103 deletions src/dev/build/lib/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ beforeEach(() => {
jest.clearAllMocks();
});

const setup = async (opts: { buildDefaultDist: boolean; buildOssDist: boolean }) => {
const setup = async () => {
const config = await Config.create({
isRelease: true,
targetAllPlatforms: true,
Expand All @@ -55,55 +55,14 @@ const setup = async (opts: { buildDefaultDist: boolean; buildOssDist: boolean })
const run = createRunner({
config,
log,
...opts,
});

return { config, run };
};

describe('buildOssDist = true, buildDefaultDist = true', () => {
describe('default dist', () => {
it('runs global task once, passing config and log', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: true,
});

const mock = jest.fn();

await run({
global: true,
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenLastCalledWith(config, log, [expect.any(Build), expect.any(Build)]);
});

it('calls local tasks twice, passing each build', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: true,
});

const mock = jest.fn();

await run({
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(2);
expect(mock).toHaveBeenCalledWith(config, log, expect.any(Build));
});
});

describe('just default dist', () => {
it('runs global task once, passing config and log', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});
const { config, run } = await setup();

const mock = jest.fn();

Expand All @@ -118,52 +77,7 @@ describe('just default dist', () => {
});

it('calls local tasks once, passing the default build', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});

const mock = jest.fn();

await run({
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenCalledWith(config, log, expect.any(Build));
const [args] = mock.mock.calls;
const [, , build] = args;
if (build.isOss()) {
throw new Error('expected build to be the default dist, not the oss dist');
}
});
});

describe('just oss dist', () => {
it('runs global task once, passing config and log', async () => {
const { config, run } = await setup({
buildDefaultDist: false,
buildOssDist: true,
});

const mock = jest.fn();

await run({
global: true,
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenLastCalledWith(config, log, [expect.any(Build)]);
});

it('calls local tasks once, passing the oss build', async () => {
const { config, run } = await setup({
buildDefaultDist: false,
buildOssDist: true,
});
const { config, run } = await setup();

const mock = jest.fn();

Expand All @@ -174,20 +88,12 @@ describe('just oss dist', () => {

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenCalledWith(config, log, expect.any(Build));
const [args] = mock.mock.calls;
const [, , build] = args;
if (!build.isOss()) {
throw new Error('expected build to be the oss dist, not the default dist');
}
});
});

describe('task rejection', () => {
it('rejects, logs error, and marks error logged', async () => {
const { run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});
const { run } = await setup();

const error = new Error('FOO');
expect(isErrorLogged(error)).toBe(false);
Expand All @@ -213,10 +119,7 @@ describe('task rejection', () => {
});

it('just rethrows errors that have already been logged', async () => {
const { run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});
const { run } = await setup();

const error = markErrorLogged(new Error('FOO'));
const promise = run({
Expand Down
Loading

0 comments on commit 1829558

Please sign in to comment.