Skip to content

Commit

Permalink
status server uris sync up
Browse files Browse the repository at this point in the history
When user sets only one of the status server values (uri, listen) Then
the avocado will stop working because it will listen on different uri
than the messages will be sent. This change will synchronize these
values if the user sets only one of them.

Reference: #5740
Signed-off-by: Jan Richter <[email protected]>
  • Loading branch information
richtja committed Aug 28, 2023
1 parent 04b6163 commit 2b24ea6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
28 changes: 25 additions & 3 deletions avocado/plugins/runner_nrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
from avocado.core.task.runtime import RuntimeTaskGraph
from avocado.core.task.statemachine import TaskStateMachine, Worker

DEFAULT_SERVER_URI = "127.0.0.1:8888"


class RunnerInit(Init):

Expand Down Expand Up @@ -69,12 +71,14 @@ def initialize(self):

help_msg = (
'URI where status server will listen on. Usually a "HOST:PORT" '
'string. This is only effective if "status_server_auto" is disabled'
'string. This is only effective if "status_server_auto" is disabled. '
'If "status_server_uri" is not set. Value from "status_server_listen " '
"will be used."
)
settings.register_option(
section=section,
key="status_server_listen",
default="127.0.0.1:8888",
default=DEFAULT_SERVER_URI,
metavar="HOST:PORT",
help_msg=help_msg,
)
Expand All @@ -84,11 +88,13 @@ def initialize(self):
'a "HOST:PORT" string. Use this if your status server '
"is in another host, or different port. This is only "
'effective if "status_server_auto" is disabled'
'If "status_server_listen" is not set. Value from "status_server_uri" '
"will be used."
)
settings.register_option(
section=section,
key="status_server_uri",
default="127.0.0.1:8888",
default=DEFAULT_SERVER_URI,
metavar="HOST:PORT",
help_msg=help_msg,
)
Expand Down Expand Up @@ -229,7 +235,23 @@ def _determine_status_server(self, test_suite, config_key):
return os.path.join(self.status_server_dir.name, ".status_server.sock")
return test_suite.config.get(config_key)

def _sync_status_server_urls(self, config):
server_listen = config.get("run.status_server_listen")
server_uri = config.get("run.status_server_uri")
if not config.get("run.status_server_auto"):
if (
server_uri is not DEFAULT_SERVER_URI
and server_listen is DEFAULT_SERVER_URI
):
config["run.status_server_listen"] = server_uri
if (
server_uri is DEFAULT_SERVER_URI
and server_listen is not DEFAULT_SERVER_URI
):
config["run.status_server_uri"] = server_listen

def _create_status_server(self, test_suite, job):
self._sync_status_server_urls(test_suite.config)
listen = self._determine_status_server(test_suite, "run.status_server_listen")
# pylint: disable=W0201
self.status_repo = StatusRepo(job.unique_id)
Expand Down
16 changes: 16 additions & 0 deletions selftests/functional/plugin/runner_nrunner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from avocado.core.exit_codes import AVOCADO_ALL_OK
from avocado.utils import process
from selftests.utils import AVOCADO, TestCaseTmpDir


class NrunnerTest(TestCaseTmpDir):
def test_status_server_uri(self):
result = process.run(
f"{AVOCADO} run "
f"--job-results-dir {self.tmpdir.name} "
f"--disable-sysinfo --status-server-disable-auto "
f"--status-server-uri 127.0.0.1:9999 "
f"examples/tests/true",
)
self.assertIn("PASS 1 ", result.stdout_text)
self.assertEqual(result.exit_status, AVOCADO_ALL_OK)

0 comments on commit 2b24ea6

Please sign in to comment.