Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status server uris sync up #5748

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, the 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)
Loading