Alexander Beletsky's development blog

My profession is engineering

Integration or Unit Tests Trade-Off

Recently, I’ve released small Express.js extension for easy switching application to maintenance mode. Sometimes, you just want to run patch against database or change the infrastructure of product, but instead of showing blank nginx 503 error page, you want to have nice looking HTML, saying will be back soon.

The maintenance package is now available on npm and you welcome to use it. But I would like to share the way I developed and test it.

Side-Project to Startup in One Year

Today is exactly one year as we started Likeastore project. It went through a different stages, from hack to side-project and finally transformed to real startup.

The year, seems to be a huge period of time. It is, but I have to say it’s only few last months (from the middle of December till today), we are fully dedicated to project. It’s been great ride so far, so I wish to share some interesting moments.

Testable API’s with Node.js

API is heart of modern web application. It’s all about to make it easy to consume, scale and make sure it works as expected. Currently I follow “all open API methods must have tests” (AOAMMHT) principle. I used to work with .NET technologies, where testing of API’s was about calling methods of corresponding controller object, which typically was unit testing – mocking up all controller dependencies, setting up expects of returned values.

I’ve changed my mind on testing with Node.js/Express.js development. For API’s I prefer “end-to-end” testing: setting up user account, authentication, HTTP calls to server, real calls to DB and serving JSON payload back. API’s have to be tested from consumer point of few to be able to give some meaningful results.

Logs Driven Development

One of the components I currently work on called collector and it has no tests. Collector is all about of building queue of tasks, executing them and store data to database after. Tasks are HTTP clients that requests API and process transform responses into generic forms.

I’ve started it with tests using nock component to mock HTTP requests, but quickly I found those tests both hard to write and no real benefit cause real responses that could broke it differs from ones I mock inside the tests.

In the same time, I regularly change that component and after changes and deployments I pretty quickly see the regressions and non-expected behavior, cause all information I need is inside of application logs. I call that “Logs Driven Development”.

Keeping Node.js Processes Running

Node.js/Express.js is great for Web API’s and applications. In contrast to known enterprise technologies, Node.js is very special. It’s single process/threaded environment. In case of unhanded exception occurred Node.js virtual machine simply stops, leaving application in unresponsive state.

Due to async nature of Node.js try/catch not always works, even with domains and stuff you have a chance that application crashed on production while you sleep.

Looking Back to 2013

Traditionally, first Saturday of New Year – time look back for year that passed. As usually, I do analisys throught a several aspects. Primary job, blogging and speaking, communities and side projects.

Open Source

I heard about open source probably the first year I started programming. I liked the idea of software to be not only presented as a final product, but with ability to see how things are done and change something if you want. For me, open source was really related to operational systems and drivers, Linux as great example.

A bit later I realised that open source is also about contribution. If you have a certain skills, you can join the project you interested in and try to help. I’ve seen some nice open source examples – tiny operational systems, drivers, music players. Almost everything was C++. The problem with C++, it’s hard to build something from sources. You typically missing some binaries, headers or SDK’s you don’t have on your machine.

Run Several Processes in Docker Container

What I like the most about Docker project is new opportunity to deploy and distribute software. Many times I’ve been to situation when I wanted to play with some software and get exited about, but after I read installation manual my excitement totally gone. Non trivial applications, requires quite a lot dependencies: runtimes, libraries, databases.

With docker, the installation instruction got reduced to something like:

1
2
$ docker pull vendor/package
$ docker run vendor/package

Simply like that, forget about missing Java Runtime on your server. It suits perfectly for TCP/HTTP applications.

Likeastore is Becoming a Company

It’s been a while since my last update on Likeastore progress. It doesn’t mean the application development is stopped, otherwise – we did a final breakthrough and today is my first day in EastLabs business accelerator. Yes, side project we’ve started to have fun on hackathon is becoming a company today.

I always wanted to build a product that could became the foundation for company. I did a few unsuccessful attempts before. There was few reason of failures: either I tried to attack very big problem or I didn’t have enough motivation to make the stuff done.

I Quit My Job

Since 6 Dec 2013, I’m officially unemployed. I quit my job in E-conomic there I spent almost 3.5 years of happy life. Leaving the company was a really tough decision, but it had to be made.

A lot of things happed during that time. No doubts, E-conomic and Ciklum did the most significant impact of my professional career so far. The reason for that is simple: the people surrounds you are most important aspect in your job. From the very first days, till last ones – I worked with high qualified professionals there.