diff --git a/packages/testkit-backend/src/controller/local.js b/packages/testkit-backend/src/controller/local.js index c5aa1aad6..84bf4d402 100644 --- a/packages/testkit-backend/src/controller/local.js +++ b/packages/testkit-backend/src/controller/local.js @@ -1,6 +1,7 @@ import Context from '../context' import Controller from './interface' import stringify from '../stringify' +import { isFrontendError } from '../request-handlers' /** @@ -25,7 +26,7 @@ export default class LocalController extends Controller { closeContext (contextId) { this._contexts.delete(contextId) } - + async handle (contextId, { name, data }) { if (!this._contexts.has(contextId)) { throw new Error(`Context ${contextId} does not exist`) @@ -54,23 +55,23 @@ export default class LocalController extends Controller { _writeError (contextId, e) { if (e.name) { - const id = this._contexts.get(contextId).addError(e) - this._writeResponse(contextId, newResponse('DriverError', { - id, - msg: e.message + ' (' + e.code + ')', - code: e.code - })) + if (isFrontendError(e)) { + this._writeResponse(contextId, newResponse('FrontendError', { + msg: 'Simulating the client code throwing some error.', + })) + } else { + const id = this._contexts.get(contextId).addError(e) + this._writeResponse(contextId, newResponse('DriverError', { + id, + msg: e.message + ' (' + e.code + ')', + code: e.code + })) + } return } this._writeBackendError(contextId, e) } - _msg (name, data) { - return { - name, data - } - } - } function newResponse (name, data) { diff --git a/packages/testkit-backend/src/request-handlers.js b/packages/testkit-backend/src/request-handlers.js index 01e8b420b..92ea423c6 100644 --- a/packages/testkit-backend/src/request-handlers.js +++ b/packages/testkit-backend/src/request-handlers.js @@ -1,9 +1,15 @@ import neo4j from './neo4j' -import { - cypherToNative -} from './cypher-native-binders.js' +import { cypherToNative } from './cypher-native-binders.js' import * as responses from './responses.js' +export function throwFrontendError() { + throw new Error("TestKit FrontendError") +} + +export function isFrontendError(error) { + return error.message === 'TestKit FrontendError' +} + export function NewDriver (context, data, wire) { const { uri, @@ -96,8 +102,7 @@ export function DriverClose (context, data, wire) { .then(() => { wire.writeResponse(responses.Driver({ id: driverId })) }) - .catch(err => wire.writeError(err)) - .finally(() => context.removeDriver(driverId)) + .catch(err => wire.writeError(err)) } export function NewSession (context, data, wire) { @@ -254,7 +259,7 @@ export function RetryablePositive (context, data, wire) { export function RetryableNegative (context, data, wire) { const { sessionId, errorId } = data - const error = context.getError(errorId) || new Error('Client error') + const error = context.getError(errorId) || new Error('TestKit FrontendError') context.getTxsBySessionId(sessionId).forEach(tx => { tx.reject(error) }) @@ -263,7 +268,7 @@ export function RetryableNegative (context, data, wire) { export function SessionBeginTransaction (context, data, wire) { const { sessionId, txMeta: metadata, timeout } = data const session = context.getSession(sessionId) - + try { return session.beginTransaction({ metadata, timeout }) .then(tx => { diff --git a/packages/testkit-backend/src/skipped-tests/common.js b/packages/testkit-backend/src/skipped-tests/common.js index ca224c8f7..e8ae62731 100644 --- a/packages/testkit-backend/src/skipped-tests/common.js +++ b/packages/testkit-backend/src/skipped-tests/common.js @@ -135,6 +135,18 @@ const skippedTests = [ skip( 'Results are always valid but don\'t return records when out of scope', ifStartsWith('stub.iteration.test_result_scope.TestResultScope.') + ), + skip( + 'Driver (still) allows explicit managing of managed transaction', + ifEquals('stub.tx_lifetime.test_tx_lifetime.TestTxLifetime.test_managed_tx_raises_tx_managed_exec') + ), + skip( + 'Flaky tests, requires investigation', + ifEndsWith('.test_should_fail_when_reading_from_unexpectedly_interrupting_readers_using_tx_function') + ), + skip( + 'Flaky tests, requires investigation', + ifEndsWith('.test_should_fail_when_writing_to_unexpectedly_interrupting_writers_using_tx_function') ) ]