From 593110525dfcae80258598f29d74ac51226e738b Mon Sep 17 00:00:00 2001 From: Sandra Date: Thu, 31 Oct 2024 15:49:00 +0200 Subject: [PATCH] PSMDB-1549. Ensure PSMDB related metrics are exported correctly --- pmm_psmdb_diffauth_setup/test-auth.sh | 2 +- .../test/expected_metrics.txt | 39 +++++++++++++++++++ pmm_psmdb_diffauth_setup/test/test.py | 13 ++++++- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 pmm_psmdb_diffauth_setup/test/expected_metrics.txt diff --git a/pmm_psmdb_diffauth_setup/test-auth.sh b/pmm_psmdb_diffauth_setup/test-auth.sh index d7230d6..05df490 100755 --- a/pmm_psmdb_diffauth_setup/test-auth.sh +++ b/pmm_psmdb_diffauth_setup/test-auth.sh @@ -68,7 +68,7 @@ done tests=${TESTS:-yes} if [ $tests = "yes" ]; then echo "running tests" - output=$(docker compose -f docker-compose-pmm-psmdb.yml run test pytest -s -x --verbose test.py) + output=$(docker compose -f docker-compose-pmm-psmdb.yml run test pytest -s --verbose test.py) else echo "skipping tests" fi diff --git a/pmm_psmdb_diffauth_setup/test/expected_metrics.txt b/pmm_psmdb_diffauth_setup/test/expected_metrics.txt new file mode 100644 index 0000000..01d876a --- /dev/null +++ b/pmm_psmdb_diffauth_setup/test/expected_metrics.txt @@ -0,0 +1,39 @@ +mongodb_up +mongodb_mongod_global_lock_client +mongodb_mongod_global_lock_current_queue +mongodb_mongod_instance_uptime_seconds +mongodb_mongod_locks_time_acquiring_global_microseconds_total +mongodb_mongod_metrics_cursor_open +mongodb_mongod_metrics_cursor_timed_out_total +mongodb_mongod_metrics_document_total +mongodb_mongod_metrics_get_last_error_wtime_num_total +mongodb_mongod_metrics_get_last_error_wtime_total_milliseconds +mongodb_mongod_metrics_get_last_error_wtimeouts_total +mongodb_mongod_metrics_operation_total +mongodb_mongod_metrics_query_executor_total +mongodb_mongod_metrics_ttl_deleted_documents_total +mongodb_mongod_metrics_ttl_passes_total +mongodb_mongod_op_counters_repl_total +mongodb_mongod_op_latencies_latency_total +mongodb_mongod_op_latencies_ops_total +mongodb_mongod_storage_engine +mongodb_mongod_wiredtiger_blockmanager_bytes_total +mongodb_mongod_wiredtiger_cache_bytes +mongodb_mongod_wiredtiger_cache_bytes_total +mongodb_mongod_wiredtiger_cache_evicted_total +mongodb_mongod_wiredtiger_cache_max_bytes +mongodb_mongod_wiredtiger_cache_overhead_percent +mongodb_mongod_wiredtiger_cache_pages +mongodb_mongod_wiredtiger_cache_pages_total +mongodb_mongod_wiredtiger_concurrent_transactions_available_tickets +mongodb_mongod_wiredtiger_concurrent_transactions_out_tickets +mongodb_mongod_wiredtiger_concurrent_transactions_total_tickets +mongodb_mongod_wiredtiger_log_bytes_total +mongodb_mongod_wiredtiger_log_operations_total +mongodb_mongod_wiredtiger_log_records_scanned_total +mongodb_mongod_wiredtiger_log_records_total +mongodb_mongod_wiredtiger_session_open_sessions_total +mongodb_mongod_wiredtiger_transactions_checkpoint_milliseconds +mongodb_mongod_wiredtiger_transactions_checkpoint_milliseconds_total +mongodb_mongod_wiredtiger_transactions_running_checkpoints +mongodb_mongod_wiredtiger_transactions_total diff --git a/pmm_psmdb_diffauth_setup/test/test.py b/pmm_psmdb_diffauth_setup/test/test.py index 049a02b..64fbb7e 100755 --- a/pmm_psmdb_diffauth_setup/test/test.py +++ b/pmm_psmdb_diffauth_setup/test/test.py @@ -39,8 +39,17 @@ def run_test(add_db_command): metrics = docker_pmm_client.run(command, timeout=30) except Exception as e: pytest.fail(f"Fail to get metrics from exporter") - if "mongodb_up" not in metrics.stdout: - pytest.fail("MongoDB related data isn't exported") + + try: + with open("expected_metrics.txt", "r") as f: + expected_metrics = {line.strip() for line in f if line.strip()} + except FileNotFoundError: + pytest.fail("Expected metrics file not found") + + for metric in expected_metrics: + if metric not in metrics.stdout: + pytest.fail(f"Metric '{metric}' is missing from the exporter output") + def test_simple_auth_wo_tls(): run_test('pmm-admin add mongodb psmdb-server --username=pmm_mongodb --password="5M](Q%q/U+YQ<^m" '\