Skip to content

Test logging chart configuration

Sett requested to merge SAR-37/test-logging-infra into master

This MR introduces some more comprehensive tests and related components for the logging chart. This extends the work from !19 (merged).

New Tests

Some of the templates in the logging chart have been tested to ensure they hold the correct values/details. These tests are all grouped in the tests.logging_chart_test.TestLoggingChartTemplates class which is marked with no_deploy so that they will execute as part of the static_analysis stage.

Test Support

Echo Server

The echo server is a python http server that can be deployed into the cluster namespace. It currently only has one endpoint (/echo) which prints any payload from a POST request to its stdout console.

This was needed to test the functionality of the logging stack in which log messages from pods inside the cluster should end up in elasticsearch.

The pod definition for the echo server can be found at /tests/testsupport/extras/echoserver.yaml and it's also encapsulated into a Python class, tests.testsupport.extras.EchoServer.

The echoserver is implemented as pytest fixture and used by tests.logging_chart_test.test_fluentd_ingests_logs_from_pod_stdout_into_elasticsearch.

ChartDeployment

The ChartDeployment class now features some convenient new methods: is_running and get_services. Additionally, get_pods has been overloaded to support filtering by pod_name.

HelmChart

HelmChart is a new object that encapsulates the static helm charts that have not been templated or deployed. It has a property, templates, which holds all the subcharts/templates.

util

A tests.testsupport.util module has been added with some useful functions to help in testing:

  • wait_until is a function that will retry the callable passed to it until the retry_timeout in seconds, with a delay between each try specified by retry_period.
  • check_connection will attempt to open a socket connection to the host and port and return True if successful.
  • parse_yaml_str will parse the given yaml string into a python object.

Housekeeping

  • testinfracontext fixture has been refactored for clarity
  • tests.tango_base_chart_test.test_tangodb_pod_should_have_mysql_server_running has be unskipped and refactored to be more reactive, (wait_until)
Edited by Sett

Merge request reports