Validation
End-to-end (e2e) tests for Kubernetes provide a mechanism to test the behaviour of the system. This is a useful indicator that the cluster is performing properly, as well as a good validation of any code changes.
For Charmed Kubernetes, these tests are encapsulated in an additional Juju charm which can be added to your cluster. Actual testing is then run through the charm’s actions.
Deploying the kubernetes-e2e charm
Add the charm to your cluster:
We also need to configure the charm to select the appropriate version of tests. This relates to the installed version of Kubernetes. You can check which version your cluster is set to by running:
The output will be in the form of version.number/risk
, e.g 1.24/stable
. You should set
the kubernetes-e2e
channel to the same value.
juju config kubernetes-e2e channel=1.24/stable
Finally we relate the charm to easyrsa
and kubernetes-control-plane
:
It may take some moments for these relations to establish. Once the connections are made, the charm will update its status to “Ready to test.”
Running the default tests
The tests are configured as a Juju action. To run the default tests:
The command will return with a number for that specific action operation.
See the section on Test output below for details.
Running specific tests
The complete set of Kubernetes e2e tests is more fully described in the upstream Kubernetes documentation. In some cases you may wish to omit particular groups of tests. This is possible by applying a regular expression defining the tests to omit when initiating the action.
By default, the standard tests marked [Flaky]
or [Serial]
are skipped. To
also omit the tests marked as [Slow]
, you could run:
Note that the brackets for the regex need to be escaped as shown.
Running this command will return a uuid for that specific test run, as with the default case.
Test output
You can check on the current status of the test by running:
where 25
is the id of the scheduled operation when the test was initiated.
This will return YAML output indicating the current status,
which can be either running
, completed
or failed
.
Once completed, you can see more detail on the timing by running:
Which will return output similar to:
If the tests fail, or you want to look through the detail of each test, you can examine the detailed log.
Viewing test logs
The test logfile is stored as a file on the test instance. The filename
corresponds to the id of the action which created it, with a ‘.log’
extension, and it is stored in the /home/ubuntu/
directory of the machine
where the tests are running. A compressed version is also stored with the
extension .log.tar.gz
This log can be copied to your local machine for easier viewing:
Note that the captured test logfile uses ANSI output, and is best viewed with
cat
, tail
or a similar command which can handle this type of output.
Alternatively, you can strip the ANSI parts of the output:
Upgrading the e2e tests
When an update is available, the kubernetes-e2e
charm can be upgraded with the command:
See the guide to contributing or discuss these docs in our public Mattermost channel.