Skip to content

Commit

Permalink
feat(muxpi): provisioning: skip user creation, custom boot check cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
thp-canonical committed Mar 1, 2024
1 parent 6dddd55 commit 4f4a03a
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,14 @@ def provision(self):
logger.info("Flashing Test image")
try:
self.flash_test_image(url)
with self.remote_mount():
image_type = self.get_image_type()
logger.info("Image type detected: {}".format(image_type))
logger.info("Creating Test User")
self.create_user(image_type)
if self.job_data["provision_data"].get("create_user", True):
with self.remote_mount():
image_type = self.get_image_type()
logger.info("Image type detected: {}".format(image_type))
logger.info("Creating Test User")
self.create_user(image_type)
else:
logger.info("Skipping test user creation (create_user=False)")
self.run_post_provision_script()
logger.info("Booting Test Image")
cmd = self.config.get("control_switch_device_cmd", "stm -dut")
Expand Down Expand Up @@ -434,22 +437,36 @@ def check_test_image_booted(self):
test_password = self.job_data.get("test_data", {}).get(
"test_password", "ubuntu"
)
boot_check_cmd_str = self.job_data.get("provision_data", {}).get(
"boot_check_cmd", None
)
env = os.environ.copy()
if boot_check_cmd_str is not None:
env.update({
'TEST_USERNAME': test_username,
'TEST_PASSWORD': test_password,
'DEVICE_IP': self.config["device_ip"],
})
logger.info("Using custom boot check script: %r", boot_check_cmd_str)
boot_check_cmd = shlex.split(boot_check_cmd_str)
else:
boot_check_cmd = [
"sshpass",
"-p",
test_password,
"ssh-copy-id",
"-o",
"StrictHostKeyChecking=no",
"-o",
"UserKnownHostsFile=/dev/null",
"{}@{}".format(test_username, self.config["device_ip"]),
]

while time.time() - started < 1200:
try:
time.sleep(10)
cmd = [
"sshpass",
"-p",
test_password,
"ssh-copy-id",
"-o",
"StrictHostKeyChecking=no",
"-o",
"UserKnownHostsFile=/dev/null",
"{}@{}".format(test_username, self.config["device_ip"]),
]
subprocess.check_output(
cmd, stderr=subprocess.STDOUT, timeout=60
boot_check_cmd, env=env, stderr=subprocess.STDOUT, timeout=60
)
return True
except Exception:
Expand Down
51 changes: 50 additions & 1 deletion docs/reference/device-connector-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To specify the commands to run by the device in each test phase, set the ``testf
* - ``multi``
- Experimental device type that is used for provisioning multiple other devices in order to coordinate a job across multiple devices at the same time.
* - ``muxpi``
- MuxPi or SDWire device capable of multiplexing the SD card so that it can be written, then control can be switched to the DUT to boot the image.
- MuxPi or SDWire device capable of multiplexing the SD card so that it can be written, then control can be switched to the DUT to boot the image, see :ref:`muxpi`.
* - ``netboot``
- Special purpose device connector for a few devices that must be booted and flashed remotely but the image they need is not compatible with MaaS.
* - ``noprovision``
Expand All @@ -32,3 +32,52 @@ To specify the commands to run by the device in each test phase, set the ``testf
- This device connector is used for Lenovo OEM devices running certain versions of OEM supported images that can use a recovery partition to recover not only the same image, but in some cases, other OEM image versions as well.
* - ``hp_oemscript``
- This device connector is used for HP OEM devices running certain versions of OEM supported images that can use a recovery partition to recover not only the same image, but in some cases, other OEM image versions as well.

.. _muxpi:

muxpi
-----

The ``muxpi`` device connector supports the following ``provision_data`` keys:

.. list-table:: Supported ``provision_data`` keys for ``muxpi``
:header-rows: 1

* - Key
- Description
* - ``url``
- URL to a zstd-compressed disk image that is downloaded, decompressed and
flashed to the SD card, which will be used to boot up the DUT.
* - ``create_user``
- Boolean (default ``true``) specifying whether a user account should be created.
* - ``boot_check_cmd``
- Shell command to use for checking if the DUT has finished booting; use
the DUT is reachable via ``$DEVICE_IP``; if not set, SSH will be used to
check when the device comes online. For logging into the device,
``$TEST_USERNAME`` and ``$TEST_PASSWORD`` will be set to the values of
``test_username`` and ``test_password`` from the job's ``test_data``.
When ``boot_check_cmd`` is set, the SSH key for public key authentication
won't be installed on the DUT to allow for testing without SSH.

Image types recognized for user account creation
(the device type is not used if ``create_user: false`` is set in ``provision_data``):

.. list-table:: Supported image types
:header-rows: 1

* - Image type
- Description
* - ``ce-oem-iot``
- IoT OEM certification
* - ``tegra``
- NVidia Tegra
* - ``pi-desktop``
- Ubuntu Desktop on Raspberry Pi
* - ``ubuntu``
- Ubuntu Classic
* - ``core``
- Ubuntu Core
* - ``core20``
- Ubuntu Core 20
* - ``ubuntu-cpc``
- Ubuntu Certified Public Cloud

0 comments on commit 4f4a03a

Please sign in to comment.