Skip to content

Commit

Permalink
caputre output
Browse files Browse the repository at this point in the history
  • Loading branch information
aureleoules committed Dec 4, 2024
1 parent 120b39b commit 88f45eb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions proxmox/datadog_checks/proxmox/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, name, init_config, instances):
def check(self, _):
try:
headers = {"Authorization": f"PVEAPIToken={self.token_id}={self.token_secret}"}
self.log.info(f"HEADERS={headers['Authorization']}")
response = self.http.get(f"{self.url}/api2/json/cluster/resources", verify=False, headers=headers)
response.raise_for_status()
response_json = response.json()
Expand Down
17 changes: 11 additions & 6 deletions proxmox/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import json
import os
import subprocess
from random import random

import pytest
import requests

from datadog_checks.dev import docker_run
from datadog_checks.dev.conditions import WaitFor

from .common import HERE, INSTANCE, PROXMOX_URL
from .common import HERE, PROXMOX_URL


def wait_for_proxmox():
Expand All @@ -30,27 +31,31 @@ def dd_environment():
compose_file=os.path.join(HERE, 'compose', 'docker-compose.yaml'),
conditions=[WaitFor(wait_for_proxmox)],
):

r = subprocess.run(
[
'docker',
'exec',
'proxmox',
'pve',
'pveum',
'user',
'token',
'add',
'root@pam',
'dd-agent',
f"dd-agent-{str(random())[2:]}",
"--output-format",
"json",
]
],
capture_output=True,
text=True,
)

r_json = json.loads(r.stdout)
yield {
'instances': [{'token_id': 'root@pam', 'token_secret': r_json['value']}],
'instances': [{'token_id': r_json['full-tokenid'], 'token_secret': r_json['value']}],
}


@pytest.fixture
def instance():
return INSTANCE
return {}
11 changes: 11 additions & 0 deletions proxmox/tests/test_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


@pytest.mark.e2e
def test_generate_metrics(dd_agent_check):
"""
Test that we collect the expected metrics.
"""

aggregator = dd_agent_check(rate=True)
aggregator.assert_metric('proxmox.cpu_current', count=1)
15 changes: 0 additions & 15 deletions proxmox/tests/test_integration.py

This file was deleted.

0 comments on commit 88f45eb

Please sign in to comment.