I am writing integration tests for my NodeJS application that connects to a Redis cluster. The test framework I use is Mocha. Is it possible to setup Redis as an in-memory database which I can use to only test which then wipes away all my keys when the test is done?
Check this out
https://github.com/mhassan1/redis-memory-server : Redis Server for testing. The server will allow you to connect your favorite client library to the Redis Server and run parallel integration tests isolated from each other.
Related
I want to use an in-memory database only while running unit test cases for express APIs.
For Instance in Java Spring we use H2 Database for testing and in main we used mysql.
So any recommendations on the same.
Also how I change the package.json so that while running mocha node will automatically catch that inmemory database for storing values.
Like in Spring we would application.properties in test folder and then spring would automatically fetch the test db settings.
I am using Mocha to unit test some of the Kue (redis) functions of my node server. Of course Mocha starts its own process. This process has its own instance which is, of course, scope protected from the node server I have running on the same physical server (my laptop in this case as I am in dev env).
My question is: how can the mocha server check any variables or events from the main node server? I realize I could get tricky and have node push variables to redis and then poll redis from mocha but that seems arduous.
You can't. Since the mocha is launching in a separate node process, any javascript variables global or local are relatively scoped to that individual node process. You are correct with the redis suggestion to send a message from process to process or literally launch the node server inside your mocha framework.
Can I use a redis cluster transparently (without writing any client side code for the redis cluster) with socket-io-redis instead of a single redis server as the default examples state? Unfortunately, there seems to be no official documentation on this.
Also, without a redis cluster, how many users can socket.io servers support with a single redis server as socket.io-redis backend?
Update:
Socket.io-redis allows specification of redis clients to use. May be some node_redis compatible redis client which also has support for redis clusters can be used? ioredis (the only other full featured/recommended client) has support for redis clusters but I am not sure if it's compatible with the node_redis client. Does anyone have some info on it or other possible solutions?
Note: I know Redis cloud provides scaling solution with a single endpoint paradigm but I need a cluster solution.
The module socket.io-ioredis allows use of ioredis with socket.io. Ioredis can connect to a redis cluster. However, I have, so far, only used socket.io-ioredis with socket.io with a single node server and single redis instance and it's working okay in this configuration.
How to Load test with NodeJS and MongoDB using Jmeter?
We need to Evaluate NodeJS and Mongo Db Performance?
As like any web application you can loadtest NodeJS application via web services or URLs.
You can use Jmeter Test Script recorder to record all requests and services of NodeJS app. If you need java script specific you can use phanos or Loadtest.
To load test mongo DB, since jmeter 2.9 there is a MongoDB sampler.
We are in process of developing an app and we started with:
Spring SockJs Java server with Servlet 3.0 container (Async support)
SockJs javascript client.
To test the load aspects, I had written a client using Bayeux API -this was for WebSockets and not for Polling.
Since Node makes strong case for async communication -so we want to evaluate its load capacity against Java server. From articles, I get a feel that Node scales -but we want to keep Java unless there is "significant" advantage going the Node.js way. And most important, we want to try it out for our specific use case rather than riding on popular opinion and hence we want to benchmark them on open connection handling over a period of time, My Question:
Is it possible to write a common client in JAVA -which can connect to both Java based server as well as NODE? Seems possible because at end its HTPP and does not matter what exposes it -but am not getting the right client. Even Bayeux does not work for NON websocket use case -Although I used same API to test "Websocket" connection for SockJs, CometD and Node server
What to do for Non Websocket , for example -Long Polling or streaming any client which can be run against a server "irrespective" whether its in CometD, SockJs or NODE?
SockJs cleint is a Java script client -we can emulate connections from browser -Is there a Java client for server?
Am new to javascript -so how a load test is written in javascript and how is it run (Socket one cannot be run from browser) -any sample code on github?