Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Archive Migrations] x-pack spaces-copy_saved_objects #136636

Closed
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
37 changes: 35 additions & 2 deletions scripts/archive_migration_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,43 @@

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/banners/multispace"
new_archive="x-pack/test/functional/fixtures/kbn_archiver/banners/multispace"
orig_archive="x-pack/test/functional/es_archives/spaces/copy_saved_objects"
new_archive="x-pack/test/functional/fixtures/kbn_archiver/spaces/copy_saved_objects"
test_config="x-pack/test/functional/apps/spaces/config.ts"

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=$(echo ${id:0:1} | tr '[a-z]' '[A-Z]')${id:1}
local name=${2:-$upperCased}
local disabledFeatures=${3:-}

if [[ ! -z $3 ]]; then
disabledFeatures="$3"
fi

# Use jq to create the i and n variables, then inject them.
local 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 -d "$payloadWithJqInjectedVars" \
--user elastic:changeme http://localhost:5620/api/spaces/space/"$id"
}

arrayify_csv() {
local xs=${1}
echo "$xs" | tr ',' '\n' | uniq | sort
Expand Down
8 changes: 5 additions & 3 deletions x-pack/test/functional/apps/spaces/copy_saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ export default function spaceSelectorFunctonalTests({
getService,
getPageObjects,
}: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const spaces = getService('spaces');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['security', 'settings', 'copySavedObjectsToSpace']);

describe('Copy Saved Objects to Space', function () {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/spaces/copy_saved_objects');
await kibanaServer.importExport.load(
`x-pack/test/functional/fixtures/kbn_archiver/spaces/copy_saved_objects`
);

await spaces.create({
id: 'marketing',
Expand All @@ -45,7 +47,7 @@ export default function spaceSelectorFunctonalTests({
after(async () => {
await spaces.delete('sales');
await spaces.delete('marketing');
await esArchiver.unload('x-pack/test/functional/es_archives/spaces/copy_saved_objects');
await kibanaServer.savedObjects.cleanStandardList();
});

it('allows a dashboard to be copied to the marketing space, with all references', async () => {
Expand Down
171 changes: 0 additions & 171 deletions x-pack/test/functional/es_archives/spaces/copy_saved_objects/data.json

This file was deleted.

This file was deleted.

Loading