File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 476476 "test:performance:dexie" : " npm run transpile && cross-env DEFAULT_STORAGE=dexie CI=true karma start ./config/karma.performance.conf.cjs --single-run" ,
477477 "test:performance:memory:browser" : " npm run transpile && cross-env DEFAULT_STORAGE=memory CI=true karma start ./config/karma.performance.conf.cjs --single-run" ,
478478 "test:performance:memory:node" : " npm run transpile && cross-env DEFAULT_STORAGE=memory mocha --config ./config/.mocharc.cjs ./test_tmp/performance.test.js --unhandled-rejections=strict --expose-gc" ,
479+ "test:performance:memory:crypto-js" : " npm run transpile && cross-env DEFAULT_STORAGE=memory STORAGE_PASSWORD=test-password mocha --config ./config/.mocharc.cjs ./test_tmp/performance.test.js --unhandled-rejections=strict --expose-gc" ,
479480 "test:performance:memory:bun" : " npm run transpile && cross-env DEFAULT_STORAGE=memory bun run ./node_modules/mocha/bin/mocha test_tmp/performance.test.js --bail" ,
480481 "test:performance:memory:deno" : " npm run transpile && cross-env DEFAULT_STORAGE=memory deno run --allow-env --allow-read -A npm:mocha test/performance.test.ts --bail" ,
481482 "test:performance:foundationdb" : " npm run transpile && cross-env DEFAULT_STORAGE=foundationdb mocha --config ./config/.mocharc.cjs ./test_tmp/performance.test.js --unhandled-rejections=strict --expose-gc" ,
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ function getEnvVariables() {
4040 const ret : any = { } ;
4141 [
4242 'DEFAULT_STORAGE' ,
43- 'NODE_ENV'
43+ 'NODE_ENV' ,
44+ 'STORAGE_PASSWORD'
4445 ] . forEach ( k => {
4546 ret [ k ] = Deno . env . get ( k ) ;
4647 } ) ;
Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ export type PerformanceTestConfig = {
5353 * @default true
5454 */
5555 log ?: boolean ;
56+ /**
57+ * If set, the database will be created with encryption
58+ * and the schema will mark applicable fields as encrypted.
59+ */
60+ password ?: any ;
5661} ;
5762
5863export type PerformanceTestResult = {
@@ -84,7 +89,8 @@ export async function runPerformanceTests(
8489 parallelQueryAmount = 4 ,
8590 insertBatches = 6 ,
8691 waitBetweenTests = 100 ,
87- log = true
92+ log = true ,
93+ password
8894 } = config ;
8995
9096 const totalTimes : { [ k : string ] : number [ ] ; } = { } ;
@@ -121,6 +127,15 @@ export async function runPerformanceTests(
121127
122128 // create database
123129 const schema = averageSchema ( ) ;
130+ if ( password ) {
131+ schema . encrypted = [ 'deep' , 'list' ] ;
132+ schema . indexes = schema . indexes ! . filter ( index => {
133+ if ( typeof index === 'string' ) {
134+ return ! index . startsWith ( 'deep.' ) ;
135+ }
136+ return ! index . some ( field => field . startsWith ( 'deep.' ) ) ;
137+ } ) ;
138+ }
124139 let collection : RxCollection < AverageSchemaDocumentType > ;
125140 async function createDbWithCollections ( ) {
126141 if ( collection ) {
@@ -137,7 +152,8 @@ export async function runPerformanceTests(
137152 * creation time.
138153 */
139154 multiInstance : false ,
140- storage
155+ storage,
156+ password
141157 } ) ;
142158
143159 // create collections
Original file line number Diff line number Diff line change 33} from '../plugins/core/index.mjs' ;
44import * as assert from 'assert' ;
55import {
6+ ENV_VARIABLES ,
7+ getEncryptedStorage ,
68 isFastMode ,
79 isDeno ,
810 runPerformanceTests
@@ -31,10 +33,13 @@ describe('performance.test.ts', () => {
3133 this . timeout ( 500 * 1000 ) ;
3234 const runs = isFastMode ( ) ? 1 : 40 ;
3335 const perfStorage = config . storage . getPerformanceStorage ( ) ;
36+ const password = ENV_VARIABLES . STORAGE_PASSWORD || undefined ;
37+ const storage = password ? getEncryptedStorage ( perfStorage . storage ) : perfStorage . storage ;
38+ const description = password ? perfStorage . description + '-encrypted' : perfStorage . description ;
3439 await runPerformanceTests (
35- perfStorage . storage ,
36- perfStorage . description ,
37- { runs }
40+ storage ,
41+ description ,
42+ { runs, password }
3843 ) ;
3944 } ) ;
4045 /**
You can’t perform that action at this time.
0 commit comments