Skip to content

Commit

Permalink
[Archive Migrations] x-pack event_log_multiple_indicies
Browse files Browse the repository at this point in the history
Add a new fn that checks for whether an archive should be
migrated.  This new fn disregards the standard_list.

Helps with: #102552
  • Loading branch information
wayneseymour committed Oct 6, 2022
1 parent 61630e3 commit f13acfc
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 71 deletions.
58 changes: 55 additions & 3 deletions scripts/archive_migration_functions.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#??? Should we migrate
# x-pack/test/functional/es_archives/event_log_multiple_indicies
#### Yes, it needs migration
# ### Saved Object type(s) within:
# config
# event_log_test
# space
# ### Test file(s) that use it:
# x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts
# ### Config(s) that govern the test file(s):
# x-pack/test/plugin_api_integration/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/banners/multispace"
new_archive="x-pack/test/functional/fixtures/kbn_archiver/banners/multi_space"
orig_archive="x-pack/test/functional/es_archives/event_log_multiple_indicies"
new_archive="x-pack/test/functional/fixtures/kbn_archiver/event_log_multiple_indicies"

# newArchives=("x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space")

# testFiles=("x-pack/test/functional/apps/discover/preserve_url.ts")

test_config="x-pack/test/banners_functional/config.ts"
test_config="x-pack/test/plugin_api_integration/config.ts"

list_stragglers() {

Expand Down Expand Up @@ -279,6 +291,46 @@ clean_up() {
done
}

should_migrate_without_standard_list() {
local archive=${1:-$orig_archive}
local archiveJson="${archive}/data.json"
printf "\n??? Should we migrate \n %s\n" "$archive"

local guardResults=($(_guard "$archive"))

if [ "${#guardResults[@]}" -eq 0 ]; then
local containedTypes=($(_types "$archive"))
local intersections=($(intersection "${containedTypes[@]}"))
local intersectionsLength="${#intersections[@]}"
local foundTestFiles=($(usages_list "$archive"))
local configs=($(find_configs "${foundTestFiles[@]}"))
local needsMigration=($(are_enabled "${configs[@]}"))
if [ "${#needsMigration[@]}" -gt 0 ]; then
echo "### Yes, it needs migration"
echo " ### Saved Object type(s) within:"
print_list "${containedTypes[@]}"
echo " ### Test file(s) that use it:"
print_list "${foundTestFiles[@]}"
echo " ### Config(s) that govern the test file(s):"
print_list "${configs[@]}"
else
echo "!!! No, do not migrate, it's config(s) is / are not enabled."
echo "!!! It contains the following saved object(s)"
print_list "${containedTypes[@]}"
echo " !!! For these files:"
print_list "${foundTestFiles[@]}"
echo " !!! Config(s) that govern the test file(s):"
print_list "${configs[@]}"
fi
else
echo "!!! No, it failed the guard(s):"
echo "${guardResults[@]}"
fi

trap clean_up EXIT
}


should_migrate() {
local archive=${1:-$orig_archive}
local archiveJson="${archive}/data.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,3 @@
{
"type": "doc",
"value": {
"id": "config:8.0.0",
"index": ".kibana_1",
"source": {
"config": {
"buildNum": 9007199254740991
},
"migrationVersion": {
"config": "7.9.0"
},
"references": [
],
"type": "config",
"updated_at": "2020-10-28T15:19:15.795Z"
}
}
}

{
"type": "doc",
"value": {
"id": "space:default",
"index": ".kibana_1",
"source": {
"migrationVersion": {
"space": "6.6.0"
},
"references": [
],
"space": {
"_reserved": true,
"color": "#00bfb3",
"description": "This is your default space!",
"disabledFeatures": [
],
"name": "Default"
},
"type": "space",
"updated_at": "2020-10-28T15:19:15.857Z"
}
}
}

{
"type": "doc",
"value": {
"id": "space:namespace-a",
"index": ".kibana_1",
"source": {
"migrationVersion": {
"space": "6.6.0"
},
"references": [
],
"space": {
"disabledFeatures": [
],
"name": "Space A"
},
"type": "space",
"updated_at": "2020-10-28T15:19:52.887Z"
}
}
}

{
"type": "doc",
"value": {
Expand Down Expand Up @@ -274,4 +207,4 @@
"message": "test 2020-10-28T15:19:55.962Z"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function ({ getService }: FtrProviderContext) {

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await spacesService.delete('namespace-a');
});

for (const namespace of [undefined, 'namespace-a']) {
Expand Down

0 comments on commit f13acfc

Please sign in to comment.