Home » Software Development » Continuous Delivery – Part 5 – Startup – Self Test

About Aviran Mordo

Aviran Mordo
Aviran Mordo has over 20 years of experience in the software industry. He has been in many engineering roles and leading positions in start-ups and large corporations. Aviran is a tech-savvy and a technology blogger since the year 2000, with vast knowledge of the internet and software development.

Continuous Delivery – Part 5 – Startup – Self Test

Previous Chapter: A/B Testing

So far we discussed Feature Toggle and A/B testing. These two methods enable safe guards that your code does not harm your system. Feature toggles enable to gradually use new features and gradually expose it to users, while monitoring that the system behaves as expected. A/B testing on the other hand let you test how your users react to new features. There is one more crucial test you as a developer should write that will protect your system from bad deployments (and also be a key to gradual deployment implementation).

Self-test sometimes called startup test or post deployment test is a test where
your system checks that it can actually work properly. A working program does not only consist of the code that the developer write. In order for an application to work it needs configuration values, external resources and dependencies such as databases and external services it depends on to work properly.

When an application loads and starts up its first operation should be Self-test. Your application should refuse to process any operation if the self-test did not pass successfully.

Self-test have two main use cases:

1. Post deployment test – A post deployment test is a test that aims to verify two things. It should verify that the artifact is deployed with the correct configuration and that it can work properly.
2. Restart test – Verify that all the first level dependencies work and your application could potentially perform its task.

Post Deployment Test

In Continuous Delivery a deployment is being done into a live system and to keep operate with zero downtime. Having said that a self-test should check the following:
• Check that you have a connection to the database.
• Verify that the database schema is what you would expect.
• All the resources your application needs are accessible and loaded properly.
• If your architecture is SOA, check that all the services you depend on are reachable.
• All the external services have the operations you expect them to have.
• Any other test your system need to do in order to declare itself operational

Restart test

Unlike post deployment test, when you restart a service it is usually due to a problem, and not due to a deployment. Because of that you need to only test your first level dependencies and not external services because you cannot be sure that these services actually operational. If you do check external services you might not be able to reload your system. For example if service A calls a method on service B, and service B calls a method on service A, after restart of both services they would fail the test because they have a circular dependency. So restart test should only check the following:
• Check that you have a connection to the database.
• Verify that the database schema is what you would expect.
• All the local resources your application need are accessible and loaded properly.

Now since restart test does not guarantee that external services are operational at the time of the restart you should have a retry policy for external resources you may load.

At Wix we built a framework that once a service loads it will return “Service Temporary Unavailable” error until the self test has passes successfully. We have a flag (basically this is a file on the file system) that “tells” the self-test if it is running a post-deployment test or post-restart test. During deployment the deployment script deletes the “lock file” thus ensuring the full post-deployment test in run. At the end of the self-test the application writes a “lock file” so consecutive tests are just startup-tests and not post-deployment tests.

Gradual Deployment

Self-test is not only important to check the health of the deployment, it is also crucial when you do gradual deployment. Since you don’t deploy all the servers at once you need to deploy servers gradually but only after the post-deployment test passed you can deploy the next server.

Next chapter: Backward and forward compatibility

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area


Leave a Reply

Be the First to Comment!

Notify of