Skip to content

Commit

Permalink
PSMDB-1549. Ensure PSMDB related metrics are exported correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sandraromanchenko committed Oct 31, 2024
1 parent 562f566 commit 5931105
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pmm_psmdb_diffauth_setup/test-auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions pmm_psmdb_diffauth_setup/test/expected_metrics.txt
Original file line number Diff line number Diff line change
@@ -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
13 changes: 11 additions & 2 deletions pmm_psmdb_diffauth_setup/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" '\
Expand Down

0 comments on commit 5931105

Please sign in to comment.