Skip to content

Conversation

@bhcopeland
Copy link
Member

tuxrun: __main__: Add device-dict mode runtime support

When --device-dict is used: use host network, skip HTTP service, bind
device control binaries, bind dispatcher download dir for NFS/TFTP.
Pass device_dict to tuxlava.

Add --device-dict argument to specify
an external device dictionary file for device-dict mode.


Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
When --device-dict is used: use host network, skip HTTP service, bind
device control binaries, bind dispatcher download dir for NFS/TFTP.
Pass device_dict to tuxlava.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
Modify runtime bind() to allow same source dir to be mounted at multiple
destinations. Required for device-dict mode where dispatcher_download_dir maps to
both /srv/sftp and /var/lib/lava/dispatcher/tmp

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
Add dispatcher_ip variable to dispatcher_ip.yaml.jinja2, defaulting to
198.18.0.1 in device-dict mode. This ip is used by DUT's to reach TFTP/NFS on the host.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
Add unit tests for device-dict mode runtime bindings, host network mode, and multiple
mount destinations.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
# <dispatcher_download_dir>/<job_id>
prefix: "{{ prefix }}-"

{% if d_dict_mode %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message for this commit mentions dispatcher_ip.yaml.jinja2, but it should be dispatcher.yaml.jinaj2

@@ -0,0 +1,50 @@
# bash completion for tuxrun
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the commit message we can remove the extra blank line before your Signed-off-by.
Instead of our own bash-completion, can't we use argcomplete?

diff --git a/tuxrun/argparse.py b/tuxrun/argparse.py
index fc7375472173..0d4dab64b5e7 100644
--- a/tuxrun/argparse.py
+++ b/tuxrun/argparse.py
@@ -5,6 +5,7 @@
 #
 # SPDX-License-Identifier: MIT
 
+import argcomplete
 import argparse
 import sys
 from pathlib import Path
@@ -17,6 +18,18 @@ from tuxlava.devices import Device  # type: ignore
 from tuxlava.tests import Test  # type: ignore
 
 
+##############
+# Completers #
+##############
+def device_completer(**kwargs):
+    devices = [d.name for d in Device.list(virtual_device=True)]
+    return sorted(set(devices))
+
+
+def test_completer(**kwargs):
+    return Test.list(virtual_device=True)
+
+
 ###########
 # Helpers #
 ###########
@@ -327,12 +340,13 @@ def setup_parser() -> argparse.ArgumentParser:
     )
 
     group = parser.add_argument_group("run options")
-    group.add_argument(
+    device_arg = group.add_argument(
         "--device",
         default=None,
         metavar="NAME",
         help="Device type",
     )
+    device_arg.completer = device_completer
     group.add_argument(
         "--device-dict",
         default=None,

popen.assert_called_once()

# Test duplicated source bindings
# Test duplicated destination bindings (duplicated sources are allowed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit messages mentions /srv/sftp do you mean sftp or tftp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants