app.beforeStart(function*() { // dumpConfig() dynamically json = readJSON(path.join(baseDir, 'run/application_config.json')); assert(json.config.dynamic === 1, 'should dump in config'); json = readJSON(path.join(baseDir, 'run/agent_config.json')); assert(json.config.dynamic === 0, 'should dump in config'); yield sleep(2000); app.config.dynamic = 2; });
globalRoutesPrint(apiPrefix) { let r = []; r.push(apiPrefix + "tables"); r.push(apiPrefix + "xjoin"); if (this.sqlConfig.dynamic) { r.push(apiPrefix + "dynamic"); r.push("/upload"); r.push("/uploads"); r.push("/download"); } return r; }
function parseRaw(query, str, args = []) { const types = [] , xargs = [] args.forEach(x => parseValue(x, xargs, types)) return { sig: !query.dynamic && types + str, str, args: xargs } }
describe('dumpConfig() dynamically', () => { let app; before(() => { app = utils.app('apps/dumpconfig'); }); after(() => app.close()); it('should dump in config', async () => { const baseDir = utils.getFilepath('apps/dumpconfig'); let json; await app.ready(); json = readJson(path.join(baseDir, 'run/application_config.json')); assert(json.config.dynamic === 2); json = readJson(path.join(baseDir, 'run/agent_config.json')); assert(json.config.dynamic === 0); }); });
function query(query, connection, xs, args) { query.origin = options.debug ? new Error().stack : cachedError(xs) query.dynamic = query.dynamic || options.no_prepare if (!query.raw && (!Array.isArray(xs) || !Array.isArray(xs.raw))) return nested(xs, args) const promise = new Promise((resolve, reject) => { query.resolve = resolve query.reject = reject ended !== null ? reject(errors.connection('CONNECTION_ENDED', options)) : ready ? send(connection, query, xs, args) : fetchArrayTypes(connection).then(() => send(connection, query, xs, args)).catch(reject) }) addMethods(promise, query) return promise }
test('.updateValue() checks too large', () => { const mockKernel = { constructor: { features: { maxTextureSize: 1 }, }, validate: true, }; const v = new webGLKernelValueMaps.single.dynamic["Array1D(2)"]([[1,2]], { kernel: mockKernel, name: 'test', type: 'Array1D(2)', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue([[1,2],[3,4],[5,6],[7,8]]); }, new Error('Argument texture height of 2 larger than maximum size of 1 for your GPU')); });
test('.updateValue() checks too large', () => { const mockKernel = { constructor: { features: { maxTextureSize: 2 }, }, validate: true, }; const v = new webGLKernelValueMaps.unsigned.dynamic.Array([1,2], { kernel: mockKernel, name: 'test', type: 'Array', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue(new Array([1,2,3,4,5,6,7,8])); }, new Error('Argument texture width of 4 larger than maximum size of 2 for your GPU')); });
test('.updateValue() checks too large height', () => { const mockKernel = { constructor: { features: { maxTextureSize: 4 }, }, validate: true, }; const v = new webGL2KernelValueMaps.single.dynamic.Input({ size: [5, 5], value: [0] }, { kernel: mockKernel, name: 'test', type: 'Input', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue({ size: [16,16] }); }, new Error('Argument texture height and width of 8 larger than maximum size of 4 for your GPU')); });
test('.updateValue() checks too large height', () => { const mockKernel = { constructor: { features: { maxTextureSize: 1 }, }, validate: true, }; const v = new webGL2KernelValueMaps.unsigned.dynamic.HTMLImageArray([{ width: 1, height: 1 }], { kernel: mockKernel, name: 'test', type: 'HTMLImage', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue([{ width: 1, height: 2 }]); }, new Error('Argument texture height of 2 larger than maximum size of 1 for your GPU')); });
test('.updateValue() checks too large', () => { const mockKernel = { constructor: { features: { maxTextureSize: 1 }, }, validate: true, }; const v = new webGL2KernelValueMaps.single.dynamic.Array([1,2], { kernel: mockKernel, name: 'test', type: 'Array', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue(new Array([1,2,3,4,5,6,7,8])); }, new Error('Argument texture height of 2 larger than maximum size of 1 for your GPU')); });
test('.updateValue() checks too large width', () => { const mockKernel = { constructor: { features: { maxTextureSize: 1 }, }, validate: true, }; const v = new webGLKernelValueMaps.single.dynamic.Input({ size: [1, 1], value: [0] }, { kernel: mockKernel, name: 'test', type: 'Input', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue({ size: [3,3] }) }, new Error('Argument texture width of 3 larger than maximum size of 1 for your GPU')); });
test('.updateValue() checks too large width', () => { const mockKernel = { constructor: { features: { maxTextureSize: 4 }, }, validate: true, }; const v = new webGL2KernelValueMaps.single.dynamic.Input({ size: [1, 1], value: [0] }, { kernel: mockKernel, name: 'test', type: 'Input', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue({ size: [12,12] }) }, new Error('Argument texture height and width of 6 larger than maximum size of 4 for your GPU')); });
test('.updateValue() checks too large', () => { const mockKernel = { constructor: { features: { maxTextureSize: 1 }, }, validate: true, }; const v = new webGLKernelValueMaps.single.dynamic["Array2D(2)"]([[[1,2]]], { kernel: mockKernel, name: 'test', type: 'Array2D(2)', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue([[[1,2],[3,4],[5,6],[7,8]]]); }, new Error('Argument texture height of 2 larger than maximum size of 1 for your GPU')); });
test('.updateValue() checks too large', () => { const mockKernel = { constructor: { features: { maxTextureSize: 1 }, }, validate: true, }; const v = new webGLKernelValueMaps.single.dynamic["Array3D(2)"]([[[[1,2]]]], { kernel: mockKernel, name: 'test', type: 'Array3D(2)', origin: 'user', tactic: 'speed', onRequestContextHandle: () => 1, onRequestTexture: () => null, onRequestIndex: () => 1 }); assert.throws(() => { v.updateValue([[[[1,2],[3,4],[5,6],[7,8]]]]); }, new Error('Argument texture height of 2 larger than maximum size of 1 for your GPU')); });