Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function makeFtrConfigProvider(
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
preferCached: true,
},
}),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const dockerServerSchema = () =>
image: requiredWhenEnabled(Joi.string()),
port: requiredWhenEnabled(Joi.number()),
portInContainer: requiredWhenEnabled(Joi.number()),
preferCached: Joi.boolean().optional(),
waitForLogLine: Joi.alternatives(Joi.object().instance(RegExp), Joi.string()).optional(),
waitForLogLineTimeoutMs: Joi.number().integer().optional(),
waitFor: Joi.func().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const defaultConfig: ScoutServerConfig = {
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
preferCached: true,
},
}),
esTestCluster: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export const defaultConfig: ScoutServerConfig = {
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
}),
esTestCluster: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const dockerServerSchema = () =>
image: requiredWhenEnabled(Joi.string()),
port: requiredWhenEnabled(Joi.number()),
portInContainer: requiredWhenEnabled(Joi.number()),
preferCached: Joi.boolean().optional(),
waitForLogLine: Joi.alternatives(Joi.object().instance(RegExp), Joi.string()).optional(),
waitForLogLineTimeoutMs: Joi.number().integer().optional(),
waitFor: Joi.func().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface DockerServerSpec {
portInContainer: number;
port: number;
image: string;
preferCached?: boolean;
waitForLogLine?: RegExp | string;
waitForLogLineTimeoutMs?: number;
/** a function that should return an observable that will allow the tests to execute as soon as it emits anything */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ export class DockerServersService {
const { image, name, waitFor, waitForLogLine, waitForLogLineTimeoutMs } = server;

// pull image from registry
log.info(`[docker:${name}] pulling docker image "${image}"`);
await execa('docker', ['pull', image]);
if (server.preferCached && (await this.isImageAvailableLocally(image))) {
log.info(`[docker:${name}] skipping pull of docker image "${image}"`);
} else {
log.info(`[docker:${name}] pulling docker image "${image}"`);
await execa('docker', ['pull', image]);
}

// run the image that we just pulled
const containerId = await this.dockerRun(server);
Expand Down Expand Up @@ -208,6 +212,15 @@ export class DockerServersService {
).toPromise();
}

private async isImageAvailableLocally(imageUrl: string) {
try {
const { stdout } = await execa('docker', ['images', '-q', imageUrl]);
return stdout.trim().length > 0;
} catch {
return false;
}
}

private async startServers() {
if (this.disabled) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { isActualError } from '@kbn/test/src/functional_test_runner/lib/docker_s
const BEFORE_SETUP_TIMEOUT = 30 * 60 * 1000; // 30 minutes;

const DOCKER_START_TIMEOUT = 6 * 60 * 1000; // 6 minutes
// This image comes from the latest successful build of https://buildkite.com/elastic/kibana-package-registry-promote
// This image comes from the latest successful build of https://buildkite.com/elastic/kibana-package-registry-verify-and-promote
// which is promoted after acceptance tests succeed against docker.elastic.co/package-registry/distribution:lite
const DOCKER_IMAGE =
process.env.FLEET_PACKAGE_REGISTRY_DOCKER_IMAGE ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export function createServerlessFeatureFlagTestConfig<T extends DeploymentAgnost
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
}),
esTestCluster: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export function createStatefulFeatureFlagTestConfig<T extends DeploymentAgnostic
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
}),
testFiles: options.testFiles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export function createServerlessTestConfig<T extends DeploymentAgnosticCommonSer
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
}),
esTestCluster: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export function createStatefulTestConfig<T extends DeploymentAgnosticCommonServi
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
}),
testFiles: options.testFiles,
Expand Down
3 changes: 2 additions & 1 deletion x-pack/platform/test/fleet_api_integration/config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export default async function ({ readConfigFile, log }: FtrConfigProviderContext
port: registryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
})
: undefined;
Expand Down
3 changes: 2 additions & 1 deletion x-pack/platform/test/serverless/shared/config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export default async () => {
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
}),
browser: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ export function createTestConfig(
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
}),
testFiles: [require.resolve('../tests')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function SecuritySolutionEndpointRegistryHelpers() {
args,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function SecuritySolutionEndpointRegistryHelpers() {
args,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 6 * 1000, // 6 minutes,
preferCached: true,
},
});
},
Expand Down