@itwin/core-backend 5.12.0-dev.12 → 5.12.0-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,7 +37,7 @@ async function assertThrowsAsync(test, msg) {
|
|
|
37
37
|
}
|
|
38
38
|
throw new Error(`Failed to throw error with message: "${msg}"`);
|
|
39
39
|
}
|
|
40
|
-
describe
|
|
40
|
+
describe("Merge conflict & locking", () => {
|
|
41
41
|
let iTwinId;
|
|
42
42
|
before(() => {
|
|
43
43
|
HubMock.startup("MergeConflictTest", KnownTestLocations.outputDir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MergeConflict.test.js","sourceRoot":"","sources":["../../../../src/test/standalone/MergeConflict.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAG/F,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAEL,MAAM,EACN,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,cAAc,EAGd,eAAe,GAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnE,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACzB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,GAAY,EAAE,MAAmB;IAC/E,MAAM,QAAQ,GAAG,GAAG,C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,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { GuidString, Id64String } from \"@itwin/core-bentley\";\nimport { EditTxn, withEditTxn } from \"../../EditTxn\";\nimport {\n ElementAspectProps,\n IModel,\n SubCategoryAppearance,\n} from \"@itwin/core-common\";\nimport * as chai from \"chai\";\nimport { assert, expect } from \"chai\";\nimport * as chaiAsPromised from \"chai-as-promised\";\nimport { HubWrappers, KnownTestLocations } from \"../\";\nimport { HubMock } from \"../../internal/HubMock\";\nimport {\n BriefcaseDb,\n ChannelControl,\n DictionaryModel,\n ExternalSourceAspect,\n SpatialCategory,\n SqliteChangeOp,\n} from \"../../core-backend\";\nimport { IModelTestUtils, TestUserType } from \"../IModelTestUtils\";\nimport { RebaseChangesetConflictArgs, SqliteConflictCause } from \"../../internal/ChangesetConflictArgs\";\nchai.use(chaiAsPromised);\nimport * as sinon from \"sinon\";\n\nexport async function createNewModelAndCategory(txn: EditTxn, parent?: Id64String) {\n const rwIModel = txn.iModel as BriefcaseDb;\n // Create a new physical model.\n const [, modelId] = await IModelTestUtils.createAndInsertPhysicalPartitionAndModelAsync(txn, IModelTestUtils.getUniqueModelCode(rwIModel, \"newPhysicalModel\"), true, parent);\n\n // Find or create a SpatialCategory.\n const dictionary: DictionaryModel = rwIModel.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n const category = SpatialCategory.create(rwIModel, IModel.dictionaryId, newCategoryCode.value);\n const spatialCategoryId = txn.insertElement(category.toJSON());\n category.setDefaultAppearance(txn, new SubCategoryAppearance({ color: 0xff0000 }));\n\n return { modelId, spatialCategoryId };\n}\n\nasync function assertThrowsAsync<T>(test: () => Promise<T>, msg?: string) {\n try {\n await test();\n } catch (e) {\n if (e instanceof Error && msg) {\n assert.equal(e.message, msg);\n }\n return;\n }\n throw new Error(`Failed to throw error with message: \"${msg}\"`);\n}\n\ndescribe.skip(\"Merge conflict & locking\", () => { // ###TODO FLAKY https://github.com/iTwin/itwinjs-core/issues/7730\n let iTwinId: GuidString;\n\n before(() => {\n HubMock.startup(\"MergeConflictTest\", KnownTestLocations.outputDir);\n iTwinId = HubMock.iTwinId;\n });\n after(() => HubMock.shutdown());\n\n it(\"pull/merge causing update conflict - dirty read/modify (with no lock)\", async () => {\n /**\n * To simulate a a data conflict for dirty read we update same aspect from two different briefcases\n * and when the second briefcase try to push its changes it will fail with following error.\n * \"UPDATE/DELETE before value do not match with one in db or CASCADE action was triggered.\"\n */\n const accessToken1 = await HubWrappers.getAccessToken(TestUserType.SuperManager);\n const accessToken2 = await HubWrappers.getAccessToken(TestUserType.Regular);\n const accessToken3 = await HubWrappers.getAccessToken(TestUserType.Super);\n\n // Delete any existing iModels with the same name as the read-write test iModel\n const iModelName = \"TestIModel\";\n\n // Create a new empty iModel on the Hub & obtain a briefcase\n const rwIModelId = await HubMock.createNewIModel({ accessToken: accessToken1, iTwinId, iModelName, description: \"TestSubject\", noLocks: undefined });\n assert.isNotEmpty(rwIModelId);\n\n // to reproduce the issue we will disable locks altogether.\n const b1 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken1, iTwinId, iModelId: rwIModelId, noLock: true });\n b1.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b2 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken2, iTwinId, iModelId: rwIModelId, noLock: true });\n b2.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b3 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken3, iTwinId, iModelId: rwIModelId, noLock: true });\n const b1Txn = new EditTxn(b1, \"merge conflict\");\n b1Txn.start();\n const b2Txn = new EditTxn(b2, \"merge conflict\");\n b2Txn.start();\n\n // create and insert a new model with code1\n const [, modelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(\n b1Txn,\n IModelTestUtils.getUniqueModelCode(b1, \"newPhysicalModel\"),\n true);\n\n const dictionary: DictionaryModel = b1.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n\n const spatialCategoryId = SpatialCategory.insert(\n b1Txn,\n dictionary.id,\n newCategoryCode.value,\n new SubCategoryAppearance({ color: 0xff0000 }),\n );\n\n // insert element and aspect\n const el1 = b1Txn.insertElement(IModelTestUtils.createPhysicalObject(b1, modelId, spatialCategoryId).toJSON());\n await b1.pullChanges();\n const aspectId1 = b1Txn.insertAspect({\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier\",\n } as ElementAspectProps);\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `inserted element with aspect ${el1}` });\n\n // b1 same as b2 and now both will modify same aspect\n await b2.pullChanges();\n\n // b1 will change identifier from \"test identifier\" to \"test identifier (modified by b1)\"\n b1Txn.updateAspect({\n id: aspectId1,\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier (modified by b1)\",\n } as ElementAspectProps);\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `modify aspect ${aspectId1} with no lock` });\n\n // b2 will change identifier from \"test identifier\" to \"test identifier (modified by b2)\"\n b2Txn.updateAspect({\n id: aspectId1,\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier (modified by b2)\",\n } as ElementAspectProps);\n b2Txn.saveChanges();\n\n const conflicts: {\n cause: SqliteConflictCause,\n tableName: string,\n opcode?: SqliteChangeOp,\n id: Id64String,\n }[] = [];\n\n // we will not handle conflict and let the default conflict handler deal with it.\n b2.txns.rebaser.addConflictHandler({\n id: \"custom\", handler: (arg: RebaseChangesetConflictArgs) => {\n conflicts.push({\n cause: arg.cause,\n tableName: arg.tableName,\n opcode: arg.opcode,\n id: arg.getValueId(0, arg.opcode === \"Inserted\" ? \"New\" : \"Old\") as Id64String,\n });\n return undefined;\n }\n });\n\n await b2.pushChanges({ accessToken: accessToken1, description: `modify aspect ${aspectId1} with no lock` });\n\n expect(conflicts.length).to.be.equals(3);\n\n chai.expect(\n [\n {\n \"cause\": \"Data\",\n \"tableName\": \"bis_Element\",\n \"opcode\": \"Updated\",\n \"id\": \"0x20000000004\"\n },\n {\n \"cause\": \"Data\",\n \"tableName\": \"bis_ElementMultiAspect\",\n \"opcode\": \"Updated\",\n \"id\": \"0x20000000001\"\n },\n {\n \"cause\": \"Data\",\n \"tableName\": \"bis_Model\",\n \"opcode\": \"Updated\",\n \"id\": \"0x20000000001\"\n }\n ]).to.be.deep.equals(conflicts);\n\n await b3.pullChanges();\n await b1.pullChanges();\n\n // b2 win as default conflict handler choose Replace to override local changes over master.\n (b2.elements.getAspect(aspectId1) as ExternalSourceAspect).identifier = \"test identifier (modified by b2)\";\n (b3.elements.getAspect(aspectId1) as ExternalSourceAspect).identifier = \"test identifier (modified by b2)\";\n (b1.elements.getAspect(aspectId1) as ExternalSourceAspect).identifier = \"test identifier (modified by b2)\";\n\n b1.close();\n b2.close();\n b3.close();\n });\n it(\"pull/merge causing update conflict - update causing local changes (with no lock)\", async () => {\n /**\n * To simulate a a data conflict for dirty read we update same aspect from two different briefcases\n * and when the second briefcase try to push its changes it will fail with following error.\n * \"UPDATE/DELETE before value do not match with one in db or CASCADE action was triggered.\"\n */\n const accessToken1 = await HubWrappers.getAccessToken(TestUserType.SuperManager);\n const accessToken2 = await HubWrappers.getAccessToken(TestUserType.Regular);\n const accessToken3 = await HubWrappers.getAccessToken(TestUserType.Super);\n\n // Delete any existing iModels with the same name as the read-write test iModel\n const iModelName = \"TestIModel\";\n\n // Create a new empty iModel on the Hub & obtain a briefcase\n const rwIModelId = await HubMock.createNewIModel({ accessToken: accessToken1, iTwinId, iModelName, description: \"TestSubject\", noLocks: undefined });\n assert.isNotEmpty(rwIModelId);\n\n // to reproduce the issue we will disable locks altogether.\n const b1 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken1, iTwinId, iModelId: rwIModelId, noLock: true });\n b1.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b2 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken2, iTwinId, iModelId: rwIModelId, noLock: true });\n b2.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b3 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken3, iTwinId, iModelId: rwIModelId, noLock: true });\n const b1Txn = new EditTxn(b1, \"merge conflict\");\n b1Txn.start();\n const b2Txn = new EditTxn(b2, \"merge conflict\");\n b2Txn.start();\n\n // create and insert a new model with code1\n const [, modelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(\n b1Txn,\n IModelTestUtils.getUniqueModelCode(b1, \"newPhysicalModel\"),\n true);\n\n const dictionary: DictionaryModel = b1.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n\n const spatialCategoryId = SpatialCategory.insert(\n b1Txn,\n dictionary.id,\n newCategoryCode.value,\n new SubCategoryAppearance({ color: 0xff0000 }),\n );\n\n // insert element and aspect\n const el1 = b1Txn.insertElement(IModelTestUtils.createPhysicalObject(b1, modelId, spatialCategoryId).toJSON());\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `inserted element with aspect ${el1}` });\n\n await b2.pullChanges();\n const aspectId1 = b2Txn.insertAspect({\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier\",\n } as ElementAspectProps);\n b2Txn.saveChanges();\n\n b1Txn.deleteElement(el1);\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `deleted element ${el1}` });\n\n const conflicts: {\n cause: SqliteConflictCause,\n tableName: string,\n opcode?: SqliteChangeOp,\n id: Id64String | undefined,\n }[] = [];\n\n // we will not handle conflict and let the default conflict handler deal with it.\n b2.txns.rebaser.addConflictHandler({\n id: \"custom\", handler: (arg: RebaseChangesetConflictArgs) => {\n let id;\n if (arg.cause !== \"ForeignKey\") {\n id = arg.getValueId(0, arg.opcode === \"Inserted\" ? \"New\" : \"Old\") as Id64String;\n }\n conflicts.push({\n cause: arg.cause,\n tableName: arg.tableName,\n opcode: arg.opcode,\n id,\n });\n return undefined;\n }\n });\n\n\n await assertThrowsAsync(\n async () => b2.pushChanges({ accessToken: accessToken1, description: `inserted element with aspect ${el1}` }),\n \"Foreign key conflicts in ChangeSet. Aborting rebase.\");\n\n expect(conflicts.length).to.be.equals(3);\n expect(conflicts).to.deep.equal([\n {\n cause: \"NotFound\",\n tableName: \"bis_Element\",\n opcode: \"Updated\",\n id: \"0x20000000004\"\n },\n {\n cause: \"Data\",\n tableName: \"bis_Model\",\n opcode: \"Updated\",\n id: \"0x20000000001\"\n },\n {\n cause: \"ForeignKey\",\n tableName: \"\",\n opcode: undefined,\n id: undefined\n }\n ]);\n\n b2.txns.rebaser.addConflictHandler({\n id: \"delete_aspect_when_element_is_deleted\", handler: (arg: RebaseChangesetConflictArgs) => {\n if (arg.cause === \"NotFound\" && arg.tableName === \"bis_Element\") {\n // if element does not exist any more let delete the aspects as well.\n const elId = arg.getValueId(0, arg.opcode === \"Inserted\" ? \"New\" : \"Old\") as Id64String;\n withEditTxn(b2, (txn) => {\n b2.elements.getAspects(elId).forEach((aspect) => {\n txn.deleteAspect(aspect.id);\n });\n });\n }\n return undefined;\n }\n });\n\n b2Txn.saveChanges();\n conflicts.length = 0;\n\n await b2.pushChanges({ accessToken: accessToken1, description: `nothing is pushed as the only change we made is reverted` });\n await b3.pullChanges();\n await b1.pullChanges();\n\n expect(() => b1.elements.getElement(el1)).throws(`Element=${el1}`);\n expect(() => b2.elements.getElement(el1)).throws(`Element=${el1}`);\n expect(() => b3.elements.getElement(el1)).throws(`Element=${el1}`);\n\n expect(() => b1.elements.getAspect(aspectId1)).throws(`ElementAspect not found ${aspectId1}`);\n expect(() => b2.elements.getAspect(aspectId1)).throws(`ElementAspect not found ${aspectId1}`);\n expect(() => b3.elements.getAspect(aspectId1)).throws(`ElementAspect not found ${aspectId1}`);\n\n b1.close();\n b2.close();\n b3.close();\n });\n\n it(\"aspect insert, update & delete requires exclusive lock\", async () => {\n const accessToken1 = await HubWrappers.getAccessToken(TestUserType.SuperManager);\n const accessToken2 = await HubWrappers.getAccessToken(TestUserType.Regular);\n const accessToken3 = await HubWrappers.getAccessToken(TestUserType.Super);\n\n // Delete any existing iModels with the same name as the read-write test iModel\n const iModelName = \"TestIModel\";\n\n // Create a new empty iModel on the Hub & obtain a briefcase\n const rwIModelId = await HubMock.createNewIModel({ accessToken: accessToken1, iTwinId, iModelName, description: \"TestSubject\", noLocks: undefined });\n assert.isNotEmpty(rwIModelId);\n\n const b1 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken1, iTwinId, iModelId: rwIModelId });\n b1.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b2 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken2, iTwinId, iModelId: rwIModelId });\n b2.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b3 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken3, iTwinId, iModelId: rwIModelId });\n const b1Txn = new EditTxn(b1, \"merge conflict\");\n b1Txn.start();\n const b2Txn = new EditTxn(b2, \"merge conflict\");\n b2Txn.start();\n\n await b1.locks.acquireLocks({ shared: IModel.repositoryModelId });\n await b2.locks.acquireLocks({ shared: IModel.repositoryModelId });\n\n // create and insert a new model with code1\n const [, modelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(\n b1Txn,\n IModelTestUtils.getUniqueModelCode(b1, \"newPhysicalModel\"),\n true);\n\n const dictionary: DictionaryModel = b1.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n\n await b1.locks.acquireLocks({ shared: dictionary.id });\n const spatialCategoryId = SpatialCategory.insert(\n b1Txn,\n dictionary.id,\n newCategoryCode.value,\n new SubCategoryAppearance({ color: 0xff0000 }),\n );\n const el1 = b1Txn.insertElement(IModelTestUtils.createPhysicalObject(b1, modelId, spatialCategoryId).toJSON());\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `inserted element ${el1}` });\n\n await b2.pullChanges();\n let aspectId: Id64String;\n const insertAspectIntoB2 = () => {\n aspectId = b2Txn.insertAspect({\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier\",\n } as ElementAspectProps);\n };\n\n /* attempt to insert aspect without a lock */\n assert.throws(insertAspectIntoB2, \"Error inserting ElementAspect [exclusive lock not held on element for insert aspect (id=0x20000000004)], class: BisCore:ExternalSourceAspect\");\n\n /* acquire lock and try again */\n await b2.locks.acquireLocks({ exclusive: el1 });\n insertAspectIntoB2();\n\n /* b1 cannot acquire lock on el1 as its already taken by b2 */\n await expect(b1.locks.acquireLocks({ exclusive: el1 })).to.be.rejectedWith(\"exclusive lock is already held\");\n\n /* push changes on b2 to release lock on el1 */\n b2Txn.saveChanges();\n await b2.pushChanges({ accessToken: accessToken2, description: `add aspect to element ${el1}` });\n\n await b1.pullChanges();\n\n const updateAspectIntoB1 = () => {\n b1Txn.updateAspect({\n id: aspectId,\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier (modified)\",\n } as ElementAspectProps);\n };\n\n /* attempt to update aspect without a lock */\n assert.throws(updateAspectIntoB1, \"Error updating ElementAspect [exclusive lock not held on element for update aspect (id=0x20000000004)], id: 0x30000000001\");\n\n /* acquire lock and try again */\n await b1.locks.acquireLocks({ exclusive: el1 });\n updateAspectIntoB1();\n\n /* delete the element */\n b1Txn.deleteElement(el1);\n b1Txn.saveChanges();\n\n await b1.pushChanges({ accessToken: accessToken1, description: `deleted element ${el1}` });\n\n const onChangesetConflictStub = sinon.stub(BriefcaseDb.prototype, \"onChangesetConflict\" as any);\n /* we should be able to apply all changesets */\n await b3.pullChanges();\n expect(onChangesetConflictStub.callCount).eq(0, \"native conflict handler should not be called BriefcaseDb.onChangesetConflict()\");\n onChangesetConflictStub.restore();\n b1.close();\n b2.close();\n b3.close();\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"MergeConflict.test.js","sourceRoot":"","sources":["../../../../src/test/standalone/MergeConflict.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAG/F,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAEL,MAAM,EACN,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,cAAc,EAGd,eAAe,GAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnE,IAAI,CAA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AO,EAAE,CAAC;QAClC,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { GuidString, Id64String } from \"@itwin/core-bentley\";\nimport { EditTxn, withEditTxn } from \"../../EditTxn\";\nimport {\n ElementAspectProps,\n IModel,\n SubCategoryAppearance,\n} from \"@itwin/core-common\";\nimport * as chai from \"chai\";\nimport { assert, expect } from \"chai\";\nimport * as chaiAsPromised from \"chai-as-promised\";\nimport { HubWrappers, KnownTestLocations } from \"../\";\nimport { HubMock } from \"../../internal/HubMock\";\nimport {\n BriefcaseDb,\n ChannelControl,\n DictionaryModel,\n ExternalSourceAspect,\n SpatialCategory,\n SqliteChangeOp,\n} from \"../../core-backend\";\nimport { IModelTestUtils, TestUserType } from \"../IModelTestUtils\";\nimport { RebaseChangesetConflictArgs, SqliteConflictCause } from \"../../internal/ChangesetConflictArgs\";\nchai.use(chaiAsPromised);\nimport * as sinon from \"sinon\";\n\nexport async function createNewModelAndCategory(txn: EditTxn, parent?: Id64String) {\n const rwIModel = txn.iModel as BriefcaseDb;\n // Create a new physical model.\n const [, modelId] = await IModelTestUtils.createAndInsertPhysicalPartitionAndModelAsync(txn, IModelTestUtils.getUniqueModelCode(rwIModel, \"newPhysicalModel\"), true, parent);\n\n // Find or create a SpatialCategory.\n const dictionary: DictionaryModel = rwIModel.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n const category = SpatialCategory.create(rwIModel, IModel.dictionaryId, newCategoryCode.value);\n const spatialCategoryId = txn.insertElement(category.toJSON());\n category.setDefaultAppearance(txn, new SubCategoryAppearance({ color: 0xff0000 }));\n\n return { modelId, spatialCategoryId };\n}\n\nasync function assertThrowsAsync<T>(test: () => Promise<T>, msg?: string) {\n try {\n await test();\n } catch (e) {\n if (e instanceof Error && msg) {\n assert.equal(e.message, msg);\n }\n return;\n }\n throw new Error(`Failed to throw error with message: \"${msg}\"`);\n}\n\ndescribe(\"Merge conflict & locking\", () => { \n let iTwinId: GuidString;\n\n before(() => {\n HubMock.startup(\"MergeConflictTest\", KnownTestLocations.outputDir);\n iTwinId = HubMock.iTwinId;\n });\n after(() => HubMock.shutdown());\n\n it(\"pull/merge causing update conflict - dirty read/modify (with no lock)\", async () => {\n /**\n * To simulate a a data conflict for dirty read we update same aspect from two different briefcases\n * and when the second briefcase try to push its changes it will fail with following error.\n * \"UPDATE/DELETE before value do not match with one in db or CASCADE action was triggered.\"\n */\n const accessToken1 = await HubWrappers.getAccessToken(TestUserType.SuperManager);\n const accessToken2 = await HubWrappers.getAccessToken(TestUserType.Regular);\n const accessToken3 = await HubWrappers.getAccessToken(TestUserType.Super);\n\n // Delete any existing iModels with the same name as the read-write test iModel\n const iModelName = \"TestIModel\";\n\n // Create a new empty iModel on the Hub & obtain a briefcase\n const rwIModelId = await HubMock.createNewIModel({ accessToken: accessToken1, iTwinId, iModelName, description: \"TestSubject\", noLocks: undefined });\n assert.isNotEmpty(rwIModelId);\n\n // to reproduce the issue we will disable locks altogether.\n const b1 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken1, iTwinId, iModelId: rwIModelId, noLock: true });\n b1.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b2 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken2, iTwinId, iModelId: rwIModelId, noLock: true });\n b2.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b3 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken3, iTwinId, iModelId: rwIModelId, noLock: true });\n const b1Txn = new EditTxn(b1, \"merge conflict\");\n b1Txn.start();\n const b2Txn = new EditTxn(b2, \"merge conflict\");\n b2Txn.start();\n\n // create and insert a new model with code1\n const [, modelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(\n b1Txn,\n IModelTestUtils.getUniqueModelCode(b1, \"newPhysicalModel\"),\n true);\n\n const dictionary: DictionaryModel = b1.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n\n const spatialCategoryId = SpatialCategory.insert(\n b1Txn,\n dictionary.id,\n newCategoryCode.value,\n new SubCategoryAppearance({ color: 0xff0000 }),\n );\n\n // insert element and aspect\n const el1 = b1Txn.insertElement(IModelTestUtils.createPhysicalObject(b1, modelId, spatialCategoryId).toJSON());\n await b1.pullChanges();\n const aspectId1 = b1Txn.insertAspect({\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier\",\n } as ElementAspectProps);\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `inserted element with aspect ${el1}` });\n\n // b1 same as b2 and now both will modify same aspect\n await b2.pullChanges();\n\n // b1 will change identifier from \"test identifier\" to \"test identifier (modified by b1)\"\n b1Txn.updateAspect({\n id: aspectId1,\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier (modified by b1)\",\n } as ElementAspectProps);\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `modify aspect ${aspectId1} with no lock` });\n\n // b2 will change identifier from \"test identifier\" to \"test identifier (modified by b2)\"\n b2Txn.updateAspect({\n id: aspectId1,\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier (modified by b2)\",\n } as ElementAspectProps);\n b2Txn.saveChanges();\n\n const conflicts: {\n cause: SqliteConflictCause,\n tableName: string,\n opcode?: SqliteChangeOp,\n id: Id64String,\n }[] = [];\n\n // we will not handle conflict and let the default conflict handler deal with it.\n b2.txns.rebaser.addConflictHandler({\n id: \"custom\", handler: (arg: RebaseChangesetConflictArgs) => {\n conflicts.push({\n cause: arg.cause,\n tableName: arg.tableName,\n opcode: arg.opcode,\n id: arg.getValueId(0, arg.opcode === \"Inserted\" ? \"New\" : \"Old\") as Id64String,\n });\n return undefined;\n }\n });\n\n await b2.pushChanges({ accessToken: accessToken1, description: `modify aspect ${aspectId1} with no lock` });\n\n expect(conflicts.length).to.be.equals(3);\n\n chai.expect(\n [\n {\n \"cause\": \"Data\",\n \"tableName\": \"bis_Element\",\n \"opcode\": \"Updated\",\n \"id\": \"0x20000000004\"\n },\n {\n \"cause\": \"Data\",\n \"tableName\": \"bis_ElementMultiAspect\",\n \"opcode\": \"Updated\",\n \"id\": \"0x20000000001\"\n },\n {\n \"cause\": \"Data\",\n \"tableName\": \"bis_Model\",\n \"opcode\": \"Updated\",\n \"id\": \"0x20000000001\"\n }\n ]).to.be.deep.equals(conflicts);\n\n await b3.pullChanges();\n await b1.pullChanges();\n\n // b2 win as default conflict handler choose Replace to override local changes over master.\n (b2.elements.getAspect(aspectId1) as ExternalSourceAspect).identifier = \"test identifier (modified by b2)\";\n (b3.elements.getAspect(aspectId1) as ExternalSourceAspect).identifier = \"test identifier (modified by b2)\";\n (b1.elements.getAspect(aspectId1) as ExternalSourceAspect).identifier = \"test identifier (modified by b2)\";\n\n b1.close();\n b2.close();\n b3.close();\n });\n it(\"pull/merge causing update conflict - update causing local changes (with no lock)\", async () => {\n /**\n * To simulate a a data conflict for dirty read we update same aspect from two different briefcases\n * and when the second briefcase try to push its changes it will fail with following error.\n * \"UPDATE/DELETE before value do not match with one in db or CASCADE action was triggered.\"\n */\n const accessToken1 = await HubWrappers.getAccessToken(TestUserType.SuperManager);\n const accessToken2 = await HubWrappers.getAccessToken(TestUserType.Regular);\n const accessToken3 = await HubWrappers.getAccessToken(TestUserType.Super);\n\n // Delete any existing iModels with the same name as the read-write test iModel\n const iModelName = \"TestIModel\";\n\n // Create a new empty iModel on the Hub & obtain a briefcase\n const rwIModelId = await HubMock.createNewIModel({ accessToken: accessToken1, iTwinId, iModelName, description: \"TestSubject\", noLocks: undefined });\n assert.isNotEmpty(rwIModelId);\n\n // to reproduce the issue we will disable locks altogether.\n const b1 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken1, iTwinId, iModelId: rwIModelId, noLock: true });\n b1.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b2 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken2, iTwinId, iModelId: rwIModelId, noLock: true });\n b2.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b3 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken3, iTwinId, iModelId: rwIModelId, noLock: true });\n const b1Txn = new EditTxn(b1, \"merge conflict\");\n b1Txn.start();\n const b2Txn = new EditTxn(b2, \"merge conflict\");\n b2Txn.start();\n\n // create and insert a new model with code1\n const [, modelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(\n b1Txn,\n IModelTestUtils.getUniqueModelCode(b1, \"newPhysicalModel\"),\n true);\n\n const dictionary: DictionaryModel = b1.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n\n const spatialCategoryId = SpatialCategory.insert(\n b1Txn,\n dictionary.id,\n newCategoryCode.value,\n new SubCategoryAppearance({ color: 0xff0000 }),\n );\n\n // insert element and aspect\n const el1 = b1Txn.insertElement(IModelTestUtils.createPhysicalObject(b1, modelId, spatialCategoryId).toJSON());\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `inserted element with aspect ${el1}` });\n\n await b2.pullChanges();\n const aspectId1 = b2Txn.insertAspect({\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier\",\n } as ElementAspectProps);\n b2Txn.saveChanges();\n\n b1Txn.deleteElement(el1);\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `deleted element ${el1}` });\n\n const conflicts: {\n cause: SqliteConflictCause,\n tableName: string,\n opcode?: SqliteChangeOp,\n id: Id64String | undefined,\n }[] = [];\n\n // we will not handle conflict and let the default conflict handler deal with it.\n b2.txns.rebaser.addConflictHandler({\n id: \"custom\", handler: (arg: RebaseChangesetConflictArgs) => {\n let id;\n if (arg.cause !== \"ForeignKey\") {\n id = arg.getValueId(0, arg.opcode === \"Inserted\" ? \"New\" : \"Old\") as Id64String;\n }\n conflicts.push({\n cause: arg.cause,\n tableName: arg.tableName,\n opcode: arg.opcode,\n id,\n });\n return undefined;\n }\n });\n\n\n await assertThrowsAsync(\n async () => b2.pushChanges({ accessToken: accessToken1, description: `inserted element with aspect ${el1}` }),\n \"Foreign key conflicts in ChangeSet. Aborting rebase.\");\n\n expect(conflicts.length).to.be.equals(3);\n expect(conflicts).to.deep.equal([\n {\n cause: \"NotFound\",\n tableName: \"bis_Element\",\n opcode: \"Updated\",\n id: \"0x20000000004\"\n },\n {\n cause: \"Data\",\n tableName: \"bis_Model\",\n opcode: \"Updated\",\n id: \"0x20000000001\"\n },\n {\n cause: \"ForeignKey\",\n tableName: \"\",\n opcode: undefined,\n id: undefined\n }\n ]);\n\n b2.txns.rebaser.addConflictHandler({\n id: \"delete_aspect_when_element_is_deleted\", handler: (arg: RebaseChangesetConflictArgs) => {\n if (arg.cause === \"NotFound\" && arg.tableName === \"bis_Element\") {\n // if element does not exist any more let delete the aspects as well.\n const elId = arg.getValueId(0, arg.opcode === \"Inserted\" ? \"New\" : \"Old\") as Id64String;\n withEditTxn(b2, (txn) => {\n b2.elements.getAspects(elId).forEach((aspect) => {\n txn.deleteAspect(aspect.id);\n });\n });\n }\n return undefined;\n }\n });\n\n b2Txn.saveChanges();\n conflicts.length = 0;\n\n await b2.pushChanges({ accessToken: accessToken1, description: `nothing is pushed as the only change we made is reverted` });\n await b3.pullChanges();\n await b1.pullChanges();\n\n expect(() => b1.elements.getElement(el1)).throws(`Element=${el1}`);\n expect(() => b2.elements.getElement(el1)).throws(`Element=${el1}`);\n expect(() => b3.elements.getElement(el1)).throws(`Element=${el1}`);\n\n expect(() => b1.elements.getAspect(aspectId1)).throws(`ElementAspect not found ${aspectId1}`);\n expect(() => b2.elements.getAspect(aspectId1)).throws(`ElementAspect not found ${aspectId1}`);\n expect(() => b3.elements.getAspect(aspectId1)).throws(`ElementAspect not found ${aspectId1}`);\n\n b1.close();\n b2.close();\n b3.close();\n });\n\n it(\"aspect insert, update & delete requires exclusive lock\", async () => {\n const accessToken1 = await HubWrappers.getAccessToken(TestUserType.SuperManager);\n const accessToken2 = await HubWrappers.getAccessToken(TestUserType.Regular);\n const accessToken3 = await HubWrappers.getAccessToken(TestUserType.Super);\n\n // Delete any existing iModels with the same name as the read-write test iModel\n const iModelName = \"TestIModel\";\n\n // Create a new empty iModel on the Hub & obtain a briefcase\n const rwIModelId = await HubMock.createNewIModel({ accessToken: accessToken1, iTwinId, iModelName, description: \"TestSubject\", noLocks: undefined });\n assert.isNotEmpty(rwIModelId);\n\n const b1 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken1, iTwinId, iModelId: rwIModelId });\n b1.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b2 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken2, iTwinId, iModelId: rwIModelId });\n b2.channels.addAllowedChannel(ChannelControl.sharedChannelName);\n const b3 = await HubWrappers.downloadAndOpenBriefcase({ accessToken: accessToken3, iTwinId, iModelId: rwIModelId });\n const b1Txn = new EditTxn(b1, \"merge conflict\");\n b1Txn.start();\n const b2Txn = new EditTxn(b2, \"merge conflict\");\n b2Txn.start();\n\n await b1.locks.acquireLocks({ shared: IModel.repositoryModelId });\n await b2.locks.acquireLocks({ shared: IModel.repositoryModelId });\n\n // create and insert a new model with code1\n const [, modelId] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(\n b1Txn,\n IModelTestUtils.getUniqueModelCode(b1, \"newPhysicalModel\"),\n true);\n\n const dictionary: DictionaryModel = b1.models.getModel<DictionaryModel>(IModel.dictionaryId);\n const newCategoryCode = IModelTestUtils.getUniqueSpatialCategoryCode(dictionary, \"ThisTestSpatialCategory\");\n\n await b1.locks.acquireLocks({ shared: dictionary.id });\n const spatialCategoryId = SpatialCategory.insert(\n b1Txn,\n dictionary.id,\n newCategoryCode.value,\n new SubCategoryAppearance({ color: 0xff0000 }),\n );\n const el1 = b1Txn.insertElement(IModelTestUtils.createPhysicalObject(b1, modelId, spatialCategoryId).toJSON());\n b1Txn.saveChanges();\n await b1.pushChanges({ accessToken: accessToken1, description: `inserted element ${el1}` });\n\n await b2.pullChanges();\n let aspectId: Id64String;\n const insertAspectIntoB2 = () => {\n aspectId = b2Txn.insertAspect({\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier\",\n } as ElementAspectProps);\n };\n\n /* attempt to insert aspect without a lock */\n assert.throws(insertAspectIntoB2, \"Error inserting ElementAspect [exclusive lock not held on element for insert aspect (id=0x20000000004)], class: BisCore:ExternalSourceAspect\");\n\n /* acquire lock and try again */\n await b2.locks.acquireLocks({ exclusive: el1 });\n insertAspectIntoB2();\n\n /* b1 cannot acquire lock on el1 as its already taken by b2 */\n await expect(b1.locks.acquireLocks({ exclusive: el1 })).to.be.rejectedWith(\"exclusive lock is already held\");\n\n /* push changes on b2 to release lock on el1 */\n b2Txn.saveChanges();\n await b2.pushChanges({ accessToken: accessToken2, description: `add aspect to element ${el1}` });\n\n await b1.pullChanges();\n\n const updateAspectIntoB1 = () => {\n b1Txn.updateAspect({\n id: aspectId,\n classFullName: \"BisCore:ExternalSourceAspect\",\n element: {\n relClassName: \"BisCore:ElementOwnsExternalSourceAspects\",\n id: el1,\n },\n kind: \"\",\n identifier: \"test identifier (modified)\",\n } as ElementAspectProps);\n };\n\n /* attempt to update aspect without a lock */\n assert.throws(updateAspectIntoB1, \"Error updating ElementAspect [exclusive lock not held on element for update aspect (id=0x20000000004)], id: 0x30000000001\");\n\n /* acquire lock and try again */\n await b1.locks.acquireLocks({ exclusive: el1 });\n updateAspectIntoB1();\n\n /* delete the element */\n b1Txn.deleteElement(el1);\n b1Txn.saveChanges();\n\n await b1.pushChanges({ accessToken: accessToken1, description: `deleted element ${el1}` });\n\n const onChangesetConflictStub = sinon.stub(BriefcaseDb.prototype, \"onChangesetConflict\" as any);\n /* we should be able to apply all changesets */\n await b3.pullChanges();\n expect(onChangesetConflictStub.callCount).eq(0, \"native conflict handler should not be called BriefcaseDb.onChangesetConflict()\");\n onChangesetConflictStub.restore();\n b1.close();\n b2.close();\n b3.close();\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-backend",
|
|
3
|
-
"version": "5.12.0-dev.
|
|
3
|
+
"version": "5.12.0-dev.13",
|
|
4
4
|
"description": "iTwin.js backend components",
|
|
5
5
|
"main": "lib/cjs/core-backend.js",
|
|
6
6
|
"module": "lib/esm/core-backend.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@opentelemetry/api": "^1.0.4",
|
|
30
|
-
"@itwin/core-
|
|
31
|
-
"@itwin/core-
|
|
32
|
-
"@itwin/
|
|
33
|
-
"@itwin/
|
|
30
|
+
"@itwin/core-common": "5.12.0-dev.13",
|
|
31
|
+
"@itwin/core-bentley": "5.12.0-dev.13",
|
|
32
|
+
"@itwin/core-geometry": "5.12.0-dev.13",
|
|
33
|
+
"@itwin/ecschema-metadata": "5.12.0-dev.13"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"@opentelemetry/api": {
|
|
@@ -77,17 +77,17 @@
|
|
|
77
77
|
"marked": "^14.1.3",
|
|
78
78
|
"sql-formatter": "^15.4.6",
|
|
79
79
|
"webpack": "^5.97.1",
|
|
80
|
-
"@itwin/
|
|
81
|
-
"@itwin/
|
|
80
|
+
"@itwin/build-tools": "5.12.0-dev.13",
|
|
81
|
+
"@itwin/ecschema-locaters": "5.12.0-dev.13",
|
|
82
|
+
"@itwin/core-bentley": "5.12.0-dev.13",
|
|
83
|
+
"@itwin/ecschema-metadata": "5.12.0-dev.13",
|
|
84
|
+
"@itwin/core-common": "5.12.0-dev.13",
|
|
82
85
|
"internal-tools": "3.0.0-dev.69",
|
|
83
|
-
"@itwin/
|
|
84
|
-
"@itwin/
|
|
85
|
-
"@itwin/core-common": "5.12.0-dev.12",
|
|
86
|
-
"@itwin/core-geometry": "5.12.0-dev.12",
|
|
87
|
-
"@itwin/ecschema-metadata": "5.12.0-dev.12"
|
|
86
|
+
"@itwin/ecsql-common": "5.12.0-dev.13",
|
|
87
|
+
"@itwin/core-geometry": "5.12.0-dev.13"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@bentley/imodeljs-native": "5.12.
|
|
90
|
+
"@bentley/imodeljs-native": "5.12.18",
|
|
91
91
|
"@itwin/object-storage-azure": "^3.0.4",
|
|
92
92
|
"@azure/storage-blob": "^12.28.0",
|
|
93
93
|
"form-data": "^4.0.6",
|