node.js - Simulating Failure to Access Mongodb -
I create an Express.JS Library which uses the official Node.js driver for its Mongodb operation.
I am currently in the process of writing the unit test and I have to simulate the failures to reach the database to ensure:
- accept cases of library failure (Error is handled)
- Creates the right error callback and removes the appropriate events.
I want to run the exams cross-platform, specially without having to turn off the database of special parameters or start
for the command , This order is doing exactly what I want, but waiting time in seconds is too long, plus it has been marked only for internal use and you have to set the database to fire a particular parameter with The command looks good, but again, it's only been listed for internal use and details at ambiguous to say the least.
I'm wondering if there is a recommended (preferably not swan) ways to do this
Here, to execute this script, the node process requires superuser privileges for mono ddb process Without generating it, but the best part is that I have been able to simulate irregularity so far:
var needs MongoDB = ('mandode'); MongoDB.MongoClient.connect ("mongodb: // localhost: 27017 / someDB", {'server': {'socketOptions': {'connectTimeoutMS': 50, 'socketTimeoutMS': 50}}}, function (error, db) {If (Err) {console.log (Err);} else {DB.command ({'serverStatus': 1}, function (error, result) {if (Err) {console.log (Err)} other {process Check for the inscrutability process for testing .kill (Result.pid, 'sigstop'); // Kill (Result.pid, 'SIGCONT'); db.clos ();}});}}); EDIT: EDIT:
If your test argument crashes on Linux, then you can manually implement the monoodb process on the shell:
Mar-Penit PID
Where the PID is the process ID of the Songodi process.
Comments
Post a Comment