Skip to content

Commit 9fcafb2

Browse files
Relax query time tests
1 parent d1958b4 commit 9fcafb2

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

test/connection.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import { SQLiteCloudError } from '../src/index'
66
import { SQLiteCloudConnection, anonimizeCommand } from '../src/connection'
77
import { parseConnectionString } from '../src/utilities'
8-
import { CHINOOK_DATABASE_URL, TESTING_DATABASE_URL, LONG_TIMEOUT, getTestingConfig, getChinookConfig, getChinookConnection } from './shared'
9-
import { Database } from 'sqlite3'
8+
import { CHINOOK_DATABASE_URL, LONG_TIMEOUT, getTestingConfig, getChinookConfig, getChinookConnection, WARN_SPEED_MS, EXPECT_SPEED_MS } from './shared'
109

1110
describe('connection', () => {
1211
let chinook: SQLiteCloudConnection
@@ -363,8 +362,10 @@ describe('connection', () => {
363362
expect(results).toBe('Hello World, this is a test string.')
364363
if (++completed >= numQueries) {
365364
const queryMs = (Date.now() - startTime) / numQueries
366-
console.log(`${numQueries}x test string, ${queryMs.toFixed(0)}ms per query`)
367-
expect(queryMs).toBeLessThan(2000)
365+
if (queryMs > WARN_SPEED_MS) {
366+
console.log(`${numQueries}x test string, ${queryMs.toFixed(0)}ms per query`)
367+
expect(queryMs).toBeLessThan(EXPECT_SPEED_MS)
368+
}
368369
done()
369370
}
370371
})
@@ -386,8 +387,10 @@ describe('connection', () => {
386387
expect(results.numberOfRows).toBe(4)
387388
if (++completed >= numQueries) {
388389
const queryMs = (Date.now() - startTime) / numQueries
389-
console.log(`${numQueries}x individual selects, ${queryMs.toFixed(0)}ms per query`)
390-
expect(queryMs).toBeLessThan(2000)
390+
if (queryMs > WARN_SPEED_MS) {
391+
console.log(`${numQueries}x individual selects, ${queryMs.toFixed(0)}ms per query`)
392+
expect(queryMs).toBeLessThan(EXPECT_SPEED_MS)
393+
}
391394
done()
392395
}
393396
})
@@ -412,8 +415,10 @@ describe('connection', () => {
412415
expect(results.numberOfRows).toBe(4)
413416
if (++completed >= numQueries) {
414417
const queryMs = (Date.now() - startTime) / numQueries
415-
console.log(`${numQueries}x batched selects, ${queryMs.toFixed(0)}ms per query`)
416-
expect(queryMs).toBeLessThan(5000)
418+
if (queryMs > WARN_SPEED_MS) {
419+
console.log(`${numQueries}x batched selects, ${queryMs.toFixed(0)}ms per query`)
420+
expect(queryMs).toBeLessThan(EXPECT_SPEED_MS)
421+
}
417422
done()
418423
}
419424
}

test/shared.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ dotenv.config()
1515
export const LONG_TIMEOUT = 100 * 1000 // 100 seconds
1616
export const EXTRA_LONG_TIMEOUT = 60 * 60 * 1000 // 1 hour
1717

18+
/** Will warn if a query or other basic operation is slower than this */
19+
export const WARN_SPEED_MS = 500
20+
/** Will except queries to be quicker than this */
21+
export const EXPECT_SPEED_MS = 6 * 1000
22+
1823
/** Number of times or size of stress (when repeated in sequence) */
1924
export const SEQUENCE_TEST_SIZE = 75
2025
/** Concurrency size for multiple connection tests */

test/stress.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
*/
44

55
import { Database, SQLiteCloudRowset } from '../src'
6-
import { getChinookDatabase, getTestingDatabaseAsync, removeDatabaseAsync, SEQUENCE_TEST_SIZE, SIMULTANEOUS_TEST_SIZE, EXTRA_LONG_TIMEOUT } from './shared'
7-
8-
const WARN_SPEED_MS = 500 // will warn if slower than this
9-
const EXPECT_SPEED_MS = 6 * 1000 // will throw error if slower than this
6+
import {
7+
getChinookDatabase,
8+
getTestingDatabaseAsync,
9+
removeDatabaseAsync,
10+
SEQUENCE_TEST_SIZE,
11+
SIMULTANEOUS_TEST_SIZE,
12+
EXTRA_LONG_TIMEOUT,
13+
WARN_SPEED_MS,
14+
EXPECT_SPEED_MS
15+
} from './shared'
1016

1117
describe('stress testing', () => {
1218
it(

0 commit comments

Comments
 (0)