@itwin/ecschema-locaters 5.0.0-dev.10 → 5.0.0-dev.102
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 +56 -1
- package/lib/cjs/SchemaFileLocater.d.ts +10 -2
- package/lib/cjs/SchemaFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaFileLocater.js +14 -9
- package/lib/cjs/SchemaFileLocater.js.map +1 -1
- package/lib/cjs/SchemaJsonFileLocater.d.ts +2 -2
- package/lib/cjs/SchemaJsonFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaJsonFileLocater.js.map +1 -1
- package/lib/cjs/SchemaStringLocater.d.ts +2 -2
- package/lib/cjs/SchemaStringLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaStringLocater.js +12 -9
- package/lib/cjs/SchemaStringLocater.js.map +1 -1
- package/lib/cjs/SchemaXmlFileLocater.d.ts +30 -2
- package/lib/cjs/SchemaXmlFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaXmlFileLocater.js +43 -1
- package/lib/cjs/SchemaXmlFileLocater.js.map +1 -1
- package/lib/cjs/SchemaXmlStringLocater.d.ts +2 -2
- package/lib/cjs/SchemaXmlStringLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaXmlStringLocater.js.map +1 -1
- package/lib/cjs/StubSchemaXmlFileLocater.d.ts +2 -2
- package/lib/cjs/StubSchemaXmlFileLocater.d.ts.map +1 -1
- package/lib/cjs/StubSchemaXmlFileLocater.js.map +1 -1
- package/lib/cjs/test/SchemaXmlFileLocator.test.js +3 -0
- package/lib/cjs/test/SchemaXmlFileLocator.test.js.map +1 -1
- package/lib/esm/SchemaFileLocater.d.ts +94 -0
- package/lib/esm/SchemaFileLocater.d.ts.map +1 -0
- package/lib/esm/SchemaFileLocater.js +213 -0
- package/lib/esm/SchemaFileLocater.js.map +1 -0
- package/lib/esm/SchemaJsonFileLocater.d.ts +42 -0
- package/lib/esm/SchemaJsonFileLocater.d.ts.map +1 -0
- package/lib/esm/SchemaJsonFileLocater.js +96 -0
- package/lib/esm/SchemaJsonFileLocater.js.map +1 -0
- package/lib/esm/SchemaStringLocater.d.ts +54 -0
- package/lib/esm/SchemaStringLocater.d.ts.map +1 -0
- package/lib/esm/SchemaStringLocater.js +83 -0
- package/lib/esm/SchemaStringLocater.js.map +1 -0
- package/lib/esm/SchemaXml.d.ts +22 -0
- package/lib/esm/SchemaXml.d.ts.map +1 -0
- package/lib/esm/SchemaXml.js +55 -0
- package/lib/esm/SchemaXml.js.map +1 -0
- package/lib/esm/SchemaXmlFileLocater.d.ts +70 -0
- package/lib/esm/SchemaXmlFileLocater.d.ts.map +1 -0
- package/lib/esm/SchemaXmlFileLocater.js +140 -0
- package/lib/esm/SchemaXmlFileLocater.js.map +1 -0
- package/lib/esm/SchemaXmlStringLocater.d.ts +48 -0
- package/lib/esm/SchemaXmlStringLocater.d.ts.map +1 -0
- package/lib/esm/SchemaXmlStringLocater.js +100 -0
- package/lib/esm/SchemaXmlStringLocater.js.map +1 -0
- package/lib/esm/StubSchemaXmlFileLocater.d.ts +81 -0
- package/lib/esm/StubSchemaXmlFileLocater.d.ts.map +1 -0
- package/lib/esm/StubSchemaXmlFileLocater.js +184 -0
- package/lib/esm/StubSchemaXmlFileLocater.js.map +1 -0
- package/lib/esm/ecschema-locaters.d.ts +20 -0
- package/lib/esm/ecschema-locaters.d.ts.map +1 -0
- package/lib/esm/ecschema-locaters.js +24 -0
- package/lib/esm/ecschema-locaters.js.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.d.ts +2 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.d.ts.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.js +249 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.js.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.d.ts +2 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.d.ts.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.js +186 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.js.map +1 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.d.ts +2 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.js +118 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.js.map +1 -0
- package/lib/esm/test/SchemaXml.test.d.ts +2 -0
- package/lib/esm/test/SchemaXml.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaXml.test.js +55 -0
- package/lib/esm/test/SchemaXml.test.js.map +1 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.d.ts +2 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.js +182 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.js.map +1 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.d.ts +2 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.js +219 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.js.map +1 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.d.ts +2 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.d.ts.map +1 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.js +169 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.js.map +1 -0
- package/package.json +14 -12
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { assert, expect } from "chai";
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { ECVersion, SchemaContext, SchemaJsonLocater, SchemaKey, SchemaMatchType } from "@itwin/ecschema-metadata";
|
|
9
|
+
import { SchemaJsonFileLocater } from "../SchemaJsonFileLocater";
|
|
10
|
+
describe("Concurrent schema JSON deserialization", () => {
|
|
11
|
+
const assetDir = path.join(__dirname, "assets");
|
|
12
|
+
const schemaFolder = path.join(__dirname, "assets", "json");
|
|
13
|
+
const schemaKeys = [];
|
|
14
|
+
let context;
|
|
15
|
+
let contextSync;
|
|
16
|
+
let syncSchemas = [];
|
|
17
|
+
const locater = new SchemaJsonFileLocater();
|
|
18
|
+
before(() => {
|
|
19
|
+
if (!fs.existsSync(assetDir))
|
|
20
|
+
fs.mkdirSync(assetDir);
|
|
21
|
+
if (!fs.existsSync(schemaFolder))
|
|
22
|
+
fs.mkdirSync(schemaFolder);
|
|
23
|
+
copySchemasToAssetsDir();
|
|
24
|
+
// Deserialize schemas synchronously/serially as standard to compare to
|
|
25
|
+
contextSync = new SchemaContext();
|
|
26
|
+
locater.addSchemaSearchPath(schemaFolder);
|
|
27
|
+
contextSync.addLocater(locater);
|
|
28
|
+
const schemaFiles = fs.readdirSync(schemaFolder);
|
|
29
|
+
schemaFiles.forEach((fileName) => {
|
|
30
|
+
const schemaFile = path.join(schemaFolder, fileName);
|
|
31
|
+
const schemaJson = JSON.parse(fs.readFileSync(schemaFile, "utf-8"));
|
|
32
|
+
const schemaName = schemaJson.name;
|
|
33
|
+
const schemaVersion = schemaJson.version;
|
|
34
|
+
const key = new SchemaKey(schemaName.toString(), ECVersion.fromString(schemaVersion.toString()));
|
|
35
|
+
schemaKeys.push(key);
|
|
36
|
+
});
|
|
37
|
+
syncSchemas = schemaKeys.map((key) => {
|
|
38
|
+
if (!key)
|
|
39
|
+
return undefined;
|
|
40
|
+
const schema = contextSync.getSchemaSync(key, SchemaMatchType.Latest);
|
|
41
|
+
return schema;
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
context = new SchemaContext();
|
|
46
|
+
context.addLocater(locater);
|
|
47
|
+
});
|
|
48
|
+
function getSchemaPathFromPackage(packageName, schemaFileName) {
|
|
49
|
+
const schemaFile = path.join(__dirname, "..", "..", "..", "node_modules", "@bentley", packageName, schemaFileName);
|
|
50
|
+
return schemaFile;
|
|
51
|
+
}
|
|
52
|
+
function copySchemasToAssetsDir() {
|
|
53
|
+
// Copy Schemas that we need for testing
|
|
54
|
+
fs.copyFileSync(getSchemaPathFromPackage("aec-units-schema", "AecUnits.ecschema.json"), path.join(schemaFolder, "AecUnits.ecschema.json"));
|
|
55
|
+
fs.copyFileSync(getSchemaPathFromPackage("architectural-physical-schema", "ArchitecturalPhysical.ecschema.json"), path.join(schemaFolder, "ArchitecturalPhysical.ecschema.json"));
|
|
56
|
+
fs.copyFileSync(getSchemaPathFromPackage("bis-core-schema", "BisCore.ecschema.json"), path.join(schemaFolder, "BisCore.ecschema.json"));
|
|
57
|
+
fs.copyFileSync(getSchemaPathFromPackage("bis-custom-attributes-schema", "BisCustomAttributes.ecschema.json"), path.join(schemaFolder, "BisCustomAttributes.ecschema.json"));
|
|
58
|
+
fs.copyFileSync(getSchemaPathFromPackage("construction-schema", "Construction.ecschema.json"), path.join(schemaFolder, "Construction.ecschema.json"));
|
|
59
|
+
fs.copyFileSync(getSchemaPathFromPackage("core-custom-attributes-schema", "CoreCustomAttributes.ecschema.json"), path.join(schemaFolder, "CoreCustomAttributes.ecschema.json"));
|
|
60
|
+
fs.copyFileSync(getSchemaPathFromPackage("ecdb-map-schema", "ECDbMap.ecschema.json"), path.join(schemaFolder, "ECDbMap.ecschema.json"));
|
|
61
|
+
fs.copyFileSync(getSchemaPathFromPackage("ecdb-schema-policies-schema", "ECDbSchemaPolicies.ecschema.json"), path.join(schemaFolder, "ECDbSchemaPolicies.ecschema.json"));
|
|
62
|
+
fs.copyFileSync(getSchemaPathFromPackage("formats-schema", "Formats.ecschema.json"), path.join(schemaFolder, "Formats.ecschema.json"));
|
|
63
|
+
fs.copyFileSync(getSchemaPathFromPackage("linear-referencing-schema", "LinearReferencing.ecschema.json"), path.join(schemaFolder, "LinearReferencing.ecschema.json"));
|
|
64
|
+
fs.copyFileSync(getSchemaPathFromPackage("physical-material-schema", "PhysicalMaterial.ecschema.json"), path.join(schemaFolder, "PhysicalMaterial.ecschema.json"));
|
|
65
|
+
fs.copyFileSync(getSchemaPathFromPackage("plant-custom-attributes-schema", "PlantCustomAttributes.ecschema.json"), path.join(schemaFolder, "PlantCustomAttributes.ecschema.json"));
|
|
66
|
+
fs.copyFileSync(getSchemaPathFromPackage("quantity-takeoffs-aspects-schema", "QuantityTakeoffsAspects.ecschema.json"), path.join(schemaFolder, "QuantityTakeoffsAspects.ecschema.json"));
|
|
67
|
+
fs.copyFileSync(getSchemaPathFromPackage("spatial-composition-schema", "SpatialComposition.ecschema.json"), path.join(schemaFolder, "SpatialComposition.ecschema.json"));
|
|
68
|
+
fs.copyFileSync(getSchemaPathFromPackage("structural-physical-schema", "StructuralPhysical.ecschema.json"), path.join(schemaFolder, "StructuralPhysical.ecschema.json"));
|
|
69
|
+
fs.copyFileSync(getSchemaPathFromPackage("units-schema", "Units.ecschema.json"), path.join(schemaFolder, "Units.ecschema.json"));
|
|
70
|
+
}
|
|
71
|
+
it("should match schemas deserialized concurrently with schemas deserialized serially", async () => {
|
|
72
|
+
const schemaPromises = schemaKeys.map(async (key) => {
|
|
73
|
+
if (!key)
|
|
74
|
+
return undefined;
|
|
75
|
+
const schema = await context.getSchema(key, SchemaMatchType.Latest);
|
|
76
|
+
return schema;
|
|
77
|
+
});
|
|
78
|
+
const asyncSchemas = await Promise.all(schemaPromises);
|
|
79
|
+
for (let i = 0; i < schemaKeys.length; i++) {
|
|
80
|
+
const syncSchema = syncSchemas[i];
|
|
81
|
+
expect(syncSchema).not.to.be.undefined;
|
|
82
|
+
const syncJSON = syncSchema.toJSON();
|
|
83
|
+
const asyncSchema = asyncSchemas[i];
|
|
84
|
+
expect(asyncSchema).not.to.be.undefined;
|
|
85
|
+
const asyncJSON = asyncSchema.toJSON();
|
|
86
|
+
expect(asyncJSON).to.deep.equal(syncJSON);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
it("should be able to mix getSchema and getSchemaSync", async () => {
|
|
90
|
+
const schemaPromises = schemaKeys.map(async (key, index) => {
|
|
91
|
+
if (index % 2 === 0) {
|
|
92
|
+
// Use getSchema() for even indices
|
|
93
|
+
if (!key)
|
|
94
|
+
return undefined;
|
|
95
|
+
const schema = await context.getSchema(key, SchemaMatchType.Latest);
|
|
96
|
+
return schema;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// Use getSchemaSync() for odd indices
|
|
100
|
+
if (!key)
|
|
101
|
+
return undefined;
|
|
102
|
+
const schema = context.getSchemaSync(key, SchemaMatchType.Latest);
|
|
103
|
+
return schema;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const schemas = await Promise.all(schemaPromises);
|
|
107
|
+
for (let i = 0; i < schemaKeys.length; i++) {
|
|
108
|
+
const syncSchema = syncSchemas[i];
|
|
109
|
+
expect(syncSchema).not.to.be.undefined;
|
|
110
|
+
const syncJSON = syncSchema.toJSON();
|
|
111
|
+
const schema = schemas[i];
|
|
112
|
+
expect(schema).not.to.be.undefined;
|
|
113
|
+
const schemaJSON = schema.toJSON();
|
|
114
|
+
expect(schemaJSON).to.deep.equal(syncJSON);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
/* Run these tests below one at a time. Running them together doesn't get accurate performance likely bc of disk access caching */
|
|
118
|
+
it.skip("should measure regular deserialization performance", async () => {
|
|
119
|
+
const schemaPromises = schemaKeys.map(async (key) => {
|
|
120
|
+
if (!key)
|
|
121
|
+
return undefined;
|
|
122
|
+
const schema = await context.getSchema(key, SchemaMatchType.Latest);
|
|
123
|
+
return schema;
|
|
124
|
+
});
|
|
125
|
+
for (const promise of schemaPromises) {
|
|
126
|
+
await promise;
|
|
127
|
+
}
|
|
128
|
+
expect(schemaPromises.length).to.equal(schemaKeys.length);
|
|
129
|
+
});
|
|
130
|
+
it.skip("should measure concurrent deserialization performance", async () => {
|
|
131
|
+
const schemaPromises = schemaKeys.map(async (key) => {
|
|
132
|
+
if (!key)
|
|
133
|
+
return undefined;
|
|
134
|
+
const schema = await context.getSchema(key, SchemaMatchType.Latest);
|
|
135
|
+
return schema;
|
|
136
|
+
});
|
|
137
|
+
const asyncSchemas = await Promise.all(schemaPromises);
|
|
138
|
+
expect(asyncSchemas.length).to.equal(schemaKeys.length);
|
|
139
|
+
});
|
|
140
|
+
it("Concurrently get BisCore with SchemaJsonFileLocater", async () => {
|
|
141
|
+
const schemaContext = new SchemaContext();
|
|
142
|
+
const jsonFileLocater = new SchemaJsonFileLocater();
|
|
143
|
+
jsonFileLocater.addSchemaSearchPath(schemaFolder);
|
|
144
|
+
schemaContext.addLocater(jsonFileLocater);
|
|
145
|
+
const schemas = await Promise.all([...Array(100).keys()].map(async () => {
|
|
146
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
147
|
+
}));
|
|
148
|
+
expect(schemas.length).to.equal(100);
|
|
149
|
+
schemas.forEach((schema) => {
|
|
150
|
+
assert(schema !== undefined);
|
|
151
|
+
expect(schema.fullName).to.equal("BisCore");
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
it("Concurrently get a schema and it's referenced schema with SchemaJsonFileLocater", async () => {
|
|
155
|
+
const schemaContext = new SchemaContext();
|
|
156
|
+
const jsonFileLocater = new SchemaJsonFileLocater();
|
|
157
|
+
jsonFileLocater.addSchemaSearchPath(schemaFolder);
|
|
158
|
+
schemaContext.addLocater(jsonFileLocater);
|
|
159
|
+
let getBisCoreFirst = 0;
|
|
160
|
+
const schemas = await Promise.all([...Array(2).keys()].map(async () => {
|
|
161
|
+
if (getBisCoreFirst === 0) {
|
|
162
|
+
getBisCoreFirst = 1;
|
|
163
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
164
|
+
}
|
|
165
|
+
return schemaContext.getSchema(new SchemaKey("CoreCustomAttributes"));
|
|
166
|
+
}));
|
|
167
|
+
expect(schemas.length).to.equal(2);
|
|
168
|
+
schemas.forEach((schema) => {
|
|
169
|
+
expect(schema).to.not.be.undefined;
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
const getSchemaProps = (schemaName) => {
|
|
173
|
+
if (schemaName === "BisCore") {
|
|
174
|
+
return {
|
|
175
|
+
$schema: "https://dev.bentley.com/json_schemas/ec/32/ecschema",
|
|
176
|
+
alias: "bis",
|
|
177
|
+
description: "The BIS core schema contains classes that all other domain schemas extend.",
|
|
178
|
+
label: "BIS Core",
|
|
179
|
+
name: "BisCore",
|
|
180
|
+
version: "01.00.15",
|
|
181
|
+
references: [{ name: "CoreCustomAttributes", version: "01.00.04" }, { name: "ECDbMap", version: "02.00.00" }, { name: "ECDbSchemaPolicies", version: "01.00.00" }],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (schemaName === "CoreCustomAttributes") {
|
|
185
|
+
return {
|
|
186
|
+
$schema: "https://dev.bentley.com/json_schemas/ec/32/ecschema",
|
|
187
|
+
alias: "CoreCA",
|
|
188
|
+
description: "Custom attributes to indicate core EC concepts, may include struct classes intended for use in core custom attributes.",
|
|
189
|
+
label: "Core Custom Attributes",
|
|
190
|
+
name: "CoreCustomAttributes",
|
|
191
|
+
version: "01.00.04",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (schemaName === "ECDbMap") {
|
|
195
|
+
return {
|
|
196
|
+
$schema: "https://dev.bentley.com/json_schemas/ec/32/ecschema",
|
|
197
|
+
alias: "ECDbMap",
|
|
198
|
+
description: "ECDbMap Desc",
|
|
199
|
+
label: "ECDbMap",
|
|
200
|
+
name: "ECDbMap",
|
|
201
|
+
version: "02.00.00",
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (schemaName === "ECDbSchemaPolicies") {
|
|
205
|
+
return {
|
|
206
|
+
$schema: "https://dev.bentley.com/json_schemas/ec/32/ecschema",
|
|
207
|
+
alias: "ECDbSchemaPolicies",
|
|
208
|
+
description: "ECDbSchemaPolicies Desc",
|
|
209
|
+
label: "ECDbSchemaPolicies",
|
|
210
|
+
name: "ECDbSchemaPolicies",
|
|
211
|
+
version: "01.00.00",
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return undefined;
|
|
215
|
+
};
|
|
216
|
+
it("Concurrently get BisCore with SchemaJsonLocater", async () => {
|
|
217
|
+
const schemaContext = new SchemaContext();
|
|
218
|
+
const jsonLocater = new SchemaJsonLocater(getSchemaProps);
|
|
219
|
+
schemaContext.addLocater(jsonLocater);
|
|
220
|
+
const schemaCount = 1000;
|
|
221
|
+
const schemas = await Promise.all([...Array(schemaCount).keys()].map(async () => {
|
|
222
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
223
|
+
}));
|
|
224
|
+
expect(schemas.length).to.equal(schemaCount);
|
|
225
|
+
schemas.forEach((schema) => {
|
|
226
|
+
assert(schema !== undefined);
|
|
227
|
+
expect(schema.fullName).to.equal("BisCore");
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
it("Concurrently get a schema and it's referenced schema with SchemaJsonLocater", async () => {
|
|
231
|
+
const schemaContext = new SchemaContext();
|
|
232
|
+
const jsonLocater = new SchemaJsonLocater(getSchemaProps);
|
|
233
|
+
schemaContext.addLocater(jsonLocater);
|
|
234
|
+
let getBisCoreFirst = 0;
|
|
235
|
+
const schemaCount = 1000;
|
|
236
|
+
const schemas = await Promise.all([...Array(schemaCount).keys()].map(async () => {
|
|
237
|
+
if (getBisCoreFirst === 0) {
|
|
238
|
+
getBisCoreFirst = 1;
|
|
239
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
240
|
+
}
|
|
241
|
+
return schemaContext.getSchema(new SchemaKey("CoreCustomAttributes"));
|
|
242
|
+
}));
|
|
243
|
+
expect(schemas.length).to.equal(schemaCount);
|
|
244
|
+
schemas.forEach((schema) => {
|
|
245
|
+
expect(schema).to.not.be.undefined;
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
//# sourceMappingURL=ConcurrentGetSchemaJson.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrentGetSchemaJson.test.js","sourceRoot":"","sources":["../../../src/test/ConcurrentGetSchemaJson.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAU,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3H,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE5D,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,IAAI,OAAsB,CAAC;IAC3B,IAAI,WAA0B,CAAC;IAC/B,IAAI,WAAW,GAA8B,EAAE,CAAC;IAEhD,MAAM,OAAO,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAE5C,MAAM,CAAC,GAAG,EAAE;QACV,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC1B,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;YAC9B,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAE7B,sBAAsB,EAAE,CAAC;QAEzB,uEAAu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C;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6EAA6E,EAAE,KAAK,IAAI,EAAE;QAC3F,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;QAC1C,MAAM,WAAW,GAAG,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAC1D,aAAa,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAEtC,IAAI,eAAe,GAAG,CAAC,CAAC;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;YAC5C,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;gBAC1B,eAAe,GAAG,CAAC,CAAC;gBACpB,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACxE,CAAC,CAAC,CACH,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","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 { assert, expect } from \"chai\";\r\nimport * as fs from \"fs\";\r\nimport * as path from \"path\";\r\nimport { ECVersion, Schema, SchemaContext, SchemaJsonLocater, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaJsonFileLocater } from \"../SchemaJsonFileLocater\";\r\n\r\ndescribe(\"Concurrent schema JSON deserialization\", () => {\r\n const assetDir: string = path.join(__dirname, \"assets\");\r\n const schemaFolder = path.join(__dirname, \"assets\", \"json\");\r\n\r\n const schemaKeys: SchemaKey[] = [];\r\n let context: SchemaContext;\r\n let contextSync: SchemaContext;\r\n let syncSchemas: Array<Schema | undefined> = [];\r\n\r\n const locater = new SchemaJsonFileLocater();\r\n\r\n before(() => {\r\n if (!fs.existsSync(assetDir))\r\n fs.mkdirSync(assetDir);\r\n if (!fs.existsSync(schemaFolder))\r\n fs.mkdirSync(schemaFolder);\r\n\r\n copySchemasToAssetsDir();\r\n\r\n // Deserialize schemas synchronously/serially as standard to compare to\r\n contextSync = new SchemaContext();\r\n locater.addSchemaSearchPath(schemaFolder);\r\n contextSync.addLocater(locater);\r\n\r\n const schemaFiles = fs.readdirSync(schemaFolder);\r\n schemaFiles.forEach((fileName) => {\r\n const schemaFile = path.join(schemaFolder, fileName);\r\n const schemaJson = JSON.parse(fs.readFileSync(schemaFile, \"utf-8\"));\r\n const schemaName = schemaJson.name;\r\n const schemaVersion = schemaJson.version;\r\n\r\n const key = new SchemaKey(schemaName.toString(), ECVersion.fromString(schemaVersion.toString()));\r\n schemaKeys.push(key);\r\n });\r\n\r\n syncSchemas = schemaKeys.map((key): Schema | undefined => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = contextSync.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n });\r\n\r\n beforeEach(() => {\r\n context = new SchemaContext();\r\n context.addLocater(locater);\r\n });\r\n\r\n function getSchemaPathFromPackage(packageName: string, schemaFileName: string): string {\r\n const schemaFile = path.join(__dirname, \"..\", \"..\", \"..\", \"node_modules\", \"@bentley\", packageName, schemaFileName);\r\n return schemaFile;\r\n }\r\n\r\n function copySchemasToAssetsDir() {\r\n // Copy Schemas that we need for testing\r\n fs.copyFileSync(getSchemaPathFromPackage(\"aec-units-schema\", \"AecUnits.ecschema.json\"), path.join(schemaFolder, \"AecUnits.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"architectural-physical-schema\", \"ArchitecturalPhysical.ecschema.json\"), path.join(schemaFolder, \"ArchitecturalPhysical.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-core-schema\", \"BisCore.ecschema.json\"), path.join(schemaFolder, \"BisCore.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-custom-attributes-schema\", \"BisCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"BisCustomAttributes.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"construction-schema\", \"Construction.ecschema.json\"), path.join(schemaFolder, \"Construction.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"core-custom-attributes-schema\", \"CoreCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"CoreCustomAttributes.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-map-schema\", \"ECDbMap.ecschema.json\"), path.join(schemaFolder, \"ECDbMap.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-schema-policies-schema\", \"ECDbSchemaPolicies.ecschema.json\"), path.join(schemaFolder, \"ECDbSchemaPolicies.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"formats-schema\", \"Formats.ecschema.json\"), path.join(schemaFolder, \"Formats.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"linear-referencing-schema\", \"LinearReferencing.ecschema.json\"), path.join(schemaFolder, \"LinearReferencing.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"physical-material-schema\", \"PhysicalMaterial.ecschema.json\"), path.join(schemaFolder, \"PhysicalMaterial.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"plant-custom-attributes-schema\", \"PlantCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"PlantCustomAttributes.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"quantity-takeoffs-aspects-schema\", \"QuantityTakeoffsAspects.ecschema.json\"), path.join(schemaFolder, \"QuantityTakeoffsAspects.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"spatial-composition-schema\", \"SpatialComposition.ecschema.json\"), path.join(schemaFolder, \"SpatialComposition.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"structural-physical-schema\", \"StructuralPhysical.ecschema.json\"), path.join(schemaFolder, \"StructuralPhysical.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"units-schema\", \"Units.ecschema.json\"), path.join(schemaFolder, \"Units.ecschema.json\"));\r\n }\r\n\r\n it(\"should match schemas deserialized concurrently with schemas deserialized serially\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n const asyncSchemas = await Promise.all(schemaPromises);\r\n\r\n for (let i = 0; i < schemaKeys.length; i++) {\r\n const syncSchema = syncSchemas[i];\r\n expect(syncSchema).not.to.be.undefined;\r\n const syncJSON = syncSchema!.toJSON();\r\n\r\n const asyncSchema = asyncSchemas[i];\r\n expect(asyncSchema).not.to.be.undefined;\r\n const asyncJSON = asyncSchema!.toJSON();\r\n expect(asyncJSON).to.deep.equal(syncJSON);\r\n }\r\n });\r\n\r\n it(\"should be able to mix getSchema and getSchemaSync\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key, index): Promise<Schema | undefined> => {\r\n if (index % 2 === 0) {\r\n // Use getSchema() for even indices\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n } else {\r\n // Use getSchemaSync() for odd indices\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema;\r\n }\r\n });\r\n const schemas = await Promise.all(schemaPromises);\r\n\r\n for (let i = 0; i < schemaKeys.length; i++) {\r\n const syncSchema = syncSchemas[i];\r\n expect(syncSchema).not.to.be.undefined;\r\n const syncJSON = syncSchema!.toJSON();\r\n\r\n const schema = schemas[i];\r\n expect(schema).not.to.be.undefined;\r\n const schemaJSON = schema!.toJSON();\r\n expect(schemaJSON).to.deep.equal(syncJSON);\r\n }\r\n });\r\n\r\n /* Run these tests below one at a time. Running them together doesn't get accurate performance likely bc of disk access caching */\r\n it.skip(\"should measure regular deserialization performance\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n\r\n for (const promise of schemaPromises) {\r\n await promise;\r\n }\r\n\r\n expect(schemaPromises.length).to.equal(schemaKeys.length);\r\n });\r\n\r\n it.skip(\"should measure concurrent deserialization performance\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n const asyncSchemas = await Promise.all(schemaPromises);\r\n\r\n expect(asyncSchemas.length).to.equal(schemaKeys.length);\r\n });\r\n\r\n it(\"Concurrently get BisCore with SchemaJsonFileLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonFileLocater = new SchemaJsonFileLocater();\r\n jsonFileLocater.addSchemaSearchPath(schemaFolder);\r\n schemaContext.addLocater(jsonFileLocater);\r\n\r\n const schemas = await Promise.all(\r\n [...Array(100).keys()].map(async () => {\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(100);\r\n schemas.forEach((schema) => {\r\n assert(schema !== undefined);\r\n expect(schema.fullName).to.equal(\"BisCore\");\r\n });\r\n });\r\n\r\n it(\"Concurrently get a schema and it's referenced schema with SchemaJsonFileLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonFileLocater = new SchemaJsonFileLocater();\r\n jsonFileLocater.addSchemaSearchPath(schemaFolder);\r\n schemaContext.addLocater(jsonFileLocater);\r\n\r\n let getBisCoreFirst = 0;\r\n const schemas = await Promise.all(\r\n [...Array(2).keys()].map(async () => {\r\n if (getBisCoreFirst === 0) {\r\n getBisCoreFirst = 1;\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }\r\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(2);\r\n schemas.forEach((schema) => {\r\n expect(schema).to.not.be.undefined;\r\n });\r\n });\r\n\r\n const getSchemaProps = (schemaName: string) => {\r\n if (schemaName === \"BisCore\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"bis\",\r\n description: \"The BIS core schema contains classes that all other domain schemas extend.\",\r\n label: \"BIS Core\",\r\n name: \"BisCore\",\r\n version: \"01.00.15\",\r\n references:[{name:\"CoreCustomAttributes\", version:\"01.00.04\"},{name:\"ECDbMap\", version:\"02.00.00\"},{name:\"ECDbSchemaPolicies\", version:\"01.00.00\"}],\r\n };\r\n }\r\n if (schemaName === \"CoreCustomAttributes\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"CoreCA\",\r\n description: \"Custom attributes to indicate core EC concepts, may include struct classes intended for use in core custom attributes.\",\r\n label: \"Core Custom Attributes\",\r\n name: \"CoreCustomAttributes\",\r\n version: \"01.00.04\",\r\n };\r\n }\r\n if (schemaName === \"ECDbMap\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"ECDbMap\",\r\n description: \"ECDbMap Desc\",\r\n label: \"ECDbMap\",\r\n name: \"ECDbMap\",\r\n version: \"02.00.00\",\r\n };\r\n }\r\n if (schemaName === \"ECDbSchemaPolicies\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"ECDbSchemaPolicies\",\r\n description: \"ECDbSchemaPolicies Desc\",\r\n label: \"ECDbSchemaPolicies\",\r\n name: \"ECDbSchemaPolicies\",\r\n version: \"01.00.00\",\r\n };\r\n }\r\n\r\n return undefined;\r\n };\r\n\r\n it(\"Concurrently get BisCore with SchemaJsonLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonLocater = new SchemaJsonLocater(getSchemaProps);\r\n schemaContext.addLocater(jsonLocater);\r\n\r\n const schemaCount = 1000;\r\n const schemas = await Promise.all(\r\n [...Array(schemaCount).keys()].map(async () => {\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(schemaCount);\r\n schemas.forEach((schema) => {\r\n assert(schema !== undefined);\r\n expect(schema.fullName).to.equal(\"BisCore\");\r\n });\r\n });\r\n\r\n it(\"Concurrently get a schema and it's referenced schema with SchemaJsonLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonLocater = new SchemaJsonLocater(getSchemaProps);\r\n schemaContext.addLocater(jsonLocater);\r\n\r\n let getBisCoreFirst = 0;\r\n const schemaCount = 1000;\r\n const schemas = await Promise.all(\r\n [...Array(schemaCount).keys()].map(async () => {\r\n if (getBisCoreFirst === 0) {\r\n getBisCoreFirst = 1;\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }\r\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(schemaCount);\r\n schemas.forEach((schema) => {\r\n expect(schema).to.not.be.undefined;\r\n });\r\n });\r\n});\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrentGetSchemaXml.test.d.ts","sourceRoot":"","sources":["../../../src/test/ConcurrentGetSchemaXml.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { assert, expect } from "chai";
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { SchemaContext, SchemaKey, SchemaMatchType } from "@itwin/ecschema-metadata";
|
|
9
|
+
import { SchemaXmlFileLocater } from "../SchemaXmlFileLocater";
|
|
10
|
+
import { StubSchemaXmlFileLocater } from "../StubSchemaXmlFileLocater";
|
|
11
|
+
import { SchemaXml } from "../SchemaXml";
|
|
12
|
+
import { SchemaXmlStringLocater } from "../SchemaXmlStringLocater";
|
|
13
|
+
describe("Concurrent XML schema deserialization", () => {
|
|
14
|
+
const assetDir = path.join(__dirname, "assets");
|
|
15
|
+
const schemaFolder = path.join(__dirname, "assets", "xml");
|
|
16
|
+
const schemaKeys = [];
|
|
17
|
+
let context;
|
|
18
|
+
let contextSync;
|
|
19
|
+
let syncSchemas = [];
|
|
20
|
+
const locater = new SchemaXmlFileLocater();
|
|
21
|
+
const helperLocater = new StubSchemaXmlFileLocater();
|
|
22
|
+
before(() => {
|
|
23
|
+
if (!fs.existsSync(assetDir))
|
|
24
|
+
fs.mkdirSync(assetDir);
|
|
25
|
+
if (!fs.existsSync(schemaFolder))
|
|
26
|
+
fs.mkdirSync(schemaFolder);
|
|
27
|
+
copySchemasToAssetsDir();
|
|
28
|
+
// Deserialize schemas synchronously/serially as standard to compare to
|
|
29
|
+
contextSync = new SchemaContext();
|
|
30
|
+
locater.addSchemaSearchPath(schemaFolder);
|
|
31
|
+
contextSync.addLocater(locater);
|
|
32
|
+
const schemaFiles = fs.readdirSync(schemaFolder);
|
|
33
|
+
schemaFiles.forEach((fileName) => {
|
|
34
|
+
const schemaFile = path.join(schemaFolder, fileName);
|
|
35
|
+
const key = helperLocater.getSchemaKey(fs.readFileSync(schemaFile, "utf-8"));
|
|
36
|
+
schemaKeys.push(key);
|
|
37
|
+
});
|
|
38
|
+
syncSchemas = schemaKeys.map((key) => {
|
|
39
|
+
if (!key)
|
|
40
|
+
return undefined;
|
|
41
|
+
const schema = contextSync.getSchemaSync(key, SchemaMatchType.Latest);
|
|
42
|
+
return schema;
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
context = new SchemaContext();
|
|
47
|
+
context.addLocater(locater);
|
|
48
|
+
});
|
|
49
|
+
function getSchemaPathFromPackage(packageName, schemaFileName) {
|
|
50
|
+
const schemaFile = path.join(__dirname, "..", "..", "..", "node_modules", "@bentley", packageName, schemaFileName);
|
|
51
|
+
return schemaFile;
|
|
52
|
+
}
|
|
53
|
+
function copySchemasToAssetsDir() {
|
|
54
|
+
// Copy Schemas that we need for testing
|
|
55
|
+
fs.copyFileSync(getSchemaPathFromPackage("aec-units-schema", "AecUnits.ecschema.xml"), path.join(schemaFolder, "AecUnits.ecschema.xml"));
|
|
56
|
+
fs.copyFileSync(getSchemaPathFromPackage("bis-custom-attributes-schema", "BisCustomAttributes.ecschema.xml"), path.join(schemaFolder, "BisCustomAttributes.ecschema.xml"));
|
|
57
|
+
fs.copyFileSync(getSchemaPathFromPackage("ecdb-map-schema", "ECDbMap.ecschema.xml"), path.join(schemaFolder, "ECDbMap.ecschema.xml"));
|
|
58
|
+
fs.copyFileSync(getSchemaPathFromPackage("ecdb-schema-policies-schema", "ECDbSchemaPolicies.ecschema.xml"), path.join(schemaFolder, "ECDbSchemaPolicies.ecschema.xml"));
|
|
59
|
+
fs.copyFileSync(getSchemaPathFromPackage("formats-schema", "Formats.ecschema.xml"), path.join(schemaFolder, "Formats.ecschema.xml"));
|
|
60
|
+
fs.copyFileSync(getSchemaPathFromPackage("units-schema", "Units.ecschema.xml"), path.join(schemaFolder, "Units.ecschema.xml"));
|
|
61
|
+
fs.copyFileSync(getSchemaPathFromPackage("core-custom-attributes-schema", "CoreCustomAttributes.ecschema.xml"), path.join(schemaFolder, "CoreCustomAttributes.ecschema.xml"));
|
|
62
|
+
fs.copyFileSync(getSchemaPathFromPackage("bis-core-schema", "BisCore.ecschema.xml"), path.join(schemaFolder, "BisCore.ecschema.xml"));
|
|
63
|
+
}
|
|
64
|
+
const loadSchemaString = (schemaName) => {
|
|
65
|
+
const searchPath = path.join(__dirname, "assets", "xml", `${schemaName}.ecschema.xml`);
|
|
66
|
+
const file = fs.readFileSync(searchPath);
|
|
67
|
+
return file.toString();
|
|
68
|
+
};
|
|
69
|
+
it("should match schemas deserialized concurrently with schemas deserialized serially", async () => {
|
|
70
|
+
const schemaPromises = schemaKeys.map(async (key) => {
|
|
71
|
+
if (!key)
|
|
72
|
+
return undefined;
|
|
73
|
+
const schema = await context.getSchema(key, SchemaMatchType.Latest);
|
|
74
|
+
return schema;
|
|
75
|
+
});
|
|
76
|
+
const asyncSchemas = await Promise.all(schemaPromises);
|
|
77
|
+
for (let i = 0; i < schemaKeys.length; i++) {
|
|
78
|
+
const syncSchema = syncSchemas[i];
|
|
79
|
+
expect(syncSchema).not.to.be.undefined;
|
|
80
|
+
const syncXML = await SchemaXml.writeString(syncSchema);
|
|
81
|
+
const asyncSchema = asyncSchemas[i];
|
|
82
|
+
expect(asyncSchema).not.to.be.undefined;
|
|
83
|
+
const asyncXML = await SchemaXml.writeString(asyncSchema);
|
|
84
|
+
expect(asyncXML).to.deep.equal(syncXML);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
it("should be able to mix getSchema and getSchemaSync", async () => {
|
|
88
|
+
const schemaPromises = schemaKeys.map(async (key, index) => {
|
|
89
|
+
if (index % 2 === 0) {
|
|
90
|
+
// Use getSchema() for even indices
|
|
91
|
+
if (!key)
|
|
92
|
+
return undefined;
|
|
93
|
+
const schema = await context.getSchema(key, SchemaMatchType.Latest);
|
|
94
|
+
return schema;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Use getSchemaSync() for odd indices
|
|
98
|
+
if (!key)
|
|
99
|
+
return undefined;
|
|
100
|
+
const schema = context.getSchemaSync(key, SchemaMatchType.Latest);
|
|
101
|
+
return schema;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const asyncSchemas = await Promise.all(schemaPromises);
|
|
105
|
+
for (let i = 0; i < schemaKeys.length; i++) {
|
|
106
|
+
const syncSchema = syncSchemas[i];
|
|
107
|
+
expect(syncSchema).not.to.be.undefined;
|
|
108
|
+
const syncXML = await SchemaXml.writeString(syncSchema);
|
|
109
|
+
const asyncSchema = asyncSchemas[i];
|
|
110
|
+
expect(asyncSchema).not.to.be.undefined;
|
|
111
|
+
const asyncXML = await SchemaXml.writeString(asyncSchema);
|
|
112
|
+
expect(asyncXML).to.deep.equal(syncXML);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
it("Concurrently get BisCore with SchemaXmlFileLocater", async () => {
|
|
116
|
+
const schemaContext = new SchemaContext();
|
|
117
|
+
const xmlFileLocater = new SchemaXmlFileLocater();
|
|
118
|
+
xmlFileLocater.addSchemaSearchPath(schemaFolder);
|
|
119
|
+
schemaContext.addLocater(xmlFileLocater);
|
|
120
|
+
const schemas = await Promise.all([...Array(100).keys()].map(async () => {
|
|
121
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
122
|
+
}));
|
|
123
|
+
expect(schemas.length).to.equal(100);
|
|
124
|
+
schemas.forEach((schema) => {
|
|
125
|
+
assert(schema !== undefined);
|
|
126
|
+
expect(schema.fullName).to.equal("BisCore");
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it("Concurrently get a schema and it's referenced schema with SchemaXmlFileLocater", async () => {
|
|
130
|
+
const schemaContext = new SchemaContext();
|
|
131
|
+
const xmlFileLocater = new SchemaXmlFileLocater();
|
|
132
|
+
xmlFileLocater.addSchemaSearchPath(schemaFolder);
|
|
133
|
+
schemaContext.addLocater(xmlFileLocater);
|
|
134
|
+
let getBisCoreFirst = 0;
|
|
135
|
+
const schemas = await Promise.all([...Array(2).keys()].map(async () => {
|
|
136
|
+
if (getBisCoreFirst === 0) {
|
|
137
|
+
getBisCoreFirst = 1;
|
|
138
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
139
|
+
}
|
|
140
|
+
return schemaContext.getSchema(new SchemaKey("CoreCustomAttributes"));
|
|
141
|
+
}));
|
|
142
|
+
expect(schemas.length).to.equal(2);
|
|
143
|
+
schemas.forEach((schema) => {
|
|
144
|
+
expect(schema).to.not.be.undefined;
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
it("Concurrently get BisCore with SchemaXmlStringLocater", async () => {
|
|
148
|
+
const schemaContext = new SchemaContext();
|
|
149
|
+
const xmlStringLocater = new SchemaXmlStringLocater();
|
|
150
|
+
schemaContext.addLocater(xmlStringLocater);
|
|
151
|
+
xmlStringLocater.addSchemaString(loadSchemaString("CoreCustomAttributes"));
|
|
152
|
+
xmlStringLocater.addSchemaString(loadSchemaString("ECDbMap"));
|
|
153
|
+
xmlStringLocater.addSchemaString(loadSchemaString("ECDbSchemaPolicies"));
|
|
154
|
+
xmlStringLocater.addSchemaString(loadSchemaString("BisCore"));
|
|
155
|
+
const schemas = await Promise.all([...Array(100).keys()].map(async () => {
|
|
156
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
157
|
+
}));
|
|
158
|
+
expect(schemas.length).to.equal(100);
|
|
159
|
+
schemas.forEach((schema) => {
|
|
160
|
+
assert(schema !== undefined);
|
|
161
|
+
expect(schema.fullName).to.equal("BisCore");
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
it("Concurrently get a schema and it's referenced schema with SchemaXmlStringLocater", async () => {
|
|
165
|
+
const schemaContext = new SchemaContext();
|
|
166
|
+
const xmlStringLocater = new SchemaXmlStringLocater();
|
|
167
|
+
schemaContext.addLocater(xmlStringLocater);
|
|
168
|
+
xmlStringLocater.addSchemaString(loadSchemaString("CoreCustomAttributes"));
|
|
169
|
+
xmlStringLocater.addSchemaString(loadSchemaString("ECDbMap"));
|
|
170
|
+
xmlStringLocater.addSchemaString(loadSchemaString("ECDbSchemaPolicies"));
|
|
171
|
+
xmlStringLocater.addSchemaString(loadSchemaString("BisCore"));
|
|
172
|
+
let getBisCoreFirst = 0;
|
|
173
|
+
const schemas = await Promise.all([...Array(2).keys()].map(async () => {
|
|
174
|
+
if (getBisCoreFirst === 0) {
|
|
175
|
+
getBisCoreFirst = 1;
|
|
176
|
+
return schemaContext.getSchema(new SchemaKey("BisCore"));
|
|
177
|
+
}
|
|
178
|
+
return schemaContext.getSchema(new SchemaKey("CoreCustomAttributes"));
|
|
179
|
+
}));
|
|
180
|
+
expect(schemas.length).to.equal(2);
|
|
181
|
+
schemas.forEach((schema) => {
|
|
182
|
+
expect(schema).to.not.be.undefined;
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
//# sourceMappingURL=ConcurrentGetSchemaXml.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrentGetSchemaXml.test.js","sourceRoot":"","sources":["../../../src/test/ConcurrentGetSchemaXml.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAU,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAA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C,CAAC;QACnC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","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 { assert, expect } from \"chai\";\r\nimport * as fs from \"fs\";\r\nimport * as path from \"path\";\r\nimport { Schema, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaXmlFileLocater } from \"../SchemaXmlFileLocater\";\r\nimport { StubSchemaXmlFileLocater } from \"../StubSchemaXmlFileLocater\";\r\nimport { SchemaXml } from \"../SchemaXml\";\r\nimport { SchemaXmlStringLocater } from \"../SchemaXmlStringLocater\";\r\n\r\ndescribe(\"Concurrent XML schema deserialization\", () => {\r\n const assetDir: string = path.join(__dirname, \"assets\");\r\n const schemaFolder = path.join(__dirname, \"assets\", \"xml\");\r\n\r\n const schemaKeys: SchemaKey[] = [];\r\n let context: SchemaContext;\r\n let contextSync: SchemaContext;\r\n let syncSchemas: Array<Schema | undefined> = [];\r\n\r\n const locater = new SchemaXmlFileLocater();\r\n const helperLocater = new StubSchemaXmlFileLocater();\r\n\r\n before(() => {\r\n if (!fs.existsSync(assetDir))\r\n fs.mkdirSync(assetDir);\r\n if (!fs.existsSync(schemaFolder))\r\n fs.mkdirSync(schemaFolder);\r\n\r\n copySchemasToAssetsDir();\r\n\r\n // Deserialize schemas synchronously/serially as standard to compare to\r\n contextSync = new SchemaContext();\r\n locater.addSchemaSearchPath(schemaFolder);\r\n contextSync.addLocater(locater);\r\n\r\n const schemaFiles = fs.readdirSync(schemaFolder);\r\n schemaFiles.forEach((fileName) => {\r\n const schemaFile = path.join(schemaFolder, fileName);\r\n const key = helperLocater.getSchemaKey(fs.readFileSync(schemaFile, \"utf-8\"));\r\n\r\n schemaKeys.push(key);\r\n });\r\n\r\n syncSchemas = schemaKeys.map((key): Schema | undefined => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = contextSync.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n });\r\n\r\n beforeEach(() => {\r\n context = new SchemaContext();\r\n context.addLocater(locater);\r\n });\r\n\r\n function getSchemaPathFromPackage(packageName: string, schemaFileName: string): string {\r\n const schemaFile = path.join(__dirname, \"..\", \"..\", \"..\", \"node_modules\", \"@bentley\", packageName, schemaFileName);\r\n return schemaFile;\r\n }\r\n\r\n function copySchemasToAssetsDir() {\r\n // Copy Schemas that we need for testing\r\n fs.copyFileSync(getSchemaPathFromPackage(\"aec-units-schema\", \"AecUnits.ecschema.xml\"), path.join(schemaFolder, \"AecUnits.ecschema.xml\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-custom-attributes-schema\", \"BisCustomAttributes.ecschema.xml\"), path.join(schemaFolder, \"BisCustomAttributes.ecschema.xml\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-map-schema\", \"ECDbMap.ecschema.xml\"), path.join(schemaFolder, \"ECDbMap.ecschema.xml\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-schema-policies-schema\", \"ECDbSchemaPolicies.ecschema.xml\"), path.join(schemaFolder, \"ECDbSchemaPolicies.ecschema.xml\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"formats-schema\", \"Formats.ecschema.xml\"), path.join(schemaFolder, \"Formats.ecschema.xml\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"units-schema\", \"Units.ecschema.xml\"), path.join(schemaFolder, \"Units.ecschema.xml\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"core-custom-attributes-schema\", \"CoreCustomAttributes.ecschema.xml\"), path.join(schemaFolder, \"CoreCustomAttributes.ecschema.xml\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-core-schema\", \"BisCore.ecschema.xml\"), path.join(schemaFolder, \"BisCore.ecschema.xml\"));\r\n }\r\n\r\n const loadSchemaString = (schemaName: string) => {\r\n const searchPath = path.join(__dirname, \"assets\", \"xml\", `${schemaName}.ecschema.xml`);\r\n const file = fs.readFileSync(searchPath);\r\n return file.toString();\r\n };\r\n\r\n it(\"should match schemas deserialized concurrently with schemas deserialized serially\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n const asyncSchemas = await Promise.all(schemaPromises);\r\n\r\n for (let i = 0; i < schemaKeys.length; i++) {\r\n const syncSchema = syncSchemas[i];\r\n expect(syncSchema).not.to.be.undefined;\r\n const syncXML = await SchemaXml.writeString(syncSchema!);\r\n\r\n const asyncSchema = asyncSchemas[i];\r\n expect(asyncSchema).not.to.be.undefined;\r\n const asyncXML = await SchemaXml.writeString(asyncSchema!);\r\n expect(asyncXML).to.deep.equal(syncXML);\r\n }\r\n });\r\n\r\n it(\"should be able to mix getSchema and getSchemaSync\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key, index): Promise<Schema | undefined> => {\r\n if (index % 2 === 0) {\r\n // Use getSchema() for even indices\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n } else {\r\n // Use getSchemaSync() for odd indices\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema;\r\n }\r\n });\r\n const asyncSchemas = await Promise.all(schemaPromises);\r\n\r\n for (let i = 0; i < schemaKeys.length; i++) {\r\n const syncSchema = syncSchemas[i];\r\n expect(syncSchema).not.to.be.undefined;\r\n const syncXML = await SchemaXml.writeString(syncSchema!);\r\n\r\n const asyncSchema = asyncSchemas[i];\r\n expect(asyncSchema).not.to.be.undefined;\r\n const asyncXML = await SchemaXml.writeString(asyncSchema!);\r\n expect(asyncXML).to.deep.equal(syncXML);\r\n }\r\n });\r\n\r\n it(\"Concurrently get BisCore with SchemaXmlFileLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const xmlFileLocater = new SchemaXmlFileLocater();\r\n xmlFileLocater.addSchemaSearchPath(schemaFolder);\r\n schemaContext.addLocater(xmlFileLocater);\r\n\r\n const schemas = await Promise.all(\r\n [...Array(100).keys()].map(async () => {\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(100);\r\n schemas.forEach((schema) => {\r\n assert(schema !== undefined);\r\n expect(schema.fullName).to.equal(\"BisCore\");\r\n });\r\n });\r\n\r\n it(\"Concurrently get a schema and it's referenced schema with SchemaXmlFileLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const xmlFileLocater = new SchemaXmlFileLocater();\r\n xmlFileLocater.addSchemaSearchPath(schemaFolder);\r\n schemaContext.addLocater(xmlFileLocater);\r\n\r\n let getBisCoreFirst = 0;\r\n const schemas = await Promise.all(\r\n [...Array(2).keys()].map(async () => {\r\n if (getBisCoreFirst === 0) {\r\n getBisCoreFirst = 1;\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }\r\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(2);\r\n schemas.forEach((schema) => {\r\n expect(schema).to.not.be.undefined;\r\n });\r\n });\r\n\r\n it(\"Concurrently get BisCore with SchemaXmlStringLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const xmlStringLocater = new SchemaXmlStringLocater();\r\n schemaContext.addLocater(xmlStringLocater);\r\n\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"CoreCustomAttributes\"));\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"ECDbMap\"));\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"ECDbSchemaPolicies\"));\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"BisCore\"));\r\n\r\n const schemas = await Promise.all(\r\n [...Array(100).keys()].map(async () => {\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(100);\r\n schemas.forEach((schema) => {\r\n assert(schema !== undefined);\r\n expect(schema.fullName).to.equal(\"BisCore\");\r\n });\r\n });\r\n\r\n it(\"Concurrently get a schema and it's referenced schema with SchemaXmlStringLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const xmlStringLocater = new SchemaXmlStringLocater();\r\n schemaContext.addLocater(xmlStringLocater);\r\n\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"CoreCustomAttributes\"));\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"ECDbMap\"));\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"ECDbSchemaPolicies\"));\r\n xmlStringLocater.addSchemaString(loadSchemaString(\"BisCore\"));\r\n\r\n let getBisCoreFirst = 0;\r\n const schemas = await Promise.all(\r\n [...Array(2).keys()].map(async () => {\r\n if (getBisCoreFirst === 0) {\r\n getBisCoreFirst = 1;\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }\r\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(2);\r\n schemas.forEach((schema) => {\r\n expect(schema).to.not.be.undefined;\r\n });\r\n });\r\n});\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaJsonFileLocator.test.d.ts","sourceRoot":"","sources":["../../../src/test/SchemaJsonFileLocator.test.ts"],"names":[],"mappings":""}
|