MCPcopy
hub / github.com/mongodb/node-mongodb-native / getTestOpDefinitions

Function getTestOpDefinitions

test/tools/cmap_spec_runner.ts:194–270  ·  view source on GitHub ↗
(threadContext: ThreadContext)

Source from the content-addressed store, hash-verified

192};
193
194const getTestOpDefinitions = (threadContext: ThreadContext) => ({
195 checkOut: async function (op) {
196 const timeoutContext = TimeoutContext.create({
197 serverSelectionTimeoutMS: 0,
198 waitQueueTimeoutMS: threadContext.pool.options.waitQueueTimeoutMS
199 });
200 const connection: Connection = await ConnectionPool.prototype.checkOut.call(
201 threadContext.pool,
202 { timeoutContext }
203 );
204 if (op.label != null) {
205 threadContext.connections.set(op.label, connection);
206 } else {
207 threadContext.orphans.add(connection);
208 }
209 },
210 checkIn: function (op) {
211 const connection = threadContext.connections.get(op.connection);
212 threadContext.connections.delete(op.connection);
213
214 if (!connection) {
215 throw new Error(`Attempted to release non-existient connection ${op.connection}`);
216 }
217
218 return threadContext.pool.checkIn(connection);
219 },
220 clear: function ({ interruptInUseConnections }: { interruptInUseConnections: boolean }) {
221 return threadContext.pool.clear({ interruptInUseConnections });
222 },
223 close: function () {
224 return ConnectionPool.prototype.close.call(threadContext.pool);
225 },
226 ready: function () {
227 return threadContext.pool.ready();
228 },
229 wait: function (options) {
230 const ms = options.ms;
231 return sleep(ms);
232 },
233 start: function (options) {
234 const target = options.target;
235 const thread = threadContext.getThread(target);
236 thread.start();
237 },
238 waitForThread: async function (options): Promise<void> {
239 const name = options.name;
240 const target = options.target;
241
242 const threadObj = threadContext.threads.get(target);
243
244 if (!threadObj) {
245 throw new Error(`Attempted to run op ${name} on non-existent thread ${target}`);
246 }
247
248 await threadObj.finish();
249 },
250 waitForEvent: function (options): Promise<void> {
251 const event = options.event;

Callers 1

constructorMethod · 0.85

Calls 11

setMethod · 0.80
addMethod · 0.80
checkInMethod · 0.80
getThreadMethod · 0.80
runFunction · 0.70
getMethod · 0.45
deleteMethod · 0.45
clearMethod · 0.45
readyMethod · 0.45
startMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected