@itwin/core-backend 3.3.0-dev.3 → 3.3.0-dev.30
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.
- package/CHANGELOG.md +23 -1
- package/lib/cjs/HubMock.d.ts +99 -0
- package/lib/cjs/HubMock.d.ts.map +1 -0
- package/lib/cjs/HubMock.js +195 -0
- package/lib/cjs/HubMock.js.map +1 -0
- package/lib/cjs/IModelHost.d.ts +7 -2
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +6 -5
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts +161 -0
- package/lib/cjs/LocalHub.d.ts.map +1 -0
- package/lib/cjs/LocalHub.js +588 -0
- package/lib/cjs/LocalHub.js.map +1 -0
- package/lib/cjs/RpcBackend.d.ts +2 -0
- package/lib/cjs/RpcBackend.d.ts.map +1 -1
- package/lib/cjs/RpcBackend.js +19 -2
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +2 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +2 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/package.json +13 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
# Change Log - @itwin/core-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on Fri,
|
|
3
|
+
This log was last generated on Fri, 10 Jun 2022 16:11:36 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.2.2
|
|
6
|
+
Fri, 10 Jun 2022 16:11:36 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 3.2.1
|
|
11
|
+
Tue, 07 Jun 2022 15:02:56 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 3.2.0
|
|
16
|
+
Fri, 20 May 2022 13:10:54 GMT
|
|
17
|
+
|
|
18
|
+
### Updates
|
|
19
|
+
|
|
20
|
+
- Added new additionalTransformPath property to GeodeticDatums and tests
|
|
21
|
+
- changed name of GCS in test dataset
|
|
22
|
+
- Create an ios test project to run webpacked core tests.
|
|
23
|
+
- Added "getMassPropertiesPerCandidate" RPC operation to IModelReadRpcInterface which returns mass properties for each candidate separately.
|
|
24
|
+
- Add two new rpcimpls, hydrateViewState and getCustomViewState3dData
|
|
25
|
+
- add imodel import context state saving/loading functions for transformer
|
|
4
26
|
|
|
5
27
|
## 3.1.3
|
|
6
28
|
Fri, 15 Apr 2022 13:49:25 GMT
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { GuidString } from "@itwin/core-bentley";
|
|
2
|
+
import { ChangesetFileProps, ChangesetIndex, ChangesetIndexAndId, ChangesetProps, ChangesetRange, IModelVersion, LocalDirName } from "@itwin/core-common";
|
|
3
|
+
import { AcquireNewBriefcaseIdArg, BriefcaseDbArg, BriefcaseIdArg, ChangesetArg, ChangesetRangeArg, CheckpointArg, CreateNewIModelProps, IModelIdArg, IModelNameArg, LockMap, LockProps, V2CheckpointAccessProps } from "./BackendHubAccess";
|
|
4
|
+
import { CheckpointProps } from "./CheckpointManager";
|
|
5
|
+
import { LocalHub } from "./LocalHub";
|
|
6
|
+
/**
|
|
7
|
+
* Mocks iModelHub for testing creating Briefcases, downloading checkpoints, and simulating multiple users pushing and pulling changesets, etc.
|
|
8
|
+
*
|
|
9
|
+
* Generally, tests for apis that *create or modify* iModels can and should be mocked. Otherwise they:
|
|
10
|
+
* - create tremendous load on the test servers when they run on programmer's desktops and in CI jobs
|
|
11
|
+
* - waste network and data center resources (i.e. $$$s),
|
|
12
|
+
* - interfere with other tests running on the same or other systems, and
|
|
13
|
+
* - (far worse) are the source of test flakiness outside of the api being tested.
|
|
14
|
+
*
|
|
15
|
+
* This class can be used to create tests that do not require authentication, are synchronous,
|
|
16
|
+
* are guaranteed to be self-contained (i.e. do not interfere with other tests running at the same time or later), and do not fail for reasons outside
|
|
17
|
+
* of the control of the test itself. As a bonus, in addition to making tests more reliable, mocking IModelHub generally makes tests run *much* faster.
|
|
18
|
+
*
|
|
19
|
+
* On the other hand, tests that expect to find an existing iModels, checkpoints, changesets, etc. in IModelHub cannot be mocked. In that case, those tests
|
|
20
|
+
* should be careful to NOT modify the data, since doing so causes interference with other tests running simultaneously. These tests should be limited to
|
|
21
|
+
* low level testing of the core apis only.
|
|
22
|
+
*
|
|
23
|
+
* To initialize HubMock, call [[startup]] at the beginning of your test, usually in `describe.before`. Thereafter, all access to iModelHub for an iModel will be
|
|
24
|
+
* directed to a [[LocalHub]] - your test code does not change. After the test(s) complete, call [[shutdown]] (usually in `describe.after`) to stop mocking IModelHub and clean
|
|
25
|
+
* up any resources used by the test(s). If you want to mock a single test, call [[startup]] as the first line and [[shutdown]] as the last. If you wish to run the
|
|
26
|
+
* test against a "real" IModelHub, you can simply comment off the call [[startup]], though in that case you should make sure the name of your
|
|
27
|
+
* iModel is unique so your test won't collide with other tests (iModel name uniqueness is not necessary for mocked tests.)
|
|
28
|
+
*
|
|
29
|
+
* Mocked tests must always start by creating a new iModel via [[IModelHost.hubAccess.createNewIModel]] with a `version0` iModel.
|
|
30
|
+
* They use mock (aka "bogus") credentials for `AccessTokens`, which is fine since [[HubMock]] never accesses resources outside the current
|
|
31
|
+
* computer.
|
|
32
|
+
*
|
|
33
|
+
* @note Only one HubMock at a time, *running in a single process*, may be active. The comments above about multiple simultaneous tests refer to tests
|
|
34
|
+
* running on different computers, or on a single computer in multiple processes. All of those scenarios are problematic without mocking.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export declare class HubMock {
|
|
39
|
+
private static mockRoot;
|
|
40
|
+
private static hubs;
|
|
41
|
+
private static _saveHubAccess;
|
|
42
|
+
private static _iTwinId;
|
|
43
|
+
/** Determine whether a test us currently being run under HubMock */
|
|
44
|
+
static get isValid(): boolean;
|
|
45
|
+
static get iTwinId(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Begin mocking IModelHub access. After this call, all access to IModelHub will be directed to a [[LocalHub]].
|
|
48
|
+
* @param mockName a unique name (e.g. "MyTest") for this HubMock to disambiguate tests when more than one is simultaneously active.
|
|
49
|
+
* It is used to create a private directory used by the HubMock for a test. That directory is removed when [[shutdown]] is called.
|
|
50
|
+
*/
|
|
51
|
+
static startup(mockName: LocalDirName, outputDir: string): void;
|
|
52
|
+
/** Stop a HubMock that was previously started with [[startup]]
|
|
53
|
+
* @note this function throws an exception if any of the iModels used during the tests are left open.
|
|
54
|
+
*/
|
|
55
|
+
static shutdown(): void;
|
|
56
|
+
static findLocalHub(iModelId: GuidString): LocalHub;
|
|
57
|
+
/** create a [[LocalHub]] for an iModel. */
|
|
58
|
+
static createNewIModel(arg: CreateNewIModelProps): Promise<GuidString>;
|
|
59
|
+
/** remove the [[LocalHub]] for an iModel */
|
|
60
|
+
static destroy(iModelId: GuidString): void;
|
|
61
|
+
/** All methods below are mocks of the [[BackendHubAccess]] interface */
|
|
62
|
+
static getChangesetFromNamedVersion(arg: IModelIdArg & {
|
|
63
|
+
versionName: string;
|
|
64
|
+
}): Promise<ChangesetProps>;
|
|
65
|
+
private static changesetIndexFromArg;
|
|
66
|
+
static getChangesetFromVersion(arg: IModelIdArg & {
|
|
67
|
+
version: IModelVersion;
|
|
68
|
+
}): Promise<ChangesetProps>;
|
|
69
|
+
static getLatestChangeset(arg: IModelIdArg): Promise<ChangesetProps>;
|
|
70
|
+
private static getAccessToken;
|
|
71
|
+
static getMyBriefcaseIds(arg: IModelIdArg): Promise<number[]>;
|
|
72
|
+
static acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<number>;
|
|
73
|
+
/** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */
|
|
74
|
+
static releaseBriefcase(arg: BriefcaseIdArg): Promise<void>;
|
|
75
|
+
static downloadChangeset(arg: ChangesetArg & {
|
|
76
|
+
targetDir: LocalDirName;
|
|
77
|
+
}): Promise<ChangesetFileProps>;
|
|
78
|
+
static downloadChangesets(arg: ChangesetRangeArg & {
|
|
79
|
+
targetDir: LocalDirName;
|
|
80
|
+
}): Promise<ChangesetFileProps[]>;
|
|
81
|
+
static queryChangeset(arg: ChangesetArg): Promise<ChangesetProps>;
|
|
82
|
+
static queryChangesets(arg: IModelIdArg & {
|
|
83
|
+
range?: ChangesetRange;
|
|
84
|
+
}): Promise<ChangesetProps[]>;
|
|
85
|
+
static pushChangeset(arg: IModelIdArg & {
|
|
86
|
+
changesetProps: ChangesetFileProps;
|
|
87
|
+
}): Promise<ChangesetIndex>;
|
|
88
|
+
static queryV2Checkpoint(_arg: CheckpointProps): Promise<V2CheckpointAccessProps | undefined>;
|
|
89
|
+
static downloadV2Checkpoint(arg: CheckpointArg): Promise<ChangesetIndexAndId>;
|
|
90
|
+
static downloadV1Checkpoint(arg: CheckpointArg): Promise<ChangesetIndexAndId>;
|
|
91
|
+
static releaseAllLocks(arg: BriefcaseDbArg): Promise<void>;
|
|
92
|
+
static queryAllLocks(_arg: BriefcaseDbArg): Promise<LockProps[]>;
|
|
93
|
+
static acquireLocks(arg: BriefcaseDbArg, locks: LockMap): Promise<void>;
|
|
94
|
+
static queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined>;
|
|
95
|
+
static deleteIModel(arg: IModelIdArg & {
|
|
96
|
+
iTwinId: GuidString;
|
|
97
|
+
}): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=HubMock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HubMock.d.ts","sourceRoot":"","sources":["../../src/HubMock.ts"],"names":[],"mappings":"AAOA,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EACrH,MAAM,oBAAoB,CAAC;AAC5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E,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;WAStE,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG;QAAE,OAAO,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5F"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.HubMock = void 0;
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const sinon = require("sinon");
|
|
10
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
11
|
+
const IModelHost_1 = require("./IModelHost");
|
|
12
|
+
const IModelJsFs_1 = require("./IModelJsFs");
|
|
13
|
+
const LocalHub_1 = require("./LocalHub");
|
|
14
|
+
/**
|
|
15
|
+
* Mocks iModelHub for testing creating Briefcases, downloading checkpoints, and simulating multiple users pushing and pulling changesets, etc.
|
|
16
|
+
*
|
|
17
|
+
* Generally, tests for apis that *create or modify* iModels can and should be mocked. Otherwise they:
|
|
18
|
+
* - create tremendous load on the test servers when they run on programmer's desktops and in CI jobs
|
|
19
|
+
* - waste network and data center resources (i.e. $$$s),
|
|
20
|
+
* - interfere with other tests running on the same or other systems, and
|
|
21
|
+
* - (far worse) are the source of test flakiness outside of the api being tested.
|
|
22
|
+
*
|
|
23
|
+
* This class can be used to create tests that do not require authentication, are synchronous,
|
|
24
|
+
* are guaranteed to be self-contained (i.e. do not interfere with other tests running at the same time or later), and do not fail for reasons outside
|
|
25
|
+
* of the control of the test itself. As a bonus, in addition to making tests more reliable, mocking IModelHub generally makes tests run *much* faster.
|
|
26
|
+
*
|
|
27
|
+
* On the other hand, tests that expect to find an existing iModels, checkpoints, changesets, etc. in IModelHub cannot be mocked. In that case, those tests
|
|
28
|
+
* should be careful to NOT modify the data, since doing so causes interference with other tests running simultaneously. These tests should be limited to
|
|
29
|
+
* low level testing of the core apis only.
|
|
30
|
+
*
|
|
31
|
+
* To initialize HubMock, call [[startup]] at the beginning of your test, usually in `describe.before`. Thereafter, all access to iModelHub for an iModel will be
|
|
32
|
+
* directed to a [[LocalHub]] - your test code does not change. After the test(s) complete, call [[shutdown]] (usually in `describe.after`) to stop mocking IModelHub and clean
|
|
33
|
+
* up any resources used by the test(s). If you want to mock a single test, call [[startup]] as the first line and [[shutdown]] as the last. If you wish to run the
|
|
34
|
+
* test against a "real" IModelHub, you can simply comment off the call [[startup]], though in that case you should make sure the name of your
|
|
35
|
+
* iModel is unique so your test won't collide with other tests (iModel name uniqueness is not necessary for mocked tests.)
|
|
36
|
+
*
|
|
37
|
+
* Mocked tests must always start by creating a new iModel via [[IModelHost.hubAccess.createNewIModel]] with a `version0` iModel.
|
|
38
|
+
* They use mock (aka "bogus") credentials for `AccessTokens`, which is fine since [[HubMock]] never accesses resources outside the current
|
|
39
|
+
* computer.
|
|
40
|
+
*
|
|
41
|
+
* @note Only one HubMock at a time, *running in a single process*, may be active. The comments above about multiple simultaneous tests refer to tests
|
|
42
|
+
* running on different computers, or on a single computer in multiple processes. All of those scenarios are problematic without mocking.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
class HubMock {
|
|
47
|
+
/** Determine whether a test us currently being run under HubMock */
|
|
48
|
+
static get isValid() { return undefined !== this.mockRoot; }
|
|
49
|
+
static get iTwinId() {
|
|
50
|
+
if (undefined === this._iTwinId)
|
|
51
|
+
throw new Error("Either a previous test did not call HubMock.shutdown() properly, or more than one test is simultaneously attempting to use HubMock, which is not allowed");
|
|
52
|
+
return this._iTwinId;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Begin mocking IModelHub access. After this call, all access to IModelHub will be directed to a [[LocalHub]].
|
|
56
|
+
* @param mockName a unique name (e.g. "MyTest") for this HubMock to disambiguate tests when more than one is simultaneously active.
|
|
57
|
+
* It is used to create a private directory used by the HubMock for a test. That directory is removed when [[shutdown]] is called.
|
|
58
|
+
*/
|
|
59
|
+
static startup(mockName, outputDir) {
|
|
60
|
+
if (this.isValid)
|
|
61
|
+
throw new Error("Either a previous test did not call HubMock.shutdown() properly, or more than one test is simultaneously attempting to use HubMock, which is not allowed");
|
|
62
|
+
this.hubs.clear();
|
|
63
|
+
this.mockRoot = (0, path_1.join)(outputDir, "HubMock", mockName);
|
|
64
|
+
IModelJsFs_1.IModelJsFs.recursiveMkDirSync(this.mockRoot);
|
|
65
|
+
IModelJsFs_1.IModelJsFs.purgeDirSync(this.mockRoot);
|
|
66
|
+
this._saveHubAccess = IModelHost_1.IModelHost.getHubAccess();
|
|
67
|
+
IModelHost_1.IModelHost.setHubAccess(this);
|
|
68
|
+
HubMock._iTwinId = core_bentley_1.Guid.createValue(); // all iModels for this test get the same "iTwinId"
|
|
69
|
+
}
|
|
70
|
+
/** Stop a HubMock that was previously started with [[startup]]
|
|
71
|
+
* @note this function throws an exception if any of the iModels used during the tests are left open.
|
|
72
|
+
*/
|
|
73
|
+
static shutdown() {
|
|
74
|
+
if (!this.isValid)
|
|
75
|
+
return;
|
|
76
|
+
HubMock._iTwinId = undefined;
|
|
77
|
+
for (const hub of this.hubs)
|
|
78
|
+
hub[1].cleanup();
|
|
79
|
+
this.hubs.clear();
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
81
|
+
IModelJsFs_1.IModelJsFs.purgeDirSync(this.mockRoot);
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
83
|
+
IModelJsFs_1.IModelJsFs.removeSync(this.mockRoot);
|
|
84
|
+
sinon.restore();
|
|
85
|
+
IModelHost_1.IModelHost.setHubAccess(this._saveHubAccess);
|
|
86
|
+
this.mockRoot = undefined;
|
|
87
|
+
}
|
|
88
|
+
static findLocalHub(iModelId) {
|
|
89
|
+
const hub = this.hubs.get(iModelId);
|
|
90
|
+
if (!hub)
|
|
91
|
+
throw new Error(`local hub for iModel ${iModelId} not created`);
|
|
92
|
+
return hub;
|
|
93
|
+
}
|
|
94
|
+
/** create a [[LocalHub]] for an iModel. */
|
|
95
|
+
static async createNewIModel(arg) {
|
|
96
|
+
if (!this.mockRoot)
|
|
97
|
+
throw new Error("call startup first");
|
|
98
|
+
const props = { ...arg, iModelId: core_bentley_1.Guid.createValue() };
|
|
99
|
+
const mock = new LocalHub_1.LocalHub((0, path_1.join)(this.mockRoot, props.iModelId), props);
|
|
100
|
+
this.hubs.set(props.iModelId, mock);
|
|
101
|
+
return props.iModelId;
|
|
102
|
+
}
|
|
103
|
+
/** remove the [[LocalHub]] for an iModel */
|
|
104
|
+
static destroy(iModelId) {
|
|
105
|
+
this.findLocalHub(iModelId).cleanup();
|
|
106
|
+
this.hubs.delete(iModelId);
|
|
107
|
+
}
|
|
108
|
+
/** All methods below are mocks of the [[BackendHubAccess]] interface */
|
|
109
|
+
static async getChangesetFromNamedVersion(arg) {
|
|
110
|
+
return this.findLocalHub(arg.iModelId).findNamedVersion(arg.versionName);
|
|
111
|
+
}
|
|
112
|
+
static changesetIndexFromArg(arg) {
|
|
113
|
+
return (undefined !== arg.changeset.index) ? arg.changeset.index : this.findLocalHub(arg.iModelId).getChangesetIndex(arg.changeset.id);
|
|
114
|
+
}
|
|
115
|
+
static async getChangesetFromVersion(arg) {
|
|
116
|
+
const hub = this.findLocalHub(arg.iModelId);
|
|
117
|
+
const version = arg.version;
|
|
118
|
+
if (version.isFirst)
|
|
119
|
+
return hub.getChangesetByIndex(0);
|
|
120
|
+
const asOf = version.getAsOfChangeSet();
|
|
121
|
+
if (asOf)
|
|
122
|
+
return hub.getChangesetById(asOf);
|
|
123
|
+
const versionName = version.getName();
|
|
124
|
+
if (versionName)
|
|
125
|
+
return hub.findNamedVersion(versionName);
|
|
126
|
+
return hub.getLatestChangeset();
|
|
127
|
+
}
|
|
128
|
+
static async getLatestChangeset(arg) {
|
|
129
|
+
return this.findLocalHub(arg.iModelId).getLatestChangeset();
|
|
130
|
+
}
|
|
131
|
+
static async getAccessToken(arg) {
|
|
132
|
+
var _a;
|
|
133
|
+
return (_a = arg.accessToken) !== null && _a !== void 0 ? _a : await IModelHost_1.IModelHost.getAccessToken();
|
|
134
|
+
}
|
|
135
|
+
static async getMyBriefcaseIds(arg) {
|
|
136
|
+
const accessToken = await this.getAccessToken(arg);
|
|
137
|
+
return this.findLocalHub(arg.iModelId).getBriefcaseIds(accessToken);
|
|
138
|
+
}
|
|
139
|
+
static async acquireNewBriefcaseId(arg) {
|
|
140
|
+
const accessToken = await this.getAccessToken(arg);
|
|
141
|
+
return this.findLocalHub(arg.iModelId).acquireNewBriefcaseId(accessToken, arg.briefcaseAlias);
|
|
142
|
+
}
|
|
143
|
+
/** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */
|
|
144
|
+
static async releaseBriefcase(arg) {
|
|
145
|
+
return this.findLocalHub(arg.iModelId).releaseBriefcaseId(arg.briefcaseId);
|
|
146
|
+
}
|
|
147
|
+
static async downloadChangeset(arg) {
|
|
148
|
+
return this.findLocalHub(arg.iModelId).downloadChangeset({ index: this.changesetIndexFromArg(arg), targetDir: arg.targetDir });
|
|
149
|
+
}
|
|
150
|
+
static async downloadChangesets(arg) {
|
|
151
|
+
return this.findLocalHub(arg.iModelId).downloadChangesets({ range: arg.range, targetDir: arg.targetDir });
|
|
152
|
+
}
|
|
153
|
+
static async queryChangeset(arg) {
|
|
154
|
+
return this.findLocalHub(arg.iModelId).getChangesetByIndex(this.changesetIndexFromArg(arg));
|
|
155
|
+
}
|
|
156
|
+
static async queryChangesets(arg) {
|
|
157
|
+
return this.findLocalHub(arg.iModelId).queryChangesets(arg.range);
|
|
158
|
+
}
|
|
159
|
+
static async pushChangeset(arg) {
|
|
160
|
+
return this.findLocalHub(arg.iModelId).addChangeset(arg.changesetProps);
|
|
161
|
+
}
|
|
162
|
+
static async queryV2Checkpoint(_arg) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
static async downloadV2Checkpoint(arg) {
|
|
166
|
+
return this.findLocalHub(arg.checkpoint.iModelId).downloadCheckpoint({ changeset: arg.checkpoint.changeset, targetFile: arg.localFile });
|
|
167
|
+
}
|
|
168
|
+
static async downloadV1Checkpoint(arg) {
|
|
169
|
+
return this.findLocalHub(arg.checkpoint.iModelId).downloadCheckpoint({ changeset: arg.checkpoint.changeset, targetFile: arg.localFile });
|
|
170
|
+
}
|
|
171
|
+
static async releaseAllLocks(arg) {
|
|
172
|
+
const hub = this.findLocalHub(arg.iModelId);
|
|
173
|
+
hub.releaseAllLocks({ briefcaseId: arg.briefcaseId, changesetIndex: hub.getIndexFromChangeset(arg.changeset) });
|
|
174
|
+
}
|
|
175
|
+
static async queryAllLocks(_arg) {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
static async acquireLocks(arg, locks) {
|
|
179
|
+
this.findLocalHub(arg.iModelId).acquireLocks(locks, arg);
|
|
180
|
+
}
|
|
181
|
+
static async queryIModelByName(arg) {
|
|
182
|
+
for (const hub of this.hubs) {
|
|
183
|
+
const localHub = hub[1];
|
|
184
|
+
if (localHub.iTwinId === arg.iTwinId && localHub.iModelName === arg.iModelName)
|
|
185
|
+
return localHub.iModelId;
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
static async deleteIModel(arg) {
|
|
190
|
+
return this.destroy(arg.iModelId);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.HubMock = HubMock;
|
|
194
|
+
HubMock.hubs = new Map();
|
|
195
|
+
//# sourceMappingURL=HubMock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HubMock.js","sourceRoot":"","sources":["../../src/HubMock.ts"],"names":[],"mappings":";AAAA;;;+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AAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { join } from \"path\";\r\nimport * as sinon from \"sinon\";\r\nimport { Guid, GuidString } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetFileProps, ChangesetIndex, ChangesetIndexAndId, ChangesetProps, ChangesetRange, IModelVersion, LocalDirName,\r\n} from \"@itwin/core-common\";\r\nimport {\r\n AcquireNewBriefcaseIdArg,\r\n BackendHubAccess, BriefcaseDbArg, BriefcaseIdArg, ChangesetArg, ChangesetRangeArg, CheckpointArg, CreateNewIModelProps, IModelIdArg, IModelNameArg,\r\n LockMap, LockProps, V2CheckpointAccessProps,\r\n} from \"./BackendHubAccess\";\r\nimport { CheckpointProps } from \"./CheckpointManager\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { LocalHub } from \"./LocalHub\";\r\nimport { TokenArg } from \"./IModelDb\";\r\n\r\n/**\r\n * Mocks iModelHub for testing creating Briefcases, downloading checkpoints, and simulating multiple users pushing and pulling changesets, etc.\r\n *\r\n * Generally, tests for apis that *create or modify* iModels can and should be mocked. Otherwise they:\r\n * - create tremendous load on the test servers when they run on programmer's desktops and in CI jobs\r\n * - waste network and data center resources (i.e. $$$s),\r\n * - interfere with other tests running on the same or other systems, and\r\n * - (far worse) are the source of test flakiness outside of the api being tested.\r\n *\r\n * This class can be used to create tests that do not require authentication, are synchronous,\r\n * are guaranteed to be self-contained (i.e. do not interfere with other tests running at the same time or later), and do not fail for reasons outside\r\n * of the control of the test itself. As a bonus, in addition to making tests more reliable, mocking IModelHub generally makes tests run *much* faster.\r\n *\r\n * On the other hand, tests that expect to find an existing iModels, checkpoints, changesets, etc. in IModelHub cannot be mocked. In that case, those tests\r\n * should be careful to NOT modify the data, since doing so causes interference with other tests running simultaneously. These tests should be limited to\r\n * low level testing of the core apis only.\r\n *\r\n * To initialize HubMock, call [[startup]] at the beginning of your test, usually in `describe.before`. Thereafter, all access to iModelHub for an iModel will be\r\n * directed to a [[LocalHub]] - your test code does not change. After the test(s) complete, call [[shutdown]] (usually in `describe.after`) to stop mocking IModelHub and clean\r\n * up any resources used by the test(s). If you want to mock a single test, call [[startup]] as the first line and [[shutdown]] as the last. If you wish to run the\r\n * test against a \"real\" IModelHub, you can simply comment off the call [[startup]], though in that case you should make sure the name of your\r\n * iModel is unique so your test won't collide with other tests (iModel name uniqueness is not necessary for mocked tests.)\r\n *\r\n * Mocked tests must always start by creating a new iModel via [[IModelHost.hubAccess.createNewIModel]] with a `version0` iModel.\r\n * They use mock (aka \"bogus\") credentials for `AccessTokens`, which is fine since [[HubMock]] never accesses resources outside the current\r\n * computer.\r\n *\r\n * @note Only one HubMock at a time, *running in a single process*, may be active. The comments above about multiple simultaneous tests refer to tests\r\n * running on different computers, or on a single computer in multiple processes. All of those scenarios are problematic without mocking.\r\n *\r\n * @internal\r\n */\r\nexport class HubMock {\r\n private static mockRoot: LocalDirName | undefined;\r\n private static hubs = new Map<string, LocalHub>();\r\n private static _saveHubAccess: BackendHubAccess | undefined;\r\n private static _iTwinId: GuidString | undefined;\r\n\r\n /** Determine whether a test us currently being run under HubMock */\r\n public static get isValid() { return undefined !== this.mockRoot; }\r\n\r\n public static get iTwinId() {\r\n if (undefined === this._iTwinId)\r\n throw new Error(\"Either a previous test did not call HubMock.shutdown() properly, or more than one test is simultaneously attempting to use HubMock, which is not allowed\");\r\n return this._iTwinId;\r\n }\r\n\r\n /**\r\n * Begin mocking IModelHub access. After this call, all access to IModelHub will be directed to a [[LocalHub]].\r\n * @param mockName a unique name (e.g. \"MyTest\") for this HubMock to disambiguate tests when more than one is simultaneously active.\r\n * It is used to create a private directory used by the HubMock for a test. That directory is removed when [[shutdown]] is called.\r\n */\r\n public static startup(mockName: LocalDirName, outputDir: string) {\r\n if (this.isValid)\r\n throw new Error(\"Either a previous test did not call HubMock.shutdown() properly, or more than one test is simultaneously attempting to use HubMock, which is not allowed\");\r\n\r\n this.hubs.clear();\r\n this.mockRoot = join(outputDir, \"HubMock\", mockName);\r\n IModelJsFs.recursiveMkDirSync(this.mockRoot);\r\n IModelJsFs.purgeDirSync(this.mockRoot);\r\n this._saveHubAccess = IModelHost.getHubAccess();\r\n\r\n IModelHost.setHubAccess(this);\r\n HubMock._iTwinId = Guid.createValue(); // all iModels for this test get the same \"iTwinId\"\r\n }\r\n\r\n /** Stop a HubMock that was previously started with [[startup]]\r\n * @note this function throws an exception if any of the iModels used during the tests are left open.\r\n */\r\n public static shutdown() {\r\n if (!this.isValid)\r\n return;\r\n\r\n HubMock._iTwinId = undefined;\r\n for (const hub of this.hubs)\r\n hub[1].cleanup();\r\n\r\n this.hubs.clear();\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n IModelJsFs.purgeDirSync(this.mockRoot!);\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n IModelJsFs.removeSync(this.mockRoot!);\r\n sinon.restore();\r\n IModelHost.setHubAccess(this._saveHubAccess);\r\n this.mockRoot = undefined;\r\n }\r\n\r\n public static findLocalHub(iModelId: GuidString): LocalHub {\r\n const hub = this.hubs.get(iModelId);\r\n if (!hub)\r\n throw new Error(`local hub for iModel ${iModelId} not created`);\r\n return hub;\r\n }\r\n\r\n /** create a [[LocalHub]] for an iModel. */\r\n public static async createNewIModel(arg: CreateNewIModelProps): Promise<GuidString> {\r\n if (!this.mockRoot)\r\n throw new Error(\"call startup first\");\r\n\r\n const props = { ...arg, iModelId: Guid.createValue() };\r\n const mock = new LocalHub(join(this.mockRoot, props.iModelId), props);\r\n this.hubs.set(props.iModelId, mock);\r\n return props.iModelId;\r\n }\r\n\r\n /** remove the [[LocalHub]] for an iModel */\r\n public static destroy(iModelId: GuidString) {\r\n this.findLocalHub(iModelId).cleanup();\r\n this.hubs.delete(iModelId);\r\n }\r\n\r\n /** All methods below are mocks of the [[BackendHubAccess]] interface */\r\n\r\n public static async getChangesetFromNamedVersion(arg: IModelIdArg & { versionName: string }): Promise<ChangesetProps> {\r\n return this.findLocalHub(arg.iModelId).findNamedVersion(arg.versionName);\r\n }\r\n\r\n private static changesetIndexFromArg(arg: ChangesetArg) {\r\n return (undefined !== arg.changeset.index) ? arg.changeset.index : this.findLocalHub(arg.iModelId).getChangesetIndex(arg.changeset.id);\r\n }\r\n\r\n public static async getChangesetFromVersion(arg: IModelIdArg & { version: IModelVersion }): Promise<ChangesetProps> {\r\n const hub = this.findLocalHub(arg.iModelId);\r\n const version = arg.version;\r\n if (version.isFirst)\r\n return hub.getChangesetByIndex(0);\r\n\r\n const asOf = version.getAsOfChangeSet();\r\n if (asOf)\r\n return hub.getChangesetById(asOf);\r\n\r\n const versionName = version.getName();\r\n if (versionName)\r\n return hub.findNamedVersion(versionName);\r\n\r\n return hub.getLatestChangeset();\r\n }\r\n\r\n public static async getLatestChangeset(arg: IModelIdArg): Promise<ChangesetProps> {\r\n return this.findLocalHub(arg.iModelId).getLatestChangeset();\r\n }\r\n\r\n private static async getAccessToken(arg: TokenArg) {\r\n return arg.accessToken ?? await IModelHost.getAccessToken();\r\n }\r\n\r\n public static async getMyBriefcaseIds(arg: IModelIdArg): Promise<number[]> {\r\n const accessToken = await this.getAccessToken(arg);\r\n return this.findLocalHub(arg.iModelId).getBriefcaseIds(accessToken);\r\n }\r\n\r\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<number> {\r\n const accessToken = await this.getAccessToken(arg);\r\n return this.findLocalHub(arg.iModelId).acquireNewBriefcaseId(accessToken, arg.briefcaseAlias);\r\n }\r\n\r\n /** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */\r\n public static async releaseBriefcase(arg: BriefcaseIdArg): Promise<void> {\r\n return this.findLocalHub(arg.iModelId).releaseBriefcaseId(arg.briefcaseId);\r\n }\r\n\r\n public static async downloadChangeset(arg: ChangesetArg & { targetDir: LocalDirName }): Promise<ChangesetFileProps> {\r\n return this.findLocalHub(arg.iModelId).downloadChangeset({ index: this.changesetIndexFromArg(arg), targetDir: arg.targetDir });\r\n }\r\n\r\n public static async downloadChangesets(arg: ChangesetRangeArg & { targetDir: LocalDirName }): Promise<ChangesetFileProps[]> {\r\n return this.findLocalHub(arg.iModelId).downloadChangesets({ range: arg.range, targetDir: arg.targetDir });\r\n }\r\n\r\n public static async queryChangeset(arg: ChangesetArg): Promise<ChangesetProps> {\r\n return this.findLocalHub(arg.iModelId).getChangesetByIndex(this.changesetIndexFromArg(arg));\r\n }\r\n\r\n public static async queryChangesets(arg: IModelIdArg & { range?: ChangesetRange }): Promise<ChangesetProps[]> {\r\n return this.findLocalHub(arg.iModelId).queryChangesets(arg.range);\r\n }\r\n\r\n public static async pushChangeset(arg: IModelIdArg & { changesetProps: ChangesetFileProps }): Promise<ChangesetIndex> {\r\n return this.findLocalHub(arg.iModelId).addChangeset(arg.changesetProps);\r\n }\r\n\r\n public static async queryV2Checkpoint(_arg: CheckpointProps): Promise<V2CheckpointAccessProps | undefined> {\r\n return undefined;\r\n }\r\n\r\n public static async downloadV2Checkpoint(arg: CheckpointArg): Promise<ChangesetIndexAndId> {\r\n return this.findLocalHub(arg.checkpoint.iModelId).downloadCheckpoint({ changeset: arg.checkpoint.changeset, targetFile: arg.localFile });\r\n }\r\n\r\n public static async downloadV1Checkpoint(arg: CheckpointArg): Promise<ChangesetIndexAndId> {\r\n return this.findLocalHub(arg.checkpoint.iModelId).downloadCheckpoint({ changeset: arg.checkpoint.changeset, targetFile: arg.localFile });\r\n }\r\n\r\n public static async releaseAllLocks(arg: BriefcaseDbArg) {\r\n const hub = this.findLocalHub(arg.iModelId);\r\n hub.releaseAllLocks({ briefcaseId: arg.briefcaseId, changesetIndex: hub.getIndexFromChangeset(arg.changeset) });\r\n }\r\n\r\n public static async queryAllLocks(_arg: BriefcaseDbArg): Promise<LockProps[]> {\r\n return [];\r\n }\r\n\r\n public static async acquireLocks(arg: BriefcaseDbArg, locks: LockMap): Promise<void> {\r\n this.findLocalHub(arg.iModelId).acquireLocks(locks, arg);\r\n }\r\n\r\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\r\n for (const hub of this.hubs) {\r\n const localHub = hub[1];\r\n if (localHub.iTwinId === arg.iTwinId && localHub.iModelName === arg.iModelName)\r\n return localHub.iModelId;\r\n }\r\n return undefined;\r\n }\r\n\r\n public static async deleteIModel(arg: IModelIdArg & { iTwinId: GuidString }): Promise<void> {\r\n return this.destroy(arg.iModelId);\r\n }\r\n}\r\n"]}
|
package/lib/cjs/IModelHost.d.ts
CHANGED
|
@@ -186,12 +186,17 @@ export declare class IModelHost {
|
|
|
186
186
|
static tileCacheService?: CloudStorageService;
|
|
187
187
|
/** @internal */
|
|
188
188
|
static tileUploader?: CloudStorageTileUploader;
|
|
189
|
-
private static _hubAccess
|
|
189
|
+
private static _hubAccess?;
|
|
190
190
|
/** @internal */
|
|
191
|
-
static setHubAccess(hubAccess: BackendHubAccess): void;
|
|
191
|
+
static setHubAccess(hubAccess: BackendHubAccess | undefined): void;
|
|
192
|
+
/** get the current hubAccess, if present.
|
|
193
|
+
* @beta
|
|
194
|
+
*/
|
|
195
|
+
static getHubAccess(): BackendHubAccess | undefined;
|
|
192
196
|
/** Provides access to the IModelHub for this IModelHost
|
|
193
197
|
* @beta
|
|
194
198
|
* @note If [[IModelHostConfiguration.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.
|
|
199
|
+
* To determine whether one is present, use [[getHubAccess]].
|
|
195
200
|
*/
|
|
196
201
|
static get hubAccess(): BackendHubAccess;
|
|
197
202
|
private static _isValid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHost.d.ts","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,gBAAgB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Ae,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAOnD"}
|
package/lib/cjs/IModelHost.js
CHANGED
|
@@ -174,17 +174,18 @@ class IModelHost {
|
|
|
174
174
|
}
|
|
175
175
|
/** @internal */
|
|
176
176
|
static setHubAccess(hubAccess) { this._hubAccess = hubAccess; }
|
|
177
|
+
/** get the current hubAccess, if present.
|
|
178
|
+
* @beta
|
|
179
|
+
*/
|
|
180
|
+
static getHubAccess() { return this._hubAccess; }
|
|
177
181
|
/** Provides access to the IModelHub for this IModelHost
|
|
178
182
|
* @beta
|
|
179
183
|
* @note If [[IModelHostConfiguration.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.
|
|
184
|
+
* To determine whether one is present, use [[getHubAccess]].
|
|
180
185
|
*/
|
|
181
186
|
static get hubAccess() {
|
|
182
|
-
// Strictly speaking, _hubAccess should be marked as possibly undefined since it's not needed for Snapshot iModels.
|
|
183
|
-
// However, a decision was made to not provide that type annotation so callers aren't forced to constantly check for
|
|
184
|
-
// something that's required in all other workflows.
|
|
185
|
-
// This check is here to provide a better error message when hubAccess is inadvertently undefined.
|
|
186
187
|
if (this._hubAccess === undefined)
|
|
187
|
-
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "
|
|
188
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, "No BackendHubAccess supplied in IModelHostConfiguration");
|
|
188
189
|
return this._hubAccess;
|
|
189
190
|
}
|
|
190
191
|
/** Returns true if IModelHost is started. */
|