diff options
| -rwxr-xr-x | bin/eth_hotplugging.py | 61 | ||||
| -rw-r--r-- | units/ethernet/jobs.pxu | 147 | ||||
| -rw-r--r-- | units/ethernet/test-plan.pxu | 2 | ||||
| -rw-r--r-- | units/graphics/jobs.pxu | 12 | ||||
| -rw-r--r-- | units/ubuntucore/jobs.pxu | 22 |
5 files changed, 91 insertions, 153 deletions
diff --git a/bin/eth_hotplugging.py b/bin/eth_hotplugging.py new file mode 100755 index 0000000..f1c910d --- /dev/null +++ b/bin/eth_hotplugging.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +# Copyright 2021 Canonical Ltd. +# All rights reserved. +# +# Written by: +# Maciej Kisielewski <maciej.kisielewski@canonical.com> +"""Check if hotplugging works on an ethernet port.""" + +import sys +import time + + +def has_cable(iface): + """Check if cable is inserted in the ethernet port identified by iface.""" + path = '/sys/class/net/{}/carrier'.format(iface) + with open(path) as carrier: + return carrier.read()[0] == '1' + + +def main(): + """Entry point to the program.""" + if len(sys.argv) != 2: + raise SystemExit("Usage {} INTERFACE_NAME".format(sys.argv[0])) + iface = sys.argv[1] + # sanity check of the interface path + try: + has_cable(iface) + except Exception as exc: + msg = "Could not check the cable for '{}': {}".format(iface, exc) + raise SystemExit(msg) from exc + print(("Press enter and unplug the ethernet cable " + "from the port {} of the System.").format(iface)) + print("After 15 seconds plug it back in.") + print("Checkbox session may be interrupted but it should come back up.") + input() + print("Waiting for cable to get disconnected.") + elapsed = 0 + while elapsed < 60: + if not has_cable(sys.argv[1]): + break + time.sleep(1) + print(".", flush=True, end='') + elapsed += 1 + else: + raise SystemExit("Failed to detect unplugging!") + print("Cable unplugged!") + print("Waiting for the cable to get connected.") + elapsed = 0 + while elapsed < 60: + if has_cable(sys.argv[1]): + break + time.sleep(1) + print(".", flush=True, end='') + elapsed += 1 + else: + raise SystemExit("Failed to detect plugging it back!") + print("Cable detected!") + + +if __name__ == '__main__': + main() diff --git a/units/ethernet/jobs.pxu b/units/ethernet/jobs.pxu index 69e7760..4aabac5 100644 --- a/units/ethernet/jobs.pxu +++ b/units/ethernet/jobs.pxu @@ -270,154 +270,19 @@ unit: template template-resource: device template-filter: device.category == 'NETWORK' and device.interface != 'UNKNOWN' template-engine: jinja2 -id: ethernet/hotplug-{{ interface }}-check-disconnected -_summary: Ensure ethernet port {{ interface }} is physically disconnected +id: ethernet/hotplug-{{ interface }} +_summary: Ensure hotplugging works on port {{ interface }} _purpose: - Check that ethernet port {{ interface }} is detected as being in the correct state - to begin a hotplug connection test. + Check that hotplugging works on port {{ interface }} _steps: - 1. Ensure there is no ethernet cable attached to port {{ interface }}. - 2. Begin test. + 1. Begin the test. + 2. Follow the instructions on the screen. plugin: user-interact command: - if [ "$(cat /sys/class/net/{{ interface }}/carrier)" -ne 0 ]; then - # carrier indicating cable present - exit 1 - fi - exit 0 + eth_hotplugging.py {{ interface }} && gateway_ping_test.py -v --interface {{ interface }} category_id: com.canonical.plainbox::ethernet estimated_duration: 1.0 flags: preserve-locale -after: - {%- if __index__ > 1 %}ethernet/hotplug-{{ __index__ - 1 }}-end-cycle{%- endif %} - -unit: template -template-resource: device -template-filter: device.category == 'NETWORK' and device.interface != 'UNKNOWN' -id: ethernet/hotplug-{interface}-connect -_summary: Ethernet port {interface} hotplug detection test -_purpose: - Check ethernet port {interface} connects when cable inserted. Assumes an IP - address will be assigned by DHCP. Connection asserted by pinging the network - defined gateway. -_steps: - 1. Begin the test. - 2. Insert the ethernet cable in to ethernet port {interface}. - 3. This test will timeout and fail if the insertion and connection - establishment has not been detected (10 second timeout for each check). -plugin: user-interact -command: - LOOP=0 - CABLE_DETECT=0 - while [ $LOOP -lt 10 ] && [ "$CABLE_DETECT" -eq 0 ] - do - sleep 1 - CABLE_DETECT=$(cat /sys/class/net/{interface}/carrier) - LOOP=$((LOOP=LOOP+1)) - done - if [ "$CABLE_DETECT" -eq 0 ]; then - echo "Didn't detect a cable insertion" - exit 1 - fi - echo "Detected a cable insertion" - LOOP=0 - OPSTATE="unknown" - while [ $LOOP -lt 10 ] && [ "$OPSTATE" != "up" ] - do - sleep 1 - OPSTATE=$(cat /sys/class/net/{interface}/operstate) - LOOP=$((LOOP=LOOP+1)) - done - if [ "$OPSTATE" != "up" ]; then - echo "Interface did not up" - exit 1 - fi - echo "Interface up" - gateway_ping_test.py -v --interface {interface} - PING_TEST=$? - if [ $PING_TEST -ne 0 ]; then - echo "Ping test failed" - exit 1 - fi - exit 0 -category_id: com.canonical.plainbox::ethernet -estimated_duration: 60.0 -depends: ethernet/hotplug-{interface}-check-disconnected - -unit: template -template-resource: device -template-filter: device.category == 'NETWORK' and device.interface != 'UNKNOWN' -id: ethernet/hotplug-{interface}-disconnect -_summary: Ethernet port {interface} hotplug disconnect step -_purpose: - Check that when cable removed from ethernet port {interface} the system - detects this correctly. -_steps: - 1. Depends on previous hotplug connection test passing. We will now test - cable disconnection. - 2. Begin the test. - 3. Remove the ethernet cable from ethernet port {interface}. - 4. This test will timeout and fail if the removal has not been detected and - interface marked as down (10 second timeout for each check). -plugin: user-interact -command: - LOOP=0 - CABLE_DETECT=1 - while [ $LOOP -lt 10 ] && [ "$CABLE_DETECT" -ne 0 ] - do - sleep 1 - CABLE_DETECT=$(cat /sys/class/net/{interface}/carrier) - LOOP=$((LOOP=LOOP+1)) - done - if [ "$CABLE_DETECT" -ne 0 ]; then - echo "Didn't detect a cable removal" - exit 1 - fi - echo "Detected a cable removal" - LOOP=0 - OPSTATE="up" - while [ $LOOP -lt 10 ] && [ "$OPSTATE" == "up" ] - do - sleep 1 - OPSTATE=$(cat /sys/class/net/{interface}/operstate) - LOOP=$((LOOP=LOOP+1)) - done - if [ "$OPSTATE" == "up" ]; then - echo "Interface did not go down" - exit 1 - fi - echo "Interface went down" - exit 0 -category_id: com.canonical.plainbox::ethernet -estimated_duration: 20.0 -depends: ethernet/hotplug-{interface}-connect - -unit: template -template-resource: device -template-filter: device.category == 'NETWORK' and device.interface != 'UNKNOWN' -id: ethernet/hotplug-{__index__}-end-cycle -category_id: com.canonical.plainbox::ethernet -after: ethernet/hotplug-{interface}-disconnect -command: true -flags: simple - -unit: template -template-resource: device -template-filter: device.category == 'NETWORK' and device.interface != 'UNKNOWN' -template-unit: job -id: ethernet/iperf3_{interface} -plugin: shell -_summary: Iperf3 stress testing for {interface} -category_id: com.canonical.plainbox::ethernet -estimated_duration: 740.0 -user: root -environ: - TEST_TARGET_IPERF - LD_LIBRARY_PATH -command: network.py test -i {interface} -t iperf --iperf3 --scan-timeout 3600 --fail-threshold 80 --cpu-load-fail-threshold 90 --runtime 90 --num_runs 4 -_description: - This test uses iperf3 to ensure network devices pass data at an acceptable - minimum percentage of advertized speed. unit: template template-resource: device diff --git a/units/ethernet/test-plan.pxu b/units/ethernet/test-plan.pxu index 986c886..5e003ae 100644 --- a/units/ethernet/test-plan.pxu +++ b/units/ethernet/test-plan.pxu @@ -17,6 +17,8 @@ include: ethernet/wol_S4_.* ethernet/wol_S3_.* ethernet/hotplug-.* +bootstrap_include: + device id: ethernet-automated unit: test plan diff --git a/units/graphics/jobs.pxu b/units/graphics/jobs.pxu index bf03878..acf18c3 100644 --- a/units/graphics/jobs.pxu +++ b/units/graphics/jobs.pxu @@ -545,3 +545,15 @@ _summary: Check NVIDIA NVLINK status _description: Check NVLINK are supported and NVLINK are connected properly on system, please make sure below items before testing: 1. More than one NVIDIA Graphic card are installed. 2. Each graphic card are connected by NVLINK. + +unit: template +template-resource: graphics_card +plugin: shell +category_id: com.canonical.plainbox::graphics +id: graphics/{index}_glmark2-es2_{product_slug} +requires: + executable.name == 'glmark2-es2' + 'classic' in environment.SNAP_NAME +command: glmark2-es2 --data-path "$CHECKBOX_RUNTIME"/usr/share/glmark2/ +estimated_duration: 60.5 +_summary: Run OpenGL ES 2.0 X11 benchmark on the {product} video card diff --git a/units/ubuntucore/jobs.pxu b/units/ubuntucore/jobs.pxu index c82c43b..9dbf44f 100644 --- a/units/ubuntucore/jobs.pxu +++ b/units/ubuntucore/jobs.pxu @@ -5,15 +5,15 @@ _purpose: requires: lsb.release >= '20' _steps: - 1. Send unix socket command to reboot system into recovery mode - $ sudo http --pretty=format POST snapd:///v2/systems/$(ls /run/mnt/ubuntu-seed/systems/) action=do mode=recover - If 'http' is not installed, run the following command first - $ sudo snap install http - 2. System should respond to the unix socket command and reboot itself + 1. Reboot the system to recovery mode + $ sudo snap reboot --recover + 2. System should respond to the command and reboot itself 3. Wait until system completes the reboot process - 4. Check if system is running in recovery mode through kernel cmdline + 4. Check if system is running in recovery mode $ cat /proc/cmdline - 5. Reboot the system and check again if system goes back to normal run mode + 5. Reboot the system back to normal run mode + $ sudo snap reboot + 6. Check again if system is running in run mode $ cat /proc/cmdline _verification: Check if kernel cmdline when system in recovery mode includes: @@ -39,11 +39,9 @@ _steps: $ echo 5 > /sys/class/tpm/tpm0/ppi/request For ARM-based platforms: There is no generic command for ARM-based platforms, please refer to device user manual - 3. Send unix socket command to reboot system into reinstall mode - $ sudo http --pretty=format POST snapd:///v2/systems/$(ls /run/mnt/ubuntu-seed/systems/) action=do mode=install - If 'http' is not installed, run the following command first - $ sudo snap install http - 4. System should respond to the unix socket command and reboot itself + 3. Reboot the system to reinstall mode + $ sudo snap reboot --install + 4. System should respond to the command and reboot itself 5. Wait until system completes the installation and initialization process 6. Check serial-assertion device-key after installation completes $ ls /var/lib/snapd/save/device/private-keys-v1 |
