feat: create acquire and reserve managers
These two managers can be passed to a labgrid_config_toolchain
to allow the toolchain to use Labgrid's reserve and acquire functionality to gain allocation of a place before running the test binary, then finally releasing it once the test has completed.
Here are the pieces you would need to make use of the above managers to run a test against an ssh capable remote place, using a coordinator/exporter setup:
platform(
name = "configurable-remote",
constraint_values = [
"@rules_labgrid//labgrid/constraint/device:remote_configurable",
],
parents = ["@local_config_platform//:host"],
visibility = ["//visibility:public"],
)
# Create a constraint to ensure the correct toolchain is selected.
constraint_value(
name = "remote_configurable",
constraint_setting = ":device",
visibility = ["//visibility:public"],
)
labgrid_config_toolchain(
name = "remote",
src = "config.yaml",
env = {
"LG_NETWORK_ADDRESS": "$(NETWORK_ADDRESS)",
"LG_NETWORK_USERNAME": "$(NETWORK_USERNAME)",
"LG_NETWORK_PASSWORD": "$(NETWORK_PASSWORD)",
"LG_NETWORK_PORT": "$(NETWORK_PORT)",
"LG_OPENSSH_SSH": "$(location @openssh//:ssh)",
"LG_OPENSSH_SCP": "$(location @openssh//:scp)",
"LG_PLACE": "$(LG_PLACE)",
},
managers = [
"//bazel/labgrid/manager:reserve",
"//bazel/labgrid/manager:acquire",
],
target_compatible_with = [
":remote_configurable",
],
toolchains = [
"//labgrid/flag/device:address",
"//labgrid/flag/device:password",
"//labgrid/flag/device:port",
"//labgrid/flag/device:username",
],
tools = [
"@openssh//:scp",
"@openssh//:ssh",
],
deps = [
"//bazel/labgrid/strategy",
],
)
The config.yaml to make use of the Remote Place looks like this:
targets:
main:
resources:
RemotePlace:
name: !template "$LG_PLACE"
drivers:
SSHDriver: {}
SSHStrategy: {}
tools:
ssh: !template "$LG_OPENSSH_SSH"
scp: !template "$LG_OPENSSH_SCP"
imports:
- bazel.labgrid.strategy
Then you can make use of it with this simple genrule that cat's the os-release of the device.
labgrid_genrule(
name = "os-release",
srcs = ["@ape//ape:cat"],
outs = ["stdout.log"],
cmd = "$(location @rules_labgrid//labgrid/run) $(location @ape//ape:cat) /etc/os-release > $@",
platform = ":configurable-remote",
tools = [
"@rules_labgrid//labgrid/run",
],
)
Running this rule, specifying the tag device=odroid-n2-plus
and using a coordinator that is accessible by localhost:
bazelisk build //run:os-release --action_env=LG_COORDINATOR=localhost --action_env=BZL_LG_TAGS="device=odroid-n2-plus"
Fixes #46 (closed) Relates to #43 (closed)
Edited by Jordan Bonser