From: E. Scott Daniels Date: Mon, 12 Oct 2020 13:36:39 +0000 (-0400) Subject: Remove use of "localhost" in unit tests X-Git-Tag: 1.6.0~3 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=27964b5bd61b1afe685bce4180f1e37faabf3f39;p=ric-plt%2Fxapp-frame-py.git Remove use of "localhost" in unit tests In some container environments localhost is defined multiple times in /etc/hosts. This can cause unit tests to fail if "localhost" is used to create a connection. This change switches to use the loop back address (127.0.0.1) for unit tests. Issue-ID: RIC-654 Signed-off-by: E. Scott Daniels Change-Id: Ia48ffac700b54dce59f878f46f1f011dce1df260 --- diff --git a/tests/test_alarm.py b/tests/test_alarm.py index df8b2d4..2eec9c9 100644 --- a/tests/test_alarm.py +++ b/tests/test_alarm.py @@ -79,7 +79,7 @@ def test_alarm_set_get(monkeypatch): alarm.AlarmManager(MRC_SEND, "bogus", "envvars") # good environment variables - monkeypatch.setenv(ALARM_MGR_SERVICE_NAME_ENV, "localhost") + monkeypatch.setenv(ALARM_MGR_SERVICE_NAME_ENV, "127.0.0.1") # do NOT use localhost monkeypatch.setenv(ALARM_MGR_SERVICE_PORT_ENV, "4567") # any int is ok here mgr = alarm.AlarmManager(MRC_SEND, "moid2", "appid2") assert mgr is not None @@ -106,7 +106,7 @@ def test_alarm_manager(monkeypatch): """ test send functions and ensure a message arrives """ - monkeypatch.setenv(ALARM_MGR_SERVICE_NAME_ENV, "localhost") + monkeypatch.setenv(ALARM_MGR_SERVICE_NAME_ENV, "127.0.0.1") # do NOT use localhost monkeypatch.setenv(ALARM_MGR_SERVICE_PORT_ENV, "4567") # must match rcv port above mgr = AlarmManager(MRC_SEND, "moid", "appid") assert mgr is not None