mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Archive Migrations] x-pack dashboard/session_in_spaces (#136531)
* [Archive Migrations] x-pack dashboard/session_in_spaces Replaces the old es archive with kbn archive. Change test to use new archive. Helps with: https://github.com/elastic/kibana/issues/102552 * fix deleting sessions * improve Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
This commit is contained in:
parent
4f65c099bc
commit
7b5819c940
13 changed files with 563 additions and 785 deletions
|
@ -2,11 +2,76 @@
|
|||
|
||||
standard_list="url,index-pattern,query,graph-workspace,tag,visualization,canvas-element,canvas-workpad,dashboard,search,lens,map,cases,uptime-dynamic-settings,osquery-saved-query,osquery-pack,infrastructure-ui-source,metrics-explorer-view,inventory-view,infrastructure-monitoring-log-view,apm-indices"
|
||||
|
||||
orig_archive="x-pack/test/functional/es_archives/reporting/ecommerce_kibana_spaces"
|
||||
new_archive="x-pack/test/functional/fixtures/kbn_archiver/reporting/ecommerce_kibana_spaces"
|
||||
newArchives=("x-pack/test/functional/fixtures/kbn_archiver/reporting/ecommerce_kibana_non_default_space")
|
||||
newArchives+=("x-pack/test/functional/fixtures/kbn_archiver/reporting/ecommerce_kibana_non_timezone_space")
|
||||
test_config="x-pack/test/reporting_api_integration/reporting_and_security.config.ts"
|
||||
orig_archive="x-pack/test/functional/es_archives/dashboard/session_in_space"
|
||||
new_archive="x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space"
|
||||
newArchives=("x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space")
|
||||
newArchives+=("x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_another_space")
|
||||
test_config="x-pack/test/search_sessions_integration/config.ts"
|
||||
|
||||
curl_so_count() {
|
||||
local so=${1:-search-session}
|
||||
local count
|
||||
count=$(curl -s -XGET "http://elastic:changeme@localhost:9220/.kibana/_count" -H "kbn-xsrf: archive-migration-functions" -H "Content-Type: application/json" -d'
|
||||
{
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"match_phrase": {
|
||||
"type": "${so}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}' | jq '.count')
|
||||
|
||||
echo " ### [${so}] count: ${count}"
|
||||
}
|
||||
|
||||
watch_so_count() {
|
||||
local so=${1:-search-session}
|
||||
|
||||
while true; do
|
||||
curl_so_count "$so"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
create_space() {
|
||||
# Ex: Id, Name, and Disabled Features.
|
||||
# create_space tre "Tre Space" apm,ml,canvas,dashboard,visualize,maps,monitoring,uptime
|
||||
# Ex: Id. Name is generated
|
||||
# create_space rashmi
|
||||
# Ex: Id and Name. No disabled features.
|
||||
# create_space another-space "Another Space"
|
||||
local id=${1:-sales}
|
||||
local upperCased
|
||||
upperCased=$(echo "${id:0:1}" | tr '[:lower:]' '[:upper:]')"${id:1}"
|
||||
local name=${2:-$upperCased}
|
||||
local disabledFeatures=${3:-}
|
||||
|
||||
if [[ -n $3 ]]; then
|
||||
disabledFeatures="$3"
|
||||
fi
|
||||
|
||||
# Use jq to create the i and n variables, then inject them.
|
||||
local payload
|
||||
payload=$(jq -n --arg i "$id" --arg n "$name" --arg df "$disabledFeatures" \
|
||||
'{ "id": $i, "name": $n, "disabledFeatures": [$df] }')
|
||||
|
||||
curl -H "Content-Type: application/json" -H "kbn-xsrf: archive-migration-functions" \
|
||||
-X POST -d "$payload" \
|
||||
--user elastic:changeme http://localhost:5620/api/spaces/space
|
||||
}
|
||||
|
||||
delete_space() {
|
||||
local id=${1:?Need a space id.}
|
||||
|
||||
curl -H "kbn-xsrf: archive-migration-functions" \
|
||||
-X DELETE \
|
||||
--user elastic:changeme http://localhost:5620/api/spaces/space/"$id"
|
||||
}
|
||||
|
||||
arrayify_csv() {
|
||||
local xs=${1}
|
||||
|
@ -31,11 +96,6 @@ intersection() {
|
|||
echo "${intersections[@]}"
|
||||
}
|
||||
|
||||
# Just a note that this is using Gnu date.
|
||||
# On OSX if you don't install this, and instead use the native date you only get seconds.
|
||||
# With gdate you can something like nanoseconds.
|
||||
alias timestamp='while read line; do echo "[`gdate +%H:%M:%S.%N`] $line"; done'
|
||||
|
||||
is_zipped() {
|
||||
local archive=$1
|
||||
|
||||
|
@ -98,6 +158,7 @@ _find_config() {
|
|||
|
||||
local current
|
||||
local parent
|
||||
local grandParent
|
||||
local greatGrand
|
||||
current=$(dirname "$test_file")
|
||||
parent=$(dirname "$current")
|
||||
|
@ -107,8 +168,9 @@ _find_config() {
|
|||
local dirs=("$current" "$parent" "$grandParent" "$greatGrand")
|
||||
|
||||
local configs=()
|
||||
local config
|
||||
for x in "${dirs[@]}"; do
|
||||
local config=$(find "$x" -maxdepth 1 -type f -name '*config.js' -or -name '*config.ts')
|
||||
config=$(find "$x" -maxdepth 1 -type f -name '*config.js' -or -name '*config.ts')
|
||||
if [ -n "$config" ]; then
|
||||
configs+=("$config")
|
||||
fi
|
||||
|
@ -277,42 +339,29 @@ save_kbn() {
|
|||
|
||||
load_kbn() {
|
||||
local space=${1:-default}
|
||||
local archive=${2:-${new_archive}}
|
||||
|
||||
set -x
|
||||
node scripts/kbn_archiver.js --config "$test_config" load "$new_archive" --space "$space"
|
||||
set +x
|
||||
}
|
||||
|
||||
load_kbns() {
|
||||
local space=${1:-default}
|
||||
|
||||
for x in "${newArchives[@]}"; do
|
||||
set -x
|
||||
node scripts/kbn_archiver.js --config "$test_config" load "$x" --space "$space"
|
||||
set +x
|
||||
done
|
||||
}
|
||||
|
||||
load_created_kbn_archive() {
|
||||
set -x
|
||||
node scripts/kbn_archiver.js --config "$test_config" load "$new_archive"
|
||||
node scripts/kbn_archiver.js --config "$test_config" load "$archive" --space "$space"
|
||||
set +x
|
||||
}
|
||||
|
||||
unload_kbn() {
|
||||
local archive=${1:-${new_archive}}
|
||||
set -x
|
||||
node scripts/kbn_archiver.js --config "$test_config" unload "$new_archive"
|
||||
node scripts/kbn_archiver.js --config "$test_config" unload "$archive"
|
||||
set +x
|
||||
}
|
||||
|
||||
unload_kbns() {
|
||||
local space=${1:-default}
|
||||
load_kbn_custom() {
|
||||
load_kbn default "${newArchives[1]}"
|
||||
create_space another-space "Another Space"
|
||||
load_kbn another-space "${newArchives[2]}"
|
||||
}
|
||||
|
||||
for x in "${newArchives[@]}"; do
|
||||
set -x
|
||||
node scripts/kbn_archiver.js --config "$test_config" unload "$x"
|
||||
set +x
|
||||
done
|
||||
unload_kbn_custom() {
|
||||
unload_kbn "${newArchives[1]}"
|
||||
delete_space another-space
|
||||
}
|
||||
|
||||
ping_server() {
|
||||
|
@ -338,14 +387,6 @@ run_test() {
|
|||
set +x
|
||||
}
|
||||
|
||||
run_test_with_timestamp() {
|
||||
local config=${1:-$test_config}
|
||||
|
||||
set -x
|
||||
node scripts/functional_test_runner --config "$config" | timestamp
|
||||
set +x
|
||||
}
|
||||
|
||||
run_test_extra() {
|
||||
set -x
|
||||
node scripts/functional_test_runner --config "$test_config" \
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,205 +0,0 @@
|
|||
{
|
||||
"type": "index",
|
||||
"value": {
|
||||
"aliases": {
|
||||
".kibana": {}
|
||||
},
|
||||
"index": ".kibana_1",
|
||||
"mappings": {
|
||||
"properties": {
|
||||
"config": {
|
||||
"dynamic": "true",
|
||||
"properties": {
|
||||
"buildNum": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dashboard": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"hits": {
|
||||
"type": "integer"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"optionsJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"panelsJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"refreshInterval": {
|
||||
"properties": {
|
||||
"display": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"pause": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"section": {
|
||||
"type": "integer"
|
||||
},
|
||||
"value": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeFrom": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"timeRestore": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"timeTo": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"uiStateJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"index-pattern": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"fieldFormatMap": {
|
||||
"type": "text"
|
||||
},
|
||||
"fields": {
|
||||
"type": "text"
|
||||
},
|
||||
"intervalName": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"notExpandable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"sourceFilters": {
|
||||
"type": "text"
|
||||
},
|
||||
"timeFieldName": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"search": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"columns": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"hits": {
|
||||
"type": "integer"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"url": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"accessCount": {
|
||||
"type": "long"
|
||||
},
|
||||
"accessDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"createDate": {
|
||||
"type": "date"
|
||||
},
|
||||
"url": {
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"ignore_above": 2048,
|
||||
"type": "keyword"
|
||||
}
|
||||
},
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visualization": {
|
||||
"dynamic": "strict",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"kibanaSavedObjectMeta": {
|
||||
"properties": {
|
||||
"searchSourceJSON": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"savedSearchId": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"uiStateJSON": {
|
||||
"type": "text"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
},
|
||||
"visState": {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"index": {
|
||||
"number_of_replicas": "1",
|
||||
"number_of_shards": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,7 @@ export class SearchSessionsService extends FtrService {
|
|||
private readonly log = this.ctx.getService('log');
|
||||
private readonly retry = this.ctx.getService('retry');
|
||||
private readonly browser = this.ctx.getService('browser');
|
||||
private readonly supertest = this.ctx.getService('supertest');
|
||||
private readonly security = this.ctx.getService('security');
|
||||
|
||||
public async find(): Promise<WebElementWrapper> {
|
||||
return this.testSubjects.find(SEARCH_SESSION_INDICATOR_TEST_SUBJ);
|
||||
|
@ -138,21 +138,31 @@ export class SearchSessionsService extends FtrService {
|
|||
this.log.debug('Deleting created search sessions');
|
||||
// ignores 409 errs and keeps retrying
|
||||
await this.retry.tryForTime(10000, async () => {
|
||||
const { body } = await this.supertest
|
||||
const { body } = await this.security.testUserSupertest
|
||||
.post('/internal/session/_find')
|
||||
.set('kbn-xsrf', 'anything')
|
||||
.set('kbn-system-request', 'true')
|
||||
.send({ page: 1, perPage: 10000, sortField: 'created', sortOrder: 'asc' })
|
||||
.send({
|
||||
page: 1,
|
||||
perPage: 10000,
|
||||
sortField: 'created',
|
||||
sortOrder: 'asc',
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
const { saved_objects: savedObjects } = body as SavedObjectsFindResponse;
|
||||
if (savedObjects.length) {
|
||||
|
||||
if (savedObjects.length > 0) {
|
||||
this.log.debug(`Found created search sessions: ${savedObjects.map(({ id }) => id)}`);
|
||||
} else {
|
||||
this.log.debug(`Found no search sessions to delete`);
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
savedObjects.map(async (so) => {
|
||||
this.log.debug(`Deleting search session: ${so.id}`);
|
||||
await this.supertest
|
||||
await this.security.testUserSupertest
|
||||
.delete(`/internal/session/${so.id}`)
|
||||
.set(`kbn-xsrf`, `anything`)
|
||||
.expect(200);
|
||||
|
|
|
@ -31,6 +31,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid
|
|||
|
||||
after(async () => {
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
await searchSessions.deleteAllSearchSessions();
|
||||
});
|
||||
|
||||
loadTestFile(require.resolve('./async_search'));
|
||||
|
|
|
@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';
|
|||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const spacesService = getService('spaces');
|
||||
const security = getService('security');
|
||||
const PageObjects = getPageObjects([
|
||||
'common',
|
||||
|
@ -28,57 +28,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const toasts = getService('toasts');
|
||||
|
||||
describe('dashboard in space', () => {
|
||||
afterEach(async () => await clean());
|
||||
describe('Storing search sessions in space', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
},
|
||||
kibana: [
|
||||
{
|
||||
feature: {
|
||||
dashboard: ['minimal_read', 'store_search_session'],
|
||||
},
|
||||
spaces: ['another-space'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await security.user.create('analyst', {
|
||||
password: 'analyst-password',
|
||||
roles: ['data_analyst'],
|
||||
full_name: 'test user',
|
||||
});
|
||||
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await PageObjects.security.login('analyst', 'analyst-password', {
|
||||
expectSpaceSelector: false,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
before(async () => await load(['minimal_read', 'store_search_session']));
|
||||
|
||||
it('Saves and restores a session', async () => {
|
||||
await PageObjects.common.navigateToApp('dashboard', { basePath: 's/another-space' });
|
||||
|
@ -119,58 +71,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
expect(await toasts.getToastCount()).to.be(0); // no session restoration related warnings
|
||||
});
|
||||
});
|
||||
|
||||
describe('Disabled storing search sessions', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
},
|
||||
kibana: [
|
||||
{
|
||||
feature: {
|
||||
dashboard: ['minimal_read'],
|
||||
},
|
||||
spaces: ['another-space'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await security.user.create('analyst', {
|
||||
password: 'analyst-password',
|
||||
roles: ['data_analyst'],
|
||||
full_name: 'test user',
|
||||
});
|
||||
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await PageObjects.security.login('analyst', 'analyst-password', {
|
||||
expectSpaceSelector: false,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
before(async () => await load(['minimal_read']));
|
||||
|
||||
it("Doesn't allow to store a session", async () => {
|
||||
await PageObjects.common.navigateToApp('dashboard', { basePath: 's/another-space' });
|
||||
|
@ -183,4 +85,57 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
});
|
||||
async function load(dashboard: string[]) {
|
||||
await kibanaServer.importExport.load(
|
||||
`x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space`
|
||||
);
|
||||
await spacesService.create({ id: 'another-space', name: 'Another Space' });
|
||||
await kibanaServer.importExport.load(
|
||||
`x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_another_space`,
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
},
|
||||
kibana: [
|
||||
{
|
||||
feature: {
|
||||
dashboard,
|
||||
},
|
||||
spaces: ['another-space'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await security.user.create('analyst', {
|
||||
password: 'analyst-password',
|
||||
roles: ['data_analyst'],
|
||||
full_name: 'test user',
|
||||
});
|
||||
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await PageObjects.security.login('analyst', 'analyst-password', {
|
||||
expectSpaceSelector: false,
|
||||
});
|
||||
}
|
||||
async function clean() {
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
||||
await PageObjects.security.forceLogout();
|
||||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
await spacesService.delete('another-space');
|
||||
await searchSessions.deleteAllSearchSessions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid
|
|||
const kibanaServer = getService('kibanaServer');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const PageObjects = getPageObjects(['common']);
|
||||
const searchSessions = getService('searchSessions');
|
||||
|
||||
describe('Search session sharing', function () {
|
||||
before(async () => {
|
||||
|
@ -19,6 +20,10 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid
|
|||
await PageObjects.common.navigateToApp('dashboard');
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await searchSessions.deleteAllSearchSessions();
|
||||
});
|
||||
|
||||
loadTestFile(require.resolve('./lens'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const spacesService = getService('spaces');
|
||||
const security = getService('security');
|
||||
const inspector = getService('inspector');
|
||||
const PageObjects = getPageObjects([
|
||||
|
@ -28,57 +28,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const toasts = getService('toasts');
|
||||
|
||||
describe('discover in space', () => {
|
||||
afterEach(async () => await clean());
|
||||
describe('Storing search sessions in space', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
},
|
||||
kibana: [
|
||||
{
|
||||
feature: {
|
||||
discover: ['all'],
|
||||
},
|
||||
spaces: ['another-space'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await security.user.create('analyst', {
|
||||
password: 'analyst-password',
|
||||
roles: ['data_analyst'],
|
||||
full_name: 'test user',
|
||||
});
|
||||
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await PageObjects.security.login('analyst', 'analyst-password', {
|
||||
expectSpaceSelector: false,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
before(async () => await load(['all']));
|
||||
|
||||
it('Saves and restores a session', async () => {
|
||||
await PageObjects.common.navigateToApp('discover', { basePath: 's/another-space' });
|
||||
|
@ -124,56 +76,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
describe('Disabled storing search sessions in space', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
},
|
||||
kibana: [
|
||||
{
|
||||
feature: {
|
||||
discover: ['read'],
|
||||
},
|
||||
spaces: ['another-space'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await security.user.create('analyst', {
|
||||
password: 'analyst-password',
|
||||
roles: ['data_analyst'],
|
||||
full_name: 'test user',
|
||||
});
|
||||
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await PageObjects.security.login('analyst', 'analyst-password', {
|
||||
expectSpaceSelector: false,
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
|
||||
await kibanaServer.uiSettings.unset('timepicker:timeDefaults', { space: 'another-space' });
|
||||
await kibanaServer.uiSettings.unset('defaultIndex', { space: 'another-space' });
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/dashboard/session_in_space');
|
||||
});
|
||||
before(async () => await load(['read']));
|
||||
|
||||
it("Doesn't allow to store a session", async () => {
|
||||
await PageObjects.common.navigateToApp('discover', { basePath: 's/another-space' });
|
||||
|
@ -192,4 +95,59 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
});
|
||||
async function load(discover: string[]) {
|
||||
await kibanaServer.importExport.load(
|
||||
`x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space`
|
||||
);
|
||||
await spacesService.create({ id: 'another-space', name: 'Another Space' });
|
||||
await kibanaServer.importExport.load(
|
||||
`x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_another_space`,
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
await kibanaServer.uiSettings.replace(
|
||||
{
|
||||
'timepicker:timeDefaults':
|
||||
'{ "from": "2015-09-01T00:00:00.000Z", "to": "2015-10-01T00:00:00.000Z"}',
|
||||
defaultIndex: 'd1bd6c84-d9d0-56fb-8a72-63fe60020920',
|
||||
},
|
||||
{ space: 'another-space' }
|
||||
);
|
||||
|
||||
await security.role.create('data_analyst', {
|
||||
elasticsearch: {
|
||||
indices: [{ names: ['logstash-*'], privileges: ['all'] }],
|
||||
},
|
||||
kibana: [
|
||||
{
|
||||
feature: {
|
||||
discover,
|
||||
},
|
||||
spaces: ['another-space'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await security.user.create('analyst', {
|
||||
password: 'analyst-password',
|
||||
roles: ['data_analyst'],
|
||||
full_name: 'test user',
|
||||
});
|
||||
|
||||
await PageObjects.security.forceLogout();
|
||||
|
||||
await PageObjects.security.login('analyst', 'analyst-password', {
|
||||
expectSpaceSelector: false,
|
||||
});
|
||||
}
|
||||
async function clean() {
|
||||
await kibanaServer.importExport.unload(
|
||||
'x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space'
|
||||
);
|
||||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
||||
await PageObjects.security.forceLogout();
|
||||
await security.role.delete('data_analyst');
|
||||
await security.user.delete('analyst');
|
||||
await spacesService.delete('another-space');
|
||||
await searchSessions.deleteAllSearchSessions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
export default function ({ loadTestFile, getService }: FtrProviderContext) {
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const searchSessions = getService('searchSessions');
|
||||
|
||||
describe('lens search sessions', function () {
|
||||
before(async () => {
|
||||
|
@ -17,6 +18,11 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) {
|
|||
await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' });
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await searchSessions.deleteAllSearchSessions();
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
});
|
||||
|
||||
loadTestFile(require.resolve('./search_sessions.ts'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';
|
|||
export default function ({ loadTestFile, getService }: FtrProviderContext) {
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const searchSessions = getService('searchSessions');
|
||||
|
||||
describe('search sessions management', function () {
|
||||
before(async () => {
|
||||
|
@ -25,6 +26,7 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) {
|
|||
|
||||
after(async () => {
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
await searchSessions.deleteAllSearchSessions();
|
||||
});
|
||||
|
||||
loadTestFile(require.resolve('./sessions_management'));
|
||||
|
|
|
@ -26,6 +26,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
describe('Search Sessions Management UI', () => {
|
||||
describe('New search sessions', () => {
|
||||
before(async () => {
|
||||
await searchSessions.deleteAllSearchSessions();
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
log.debug('wait for dashboard landing page');
|
||||
await retry.tryForTime(10000, async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue