Hi, Let's understand how helm deployment can be tested. As a part of the chart
We can include the test conditions as well as the test script also, and that can be used to do the testing.
I'll show the demonstration of how to do the testing and we will have quick over view on how the test script will be.
For example, I do have the following deployments. This particular deployment install upgrade rlbk -demo
I can invoke the command helm test and then this particular deployment that's going to invoke the
testing against this particular deployment, whether it is working properly or not.
So it will try to make connection with the running pods and check whether it is able to make a successful
connection or not. So it's able to make a successful connection and it's giving a message saying
yes the test is sucess and how this is possible.
Again, it is going to be a small pod condition that we will be defining it within the test folder.
Let me get into the chart that we had created. Within templates
There will be a folder called Test.
So all the test conditions will be available over here.
And I need to define what needs to be tested.
So whatever the requirements or the templates that we are making that will be having corresponding
test conditions. So all the test conditions that needs to be tested should get included in this particular folder test
and within this particular file it's nothing but it's just another pod.
And I need to have an annotation saying it is a hook. Hook
It's going to get attached to the templates, but it will not get deployed as a manifest into the kubernetes cluster.
We will be having detailed discussion about what this particular hook is and how it's going to get used
Here I'll give a very quick over view
Hook can get invoked in different stages say for example before deployment, after deployment, after rendering
There are different stages where it will get invoked. In this particular case after deployment it will get
invoked during the testing it's going to run this particular container.
So this particular container its going to get an image called busy box and it will do a wget against
this particular deployment and the port.
So it'll try to ping that particular pod.
And if it is available say, that service in the port
If it is able to get the message, then it is going to provide a message saying its success or otherwise
it's going to give a failure. In case if I list the pods I can check
There is a pod which got started for the test connection and it got over.
This is how the testing will be achieved.
say for what condition needs to be tested
The corresponding pod will get invoked using some commands and the output of the command will determine
whether that particular pods or service is working properly or not.
And mostly it will be testing against the exit condition.
A successful exit that is exit zero.
And the important thing to be consider is that particular annotation saying it is the hook.
So here I need to have a condition.
And as a part of the hook, we will discuss more about how to write this particular cases, different type of events
When the hook can get triggered. The sample conditions where we can run is whether the user name, password
is working properly or not.
The environmental variable that we have provided as a part of the helm deployment got injected properly
into the required entities like services or pods or not
And mostly we will be doing the asset of the services whether it is up and running and load balancing
it properly or not. These are all some of the test conditions that we can do by using this particular test option.
It purely depends on the condition that we are running within the test cases.