[data views] Make data view saved objects share capable (#114408)

This commit is contained in:
Matthew Kime 2021-10-25 11:10:16 -05:00 committed by GitHub
parent d91bc28846
commit 1e718a5572
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 52 deletions

View file

@ -13,7 +13,8 @@ import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../common';
export const dataViewSavedObjectType: SavedObjectsType = { export const dataViewSavedObjectType: SavedObjectsType = {
name: DATA_VIEW_SAVED_OBJECT_TYPE, name: DATA_VIEW_SAVED_OBJECT_TYPE,
hidden: false, hidden: false,
namespaceType: 'single', namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
management: { management: {
displayName: 'Data view', displayName: 'Data view',
icon: 'indexPatternApp', icon: 'indexPatternApp',

View file

@ -249,7 +249,7 @@ export default function ({ getService }: FtrProviderContext) {
path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357', path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.indexPatterns', uiCapabilitiesPath: 'management.kibana.indexPatterns',
}, },
namespaceType: 'single', namespaceType: 'multiple-isolated',
}); });
})); }));
}); });

View file

@ -91,7 +91,7 @@ export default function ({ getService }: FtrProviderContext) {
path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357', path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.indexPatterns', uiCapabilitiesPath: 'management.kibana.indexPatterns',
}, },
namespaceType: 'single', namespaceType: 'multiple-isolated',
hiddenType: false, hiddenType: false,
}, },
}, },
@ -132,7 +132,7 @@ export default function ({ getService }: FtrProviderContext) {
path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357', path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.indexPatterns', uiCapabilitiesPath: 'management.kibana.indexPatterns',
}, },
namespaceType: 'single', namespaceType: 'multiple-isolated',
hiddenType: false, hiddenType: false,
}, },
relationship: 'child', relationship: 'child',

View file

@ -153,7 +153,7 @@
"references": [ "references": [
{ {
"type": "index-pattern", "type": "index-pattern",
"id": "cts_ip_1", "id": "cts_ip_1_default",
"name": "CTS IP 1" "name": "CTS IP 1"
} }
], ],
@ -182,7 +182,7 @@
"references": [ "references": [
{ {
"type": "index-pattern", "type": "index-pattern",
"id": "cts_ip_1", "id": "cts_ip_1_default",
"name": "CTS IP 1" "name": "CTS IP 1"
} }
], ],
@ -212,7 +212,7 @@
"references": [ "references": [
{ {
"type": "index-pattern", "type": "index-pattern",
"id": "cts_ip_1", "id": "cts_ip_1_default",
"name": "CTS IP 1" "name": "CTS IP 1"
} }
], ],
@ -276,7 +276,7 @@
"references": [ "references": [
{ {
"type": "index-pattern", "type": "index-pattern",
"id": "cts_ip_1", "id": "cts_ip_1_space_1",
"name": "CTS IP 1" "name": "CTS IP 1"
} }
], ],
@ -305,7 +305,7 @@
"references": [ "references": [
{ {
"type": "index-pattern", "type": "index-pattern",
"id": "cts_ip_1", "id": "cts_ip_1_space_1",
"name": "CTS IP 1" "name": "CTS IP 1"
} }
], ],
@ -335,7 +335,7 @@
"references": [ "references": [
{ {
"type": "index-pattern", "type": "index-pattern",
"id": "cts_ip_1", "id": "cts_ip_1_space_1",
"name": "CTS IP 1" "name": "CTS IP 1"
} }
], ],
@ -350,15 +350,17 @@
{ {
"type": "_doc", "type": "_doc",
"value": { "value": {
"id": "index-pattern:cts_ip_1", "id": "index-pattern:cts_ip_1_default",
"index": ".kibana", "index": ".kibana",
"source": { "source": {
"originId": "cts_ip_1",
"index-pattern": { "index-pattern": {
"title": "Copy to Space index pattern 1 from default space" "title": "Copy to Space index pattern 1 from default space"
}, },
"references": [], "references": [],
"type": "index-pattern", "type": "index-pattern",
"updated_at": "2017-09-21T18:49:16.270Z" "updated_at": "2017-09-21T18:49:16.270Z",
"namespaces": ["default"]
}, },
"type": "_doc" "type": "_doc"
} }
@ -367,16 +369,17 @@
{ {
"type": "_doc", "type": "_doc",
"value": { "value": {
"id": "space_1:index-pattern:cts_ip_1", "id": "index-pattern:cts_ip_1_space_1",
"index": ".kibana", "index": ".kibana",
"source": { "source": {
"originId": "cts_ip_1",
"index-pattern": { "index-pattern": {
"title": "Copy to Space index pattern 1 from space_1 space" "title": "Copy to Space index pattern 1 from space_1 space"
}, },
"references": [], "references": [],
"type": "index-pattern", "type": "index-pattern",
"updated_at": "2017-09-21T18:49:16.270Z", "updated_at": "2017-09-21T18:49:16.270Z",
"namespace": "space_1" "namespaces": ["space_1"]
}, },
"type": "_doc" "type": "_doc"
} }

View file

@ -183,6 +183,8 @@ export function copyToSpaceTestSuiteFactory(
const destination = getDestinationWithoutConflicts(); const destination = getDestinationWithoutConflicts();
const result = resp.body as CopyResponse; const result = resp.body as CopyResponse;
const indexPatternDestinationId = result[destination].successResults![0].destinationId;
expect(indexPatternDestinationId).to.match(UUID_PATTERN); // this was copied to space 2 and hit an unresolvable conflict, so the object ID was regenerated silently / the destinationId is a UUID
const vis1DestinationId = result[destination].successResults![1].destinationId; const vis1DestinationId = result[destination].successResults![1].destinationId;
expect(vis1DestinationId).to.match(UUID_PATTERN); // this was copied to space 2 and hit an unresolvable conflict, so the object ID was regenerated silently / the destinationId is a UUID expect(vis1DestinationId).to.match(UUID_PATTERN); // this was copied to space 2 and hit an unresolvable conflict, so the object ID was regenerated silently / the destinationId is a UUID
const vis2DestinationId = result[destination].successResults![2].destinationId; const vis2DestinationId = result[destination].successResults![2].destinationId;
@ -196,12 +198,13 @@ export function copyToSpaceTestSuiteFactory(
successCount: 5, successCount: 5,
successResults: [ successResults: [
{ {
id: 'cts_ip_1', id: `cts_ip_1_${spaceId}`,
type: 'index-pattern', type: 'index-pattern',
meta: { meta: {
icon: 'indexPatternApp', icon: 'indexPatternApp',
title: `Copy to Space index pattern 1 from ${spaceId} space`, title: `Copy to Space index pattern 1 from ${spaceId} space`,
}, },
destinationId: indexPatternDestinationId,
}, },
{ {
id: `cts_vis_1_${spaceId}`, id: `cts_vis_1_${spaceId}`,
@ -321,13 +324,14 @@ export function copyToSpaceTestSuiteFactory(
successCount: 5, successCount: 5,
successResults: [ successResults: [
{ {
id: 'cts_ip_1', id: `cts_ip_1_${spaceId}`,
type: 'index-pattern', type: 'index-pattern',
meta: { meta: {
icon: 'indexPatternApp', icon: 'indexPatternApp',
title: `Copy to Space index pattern 1 from ${spaceId} space`, title: `Copy to Space index pattern 1 from ${spaceId} space`,
}, },
overwrite: true, overwrite: true,
destinationId: `cts_ip_1_${destination}`, // this conflicted with another index pattern in the destination space because of a shared originId
}, },
{ {
id: `cts_vis_1_${spaceId}`, id: `cts_vis_1_${spaceId}`,
@ -409,8 +413,11 @@ export function copyToSpaceTestSuiteFactory(
}, },
}, },
{ {
error: { type: 'conflict' }, error: {
id: 'cts_ip_1', type: 'conflict',
destinationId: `cts_ip_1_${destination}`, // this conflicted with another index pattern in the destination space because of a shared originId
},
id: `cts_ip_1_${spaceId}`,
title: `Copy to Space index pattern 1 from ${spaceId} space`, title: `Copy to Space index pattern 1 from ${spaceId} space`,
type: 'index-pattern', type: 'index-pattern',
meta: { meta: {

View file

@ -82,8 +82,18 @@ export function resolveCopyToSpaceConflictsSuite(
expect(result).to.eql({ expect(result).to.eql({
[destination]: { [destination]: {
success: true, success: true,
successCount: 1, successCount: 2,
successResults: [ successResults: [
{
id: `cts_ip_1_${sourceSpaceId}`,
type: 'index-pattern',
meta: {
title: `Copy to Space index pattern 1 from ${sourceSpaceId} space`,
icon: 'indexPatternApp',
},
destinationId: `cts_ip_1_${destination}`, // this conflicted with another index pattern in the destination space because of a shared originId
overwrite: true,
},
{ {
id: `cts_vis_3_${sourceSpaceId}`, id: `cts_vis_3_${sourceSpaceId}`,
type: 'visualization', type: 'visualization',
@ -146,6 +156,19 @@ export function resolveCopyToSpaceConflictsSuite(
success: false, success: false,
successCount: 0, successCount: 0,
errors: [ errors: [
{
error: {
type: 'conflict',
destinationId: `cts_ip_1_${destination}`, // this conflicted with another index pattern in the destination space because of a shared originId
},
id: `cts_ip_1_${sourceSpaceId}`,
title: `Copy to Space index pattern 1 from ${sourceSpaceId} space`,
meta: {
title: `Copy to Space index pattern 1 from ${sourceSpaceId} space`,
icon: 'indexPatternApp',
},
type: 'index-pattern',
},
{ {
error: { error: {
type: 'conflict', type: 'conflict',
@ -231,35 +254,7 @@ export function resolveCopyToSpaceConflictsSuite(
{ {
statusCode: 403, statusCode: 403,
error: 'Forbidden', error: 'Forbidden',
message: 'Unable to bulk_get index-pattern', message: 'Unable to bulk_create index-pattern,visualization',
},
],
},
} as CopyResponse);
// Query ES to ensure that nothing was copied
const [dashboard, visualization] = await getObjectsAtSpace(destination);
expect(dashboard.attributes.title).to.eql(
`This is the ${destination} test space CTS dashboard`
);
expect(visualization.attributes.title).to.eql(`CTS vis 3 from ${destination} space`);
};
const createExpectReadonlyAtSpaceWithReferencesResult =
(spaceId: string = DEFAULT_SPACE_ID) =>
async (resp: TestResponse) => {
const destination = getDestinationSpace(spaceId);
const result = resp.body as CopyResponse;
expect(result).to.eql({
[destination]: {
success: false,
successCount: 0,
errors: [
{
statusCode: 403,
error: 'Forbidden',
message: 'Unable to bulk_create visualization',
}, },
], ],
}, },
@ -449,6 +444,7 @@ export function resolveCopyToSpaceConflictsSuite(
const dashboardObject = { type: 'dashboard', id: 'cts_dashboard' }; const dashboardObject = { type: 'dashboard', id: 'cts_dashboard' };
const visualizationObject = { type: 'visualization', id: `cts_vis_3_${spaceId}` }; const visualizationObject = { type: 'visualization', id: `cts_vis_3_${spaceId}` };
const indexPatternObject = { type: 'index-pattern', id: `cts_ip_1_${spaceId}` };
it(`should return ${tests.withReferencesNotOverwriting.statusCode} when not overwriting, with references`, async () => { it(`should return ${tests.withReferencesNotOverwriting.statusCode} when not overwriting, with references`, async () => {
const destination = getDestinationSpace(spaceId); const destination = getDestinationSpace(spaceId);
@ -462,6 +458,11 @@ export function resolveCopyToSpaceConflictsSuite(
createNewCopies: false, createNewCopies: false,
retries: { retries: {
[destination]: [ [destination]: [
{
...indexPatternObject,
destinationId: `cts_ip_1_${destination}`,
overwrite: false,
},
{ {
...visualizationObject, ...visualizationObject,
destinationId: `cts_vis_3_${destination}`, destinationId: `cts_vis_3_${destination}`,
@ -486,6 +487,11 @@ export function resolveCopyToSpaceConflictsSuite(
createNewCopies: false, createNewCopies: false,
retries: { retries: {
[destination]: [ [destination]: [
{
...indexPatternObject,
destinationId: `cts_ip_1_${destination}`,
overwrite: true,
},
{ {
...visualizationObject, ...visualizationObject,
destinationId: `cts_vis_3_${destination}`, destinationId: `cts_vis_3_${destination}`,
@ -589,7 +595,6 @@ export function resolveCopyToSpaceConflictsSuite(
createExpectNonOverriddenResponseWithReferences, createExpectNonOverriddenResponseWithReferences,
createExpectNonOverriddenResponseWithoutReferences, createExpectNonOverriddenResponseWithoutReferences,
createExpectUnauthorizedAtSpaceWithReferencesResult, createExpectUnauthorizedAtSpaceWithReferencesResult,
createExpectReadonlyAtSpaceWithReferencesResult,
createExpectUnauthorizedAtSpaceWithoutReferencesResult, createExpectUnauthorizedAtSpaceWithoutReferencesResult,
createMultiNamespaceTestCases, createMultiNamespaceTestCases,
originSpaces: ['default', 'space_1'], originSpaces: ['default', 'space_1'],

View file

@ -24,7 +24,6 @@ export default function resolveCopyToSpaceConflictsTestSuite({ getService }: Ftr
createExpectOverriddenResponseWithoutReferences, createExpectOverriddenResponseWithoutReferences,
expectRouteForbiddenResponse, expectRouteForbiddenResponse,
createExpectUnauthorizedAtSpaceWithReferencesResult, createExpectUnauthorizedAtSpaceWithReferencesResult,
createExpectReadonlyAtSpaceWithReferencesResult,
createExpectUnauthorizedAtSpaceWithoutReferencesResult, createExpectUnauthorizedAtSpaceWithoutReferencesResult,
createMultiNamespaceTestCases, createMultiNamespaceTestCases,
NON_EXISTENT_SPACE_ID, NON_EXISTENT_SPACE_ID,
@ -122,11 +121,11 @@ export default function resolveCopyToSpaceConflictsTestSuite({ getService }: Ftr
tests: { tests: {
withReferencesNotOverwriting: { withReferencesNotOverwriting: {
statusCode: 200, statusCode: 200,
response: createExpectReadonlyAtSpaceWithReferencesResult(spaceId), response: createExpectUnauthorizedAtSpaceWithReferencesResult(spaceId),
}, },
withReferencesOverwriting: { withReferencesOverwriting: {
statusCode: 200, statusCode: 200,
response: createExpectReadonlyAtSpaceWithReferencesResult(spaceId), response: createExpectUnauthorizedAtSpaceWithReferencesResult(spaceId),
}, },
withoutReferencesOverwriting: { withoutReferencesOverwriting: {
statusCode: 200, statusCode: 200,