Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into implement/ass…
Browse files Browse the repository at this point in the history
…et-size-metrics
  • Loading branch information
spalger committed Jul 9, 2020
2 parents 30118e8 + e0ab85d commit e6ce0a1
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 39 deletions.
53 changes: 30 additions & 23 deletions test/functional/services/remote/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ import { Browsers } from './browsers';

const throttleOption: string = process.env.TEST_THROTTLE_NETWORK as string;
const headlessBrowser: string = process.env.TEST_BROWSER_HEADLESS as string;
const browserBinaryPath: string = process.env.TEST_BROWSER_BINARY_PATH as string;
const remoteDebug: string = process.env.TEST_REMOTE_DEBUG as string;
const certValidation: string = process.env.NODE_TLS_REJECT_UNAUTHORIZED as string;
const SECOND = 1000;
const MINUTE = 60 * SECOND;
const NO_QUEUE_COMMANDS = ['getLog', 'getStatus', 'newSession', 'quit'];
const downloadDir = resolve(REPO_ROOT, 'target/functional-tests/downloads');
const chromiumDownloadPrefs = {
prefs: {
'download.default_directory': downloadDir,
'download.prompt_for_download': false,
},
'download.default_directory': downloadDir,
'download.prompt_for_download': false,
};

/**
Expand Down Expand Up @@ -93,8 +92,8 @@ async function attemptToCreateCommand(
const buildDriverInstance = async () => {
switch (browserType) {
case 'chrome': {
const chromeCapabilities = Capabilities.chrome();
const chromeOptions = [
const chromeOptions = new chrome.Options();
chromeOptions.addArguments(
// Disables the sandbox for all process types that are normally sandboxed.
'no-sandbox',
// Launches URL in new browser window.
Expand All @@ -104,47 +103,55 @@ async function attemptToCreateCommand(
// Use fake device for Media Stream to replace actual camera and microphone.
'use-fake-device-for-media-stream',
// Bypass the media stream infobar by selecting the default device for media streams (e.g. WebRTC). Works with --use-fake-device-for-media-stream.
'use-fake-ui-for-media-stream',
];
'use-fake-ui-for-media-stream'
);

if (process.platform === 'linux') {
// The /dev/shm partition is too small in certain VM environments, causing
// Chrome to fail or crash. Use this flag to work-around this issue
// (a temporary directory will always be used to create anonymous shared memory files).
chromeOptions.push('disable-dev-shm-usage');
chromeOptions.addArguments('disable-dev-shm-usage');
}

if (headlessBrowser === '1') {
// Use --disable-gpu to avoid an error from a missing Mesa library, as per
// See: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
chromeOptions.push('headless', 'disable-gpu');
chromeOptions.headless();
chromeOptions.addArguments('disable-gpu');
}

if (certValidation === '0') {
chromeOptions.push('ignore-certificate-errors');
chromeOptions.addArguments('ignore-certificate-errors');
}

if (remoteDebug === '1') {
// Visit chrome://inspect in chrome to remotely view/debug
chromeOptions.push('headless', 'disable-gpu', 'remote-debugging-port=9222');
chromeOptions.headless();
chromeOptions.addArguments('disable-gpu', 'remote-debugging-port=9222');
}
chromeCapabilities.set('goog:chromeOptions', {
w3c: true,
args: chromeOptions,
...chromiumDownloadPrefs,
});
chromeCapabilities.set('unexpectedAlertBehaviour', 'accept');
chromeCapabilities.set('goog:loggingPrefs', { browser: 'ALL' });
chromeCapabilities.setAcceptInsecureCerts(config.acceptInsecureCerts);

if (browserBinaryPath) {
chromeOptions.setChromeBinaryPath(browserBinaryPath);
}

const prefs = new logging.Preferences();
prefs.setLevel(logging.Type.BROWSER, logging.Level.ALL);
chromeOptions.setUserPreferences(chromiumDownloadPrefs);
chromeOptions.setLoggingPrefs(prefs);
chromeOptions.set('unexpectedAlertBehaviour', 'accept');
chromeOptions.setAcceptInsecureCerts(config.acceptInsecureCerts);

let session;
if (remoteSessionUrl) {
session = await new Builder()
.forBrowser(browserType)
.withCapabilities(chromeCapabilities)
.setChromeOptions(chromeOptions)
.usingServer(remoteSessionUrl)
.build();
} else {
session = await new Builder()
.forBrowser(browserType)
.withCapabilities(chromeCapabilities)
.setChromeOptions(chromeOptions)
.setChromeService(new chrome.ServiceBuilder(chromeDriver.path).enableVerboseLogging())
.build();
}
Expand Down Expand Up @@ -179,7 +186,7 @@ async function attemptToCreateCommand(
edgeOptions.setBinaryPath(edgePaths.browserPath);
const options = edgeOptions.get('ms:edgeOptions');
// overriding options to include preferences
Object.assign(options, chromiumDownloadPrefs);
Object.assign(options, { prefs: chromiumDownloadPrefs });
edgeOptions.set('ms:edgeOptions', options);
const session = await new Builder()
.forBrowser('MicrosoftEdge')
Expand Down
1 change: 0 additions & 1 deletion x-pack/.telemetryrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"plugins/apm/server/lib/apm_telemetry/index.ts",
"plugins/canvas/server/collectors/collector.ts",
"plugins/infra/server/usage/usage_collector.ts",
"plugins/ingest_manager/server/collectors/register.ts",
"plugins/lens/server/usage/collectors.ts",
"plugins/reporting/server/usage/reporting_usage_collector.ts",
"plugins/maps/server/maps_telemetry/collectors/register.ts"
Expand Down
28 changes: 14 additions & 14 deletions x-pack/plugins/ingest_manager/server/collectors/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ export function registerIngestManagerUsageCollector(
packages: await getPackageUsage(soClient),
};
},
// schema: { // temporarily disabled because of type errors
// fleet_enabled: { type: 'boolean' },
// agents: {
// total: { type: 'number' },
// online: { type: 'number' },
// error: { type: 'number' },
// offline: { type: 'number' },
// },
// packages: {
// name: { type: 'keyword' },
// version: { type: 'keyword' },
// enabled: { type: boolean },
// },
// },
schema: {
fleet_enabled: { type: 'boolean' },
agents: {
total: { type: 'long' },
online: { type: 'long' },
error: { type: 'long' },
offline: { type: 'long' },
},
packages: {
name: { type: 'keyword' },
version: { type: 'keyword' },
enabled: { type: 'boolean' },
},
},
});

// register usage collector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function getLimitedPackages(options: {
});
})
);
return installedPackagesInfo.filter((pkgInfo) => isPackageLimited).map((pkgInfo) => pkgInfo.name);
return installedPackagesInfo.filter(isPackageLimited).map((pkgInfo) => pkgInfo.name);
}

export async function getPackageSavedObjects(savedObjectsClient: SavedObjectsClientContract) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@
}
}
},
"ingest_manager": {
"properties": {
"fleet_enabled": {
"type": "boolean"
},
"agents": {
"properties": {
"total": {
"type": "long"
},
"online": {
"type": "long"
},
"error": {
"type": "long"
},
"offline": {
"type": "long"
}
}
},
"packages": {
"properties": {
"name": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"enabled": {
"type": "boolean"
}
}
}
}
},
"mlTelemetry": {
"properties": {
"file_data_visualizer": {
Expand Down
16 changes: 16 additions & 0 deletions x-pack/test/ingest_manager_api_integration/apis/epm/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,21 @@ export default function ({ getService }: FtrProviderContext) {
warnAndSkipTest(this, log);
}
});

it('lists all limited packages from the registry', async function () {
if (server.enabled) {
const fetchLimitedPackageList = async () => {
const response = await supertest
.get('/api/ingest_manager/epm/packages/limited')
.set('kbn-xsrf', 'xxx')
.expect(200);
return response.body;
};
const listResponse = await fetchLimitedPackageList();
expect(listResponse.response).to.eql(['endpoint']);
} else {
warnAndSkipTest(this, log);
}
});
});
}

0 comments on commit e6ce0a1

Please sign in to comment.