Skip to content

Commit

Permalink
PSMDB. Ensure PSMDB related metrics are exported, run tests for PMM 2…
Browse files Browse the repository at this point in the history
… + PSMDB 8.0
  • Loading branch information
sandraromanchenko committed Nov 21, 2024
1 parent 556eb23 commit 6fffc1c
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/PMM_PSMDB_PBM_FULL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
psmdb: ["6.0", "7.0"]
psmdb: ["6.0", "7.0", "8.0"]
env:
PMM_CLIENT_VERSION: ${{ github.event.inputs.pmm_version || 'latest' }}
PMM_IMAGE: ${{ github.event.inputs.pmm_image || 'perconalab/pmm-server:dev-latest' }}
Expand All @@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
psmdb: ["6.0", "7.0"]
psmdb: ["6.0", "7.0", "8.0"]
env:
PMM_CLIENT_VERSION: ${{ github.event.inputs.pmm_version || 'latest' }}
PMM_IMAGE: ${{ github.event.inputs.pmm_image || 'perconalab/pmm-server:dev-latest' }}
Expand All @@ -59,7 +59,7 @@ jobs:
strategy:
fail-fast: false
matrix:
psmdb: ["6.0", "7.0"]
psmdb: ["6.0", "7.0", "8.0"]
env:
PMM_CLIENT_VERSION: ${{ github.event.inputs.pmm_version || 'latest' }}
PMM_IMAGE: ${{ github.event.inputs.pmm_image || 'perconalab/pmm-server:dev-latest' }}
Expand Down
38 changes: 38 additions & 0 deletions pmm_psmdb-pbm_setup/test/expected_metrics.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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_total
28 changes: 28 additions & 0 deletions pmm_psmdb-pbm_setup/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,31 @@ def test_pbm_restore():
restore_complete = True

assert restore_complete

def test_metrics():
pmm_admin_list = json.loads(docker_rs101.check_output('pmm-admin list --json', timeout=30))
for agent in pmm_admin_list['agent']:
if agent['agent_type'] == 'MONGODB_EXPORTER':
agent_id = agent['agent_id']
agent_port = agent['port']
break

agent_id_parts = agent_id.split('/')
agent_pass = f"%2F{agent_id_parts[1]}%2F{agent_id_parts[2]}"

try:
command = f"curl http://pmm:{agent_pass}@127.0.0.1:{agent_port}/metrics"
metrics = docker_rs101.run(command, timeout=30)
assert metrics.exit_status == 0, f"Curl command failed with exit status {metrics.exit_status}"
except Exception as e:
pytest.fail(f"Fail to get metrics from exporter")

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")
38 changes: 38 additions & 0 deletions pmm_psmdb_diffauth_setup/test/expected_metrics.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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_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 @@ -37,10 +37,19 @@ def run_test(add_db_command):
try:
command = f"curl http://pmm:{agent_pass}@127.0.0.1:{agent_port}/metrics"
metrics = docker_pmm_client.run(command, timeout=30)
assert metrics.exit_status == 0, f"Curl command failed with exit status {metrics.exit_status}"
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 6fffc1c

Please sign in to comment.