def test_version_metadata(datadog_agent, istiod_mixture_fixture): check = Istio(common.CHECK_NAME, {}, [common.MOCK_ISTIOD_INSTANCE]) check.check_id = 'test:123' check.check(common.MOCK_ISTIOD_INSTANCE) # Use version mocked from istiod 1.5 fixture MOCK_VERSION = '1.5.0' major, minor, patch = MOCK_VERSION.split('.') version_metadata = { 'version.scheme': 'semver', 'version.major': major, 'version.minor': minor, 'version.patch': patch, 'version.raw': MOCK_VERSION, } datadog_agent.assert_metadata('test:123', version_metadata)
def test_version_metadata(datadog_agent, dd_run_check, mock_http_response): """ Test metadata version collection with V2 implementation """ mock_http_response(file_path=get_fixture_path('1.5', 'istiod.txt')) check = Istio(common.CHECK_NAME, {}, [common.MOCK_LEGACY_ISTIOD_INSTANCE]) check.check_id = 'test:123' dd_run_check(check) # Use version mocked from istiod 1.5 fixture MOCK_VERSION = '1.5.0' major, minor, patch = MOCK_VERSION.split('.') version_metadata = { 'version.scheme': 'semver', 'version.major': major, 'version.minor': minor, 'version.patch': patch, 'version.raw': MOCK_VERSION, } datadog_agent.assert_metadata('test:123', version_metadata)
def test_legacy_version_metadata(datadog_agent, dd_run_check): check = Istio(common.CHECK_NAME, {}, [common.MOCK_LEGACY_ISTIOD_INSTANCE]) check.check_id = 'test:123' with requests_mock.Mocker() as metric_request: metric_request.get('http://localhost:8080/metrics', text=get_response('1.5', 'istiod.txt')) dd_run_check(check) # Use version mocked from istiod 1.5 fixture MOCK_VERSION = '1.5.0' major, minor, patch = MOCK_VERSION.split('.') version_metadata = { 'version.scheme': 'semver', 'version.major': major, 'version.minor': minor, 'version.patch': patch, 'version.raw': MOCK_VERSION, } datadog_agent.assert_metadata('test:123', version_metadata)