From 12c37b0e7ba36c7dc194399154227e1c1e75658f Mon Sep 17 00:00:00 2001 From: Bhavya RM Date: Thu, 10 Mar 2022 07:32:04 -0500 Subject: [PATCH] Tests to ensure Kibana is handling multi-space import of saved objects correctly (#127229) (cherry picked from commit a4babea7c1814319174c1636c86d7b1bfc6dc4c1) --- .../exports/_8.0.0_multispace_import.ndjson | 7 + .../apps/saved_objects_management/index.ts | 1 + .../multi_space_import.ts | 156 ++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 x-pack/test/functional/apps/saved_objects_management/exports/_8.0.0_multispace_import.ndjson create mode 100644 x-pack/test/functional/apps/saved_objects_management/multi_space_import.ts diff --git a/x-pack/test/functional/apps/saved_objects_management/exports/_8.0.0_multispace_import.ndjson b/x-pack/test/functional/apps/saved_objects_management/exports/_8.0.0_multispace_import.ndjson new file mode 100644 index 0000000000000..a23efab94264b --- /dev/null +++ b/x-pack/test/functional/apps/saved_objects_management/exports/_8.0.0_multispace_import.ndjson @@ -0,0 +1,7 @@ +{"attributes":{"fieldAttrs":"{}","fields":"[]","runtimeFieldMap":"{}","timeFieldName":"@timestamp","title":"logstash-*","typeMeta":"{}"},"coreMigrationVersion":"8.0.2","id":"3260ee90-9e48-11ec-8aae-2341c8c36512","migrationVersion":{"index-pattern":"8.0.0"},"references":[],"sort":[1646775920415,12],"type":"index-pattern","updated_at":"2022-03-08T21:45:20.415Z","version":"WzYxMCwxXQ=="} +{"attributes":{"description":"","layerListJSON":"[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"isAutoSelect\":true,\"lightModeDefault\":\"road_map_desaturated\"},\"id\":\"c838a964-d9cc-4f9a-ac34-75d7bde99e3e\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"visible\":true,\"style\":{\"type\":\"TILE\"},\"includeInFitToBounds\":true,\"type\":\"VECTOR_TILE\"},{\"sourceDescriptor\":{\"geoField\":\"geo.coordinates\",\"filterByMapBounds\":true,\"scalingType\":\"CLUSTERS\",\"id\":\"529a6a55-4260-4f52-b40a-d8ca299f1c02\",\"type\":\"ES_SEARCH\",\"applyGlobalQuery\":true,\"applyGlobalTime\":true,\"applyForceRefresh\":true,\"tooltipProperties\":[\"machine.os\"],\"sortField\":\"\",\"sortOrder\":\"desc\",\"topHitsSplitField\":\"\",\"topHitsSize\":1,\"indexPatternRefName\":\"layer_1_source_index_pattern\"},\"id\":\"e08e7c8c-3e6a-4fc1-912a-50c80fad723e\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"icon\":{\"type\":\"STATIC\",\"options\":{\"value\":\"marker\"}},\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#54B399\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#41937c\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":6}},\"iconOrientation\":{\"type\":\"STATIC\",\"options\":{\"orientation\":0}},\"labelText\":{\"type\":\"STATIC\",\"options\":{\"value\":\"\"}},\"labelColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#000000\"}},\"labelSize\":{\"type\":\"STATIC\",\"options\":{\"size\":14}},\"labelBorderColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"symbolizeAs\":{\"options\":{\"value\":\"circle\"}},\"labelBorderSize\":{\"options\":{\"size\":\"SMALL\"}}},\"isTimeAware\":true},\"includeInFitToBounds\":true,\"type\":\"BLENDED_VECTOR\",\"joins\":[]}]","mapStateJSON":"{\"zoom\":1.57,\"center\":{\"lon\":0,\"lat\":19.94277},\"timeFilters\":{\"from\":\"2014-04-24T12:53:25.292Z\",\"to\":\"2016-09-30T16:12:07.989Z\"},\"refreshConfig\":{\"isPaused\":true,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filters\":[],\"settings\":{\"autoFitToDataBounds\":false,\"backgroundColor\":\"#ffffff\",\"disableInteractive\":false,\"disableTooltipControl\":false,\"hideToolbarOverlay\":false,\"hideLayerControl\":false,\"hideViewControl\":false,\"initialLocation\":\"LAST_SAVED_LOCATION\",\"fixedLocation\":{\"lat\":0,\"lon\":0,\"zoom\":2},\"browserLocation\":{\"zoom\":2},\"maxZoom\":24,\"minZoom\":0,\"showScaleControl\":false,\"showSpatialFilters\":true,\"showTimesliderToggleButton\":true,\"spatialFiltersAlpa\":0.3,\"spatialFiltersFillColor\":\"#DA8B45\",\"spatialFiltersLineColor\":\"#DA8B45\"}}","title":"maps_library","uiStateJSON":"{\"isLayerTOCOpen\":true,\"openTOCDetails\":[]}"},"coreMigrationVersion":"8.0.2","id":"09733870-9e49-11ec-8aae-2341c8c36512","migrationVersion":{"map":"8.0.0"},"references":[{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"layer_1_source_index_pattern","type":"index-pattern"}],"sort":[1646775920415,17],"type":"map","updated_at":"2022-03-08T21:45:20.415Z","version":"WzYxMiwxXQ=="} +{"attributes":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"16552bb7-b452-44cb-a2d6-56e2a5788445":{"columnOrder":["5f7ae5eb-0f68-40f1-8f7f-61b7daf94833","79a39279-4598-4f09-b869-bab02336a866","8ea87f9b-7937-4c08-93dd-0759684da45c"],"columns":{"5f7ae5eb-0f68-40f1-8f7f-61b7daf94833":{"dataType":"string","isBucketed":true,"label":"Top values of geo.src","operationType":"terms","params":{"missingBucket":false,"orderBy":{"columnId":"8ea87f9b-7937-4c08-93dd-0759684da45c","type":"column"},"orderDirection":"desc","otherBucket":true,"size":3},"scale":"ordinal","sourceField":"geo.src"},"79a39279-4598-4f09-b869-bab02336a866":{"dataType":"date","isBucketed":true,"label":"@timestamp","operationType":"date_histogram","params":{"interval":"auto"},"scale":"interval","sourceField":"@timestamp"},"8ea87f9b-7937-4c08-93dd-0759684da45c":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","scale":"ratio","sourceField":"Records"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"axisTitlesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"fittingFunction":"None","gridlinesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"labelsOrientation":{"x":0,"yLeft":0,"yRight":0},"layers":[{"accessors":["8ea87f9b-7937-4c08-93dd-0759684da45c"],"layerId":"16552bb7-b452-44cb-a2d6-56e2a5788445","layerType":"data","position":"top","seriesType":"bar_stacked","showGridlines":false,"splitAccessor":"5f7ae5eb-0f68-40f1-8f7f-61b7daf94833","xAccessor":"79a39279-4598-4f09-b869-bab02336a866"}],"legend":{"isVisible":true,"position":"right"},"preferredSeriesType":"bar_stacked","tickLabelsVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"valueLabels":"hide","yLeftExtent":{"mode":"full"},"yRightExtent":{"mode":"full"}}},"title":"lens_library","visualizationType":"lnsXY"},"coreMigrationVersion":"8.0.2","id":"c74aba40-9e48-11ec-8aae-2341c8c36512","migrationVersion":{"lens":"8.0.0"},"references":[{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"indexpattern-datasource-layer-16552bb7-b452-44cb-a2d6-56e2a5788445","type":"index-pattern"}],"sort":[1646775920415,15],"type":"lens","updated_at":"2022-03-08T21:45:20.415Z","version":"WzYxMSwxXQ=="} +{"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"pie_library","uiStateJSON":"{\"vis\":{\"legendOpen\":false}}","version":1,"visState":"{\"title\":\"pie_library\",\"type\":\"pie\",\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"params\":{},\"schema\":\"metric\"},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"params\":{\"field\":\"response.raw\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"},\"schema\":\"segment\"}],\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":false,\"legendPosition\":\"right\",\"nestedLegend\":false,\"truncateLegend\":true,\"maxLegendLines\":1,\"distinctColors\":false,\"isDonut\":true,\"palette\":{\"type\":\"palette\",\"name\":\"default\"},\"labels\":{\"show\":true,\"last_level\":false,\"values\":true,\"valuesFormat\":\"percent\",\"percentDecimals\":2,\"truncate\":100,\"position\":\"default\"}}}"},"coreMigrationVersion":"8.0.2","id":"31019030-9e49-11ec-8aae-2341c8c36512","migrationVersion":{"visualization":"8.0.0"},"references":[{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"sort":[1646775920415,19],"type":"visualization","updated_at":"2022-03-08T21:45:20.415Z","version":"WzYxMywxXQ=="} +{"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"title":"tsvb_library","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"tsvb_library\",\"type\":\"metrics\",\"aggs\":[],\"params\":{\"time_range_mode\":\"entire_time_range\",\"id\":\"e1a810a5-e5a7-4165-8c5a-6ba329f07c02\",\"type\":\"timeseries\",\"series\":[{\"time_range_mode\":\"entire_time_range\",\"id\":\"f41da81d-eb2e-47e8-b9da-f63d36d25c45\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"palette\":{\"type\":\"palette\",\"name\":\"default\"},\"metrics\":[{\"id\":\"91b92fbe-ffa6-4bd7-982e-45b3b331034d\",\"type\":\"count\"}],\"separate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"default\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"override_index_pattern\":0,\"series_drop_last_bucket\":0}],\"time_field\":\"\",\"use_kibana_indexes\":true,\"interval\":\"\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"axis_scale\":\"normal\",\"show_legend\":1,\"truncate_legend\":1,\"max_lines_legend\":1,\"show_grid\":1,\"tooltip_mode\":\"show_all\",\"drop_last_bucket\":0,\"isModelInvalid\":false,\"annotations\":[{\"id\":\"d2f50670-9e48-11ec-b4aa-57b591994e43\",\"color\":\"#F00\",\"time_field\":\"@timestamp\",\"icon\":\"fa-bolt\",\"ignore_global_filters\":1,\"ignore_panel_filters\":1,\"query_string\":{\"query\":\"response.raw :\\\"404\\\" \",\"language\":\"kuery\"},\"fields\":\"response.raw\",\"template\":\"{{response.raw}}\",\"index_pattern_ref_name\":\"metrics_1_index_pattern\"}],\"index_pattern_ref_name\":\"metrics_0_index_pattern\"}}"},"coreMigrationVersion":"8.0.2","id":"ee4e3720-9e48-11ec-8aae-2341c8c36512","migrationVersion":{"visualization":"8.0.0"},"references":[{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"metrics_0_index_pattern","type":"index-pattern"},{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"metrics_1_index_pattern","type":"index-pattern"}],"sort":[1646775920415,22],"type":"visualization","updated_at":"2022-03-08T21:45:20.415Z","version":"WzYxNCwxXQ=="} +{"attributes":{"description":"","hits":0,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"},"optionsJSON":"{\"useMargins\":true,\"syncColors\":false,\"hidePanelTitles\":false}","panelsJSON":"[{\"version\":\"8.0.2\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"9ca8fce4-5967-41de-ad5b-874fee01f149\"},\"panelIndex\":\"9ca8fce4-5967-41de-ad5b-874fee01f149\",\"embeddableConfig\":{\"attributes\":{\"title\":\"\",\"visualizationType\":\"lnsXY\",\"type\":\"lens\",\"references\":[{\"id\":\"3260ee90-9e48-11ec-8aae-2341c8c36512\",\"name\":\"indexpattern-datasource-current-indexpattern\",\"type\":\"index-pattern\"},{\"id\":\"3260ee90-9e48-11ec-8aae-2341c8c36512\",\"name\":\"indexpattern-datasource-layer-668fde5a-cd73-4ffe-baed-d87c8fada2f1\",\"type\":\"index-pattern\"}],\"state\":{\"visualization\":{\"legend\":{\"isVisible\":true,\"position\":\"right\"},\"valueLabels\":\"hide\",\"fittingFunction\":\"None\",\"yLeftExtent\":{\"mode\":\"full\"},\"yRightExtent\":{\"mode\":\"full\"},\"axisTitlesVisibilitySettings\":{\"x\":true,\"yLeft\":true,\"yRight\":true},\"tickLabelsVisibilitySettings\":{\"x\":true,\"yLeft\":true,\"yRight\":true},\"labelsOrientation\":{\"x\":0,\"yLeft\":0,\"yRight\":0},\"gridlinesVisibilitySettings\":{\"x\":true,\"yLeft\":true,\"yRight\":true},\"preferredSeriesType\":\"bar_stacked\",\"layers\":[{\"layerId\":\"668fde5a-cd73-4ffe-baed-d87c8fada2f1\",\"accessors\":[\"13f915c4-6a2d-453f-b486-1a538887d053\"],\"position\":\"top\",\"seriesType\":\"bar_stacked\",\"showGridlines\":false,\"layerType\":\"data\",\"xAccessor\":\"0598a04d-0ee5-4ae4-90fb-f36ce9812635\",\"splitAccessor\":\"9b5000f2-5c12-4670-ab9d-64e9e5097981\"}]},\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filters\":[],\"datasourceStates\":{\"indexpattern\":{\"layers\":{\"668fde5a-cd73-4ffe-baed-d87c8fada2f1\":{\"columns\":{\"9b5000f2-5c12-4670-ab9d-64e9e5097981\":{\"label\":\"Top values of machine.os.raw\",\"dataType\":\"string\",\"operationType\":\"terms\",\"scale\":\"ordinal\",\"sourceField\":\"machine.os.raw\",\"isBucketed\":true,\"params\":{\"size\":3,\"orderBy\":{\"type\":\"column\",\"columnId\":\"13f915c4-6a2d-453f-b486-1a538887d053\"},\"orderDirection\":\"desc\",\"otherBucket\":true,\"missingBucket\":false}},\"0598a04d-0ee5-4ae4-90fb-f36ce9812635\":{\"label\":\"@timestamp\",\"dataType\":\"date\",\"operationType\":\"date_histogram\",\"sourceField\":\"@timestamp\",\"isBucketed\":true,\"scale\":\"interval\",\"params\":{\"interval\":\"auto\"}},\"13f915c4-6a2d-453f-b486-1a538887d053\":{\"label\":\"Count of records\",\"dataType\":\"number\",\"operationType\":\"count\",\"isBucketed\":false,\"scale\":\"ratio\",\"sourceField\":\"Records\"}},\"columnOrder\":[\"9b5000f2-5c12-4670-ab9d-64e9e5097981\",\"0598a04d-0ee5-4ae4-90fb-f36ce9812635\",\"13f915c4-6a2d-453f-b486-1a538887d053\"],\"incompleteColumns\":{}}}}}}},\"enhancements\":{}}},{\"version\":\"8.0.2\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"d4ae386e-e1fc-4f18-8b47-2b781bd98b8c\"},\"panelIndex\":\"d4ae386e-e1fc-4f18-8b47-2b781bd98b8c\",\"embeddableConfig\":{\"savedVis\":{\"id\":\"\",\"title\":\"\",\"description\":\"\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMetricsAtAllLevels\":false,\"showTotal\":false,\"showToolbar\":false,\"totalFunc\":\"sum\",\"percentageCol\":\"\",\"autoFitRowToContent\":false},\"uiState\":{},\"data\":{\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"params\":{},\"schema\":\"metric\"},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"params\":{\"field\":\"@timestamp\",\"timeRange\":{\"from\":\"2014-04-24T12:53:25.292Z\",\"to\":\"2016-09-30T16:12:07.989Z\"},\"useNormalizedEsInterval\":true,\"scaleMetricValues\":false,\"interval\":\"auto\",\"used_interval\":\"1w\",\"drop_partials\":false,\"min_doc_count\":1,\"extended_bounds\":{}},\"schema\":\"bucket\"},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"params\":{\"field\":\"response.raw\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"},\"schema\":\"bucket\"}],\"searchSource\":{\"index\":\"3260ee90-9e48-11ec-8aae-2341c8c36512\",\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}}},\"enhancements\":{}}},{\"version\":\"8.0.2\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":15,\"w\":24,\"h\":15,\"i\":\"52a90e1b-2b91-4fe9-843c-a82e511cc2f3\"},\"panelIndex\":\"52a90e1b-2b91-4fe9-843c-a82e511cc2f3\",\"embeddableConfig\":{\"savedVis\":{\"id\":\"\",\"title\":\"\",\"description\":\"\",\"type\":\"metrics\",\"params\":{\"time_range_mode\":\"entire_time_range\",\"id\":\"cd91562e-324f-49fd-b0ef-ce73e0d38e2c\",\"type\":\"timeseries\",\"series\":[{\"time_range_mode\":\"entire_time_range\",\"id\":\"6cfcd16a-8f3f-4103-956d-b724bb81a40c\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"palette\":{\"type\":\"palette\",\"name\":\"default\"},\"metrics\":[{\"id\":\"a1bec2ac-62d5-4121-9aeb-d52511bb4c61\",\"type\":\"count\"}],\"separate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"default\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"override_index_pattern\":0,\"series_drop_last_bucket\":0}],\"time_field\":\"\",\"use_kibana_indexes\":true,\"interval\":\"\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"axis_scale\":\"normal\",\"show_legend\":1,\"truncate_legend\":1,\"max_lines_legend\":1,\"show_grid\":1,\"tooltip_mode\":\"show_all\",\"drop_last_bucket\":0,\"isModelInvalid\":false,\"annotations\":[{\"id\":\"74270170-9e48-11ec-b4aa-57b591994e43\",\"color\":\"#F00\",\"time_field\":\"@timestamp\",\"icon\":\"fa-star\",\"ignore_global_filters\":1,\"ignore_panel_filters\":1,\"query_string\":{\"query\":\"machine.os.raw :\\\"win 7\\\" \",\"language\":\"kuery\"},\"fields\":\"machine.os.raw\",\"template\":\"{{machine.os.raw}}\",\"index_pattern_ref_name\":\"metrics_52a90e1b-2b91-4fe9-843c-a82e511cc2f3_1_index_pattern\"}],\"index_pattern_ref_name\":\"metrics_52a90e1b-2b91-4fe9-843c-a82e511cc2f3_0_index_pattern\"},\"uiState\":{},\"data\":{\"aggs\":[],\"searchSource\":{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}}},\"enhancements\":{}}},{\"version\":\"8.0.2\",\"type\":\"map\",\"gridData\":{\"x\":24,\"y\":15,\"w\":24,\"h\":15,\"i\":\"c0ddd0f8-8358-4737-a6f9-bf69be9e7f91\"},\"panelIndex\":\"c0ddd0f8-8358-4737-a6f9-bf69be9e7f91\",\"embeddableConfig\":{\"attributes\":{\"title\":\"\",\"description\":\"\",\"layerListJSON\":\"[{\\\"sourceDescriptor\\\":{\\\"type\\\":\\\"EMS_TMS\\\",\\\"isAutoSelect\\\":true,\\\"lightModeDefault\\\":\\\"road_map_desaturated\\\"},\\\"id\\\":\\\"088d967c-13ff-421f-9be9-862d7d619aad\\\",\\\"label\\\":null,\\\"minZoom\\\":0,\\\"maxZoom\\\":24,\\\"alpha\\\":1,\\\"visible\\\":true,\\\"style\\\":{\\\"type\\\":\\\"TILE\\\"},\\\"includeInFitToBounds\\\":true,\\\"type\\\":\\\"VECTOR_TILE\\\"},{\\\"sourceDescriptor\\\":{\\\"geoField\\\":\\\"geo.coordinates\\\",\\\"filterByMapBounds\\\":true,\\\"scalingType\\\":\\\"CLUSTERS\\\",\\\"id\\\":\\\"85fbe957-1151-4779-883c-fa11fbf917b3\\\",\\\"type\\\":\\\"ES_SEARCH\\\",\\\"applyGlobalQuery\\\":true,\\\"applyGlobalTime\\\":true,\\\"applyForceRefresh\\\":true,\\\"tooltipProperties\\\":[\\\"geo.srcdest\\\"],\\\"sortField\\\":\\\"\\\",\\\"sortOrder\\\":\\\"desc\\\",\\\"topHitsSplitField\\\":\\\"\\\",\\\"topHitsSize\\\":1,\\\"indexPatternRefName\\\":\\\"layer_1_source_index_pattern\\\"},\\\"id\\\":\\\"46fce5e4-3298-400e-b990-6364ecabf801\\\",\\\"label\\\":null,\\\"minZoom\\\":0,\\\"maxZoom\\\":24,\\\"alpha\\\":0.75,\\\"visible\\\":true,\\\"style\\\":{\\\"type\\\":\\\"VECTOR\\\",\\\"properties\\\":{\\\"icon\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"value\\\":\\\"marker\\\"}},\\\"fillColor\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"color\\\":\\\"#54B399\\\"}},\\\"lineColor\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"color\\\":\\\"#41937c\\\"}},\\\"lineWidth\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"size\\\":1}},\\\"iconSize\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"size\\\":6}},\\\"iconOrientation\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"orientation\\\":0}},\\\"labelText\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"value\\\":\\\"\\\"}},\\\"labelColor\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"color\\\":\\\"#000000\\\"}},\\\"labelSize\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"size\\\":14}},\\\"labelBorderColor\\\":{\\\"type\\\":\\\"STATIC\\\",\\\"options\\\":{\\\"color\\\":\\\"#FFFFFF\\\"}},\\\"symbolizeAs\\\":{\\\"options\\\":{\\\"value\\\":\\\"circle\\\"}},\\\"labelBorderSize\\\":{\\\"options\\\":{\\\"size\\\":\\\"SMALL\\\"}}},\\\"isTimeAware\\\":true},\\\"includeInFitToBounds\\\":true,\\\"type\\\":\\\"BLENDED_VECTOR\\\",\\\"joins\\\":[]}]\",\"mapStateJSON\":\"{\\\"zoom\\\":1.57,\\\"center\\\":{\\\"lon\\\":0,\\\"lat\\\":19.94277},\\\"timeFilters\\\":{\\\"from\\\":\\\"2014-04-24T12:53:25.292Z\\\",\\\"to\\\":\\\"2016-09-30T16:12:07.989Z\\\"},\\\"refreshConfig\\\":{\\\"isPaused\\\":true,\\\"interval\\\":0},\\\"query\\\":{\\\"query\\\":\\\"\\\",\\\"language\\\":\\\"kuery\\\"},\\\"filters\\\":[],\\\"settings\\\":{\\\"autoFitToDataBounds\\\":false,\\\"backgroundColor\\\":\\\"#ffffff\\\",\\\"disableInteractive\\\":false,\\\"disableTooltipControl\\\":false,\\\"hideToolbarOverlay\\\":false,\\\"hideLayerControl\\\":false,\\\"hideViewControl\\\":false,\\\"initialLocation\\\":\\\"LAST_SAVED_LOCATION\\\",\\\"fixedLocation\\\":{\\\"lat\\\":0,\\\"lon\\\":0,\\\"zoom\\\":2},\\\"browserLocation\\\":{\\\"zoom\\\":2},\\\"maxZoom\\\":24,\\\"minZoom\\\":0,\\\"showScaleControl\\\":false,\\\"showSpatialFilters\\\":true,\\\"showTimesliderToggleButton\\\":true,\\\"spatialFiltersAlpa\\\":0.3,\\\"spatialFiltersFillColor\\\":\\\"#DA8B45\\\",\\\"spatialFiltersLineColor\\\":\\\"#DA8B45\\\"}}\",\"uiStateJSON\":\"{\\\"isLayerTOCOpen\\\":true,\\\"openTOCDetails\\\":[]}\"},\"mapCenter\":{\"lat\":19.94277,\"lon\":0,\"zoom\":1.57},\"mapBuffer\":{\"minLon\":-180,\"minLat\":-66.51326,\"maxLon\":180,\"maxLat\":66.51326},\"isLayerTOCOpen\":true,\"openTOCDetails\":[],\"hiddenLayers\":[],\"enhancements\":{}}},{\"version\":\"8.0.2\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":30,\"w\":24,\"h\":15,\"i\":\"a5af0f87-b83d-481b-ac9d-de7fdd734a79\"},\"panelIndex\":\"a5af0f87-b83d-481b-ac9d-de7fdd734a79\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_a5af0f87-b83d-481b-ac9d-de7fdd734a79\"},{\"version\":\"8.0.2\",\"type\":\"map\",\"gridData\":{\"x\":24,\"y\":30,\"w\":24,\"h\":15,\"i\":\"1bf6596b-b9ad-4c12-941b-c876f773e1eb\"},\"panelIndex\":\"1bf6596b-b9ad-4c12-941b-c876f773e1eb\",\"embeddableConfig\":{\"mapCenter\":{\"lat\":19.94277,\"lon\":0,\"zoom\":1.57},\"mapBuffer\":{\"minLon\":-180,\"minLat\":-66.51326,\"maxLon\":180,\"maxLat\":66.51326},\"isLayerTOCOpen\":true,\"openTOCDetails\":[],\"hiddenLayers\":[],\"enhancements\":{}},\"panelRefName\":\"panel_1bf6596b-b9ad-4c12-941b-c876f773e1eb\"},{\"version\":\"8.0.2\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":45,\"w\":24,\"h\":15,\"i\":\"ac58e65d-055b-4a9f-a60b-5b68f33ff428\"},\"panelIndex\":\"ac58e65d-055b-4a9f-a60b-5b68f33ff428\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_ac58e65d-055b-4a9f-a60b-5b68f33ff428\"},{\"version\":\"8.0.2\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":45,\"w\":24,\"h\":15,\"i\":\"a568c4a6-39c7-474f-aa76-3e0ab2057b0b\"},\"panelIndex\":\"a568c4a6-39c7-474f-aa76-3e0ab2057b0b\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_a568c4a6-39c7-474f-aa76-3e0ab2057b0b\"}]","refreshInterval":{"pause":true,"value":0},"timeFrom":"2015-09-17T01:54:06.757Z","timeRestore":true,"timeTo":"2015-09-26T18:15:55.038Z","title":"multi_space_import_8.0.0_export","version":1},"coreMigrationVersion":"8.0.2","id":"23f8b4a0-9f29-11ec-87ba-55cba6cd8877","migrationVersion":{"dashboard":"8.0.1"},"references":[{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"9ca8fce4-5967-41de-ad5b-874fee01f149:indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"9ca8fce4-5967-41de-ad5b-874fee01f149:indexpattern-datasource-layer-668fde5a-cd73-4ffe-baed-d87c8fada2f1","type":"index-pattern"},{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"d4ae386e-e1fc-4f18-8b47-2b781bd98b8c:kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"},{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"52a90e1b-2b91-4fe9-843c-a82e511cc2f3:metrics_52a90e1b-2b91-4fe9-843c-a82e511cc2f3_0_index_pattern","type":"index-pattern"},{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"52a90e1b-2b91-4fe9-843c-a82e511cc2f3:metrics_52a90e1b-2b91-4fe9-843c-a82e511cc2f3_1_index_pattern","type":"index-pattern"},{"id":"3260ee90-9e48-11ec-8aae-2341c8c36512","name":"c0ddd0f8-8358-4737-a6f9-bf69be9e7f91:layer_1_source_index_pattern","type":"index-pattern"},{"id":"c74aba40-9e48-11ec-8aae-2341c8c36512","name":"a5af0f87-b83d-481b-ac9d-de7fdd734a79:panel_a5af0f87-b83d-481b-ac9d-de7fdd734a79","type":"lens"},{"id":"09733870-9e49-11ec-8aae-2341c8c36512","name":"1bf6596b-b9ad-4c12-941b-c876f773e1eb:panel_1bf6596b-b9ad-4c12-941b-c876f773e1eb","type":"map"},{"id":"31019030-9e49-11ec-8aae-2341c8c36512","name":"ac58e65d-055b-4a9f-a60b-5b68f33ff428:panel_ac58e65d-055b-4a9f-a60b-5b68f33ff428","type":"visualization"},{"id":"ee4e3720-9e48-11ec-8aae-2341c8c36512","name":"a568c4a6-39c7-474f-aa76-3e0ab2057b0b:panel_a568c4a6-39c7-474f-aa76-3e0ab2057b0b","type":"visualization"}],"sort":[1646776034314,2778],"type":"dashboard","updated_at":"2022-03-08T21:47:14.314Z","version":"WzY5MCwxXQ=="} +{"excludedObjects":[],"excludedObjectsCount":0,"exportedCount":6,"missingRefCount":0,"missingReferences":[]} \ No newline at end of file diff --git a/x-pack/test/functional/apps/saved_objects_management/index.ts b/x-pack/test/functional/apps/saved_objects_management/index.ts index d474755af4676..17cdae0707213 100644 --- a/x-pack/test/functional/apps/saved_objects_management/index.ts +++ b/x-pack/test/functional/apps/saved_objects_management/index.ts @@ -14,5 +14,6 @@ export default function savedObjectsManagementApp({ loadTestFile }: FtrProviderC loadTestFile(require.resolve('./spaces_integration')); loadTestFile(require.resolve('./feature_controls/saved_objects_management_security')); loadTestFile(require.resolve('./import_saved_objects_between_versions')); + loadTestFile(require.resolve('./multi_space_import')); }); } diff --git a/x-pack/test/functional/apps/saved_objects_management/multi_space_import.ts b/x-pack/test/functional/apps/saved_objects_management/multi_space_import.ts new file mode 100644 index 0000000000000..30c460c20ff10 --- /dev/null +++ b/x-pack/test/functional/apps/saved_objects_management/multi_space_import.ts @@ -0,0 +1,156 @@ +/* + * 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. + */ + +/* + * This test is making sure that saved object id collisions across multiple spaces are handled correctly + * https://github.com/elastic/kibana/issues/126940 + */ + +import expect from '@kbn/expect'; +import path from 'path'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const PageObjects = getPageObjects([ + 'common', + 'settings', + 'savedObjects', + 'copySavedObjectsToSpace', + 'dashboard', + ]); + const testSubjects = getService('testSubjects'); + const retry = getService('retry'); + const spacesService = getService('spaces'); + const renderService = getService('renderable'); + const kibanaServer = getService('kibanaServer'); + + const getExportCount = async () => { + return await retry.tryForTime(10000, async () => { + const exportText = await testSubjects.getVisibleText('exportAllObjects'); + const parts = exportText.trim().split(' '); + if (parts.length !== 3) { + throw new Error('text not loaded yet'); + } + const count = Number.parseInt(parts[1], 10); + if (count === 0) { + throw new Error('text not loaded yet'); + } + return count; + }); + }; + + const getSpacePrefix = (spaceId: string) => { + return spaceId && spaceId !== 'default' ? `/s/${spaceId}` : ``; + }; + + const importIntoSpace = async (spaceId: string) => { + await PageObjects.common.navigateToUrl('settings', 'kibana/objects', { + basePath: getSpacePrefix(spaceId), + shouldUseHashForSubUrl: false, + }); + await PageObjects.savedObjects.waitTableIsLoaded(); + const initialObjectCount = await getExportCount(); + + await PageObjects.savedObjects.importFile( + path.join(__dirname, 'exports', '_8.0.0_multispace_import.ndjson') + ); + await PageObjects.savedObjects.checkImportSucceeded(); + await PageObjects.savedObjects.clickImportDone(); + await PageObjects.savedObjects.waitTableIsLoaded(); + + const newObjectCount = await getExportCount(); + + expect(newObjectCount - initialObjectCount).to.eql(6); + }; + + const checkIfDashboardRendered = async (spaceId: string) => { + await PageObjects.common.navigateToUrl('dashboard', undefined, { + basePath: getSpacePrefix(spaceId), + shouldUseHashForSubUrl: false, + }); + await PageObjects.dashboard.loadSavedDashboard('multi_space_import_8.0.0_export'); + // dashboard should load properly + await PageObjects.dashboard.expectOnDashboard('multi_space_import_8.0.0_export'); + + // count of panels rendered completely + await renderService.waitForRender(8); + + // There should be 0 error embeddables on the dashboard + const errorEmbeddables = await testSubjects.findAll('embeddableStackError'); + expect(errorEmbeddables.length).to.be(0); + }; + + describe('should be able to handle multi-space imports correctly', function () { + before(async function () { + await spacesService.create({ + id: 'another_space', + name: 'another_space', + disabledFeatures: [], + }); + await spacesService.create({ + id: 'third_space', + name: 'third_space', + disabledFeatures: [], + }); + await kibanaServer.savedObjects.cleanStandardList(); + await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); + }); + + after(async () => { + await kibanaServer.savedObjects.cleanStandardList(); + await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); + await spacesService.delete('another_space'); + await spacesService.delete('third_space'); + }); + + it('imported dashboard into default space should render correctly', async () => { + const spaceId = 'default'; + await importIntoSpace(spaceId); + await checkIfDashboardRendered(spaceId); + }); + + it('imported dashboard into another space should render correctly', async () => { + const spaceId = 'another_space'; + await importIntoSpace(spaceId); + await checkIfDashboardRendered(spaceId); + }); + + it('copied dashboard from another space into third space using saved objects table should render correctly', async () => { + const destinationSpaceId = 'third_space'; + const spaceId = 'another_space'; + await PageObjects.common.navigateToUrl('settings', 'kibana/objects', { + basePath: getSpacePrefix(spaceId), + shouldUseHashForSubUrl: false, + }); + await PageObjects.savedObjects.waitTableIsLoaded(); + await PageObjects.copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject( + 'multi_space_import_8.0.0_export' + ); + await PageObjects.copySavedObjectsToSpace.setupForm({ + createNewCopies: true, + overwrite: false, + destinationSpaceId, + }); + await PageObjects.copySavedObjectsToSpace.startCopy(); + // Wait for successful copy + await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`); + await testSubjects.existOrFail(`cts-summary-indicator-success-${destinationSpaceId}`); + + const summaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts(); + + expect(summaryCounts).to.eql({ + success: 6, + pending: 0, + skipped: 0, + errors: 0, + }); + await PageObjects.copySavedObjectsToSpace.finishCopy(); + await checkIfDashboardRendered(spaceId); + }); + }); +}