Aviran Mordo

About 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

Related Whitepaper:

Software Architecture

This guide will introduce you to the world of Software Architecture!

This 162 page guide will cover topics within the field of software architecture including: software architecture as a solution balancing the concerns of different stakeholders, quality assurance, methods to describe and evaluate architectures, the influence of architecture on reuse, and the life cycle of a system and its architecture. This guide concludes with a comparison between the professions of software architect and software engineer.

Get it Now!  

Leave a Reply

8 × nine =

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books