Skip to content

Commit

Permalink
[Archive Migrations] x-pack spaces-multi-space
Browse files Browse the repository at this point in the history
Replaces the old es archive with kbn archive.
Change test to use new archive.

Helps with: elastic#102552
  • Loading branch information
wayneseymour committed Sep 6, 2022
1 parent a771b02 commit 672ae50
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 461 deletions.
36 changes: 21 additions & 15 deletions scripts/archive_migration_functions.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
#!/bin/bash

# ??? Should we migrate
# x-pack/test/functional/es_archives/dashboard/feature_controls/spaces
# x-pack/test/functional/es_archives/spaces/multi_space
# ### Yes, it needs migration
# ### Saved Object type(s) that we care about:
# dashboard
# index-pattern
# visualization
# ### Test file(s) that use it:
# x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_spaces.ts
# x-pack/test/functional/apps/discover/preserve_url.ts
# x-pack/test/functional/apps/visualize/preserve_url.ts
# x-pack/test/functional/apps/dashboard/group1/preserve_url.ts
# ### Config(s) that govern the test file(s):
# x-pack/test/functional/apps/dashboard/group1/config.ts
# x-pack/test/functional/apps/discover/config.ts
# x-pack/test/functional/apps/visualize/config.ts

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/dashboard/feature_controls/spaces"
new_archive="x-pack/test/functional/fixtures/kbn_archiver/dashboard/feature_controls/custom_space"
newArchives=("x-pack/test/functional/fixtures/kbn_archiver/dashboard/feature_controls/custom_space")
newArchives+=("x-pack/test/functional/fixtures/kbn_archiver/reporting/ecommerce_kibana_non_timezone_space")
orig_archive="x-pack/test/functional/es_archives/spaces/multi_space"
new_archive="x-pack/test/functional/fixtures/kbn_archiver/spaces/multi_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")

testFiles=("x-pack/test/functional/apps/discover/preserve_url.ts")
testFiles+=("x-pack/test/functional/apps/visualize/preserve_url.ts")
testFiles+=("x-pack/test/functional/apps/dashboard/group1/preserve_url.ts")

test_config="x-pack/test/functional/apps/dashboard/group1/config.ts"
# test_config="x-pack/test/functional/apps/discover/config.ts"
# test_config="x-pack/test/functional/apps/visualize/config.ts"

curl_so_count() {
local so=${1:-search-session}
Expand Down Expand Up @@ -356,14 +368,7 @@ save_kbn() {

load_kbn() {
local space=${1:-default}

set -x
node scripts/kbn_archiver.js --config "$test_config" load "$new_archive" --space "$space"
set +x
}

load_kbns() {
local space=${1:-default}
local archive=${2:-${new_archive}}

for x in "${newArchives[@]}"; do
set -x
Expand All @@ -379,8 +384,9 @@ load_created_kbn_archive() {
}

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
}

Expand Down
21 changes: 16 additions & 5 deletions x-pack/test/functional/apps/dashboard/group1/preserve_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,29 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'dashboard', 'spaceSelector', 'header']);
const appsMenu = getService('appsMenu');
const globalNav = getService('globalNav');
const kibanaServer = getService('kibanaServer');
const spacesService = getService('spaces');

describe('preserve url', function () {
before(async function () {
await esArchiver.load('x-pack/test/functional/es_archives/spaces/multi_space');
const anotherSpace = 'another-space';

before(async () => {
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/multi_space_default_space'
);
await spacesService.create({ id: anotherSpace, name: 'Another Space' });
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/multi_space_another_space',
{ space: anotherSpace }
);
});

after(function () {
return esArchiver.unload('x-pack/test/functional/es_archives/spaces/multi_space');
after(async () => {
await spacesService.delete(anotherSpace);
await kibanaServer.savedObjects.cleanStandardList();
});

it('goes back to last opened url', async function () {
Expand Down
20 changes: 15 additions & 5 deletions x-pack/test/functional/apps/discover/preserve_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'discover', 'spaceSelector', 'header']);
const globalNav = getService('globalNav');
const kibanaServer = getService('kibanaServer');
const spacesService = getService('spaces');

describe('preserve url', function () {
before(async function () {
await esArchiver.load('x-pack/test/functional/es_archives/spaces/multi_space');
const anotherSpace = 'another-space';

before(async () => {
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/multi_space_default_space'
);
await spacesService.create({ id: anotherSpace, name: 'Another Space' });
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/multi_space_another_space',
{ space: anotherSpace }
);
});

after(function () {
return esArchiver.unload('x-pack/test/functional/es_archives/spaces/multi_space');
after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});

it('goes back to last opened url', async function () {
Expand Down
23 changes: 17 additions & 6 deletions x-pack/test/functional/apps/visualize/preserve_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,32 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'visualize', 'spaceSelector', 'visChart']);
const appsMenu = getService('appsMenu');
const globalNav = getService('globalNav');
const kibanaServer = getService('kibanaServer');
const spacesService = getService('spaces');

describe('preserve url', function () {
before(async function () {
await esArchiver.load('x-pack/test/functional/es_archives/spaces/multi_space');
const anotherSpace = 'another-space';

before(async () => {
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/multi_space_default_space'
);
await spacesService.create({ id: anotherSpace, name: 'Another Space' });
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/spaces/multi_space_another_space',
{ space: anotherSpace }
);
});

after(function () {
return esArchiver.unload('x-pack/test/functional/es_archives/spaces/multi_space');
after(async () => {
await spacesService.delete(anotherSpace);
await kibanaServer.savedObjects.cleanStandardList();
});

it('goes back to last opened url', async function () {
it('goes back to last opened url', async () => {
await PageObjects.common.navigateToApp('visualize');
await PageObjects.visualize.openSavedVisualization('A Pie');
await PageObjects.common.navigateToApp('home');
Expand Down
Loading

0 comments on commit 672ae50

Please sign in to comment.