This is an automated email from the ASF dual-hosted git repository. arshad pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ambari-metrics.git
The following commit(s) were added to refs/heads/master by this push: new 7f5b225 [AMBARI-26134]Resolve Test case failures in Ambari Metrics host Monitoring (#133) 7f5b225 is described below commit 7f5b2256eff9bbbd0368ca26a20457883c6b166a Author: Sandeep Kumar <skuma...@visa.com> AuthorDate: Tue Oct 1 16:21:07 2024 +0530 [AMBARI-26134]Resolve Test case failures in Ambari Metrics host Monitoring (#133) Signed-off-by: Mohammad Arshad <ars...@apache.org> --- .github/workflows/ambari.yml | 6 ++++-- .../src/main/python/core/emitter.py | 8 ++++---- .../src/main/python/core/host_info.py | 1 + .../src/main/python/core/metering.py | 2 +- .../src/main/python/core/metric_collector.py | 4 ++-- .../src/main/python/core/spnego_kerberos_auth.py | 2 +- .../src/test/python/core/TestEmitter.py | 3 ++- .../src/test/python/core/TestHostInfo.py | 24 ++++++++++++++++------ .../src/test/python/mock/mock.py | 2 ++ 9 files changed, 35 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ambari.yml b/.github/workflows/ambari.yml index f5815b4..b5ac9e1 100644 --- a/.github/workflows/ambari.yml +++ b/.github/workflows/ambari.yml @@ -33,7 +33,9 @@ jobs: java-version: 8 distribution: temurin cache: maven - - name: Set up Python 2 - run: sudo apt-get update && sudo apt-get install -y python2-dev python-is-python2 + - name: Install Kerberos development libraries + run: sudo apt-get install -y libkrb5-dev + - name: Install Kerberos + run: pip3 install kerberos - name: Build with Maven run: mvn -B clean package diff --git a/ambari-metrics-host-monitoring/src/main/python/core/emitter.py b/ambari-metrics-host-monitoring/src/main/python/core/emitter.py index d220b7a..81f0655 100644 --- a/ambari-metrics-host-monitoring/src/main/python/core/emitter.py +++ b/ambari-metrics-host-monitoring/src/main/python/core/emitter.py @@ -21,10 +21,10 @@ limitations under the License. import logging import threading -from resource_monitoring.core.security import CachedHTTPSConnection, CachedHTTPConnection -from resource_monitoring.core.blacklisted_set import BlacklistedSet -from resource_monitoring.core.config_reader import ROUND_ROBIN_FAILOVER_STRATEGY -from resource_monitoring.core.spnego_kerberos_auth import SPNEGOKerberosAuth +from security import CachedHTTPSConnection, CachedHTTPConnection +from blacklisted_set import BlacklistedSet +from config_reader import ROUND_ROBIN_FAILOVER_STRATEGY +from spnego_kerberos_auth import SPNEGOKerberosAuth logger = logging.getLogger() diff --git a/ambari-metrics-host-monitoring/src/main/python/core/host_info.py b/ambari-metrics-host-monitoring/src/main/python/core/host_info.py index b33ba46..d440108 100644 --- a/ambari-metrics-host-monitoring/src/main/python/core/host_info.py +++ b/ambari-metrics-host-monitoring/src/main/python/core/host_info.py @@ -120,6 +120,7 @@ class HostInfo(): swap_total = self.__host_static_info.get('swap_total') bytes2kilobytes = lambda x: x / 1024 + mem_total = psutil.virtual_memory().total return { 'mem_total': bytes2kilobytes(mem_total) if mem_total else 0, diff --git a/ambari-metrics-host-monitoring/src/main/python/core/metering.py b/ambari-metrics-host-monitoring/src/main/python/core/metering.py index 842bfa9..c6c629a 100644 --- a/ambari-metrics-host-monitoring/src/main/python/core/metering.py +++ b/ambari-metrics-host-monitoring/src/main/python/core/metering.py @@ -21,7 +21,7 @@ limitations under the License. import logging import time import json -from resource_monitoring.core.instance_type_provider import HostInstanceTypeProvider +from instance_type_provider import HostInstanceTypeProvider logger = logging.getLogger() diff --git a/ambari-metrics-host-monitoring/src/main/python/core/metric_collector.py b/ambari-metrics-host-monitoring/src/main/python/core/metric_collector.py index f0318b6..8bd4e0d 100644 --- a/ambari-metrics-host-monitoring/src/main/python/core/metric_collector.py +++ b/ambari-metrics-host-monitoring/src/main/python/core/metric_collector.py @@ -20,8 +20,8 @@ limitations under the License. import logging from time import time -from resource_monitoring.core.event_definition import HostMetricCollectEvent, ProcessMetricCollectEvent -from resource_monitoring.core.metering import MeteringMetricHandler +from event_definition import HostMetricCollectEvent, ProcessMetricCollectEvent +from metering import MeteringMetricHandler logger = logging.getLogger() diff --git a/ambari-metrics-host-monitoring/src/main/python/core/spnego_kerberos_auth.py b/ambari-metrics-host-monitoring/src/main/python/core/spnego_kerberos_auth.py index 401f66d..bdb1d4b 100644 --- a/ambari-metrics-host-monitoring/src/main/python/core/spnego_kerberos_auth.py +++ b/ambari-metrics-host-monitoring/src/main/python/core/spnego_kerberos_auth.py @@ -26,7 +26,7 @@ logger = logging.getLogger() try: import kerberos except ImportError: - from resource_monitoring.core import krberr as kerberos + from krberr import krberr as kerberos logger.warn('import kerberos exception: %s' % str(ImportError)) pass diff --git a/ambari-metrics-host-monitoring/src/test/python/core/TestEmitter.py b/ambari-metrics-host-monitoring/src/test/python/core/TestEmitter.py index bce5e75..bf13cfd 100644 --- a/ambari-metrics-host-monitoring/src/test/python/core/TestEmitter.py +++ b/ambari-metrics-host-monitoring/src/test/python/core/TestEmitter.py @@ -21,6 +21,7 @@ limitations under the License. import json import logging import time +import distro from unittest import TestCase from mock.mock import patch, MagicMock @@ -30,7 +31,7 @@ from spnego_kerberos_auth import SPNEGOKerberosAuth os_distro_value = ('Suse','11','Final') -with patch("platform.linux_distribution", return_value = os_distro_value): +with patch("distro.linux_distribution", return_value=os_distro_value): from application_metric_map import ApplicationMetricMap from config_reader import Configuration from emitter import Emitter diff --git a/ambari-metrics-host-monitoring/src/test/python/core/TestHostInfo.py b/ambari-metrics-host-monitoring/src/test/python/core/TestHostInfo.py index 058a57e..514f364 100644 --- a/ambari-metrics-host-monitoring/src/test/python/core/TestHostInfo.py +++ b/ambari-metrics-host-monitoring/src/test/python/core/TestHostInfo.py @@ -71,21 +71,33 @@ class TestHostInfo(TestCase): vm.free = 2312043 vm.shared = 1243 vm.buffers = 23435 - vm.cached = 23545 vm.available = 2312043 + vm.total = 8192 * 1024 + vm.used = 4096 * 1024 + vm.cached = 1024 * 1024 sw = sw_mock.return_value sw.free = 2341234 + sw.used = 1024 * 1024 + sw.total = 2048 * 1024 + sw.sin = 512 * 1024 + sw.sout = 256 * 1024 hostinfo = HostInfo(MagicMock()) mem = hostinfo.get_mem_info() - self.assertAlmostEqual(mem['mem_free'], 2257) - self.assertAlmostEqual(mem['mem_shared'], 1) - self.assertAlmostEqual(mem['mem_buffered'], 22) - self.assertAlmostEqual(mem['mem_cached'], 22) - self.assertAlmostEqual(mem['swap_free'], 2286) + self.assertAlmostEqual(mem['mem_free'], 2257, delta = 1) + self.assertAlmostEqual(mem['mem_shared'], 1, delta=0.5) + self.assertAlmostEqual(mem['mem_buffered'], 22, delta = 1) + self.assertAlmostEqual(mem['mem_cached'], 1024, delta = 1) + self.assertAlmostEqual(mem['swap_free'], 2286, delta = 1) + self.assertAlmostEqual(mem['mem_total'], 8192, delta = 1) + self.assertAlmostEqual(mem['mem_used'], 3072, delta = 1) + self.assertAlmostEqual(mem['swap_used'], 1024, delta = 1) + self.assertAlmostEqual(mem['swap_total'], 2048, delta = 1) + self.assertAlmostEqual(mem['swap_in'], 512, delta = 1) + self.assertAlmostEqual(mem['swap_out'], 256, delta = 1) @patch("psutil.process_iter") diff --git a/ambari-metrics-host-monitoring/src/test/python/mock/mock.py b/ambari-metrics-host-monitoring/src/test/python/mock/mock.py index accf619..d8b854d 100644 --- a/ambari-metrics-host-monitoring/src/test/python/mock/mock.py +++ b/ambari-metrics-host-monitoring/src/test/python/mock/mock.py @@ -31,6 +31,8 @@ __version__ = '1.0.1' import pprint import sys +import distro +os_distro_value = distro.linux_distribution(full_distribution_name=False) try: import inspect --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@ambari.apache.org For additional commands, e-mail: commits-h...@ambari.apache.org