mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Search] remove enterprise search functional tests (#208857)
## Summary These tests are no longer needed with the removal of enterprise search apps --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
dff20a63c4
commit
4362931aba
18 changed files with 0 additions and 777 deletions
|
@ -1,41 +0,0 @@
|
|||
# Enterprise Search Functional E2E Tests
|
||||
|
||||
## Running these tests
|
||||
|
||||
Follow the [Functional Test Runner instructions](https://www.elastic.co/guide/en/kibana/current/development-tests.html#development-functional-tests#_running_functional_tests).
|
||||
|
||||
There are two suites available to run, a suite that requires a Kibana instance without an `enterpriseSearch.host`
|
||||
configured, and one that does. The later also [requires a running Enterprise Search instance](#enterprise-search-requirement), and a Private API key
|
||||
from that instance set in an Environment variable.
|
||||
|
||||
Ex.
|
||||
|
||||
```sh
|
||||
# Run specs from the x-pack directory
|
||||
cd x-pack
|
||||
|
||||
# Run tests that do not require enterpriseSearch.host variable
|
||||
node scripts/functional_tests --config test/functional_enterprise_search/without_host_configured.config.ts
|
||||
|
||||
# Run tests that require enterpriseSearch.host variable
|
||||
APP_SEARCH_API_KEY=[use private key from local App Search instance here] node scripts/functional_tests --config test/functional_enterprise_search/with_host_configured.config.ts
|
||||
```
|
||||
|
||||
## Enterprise Search Requirement
|
||||
|
||||
The `with_host_configured` tests will not currently start an instance of App Search automatically. As such, they are not run as part of CI and are most useful for local regression testing.
|
||||
|
||||
The easiest way to start Enterprise Search for these tests is to check out the `ent-search` project
|
||||
and use the following script.
|
||||
|
||||
```sh
|
||||
cd script/stack_scripts
|
||||
/start-with-license-and-expiration.sh platinum 500000
|
||||
```
|
||||
|
||||
Requirements for Enterprise Search:
|
||||
|
||||
- Running on port 3002 against a separate Elasticsearch cluster.
|
||||
- Elasticsearch must have a platinum or greater level license (or trial).
|
||||
- Must have Standard or Native Auth configured with an `enterprise_search` user with password `changeme`.
|
||||
- There should be NO existing Engines or Meta Engines.
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import type { Browser } from '@kbn/ftr-common-functional-ui-services';
|
||||
import { AppSearchService, IEngine } from '../../../../services/app_search_service';
|
||||
import { FtrProviderContext } from '../../../../ftr_provider_context';
|
||||
|
||||
export default function enterpriseSearchSetupEnginesTests({
|
||||
getService,
|
||||
getPageObjects,
|
||||
}: FtrProviderContext) {
|
||||
const browser = getService('browser') as Browser;
|
||||
const retry = getService('retry');
|
||||
const appSearch = getService('appSearch') as AppSearchService;
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const PageObjects = getPageObjects(['appSearch', 'security']);
|
||||
|
||||
describe('Engines Overview', function () {
|
||||
let engine1: IEngine;
|
||||
let engine2: IEngine;
|
||||
let metaEngine: IEngine;
|
||||
|
||||
before(async () => {
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
engine1 = await appSearch.createEngine();
|
||||
engine2 = await appSearch.createEngine();
|
||||
metaEngine = await appSearch.createMetaEngine([engine1.name, engine2.name]);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
await appSearch.destroyEngine(engine1.name);
|
||||
await appSearch.destroyEngine(engine2.name);
|
||||
await appSearch.destroyEngine(metaEngine.name);
|
||||
});
|
||||
|
||||
describe('when an enterpriseSearch.host is configured', () => {
|
||||
it('navigating to the enterprise_search plugin will redirect a user to the App Search Engines Overview page', async () => {
|
||||
await PageObjects.security.forceLogout();
|
||||
const { user, password } = appSearch.getEnterpriseSearchUser();
|
||||
await PageObjects.security.login(user, password, {
|
||||
expectSpaceSelector: false,
|
||||
});
|
||||
|
||||
await PageObjects.appSearch.navigateToPage();
|
||||
await retry.try(async function () {
|
||||
const currentUrl = await browser.getCurrentUrl();
|
||||
expect(currentUrl).to.contain('/app_search');
|
||||
|
||||
const documentTitle = await browser.getTitle();
|
||||
expect(documentTitle).to.contain('App Search - Elastic');
|
||||
});
|
||||
});
|
||||
|
||||
it('lists engines', async () => {
|
||||
const engineLinks = await PageObjects.appSearch.getEngineLinks();
|
||||
const engineLinksText = await Promise.all(engineLinks.map((l) => l.getVisibleText()));
|
||||
|
||||
expect(engineLinksText.includes(engine1.name)).to.equal(true);
|
||||
expect(engineLinksText.includes(engine2.name)).to.equal(true);
|
||||
});
|
||||
|
||||
it('lists meta engines', async () => {
|
||||
const metaEngineLinks = await PageObjects.appSearch.getMetaEngineLinks();
|
||||
const metaEngineLinksText = await Promise.all(
|
||||
metaEngineLinks.map((l) => l.getVisibleText())
|
||||
);
|
||||
expect(metaEngineLinksText.includes(metaEngine.name)).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('Enterprise Search', function () {
|
||||
loadTestFile(require.resolve('./app_search/engines'));
|
||||
});
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
import { last } from 'lodash';
|
||||
|
||||
export async function getLatestVersion(): Promise<string> {
|
||||
const response: any = await axios('https://artifacts-api.elastic.co/v1/versions');
|
||||
return last(response.data.versions as string[]) || '8.7.0-SNAPSHOT';
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { pageObjects } from './page_objects';
|
||||
import { services } from './services';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const xPackFunctionalConfig = await readConfigFile(
|
||||
require.resolve('../functional/config.base.js')
|
||||
);
|
||||
|
||||
const kibanaCommonTestsConfig = await readConfigFile(
|
||||
require.resolve('@kbn/test-suites-src/common/config')
|
||||
);
|
||||
return {
|
||||
// common test config
|
||||
...kibanaCommonTestsConfig.getAll(),
|
||||
|
||||
// default to the xpack functional config
|
||||
...xPackFunctionalConfig.getAll(),
|
||||
services,
|
||||
pageObjects,
|
||||
};
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { commonFunctionalServices } from '@kbn/ftr-common-functional-services';
|
||||
import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services';
|
||||
import { EnterpriseSearchCypressCliTestRunner } from './runner';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const kibanaCommonTestsConfig = await readConfigFile(
|
||||
require.resolve('@kbn/test-suites-src/common/config')
|
||||
);
|
||||
const baseConfig = await readConfigFile(require.resolve('./cypress.config'));
|
||||
|
||||
return {
|
||||
...kibanaCommonTestsConfig.getAll(),
|
||||
|
||||
services: {
|
||||
...commonFunctionalServices,
|
||||
...commonFunctionalUIServices,
|
||||
},
|
||||
|
||||
// default to the xpack functional config
|
||||
...baseConfig.getAll(),
|
||||
|
||||
junit: {
|
||||
reportName: 'X-Pack Enterprise Search Functional Tests with Host Configured',
|
||||
},
|
||||
kbnTestServer: {
|
||||
...baseConfig.get('kbnTestServer'),
|
||||
serverArgs: [
|
||||
...baseConfig.get('kbnTestServer.serverArgs'),
|
||||
'--enterpriseSearch.host=http://localhost:3022',
|
||||
],
|
||||
},
|
||||
testRunner: EnterpriseSearchCypressCliTestRunner,
|
||||
};
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const baseConfig = await readConfigFile(require.resolve('./base_config'));
|
||||
|
||||
return {
|
||||
// default to the xpack functional config
|
||||
...baseConfig.getAll(),
|
||||
|
||||
esTestCluster: {
|
||||
...baseConfig.get('esTestCluster'),
|
||||
serverArgs: [
|
||||
...baseConfig.get('esTestCluster.serverArgs'),
|
||||
'xpack.security.enabled=true',
|
||||
'xpack.security.authc.api_key.enabled=true',
|
||||
],
|
||||
},
|
||||
|
||||
kbnTestServer: {
|
||||
...baseConfig.get('kbnTestServer'),
|
||||
serverArgs: [
|
||||
...baseConfig.get('kbnTestServer.serverArgs'),
|
||||
'--csp.strict=false',
|
||||
'--csp.warnLegacyBrowsers=false',
|
||||
'--enterpriseSearch.host=http://localhost:3022',
|
||||
'--usageCollection.uiCounters.enabled=false',
|
||||
`--home.disableWelcomeScreen=true`,
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { spawn, ChildProcess } from 'child_process';
|
||||
|
||||
import { observeLines } from '@kbn/stdio-dev-helpers';
|
||||
import { ToolingLog } from '@kbn/tooling-log';
|
||||
import * as Rx from 'rxjs';
|
||||
import { filter, take, map, tap } from 'rxjs';
|
||||
import { getLatestVersion } from './artifact_manager';
|
||||
|
||||
let enterpriseSearchProcess: ChildProcess | undefined;
|
||||
|
||||
const DOCKER_START_TIMEOUT = 5 * 60 * 1000; // 5 minutes
|
||||
const dockerImage = `docker.elastic.co/enterprise-search/enterprise-search`;
|
||||
|
||||
function firstWithTimeout(source$: Rx.Observable<any>, errorMsg: string, ms = 30 * 1000) {
|
||||
return Rx.race(
|
||||
source$.pipe(take(1)),
|
||||
Rx.timer(ms).pipe(
|
||||
map(() => {
|
||||
throw new Error(`[docker:${dockerImage}] ${errorMsg} within ${ms / 1000} seconds`);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function childProcessToLogLine(childProcess: ChildProcess, log: ToolingLog) {
|
||||
const logLine$ = new Rx.Subject<string>();
|
||||
|
||||
Rx.merge(
|
||||
observeLines(childProcess.stdout!).pipe(
|
||||
tap((line) => log.info(`[docker:${dockerImage}] ${line}`))
|
||||
),
|
||||
observeLines(childProcess.stderr!).pipe(
|
||||
tap((line) => log.error(`[docker:${dockerImage}] ${line}`))
|
||||
)
|
||||
).subscribe(logLine$);
|
||||
|
||||
return logLine$.asObservable();
|
||||
}
|
||||
|
||||
export async function setupEnterpriseSearch(logger: ToolingLog): Promise<void> {
|
||||
return new Promise(async (res, rej) => {
|
||||
try {
|
||||
const dockerArgs: string[] = [
|
||||
`run`,
|
||||
`--name=enterprise-search-ftr`,
|
||||
`--rm`,
|
||||
`-p`,
|
||||
`3022:3022`,
|
||||
`-e`,
|
||||
`elasticsearch.host='http://host.docker.internal:9220'`,
|
||||
`-e`,
|
||||
`elasticsearch.username=elastic`,
|
||||
`-e`,
|
||||
`elasticsearch.password=changeme`,
|
||||
`-e`,
|
||||
`allow_es_settings_modification=true`,
|
||||
`-e`,
|
||||
`secret_management.encryption_keys=[f8482eb76613714a62569a48f854d2390a957674d46db742c008d80745cd82d9]`,
|
||||
`-e`,
|
||||
`ENT_SEARCH_DEFAULT_PASSWORD=changeme`,
|
||||
`-e`,
|
||||
`ent_search.listen_port=3022`,
|
||||
`-e`,
|
||||
`ent_search.external_url='http://localhost:3022'`,
|
||||
`docker.elastic.co/enterprise-search/enterprise-search:${await getLatestVersion()}`,
|
||||
];
|
||||
|
||||
logger.info('starting enterpriseSearch');
|
||||
logger.info('docker ' + dockerArgs.join(' '));
|
||||
|
||||
enterpriseSearchProcess = spawn('docker', dockerArgs, { stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
enterpriseSearchProcess.on('error', rej);
|
||||
|
||||
try {
|
||||
await firstWithTimeout(
|
||||
childProcessToLogLine(enterpriseSearchProcess, logger).pipe(
|
||||
filter((line) => {
|
||||
process.stdout.write(line);
|
||||
return /Success! Elastic Enterprise Search is starting successfully./.test(line);
|
||||
})
|
||||
),
|
||||
'no package manifests loaded',
|
||||
DOCKER_START_TIMEOUT
|
||||
).toPromise();
|
||||
} catch (err) {
|
||||
enterpriseSearchProcess.kill();
|
||||
throw err;
|
||||
}
|
||||
setTimeout(res, 15000);
|
||||
} catch (error) {
|
||||
rej(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function cleanupEnterpriseSearch(log: ToolingLog) {
|
||||
if (enterpriseSearchProcess) {
|
||||
log.info('Cleaning up Enterprise Search process');
|
||||
spawn('docker', ['stop', 'enterprise-search-ftr'], { stdio: 'inherit' });
|
||||
if (!enterpriseSearchProcess.kill(9)) {
|
||||
log.info("Couldn't clean Enterprise Search process");
|
||||
}
|
||||
|
||||
enterpriseSearchProcess.on('close', () => {
|
||||
log.info('Enterprise Search closed ');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { GenericFtrProviderContext } from '@kbn/test';
|
||||
|
||||
import { pageObjects } from './page_objects';
|
||||
import { services } from './services';
|
||||
|
||||
export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services';
|
||||
import { TestSubjects } from '@kbn/ftr-common-functional-ui-services';
|
||||
import { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
export function AppSearchPageProvider({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const PageObjects = getPageObjects(['common']);
|
||||
const testSubjects = getService('testSubjects') as TestSubjects;
|
||||
|
||||
return {
|
||||
async navigateToPage(): Promise<void> {
|
||||
return await PageObjects.common.navigateToApp('enterprise_search/app_search');
|
||||
},
|
||||
|
||||
async getEngineLinks(): Promise<WebElementWrapper[]> {
|
||||
const engines = await testSubjects.find('appSearchEngines');
|
||||
return await testSubjects.findAllDescendant('EngineNameLink', engines);
|
||||
},
|
||||
|
||||
async getMetaEngineLinks(): Promise<WebElementWrapper[]> {
|
||||
const metaEngines = await testSubjects.find('appSearchMetaEngines');
|
||||
return await testSubjects.findAllDescendant('EngineNameLink', metaEngines);
|
||||
},
|
||||
};
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { pageObjects as basePageObjects } from '../../functional/page_objects';
|
||||
import { AppSearchPageProvider } from './app_search';
|
||||
import { WorkplaceSearchPageProvider } from './workplace_search';
|
||||
|
||||
export const pageObjects = {
|
||||
...basePageObjects,
|
||||
appSearch: AppSearchPageProvider,
|
||||
workplaceSearch: WorkplaceSearchPageProvider,
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
export function WorkplaceSearchPageProvider({ getPageObjects }: FtrProviderContext) {
|
||||
const PageObjects = getPageObjects(['common']);
|
||||
|
||||
return {
|
||||
async navigateToPage(): Promise<void> {
|
||||
return await PageObjects.common.navigateToApp('enterprise_search/workplace_search');
|
||||
},
|
||||
};
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
import { resolve } from 'path';
|
||||
import Url from 'url';
|
||||
|
||||
import { withProcRunner } from '@kbn/dev-proc-runner';
|
||||
import { setupEnterpriseSearch, cleanupEnterpriseSearch } from './enterprise_search_server';
|
||||
|
||||
import type { FtrProviderContext } from './ftr_provider_context';
|
||||
|
||||
export async function withEnterpriseSearch(
|
||||
context: FtrProviderContext,
|
||||
runner: (runnerEnv: Record<string, string>) => Promise<void>
|
||||
) {
|
||||
const log = context.getService('log');
|
||||
await setupEnterpriseSearch(log);
|
||||
|
||||
try {
|
||||
await runner({});
|
||||
} finally {
|
||||
cleanupEnterpriseSearch(log);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runEnterpriseSearchTests(
|
||||
context: FtrProviderContext,
|
||||
cypressCommand: string
|
||||
) {
|
||||
const log = context.getService('log');
|
||||
const config = context.getService('config');
|
||||
await withEnterpriseSearch(context, (runnerEnv) =>
|
||||
withProcRunner(log, async (procs) => {
|
||||
await procs.run('cypress', {
|
||||
cmd: '../../../node_modules/.bin/cypress',
|
||||
args: [cypressCommand, '--config-file', './cypress.config.ts', '--browser', 'chrome'],
|
||||
cwd: resolve(__dirname, '../../solutions/search/plugins/enterprise_search'),
|
||||
env: {
|
||||
FORCE_COLOR: '1',
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
CYPRESS_baseUrl: Url.format(config.get('servers.kibana')),
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
CYPRESS_protocol: config.get('servers.kibana.protocol'),
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
CYPRESS_hostname: config.get('servers.kibana.hostname'),
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
CYPRESS_configport: config.get('servers.kibana.port'),
|
||||
CYPRESS_ELASTICSEARCH_URL: Url.format(config.get('servers.elasticsearch')),
|
||||
CYPRESS_ELASTICSEARCH_USERNAME: config.get('servers.elasticsearch.username'),
|
||||
CYPRESS_ELASTICSEARCH_PASSWORD: config.get('servers.elasticsearch.password'),
|
||||
CYPRESS_KIBANA_URL: Url.format({
|
||||
protocol: config.get('servers.kibana.protocol'),
|
||||
hostname: config.get('servers.kibana.hostname'),
|
||||
port: config.get('servers.kibana.port'),
|
||||
}),
|
||||
...runnerEnv,
|
||||
...process.env,
|
||||
},
|
||||
wait: true,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export async function EnterpriseSearchCypressCliTestRunner(context: FtrProviderContext) {
|
||||
await runEnterpriseSearchTests(context, 'run');
|
||||
}
|
||||
|
||||
export async function EnterpriseSearchCypressVisualTestRunner(context: FtrProviderContext) {
|
||||
await runEnterpriseSearchTests(context, 'open');
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import http from 'http';
|
||||
|
||||
/**
|
||||
* A simple request client for making API calls to the App Search API
|
||||
*/
|
||||
const makeRequest = <T>(method: string, path: string, body?: object): Promise<T> => {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const APP_SEARCH_API_KEY = process.env.APP_SEARCH_API_KEY;
|
||||
|
||||
if (!APP_SEARCH_API_KEY) {
|
||||
throw new Error('Please provide a valid APP_SEARCH_API_KEY. See README for more details.');
|
||||
}
|
||||
|
||||
let postData;
|
||||
|
||||
if (body) {
|
||||
postData = JSON.stringify(body);
|
||||
}
|
||||
|
||||
const req = http.request(
|
||||
{
|
||||
method,
|
||||
hostname: 'localhost',
|
||||
port: 3002,
|
||||
path,
|
||||
agent: false, // Create a new agent just for this one request
|
||||
headers: {
|
||||
Authorization: `Bearer ${APP_SEARCH_API_KEY}`,
|
||||
'Content-Type': 'application/json',
|
||||
...(!!postData && { 'Content-Length': Buffer.byteLength(postData) }),
|
||||
},
|
||||
},
|
||||
(res) => {
|
||||
const bodyChunks: Uint8Array[] = [];
|
||||
res.on('data', function (chunk) {
|
||||
bodyChunks.push(chunk);
|
||||
});
|
||||
|
||||
res.on('end', function () {
|
||||
let responseBody;
|
||||
try {
|
||||
responseBody = JSON.parse(Buffer.concat(bodyChunks).toString());
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
|
||||
if (res.statusCode && res.statusCode > 299) {
|
||||
reject('Error calling App Search API: ' + JSON.stringify(responseBody));
|
||||
}
|
||||
|
||||
resolve(responseBody);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
req.on('error', (e) => {
|
||||
reject(e);
|
||||
});
|
||||
|
||||
if (postData) {
|
||||
req.write(postData);
|
||||
}
|
||||
req.end();
|
||||
});
|
||||
};
|
||||
|
||||
export interface IEngine {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const createEngine = async (engineName: string): Promise<IEngine> => {
|
||||
return await makeRequest('POST', '/api/as/v1/engines', { name: engineName });
|
||||
};
|
||||
|
||||
export const destroyEngine = async (engineName: string): Promise<object> => {
|
||||
return await makeRequest('DELETE', `/api/as/v1/engines/${engineName}`);
|
||||
};
|
||||
|
||||
export const createMetaEngine = async (
|
||||
engineName: string,
|
||||
sourceEngines: string[]
|
||||
): Promise<IEngine> => {
|
||||
return await makeRequest('POST', '/api/as/v1/engines', {
|
||||
name: engineName,
|
||||
type: 'meta',
|
||||
source_engines: sourceEngines,
|
||||
});
|
||||
};
|
||||
|
||||
export interface ISearchResponse {
|
||||
results: object[];
|
||||
}
|
||||
|
||||
const search = async (engineName: string): Promise<ISearchResponse> => {
|
||||
return await makeRequest('POST', `/api/as/v1/engines/${engineName}/search`, { query: '' });
|
||||
};
|
||||
|
||||
// Since the App Search API does not issue document receipts, the only way to tell whether or not documents
|
||||
// are fully indexed is to poll the search endpoint.
|
||||
export const waitForIndexedDocs = (engineName: string) => {
|
||||
return new Promise<void>(async function (resolve, reject) {
|
||||
try {
|
||||
let isReady = false;
|
||||
|
||||
while (!isReady) {
|
||||
const response = await search(engineName);
|
||||
|
||||
if (response.results && response.results.length > 0) {
|
||||
isReady = true;
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const indexData = async (engineName: string, docs: object[]) => {
|
||||
return await makeRequest('POST', `/api/as/v1/engines/${engineName}/documents`, docs);
|
||||
};
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
const ENTERPRISE_SEARCH_USER = 'enterprise_search';
|
||||
const ENTERPRISE_SEARCH_PASSWORD = 'changeme';
|
||||
import {
|
||||
createEngine,
|
||||
createMetaEngine,
|
||||
indexData,
|
||||
waitForIndexedDocs,
|
||||
destroyEngine,
|
||||
IEngine,
|
||||
} from './app_search_client';
|
||||
|
||||
export interface IUser {
|
||||
user: string;
|
||||
password: string;
|
||||
}
|
||||
export type { IEngine };
|
||||
|
||||
export class AppSearchService {
|
||||
getEnterpriseSearchUser(): IUser {
|
||||
return {
|
||||
user: ENTERPRISE_SEARCH_USER,
|
||||
password: ENTERPRISE_SEARCH_PASSWORD,
|
||||
};
|
||||
}
|
||||
|
||||
createEngine(): Promise<IEngine> {
|
||||
const engineName = `test-engine-${new Date().getTime()}`;
|
||||
return createEngine(engineName);
|
||||
}
|
||||
|
||||
async createEngineWithDocs(): Promise<IEngine> {
|
||||
const engine = await this.createEngine();
|
||||
const docs = [
|
||||
{ id: 1, name: 'doc1' },
|
||||
{ id: 2, name: 'doc2' },
|
||||
{ id: 3, name: 'doc2' },
|
||||
];
|
||||
await indexData(engine.name, docs);
|
||||
await waitForIndexedDocs(engine.name);
|
||||
return engine;
|
||||
}
|
||||
|
||||
async createMetaEngine(sourceEngines: string[]): Promise<IEngine> {
|
||||
const engineName = `test-meta-engine-${new Date().getTime()}`;
|
||||
return createMetaEngine(engineName, sourceEngines);
|
||||
}
|
||||
|
||||
async destroyEngine(engineName: string) {
|
||||
return destroyEngine(engineName);
|
||||
}
|
||||
}
|
||||
|
||||
export async function AppSearchServiceProvider({ getService }: FtrProviderContext) {
|
||||
const lifecycle = getService('lifecycle');
|
||||
const security = getService('security');
|
||||
|
||||
lifecycle.beforeTests.add(async () => {
|
||||
// The App Search plugin passes through the current user name and password
|
||||
// through on the API call to App Search. Therefore, we need to be signed
|
||||
// in as the enterprise_search user in order for this plugin to work.
|
||||
await security.user.create(ENTERPRISE_SEARCH_USER, {
|
||||
password: ENTERPRISE_SEARCH_PASSWORD,
|
||||
roles: ['kibana_admin'],
|
||||
full_name: ENTERPRISE_SEARCH_USER,
|
||||
});
|
||||
});
|
||||
|
||||
return new AppSearchService();
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { services as functionalServices } from '../../functional/services';
|
||||
import { AppSearchServiceProvider } from './app_search_service';
|
||||
|
||||
export const services = {
|
||||
...functionalServices,
|
||||
appSearch: AppSearchServiceProvider,
|
||||
};
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* 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; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { EnterpriseSearchCypressVisualTestRunner } from './runner';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const kibanaCommonTestsConfig = await readConfigFile(
|
||||
require.resolve('@kbn/test-suites-src/common/config')
|
||||
);
|
||||
const baseConfig = await readConfigFile(require.resolve('./cypress.config'));
|
||||
|
||||
return {
|
||||
...kibanaCommonTestsConfig.getAll(),
|
||||
// default to the xpack functional config
|
||||
...baseConfig.getAll(),
|
||||
|
||||
junit: {
|
||||
reportName: 'X-Pack Enterprise Search Functional Tests with Host Configured',
|
||||
},
|
||||
kbnTestServer: {
|
||||
...baseConfig.get('kbnTestServer'),
|
||||
serverArgs: [
|
||||
...baseConfig.get('kbnTestServer.serverArgs'),
|
||||
'--enterpriseSearch.host=http://localhost:3022',
|
||||
],
|
||||
},
|
||||
testRunner: EnterpriseSearchCypressVisualTestRunner,
|
||||
};
|
||||
}
|
|
@ -106,7 +106,6 @@
|
|||
"@kbn/apm-synthtrace-client",
|
||||
"@kbn/utils",
|
||||
"@kbn/journeys",
|
||||
"@kbn/stdio-dev-helpers",
|
||||
"@kbn/alerting-api-integration-helpers",
|
||||
"@kbn/cloud-security-posture-plugin",
|
||||
"@kbn/cloud-integration-saml-provider-plugin",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue