iotcomms.io contributes back chai-sip, a plugin to the Chai.js assertion library that allows writing of test cases simulating SIP endpoints for real-time communications with low friction.

The plugin and documentation is found here:
https://github.com/iotcomms/chai-sip

The days of huge system software upgrades driving software teams to nervous breakdown weeks before releasing due to extreme workload are history! Forget keeping customers up at night during nightly service windows and at toes hoping everything worked the following weeks. This is todays reality unless you are stuck with a system of Monolithic design.

It is the evolution of Microservices architectures, modern development processes and great tool support that helps building an automated continuous deployment pipeline enabling multiple deployments of new software versions every day to customers. In fact AWS is releasing new code to the public every 11.7 second!

A key component for success in this shiny new world is to have a fully automated continuous deployment pipeline where the committed code is automatically tested. If the tests pass successfully the software is automatically released to production.

Normally the change pass multiple deployment stages where the complexity of the tests increase for each stage. As a developer you want fast feedback if something fails, and it is not unusual that basic mistakes are the cause of a problem which are captured at unit test level in test that don’t take long time to execute.

However unit tests are not enough to ensure that the new code is working. Therefore more complex end to end tests must be run which take longer time. In some cases there even may be manual tests required before a feature is passed to production, such as user experience validation.

iotcomms.io contributes back chai-sip to the community
Continuous deployment pipeline

This is all made possible by re-use of for example public cloud services to run, build and test the code and use of open source frameworks to scale development of automatic tests to be run for each code commit.

NodeJS provides a great ecosystem to rapidly develop and maintain build systems and continuous deployment pipelines. It is also one of the preferred environments for serverless backend development.

Mocha (https://mochajs.org) is a great framework where test cases are easily written to run multiple test cases in a test run for a continuous deployment pipeline. When the tests have been completed a summary of successful or failed test cases are provided. If all test-cases pass the commit is ready for the next deployment stage and level of tests.

To write a test case you take an action and evaluate the result. This typically mean you want to evaluate the result of the action invoked such as comparing input and output values or API responses. Chai.js (https://www.chaijs.com) is an assertion library that fits well with NodeJs based testing frameworks. It allow test cases to be written in an easy to read format such as:

expect(person.name).to.equal(“Sven”)

If in this case the name of the person returned from an API call is not Sven the test case would fail.

If you have a server to be tested, you need a way to simulate requests from the connecting clients. In case of real time communication systems based on SIP this means that you must be able to simulate traffic from real endpoints part of your automated tests.

Our services power mission critical solutions such as social care alarm applications. This means we have no room for human factor mistakes. SIP and real time communications are a key function provided by the platform. There exists a lot of ready-made open source tools to test REST based API calls in a CI/CD pipeline but when it comes to SIP and real time communications the options are fewer.

Chai.js provides a mechanism to write plugins which we utilized to add capabilities to write SIP based end to end tests with low friction. Our plugin has been shared as open source at GitHub where we invite others to use it and contribute to further development.

Detailed description of the current capabilities is found on the GitHub page. The example below illustrates a test case simulating two SIP endpoints where the first sends a SIP invite to a server which is expected to proxy the request back to the server running the test case. The test case automatically replies back with a 200 Ok response to simulate that the call has been answered, and the test case validates that this response has been received by the sender. As you can see it took more characters to explain the case than actually to implement it!

var sip = chai.sip({userid:"<userid>",domain:"<domain>",password:"<password>", transport:"tcp", port:5050});

sip.waitForRequest(function (req) {
console.log(“Got request”);
});

sip.invite("sip:<user>@<domain>").onFinalResponse(function (resp) {
  expect(resp).to.be.status(200);
});

The plugin provides high level function to send SIP Invite, Message requests and also SIPRec requests. In addition to simulate the signaling it also simulates voice by sending RTP streams to the called party.

To be able to test real deployments is also supports SIP/TLS as well record-route in case of multiple proxy hops.

Happy coding!