krkn_lib.tests.test_krkn_telemetry_kubernetes module

Comprehensive unit tests for KrknTelemetryKubernetes class.

This test suite uses mocks to test all methods without requiring actual Kubernetes clusters or external services.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestCollectClusterMetadata(methodName='runTest')

Bases: TestCase

Test collect_cluster_metadata method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_collect_cluster_metadata_multiple_nodes(mock_get_ci_url)

Test with multiple node types.

test_collect_cluster_metadata_success(mock_get_ci_url)

Test successful collection of cluster metadata.

test_collect_cluster_metadata_with_failed_scenario(mock_get_ci_url)

Test metadata collection when scenario failed.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestGenerateUrlAndPutToS3Worker(methodName='runTest')

Bases: TestCase

Test generate_url_and_put_to_s3_worker method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_worker_retry_on_failure(mock_sleep, mock_get_url, mock_put_file)

Test worker retry logic on failure.

test_worker_success(mock_get_url, mock_put_file)

Test successful worker execution.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestGetBucketUrlForFilename(methodName='runTest')

Bases: TestCase

Test get_bucket_url_for_filename method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_get_bucket_url_http_error(mock_get)

Test handling of HTTP errors.

test_get_bucket_url_success(mock_get)

Test successful retrieval of presigned URL.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestGetPrometheusPodData(methodName='runTest')

Bases: TestCase

Test get_prometheus_pod_data method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_prometheus_backup_disabled()

Test when prometheus backup is disabled.

test_prometheus_backup_missing_config()

Test with missing required config.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestKrknTelemetryKubernetesInit(methodName='runTest')

Bases: TestCase

Test initialization and basic getter methods.

setUp()

Hook method for setting up the test fixture before exercising it.

test_default_telemetry_group()

Test default telemetry group value.

test_init_with_config()

Test initialization with telemetry config.

test_init_without_config()

Test initialization without telemetry config.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestPutCriticalAlerts(methodName='runTest')

Bases: TestCase

Test put_critical_alerts method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_put_alerts_empty_summary()

Test with empty alert summary.

test_put_alerts_missing_config_fields()

Test with missing required config fields.

test_put_alerts_none_summary()

Test with None summary.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestPutFileToUrl(methodName='runTest')

Bases: TestCase

Test put_file_to_url method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_put_file_connection_error(mock_put)

Test handling of connection errors.

test_put_file_http_error(mock_put)

Test handling of HTTP errors.

test_put_file_success(mock_put)

Test successful file upload.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestPutPrometheusData(methodName='runTest')

Bases: TestCase

Test put_prometheus_data method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_prometheus_backup_disabled()

Test when prometheus backup is disabled.

test_put_prometheus_data_missing_config()

Test with missing required config.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestSendTelemetry(methodName='runTest')

Bases: TestCase

Test send_telemetry method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_send_telemetry_default_group(mock_post)

Test telemetry send with default group.

test_send_telemetry_disabled()

Test when telemetry is disabled.

test_send_telemetry_http_error(mock_post)

Test handling of HTTP errors.

test_send_telemetry_missing_api_url()

Test with missing api_url.

test_send_telemetry_missing_password()

Test with missing password.

test_send_telemetry_missing_username()

Test with missing username.

test_send_telemetry_multiple_missing_fields()

Test with multiple missing required fields.

test_send_telemetry_success(mock_post)

Test successful telemetry send.

class krkn_lib.tests.test_krkn_telemetry_kubernetes.TestSetParametersBase64(methodName='runTest')

Bases: TestCase

Test set_parameters_base64 method.

setUp()

Hook method for setting up the test fixture before exercising it.

test_set_parameters_base64_file_not_found()

Test with non-existent file.

test_set_parameters_base64_invalid_yaml()

Test with invalid YAML content.

test_set_parameters_base64_nested_kubeconfig()

Test anonymization of nested kubeconfig.

test_set_parameters_base64_success()

Test successful base64 encoding of scenario file.