diff --git a/argocd/tests/conftest.py b/argocd/tests/conftest.py index 4d70e9428d1e2..cc4ab0e104325 100644 --- a/argocd/tests/conftest.py +++ b/argocd/tests/conftest.py @@ -8,15 +8,8 @@ from datadog_checks.dev import get_here from datadog_checks.dev.kind import kind_run -from datadog_checks.dev.kube_port_forward import port_forward from datadog_checks.dev.subprocess import run_command -try: - from contextlib import ExitStack -except ImportError: - from contextlib2 import ExitStack - - HERE = get_here() opj = os.path.join @@ -40,39 +33,25 @@ def setup_argocd(): @pytest.fixture(scope='session') def dd_environment(dd_save_state): with kind_run(conditions=[setup_argocd]) as kubeconfig: - with ExitStack() as stack: - app_controller_host, app_controller_port = stack.enter_context( - port_forward(kubeconfig, 'argocd', 8082, 'service', 'argocd-metrics') - ) - appset_controller_host, appset_controller_port = stack.enter_context( - port_forward(kubeconfig, 'argocd', 8080, 'service', 'argocd-applicationset-controller') - ) - api_server_host, api_server_port = stack.enter_context( - port_forward(kubeconfig, 'argocd', 8083, 'service', 'argocd-server-metrics') - ) - repo_server_host, repo_server_port = stack.enter_context( - port_forward(kubeconfig, 'argocd', 8084, 'service', 'argocd-repo-server') - ) - notifications_controller_host, notifications_controller_port = stack.enter_context( - port_forward(kubeconfig, 'argocd', 9001, 'service', 'argocd-notifications-controller-metrics') - ) - app_controller_endpoint = 'http://{}:{}/metrics'.format(app_controller_host, app_controller_port) - appset_controller_endpoint = 'http://{}:{}/metrics'.format(appset_controller_host, appset_controller_port) - api_server_endpoint = 'http://{}:{}/metrics'.format(api_server_host, api_server_port) - repo_server_endpoint = 'http://{}:{}/metrics'.format(repo_server_host, repo_server_port) - notifications_controller_endpoint = 'http://{}:{}/metrics'.format( - notifications_controller_host, notifications_controller_port - ) - - instance = { - 'app_controller_endpoint': app_controller_endpoint, - 'appset_controller_endpoint': appset_controller_endpoint, - 'api_server_endpoint': api_server_endpoint, - 'repo_server_endpoint': repo_server_endpoint, - 'notifications_controller_endpoint': notifications_controller_endpoint, - } - - # save this instance to use for openmetrics_v2 instance, since the endpoint is different each run - dd_save_state("argocd_instance", instance) - - yield instance + instance = { + 'app_controller_endpoint': 'http://argocd-metrics.argocd.svc.cluster.local:8082/metrics', + 'appset_controller_endpoint': ( + 'http://argocd-applicationset-controller.argocd.svc.cluster.local:8080/metrics' + ), + 'api_server_endpoint': 'http://argocd-server-metrics.argocd.svc.cluster.local:8083/metrics', + 'repo_server_endpoint': 'http://argocd-repo-server.argocd.svc.cluster.local:8084/metrics', + 'notifications_controller_endpoint': ( + 'http://argocd-notifications-controller-metrics.argocd.svc.cluster.local:9001/metrics' + ), + } + metadata = { + 'agent_type': 'kubernetes', + 'kubernetes': { + 'kubeconfig': kubeconfig, + }, + } + + # Save this instance to use for the openmetrics_v2 instance. + dd_save_state("argocd_instance", instance) + + yield instance, metadata