Module tests.test_metric
Functions
def check_metric(core_api, metric_name, metric_labels, expected_value=None, metric_node_id=None)
def check_metric_count_all_nodes(client, core_api, metric_name, metric_labels, expected_count)
def check_metric_sum_on_all_nodes(client, core_api, metric_name, expected_labels, expected_value=None)
def check_metric_with_condition(core_api, metric_name, metric_labels, expected_value=None, metric_node_id=None)
-
Some metric have multiple conditions, for example metric longhorn_node_status have condition - allowScheduling - mountpropagation - ready - schedulable metric longhorn_disk_status have conditions - ready - schedulable Use this function to get specific condition of a mertic
def examine_metric_value(found_metric, metric_labels, expected_value=None)
def find_metric(metric_data, metric_name)
def find_metrics(metric_data, metric_name)
def get_metrics(core_api, metric_node_id)
def test_metric_longhorn_backup(set_random_backupstore, client, core_api, batch_v1_api, volume_name)
-
Scenario: test metric longhorn_backup_actual_size_bytes and longhorn_backup_state
Issue: https://github.com/longhorn/longhorn/issues/9429
Given a volume
When a backup is created by user Then has a metric longhorn_backup_actual_size_bytes value equals to the size of the backup, and volume label is the volume name and recurring_job label is empty And has a metric longhorn_backup_state value equals to 3 (Completed), and volume label is the volume name and recurring_job label is empty
When a recurring backup job is created Then should have a metric longhorn_backup_actual_size_bytes value equals to the size of the backup, and volume label is the volume name and recurring_job label is the job name And should have a metric longhorn_backup_state value equals to 3 (Completed), and volume label is the volume name and recurring_job label is the job name
def test_metric_longhorn_snapshot_actual_size_bytes(client, core_api, volume_name)
-
Scenario: test metric longhorn_snapshot_actual_size_bytes
Issue: https://github.com/longhorn/longhorn/issues/5869
Given a volume
When 1 snapshot is created by user And 1 snapshot is created by system Then has a metric longhorn_snapshot_actual_size_bytes value equals to the size of the user created snapshot, and volume label is the volume name and user_created label is true And has a metric longhorn_snapshot_actual_size_bytes value equals to the size of the system created snapshot, and volume label is the volume name and user_created label is false
When 3 snapshot is created by user Then has 4 metrics longhorn_snapshot_actual_size_bytes with volume label is the volume name and user_created label is true And has 1 metrics longhorn_snapshot_actual_size_bytes with volume label is the volume name and user_created label is false
def test_metric_longhorn_volume_file_system_read_only(client, core_api, volume_name, pod)
-
Scenario: test metric longhorn_volume_file_system_read_only
Issue: https://github.com/longhorn/longhorn/issues/8508
Given a volume is created and attached to a pod And the volume is healthy
When crash the volume engine process And wait for the volume to become healthy And write the data to the pod And flush data to persistent storage in the pod with sync command
Then has 1 metrics longhorn_volume_file_system_read_only with labels … "pvc": pvc_name … "volume": volume_name
def test_node_metrics(client, core_api)
def test_volume_metrics(client, core_api, volume_name, pvc_namespace)
-
https://longhorn.io/docs/master/monitoring/metrics/#volume
The goal of this test case is to verify that the accuracy of volume metrics by sending HTTP requests to http://{longhorn-manager IP}:9500/metrics and use prometheus_client to validate the return value.
def wait_for_metric(core_api, metric_name, metric_labels, expected_value)
def wait_for_metric_count_all_nodes(client, core_api, metric_name, metric_labels, expected_count)
def wait_for_metric_sum_on_all_nodes(client, core_api, metric_name, metric_labels, expected_value)
def wait_for_metric_volume_actual_size(client, core_api, metric_name, metric_labels, volume_name)