With the testing framework almost ready, this week involved using what is called fake listening in testing to make it independent of the internet.

What does that mean?

Fake listening means that the PulseListener instance does not actually listen for messages. You can send a message on it using listener.fakeMessage() and it is delivered to the listener. Route filtering is disabled in the fake mode. This method is almost standard in testing, using fakes wherever possible in order to avoid using real credentials and resources.

In order to send a fake message, I need to access that within my test files, and since I had defined them inside my api call function, there was no way I can do that. This left one option - carving out the listeners into its own component and making pulse credentials available to it. Earlier I had passed a PulseConnection as context to my api content. To enable fake listening I only had to set the credentials to {fake: true}.

Sounds simple, doesn’t it?

Well, not really. In order to access the Listener component in the testing framework, I will have to refactor how test suites are setup and components are loaded to be compliant with this. Luckily a lot of services had already been converted. It made life a lot easier for me.

For example, a stickyLoader was introduced in taskcluster-lib-testing which would use the same instance of a component, if already present, while loading it afterwards as a dependency. Basically, dependency injection in technical terms. In my test suite I had invoked two functions -

  • withPulse - which loads the listeners component(also making it accessible ) with fake credentials.
  • withServer - loads the server component which has listeners as a dependency.

Moving the listeners into a component (and a file) of its own, created situations where an error was not caught and this caused the UnhandledPromiseRejectionWarning which crashed the server. After a few more nits, it was ready to be pushed to heroku.

Deliverables

My earlier PR got merged this week, thanks to hassan for the quick reviews. I opened another PR , for the above changes hoping it is approved soon.

Coming up

I am leaving today for a family vacation to Ladakh. I will not be able to work due to poor network connectivity in these areas. I still have to get the pulse-inspector compatible with the new events, and then have both deployed into production.