Skip to content

Commit f539b97

Browse files
authored
teskit: Fine tunning stress tests to run in testkit
Fix the way the url is generated during the stress test enabling to use configurations came from the test environment. Skipping the non-cluster-safe stress test commands to avoid unstable behaviours and flaky tests.
1 parent 5bb6d4b commit f539b97

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

test/internal/shared-neo4j.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ const env = global.__karma__ ? global.__karma__.config.env : process.env
123123
const username = env.TEST_NEO4J_USER || 'neo4j'
124124
const password = env.TEST_NEO4J_PASS || 'password'
125125
const hostname = env.TEST_NEO4J_HOST || 'localhost'
126+
const scheme = env.TEST_NEO4J_SCHEME || 'bolt'
127+
const cluster =
128+
env.TEST_NEO4J_IS_CLUSTER !== undefined
129+
? env.TEST_NEO4J_IS_CLUSTER === '1'
130+
: false
126131
const edition = env.TEST_NEO4J_EDITION || 'enterprise'
127132
const ipv6Enabled =
128133
env.TEST_NEO4J_IPV6_ENABLED !== undefined
@@ -369,5 +374,7 @@ export default {
369374
getEdition: getEdition,
370375
hostname: hostname,
371376
ipv6Enabled: ipv6Enabled,
372-
edition: edition
377+
edition: edition,
378+
scheme: scheme,
379+
cluster: cluster
373380
}

test/stress.test.js

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import sharedNeo4j from './internal/shared-neo4j'
2525

2626
describe('#integration stress tests', () => {
2727
const TEST_MODES = {
28+
fastest: {
29+
commandsCount: 10000,
30+
parallelism: 24,
31+
maxRunTimeMs: 3 * 60000 // 3 minutes
32+
},
2833
fast: {
2934
commandsCount: 5000,
3035
parallelism: 8,
@@ -44,7 +49,7 @@ describe('#integration stress tests', () => {
4449
const TEST_MODE = modeFromEnvOrDefault('STRESS_TEST_MODE')
4550
const DATABASE_URI = fromEnvOrDefault(
4651
'STRESS_TEST_DATABASE_URI',
47-
`bolt://${sharedNeo4j.hostname}`
52+
`${sharedNeo4j.scheme}://${sharedNeo4j.hostname}:${sharedNeo4j.port}`
4853
)
4954

5055
const USERNAME = fromEnvOrDefault(
@@ -57,10 +62,11 @@ describe('#integration stress tests', () => {
5762
)
5863

5964
function isRemoteCluster () {
60-
return (
61-
fromEnvOrDefault('STRESS_TEST_DATABASE_URI') !== undefined &&
62-
fromEnvOrDefault('STRESS_TEST_DATABASE_URI') !== undefined
63-
)
65+
return fromEnvOrDefault('STRESS_TEST_DATABASE_URI') !== undefined
66+
}
67+
68+
function isCluster () {
69+
return sharedNeo4j.cluster || isRemoteCluster()
6470
}
6571

6672
const LOGGING_ENABLED = fromEnvOrDefault('STRESS_TEST_LOGGING_ENABLED', false)
@@ -128,19 +134,27 @@ describe('#integration stress tests', () => {
128134
}
129135

130136
function createUniqueCommands (context) {
137+
const clusterSafeCommands = [
138+
readQueryInTxFunctionCommand(context),
139+
readQueryInTxFunctionWithBookmarkCommand(context),
140+
writeQueryInTxFunctionWithBookmarkCommand(context),
141+
writeQueryInTxFunctionCommand(context)
142+
]
143+
144+
if (isCluster()) {
145+
return clusterSafeCommands
146+
}
147+
131148
return [
149+
...clusterSafeCommands,
132150
readQueryCommand(context),
133151
readQueryWithBookmarkCommand(context),
134152
readQueryInTxCommand(context),
135-
readQueryInTxFunctionCommand(context),
136153
readQueryInTxWithBookmarkCommand(context),
137-
readQueryInTxFunctionWithBookmarkCommand(context),
138154
writeQueryCommand(context),
139155
writeQueryWithBookmarkCommand(context),
140156
writeQueryInTxCommand(context),
141-
writeQueryInTxFunctionCommand(context),
142-
writeQueryInTxWithBookmarkCommand(context),
143-
writeQueryInTxFunctionWithBookmarkCommand(context)
157+
writeQueryInTxWithBookmarkCommand(context)
144158
]
145159
}
146160

@@ -243,6 +257,13 @@ describe('#integration stress tests', () => {
243257
) {
244258
return callback => {
245259
const commandId = context.nextCommandId()
260+
if (isCluster()) {
261+
console.log(
262+
'SKIPPED: session.run is not safe to in clusters environments'
263+
)
264+
callback()
265+
return
266+
}
246267
const session = newSession(context, accessMode, useBookmark)
247268
const params = paramsSupplier()
248269

@@ -319,6 +340,13 @@ describe('#integration stress tests', () => {
319340
) {
320341
return callback => {
321342
const commandId = context.nextCommandId()
343+
if (isCluster()) {
344+
console.log(
345+
'SKIPPED: session.begintTransaction is not safe to in clusters environments'
346+
)
347+
callback()
348+
return
349+
}
322350
const session = newSession(context, accessMode, useBookmark)
323351
const tx = session.beginTransaction()
324352
const params = paramsSupplier()
@@ -415,7 +443,7 @@ describe('#integration stress tests', () => {
415443
function verifyServers (context) {
416444
const routing = DATABASE_URI.indexOf('neo4j') === 0
417445

418-
if (routing) {
446+
if (routing && isCluster()) {
419447
return verifyCausalClusterMembers(context)
420448
}
421449
return verifySingleInstance(context)

0 commit comments

Comments
 (0)