Dasharo / open-source-firmware-validation

OSFV infrastructure with automated tests and scripts for managing test results
Apache License 2.0
8 stars 1 forks source link

Use OSFV python lib to implement low-level interfaces, like flashing #257

Closed macpijan closed 3 months ago

macpijan commented 6 months ago

Test environment version

Dasharo version (if applicable)

Dasharo variant (if applicable)

Affected component(s) or functionality (if applicable)

Brief summary

Implement DRY strategy. Avoid reimplementing low-level flashing and platform control login in multiple places:

Keep the low-level details only in one place, and provide an interface to be used in tests.

Additional context

WIP work:

macpijan commented 5 months ago

@PLangowski

I have tried various way of sharing this, and probably the best way is as in the linked branches. I would start from there adn check if we can call basic functions (like flash probe/read) from osfv-script repo in all these cases:

If the answer is yes, and we cannot see probles with this approach, we can continue with cleanup, further improvements, and replacing the previous Rte library with the calls from osfv-scripts libs.

High-level TODOs:

PLangowski commented 5 months ago

@macpijan I've heard the Sonoff API has changed. It seems to be confirmed when i try to use osfv_cli to control sonoff

osfv_cli sonoff --rte_ip 192.168.10.107 get
Getting Sonoff relay state...
Failed to get Sonoff relay state. Error: 404 Client Error: Not Found for url: http://192.168.10.170/switch/sonoff_s20_relay

Below is the content of the sonoff.sh script on the rte in question:

#!/bin/bash

SONOFF_IP=192.168.10.170

if [[ "$1" == "off" ]]; then
    wget -q -O - http://$SONOFF_IP/cm?cmnd=Power%20off --method=POST
    echo -e '\n'
elif [[ "$1" == "on" ]]; then
    wget -q -O - http://$SONOFF_IP/cm?cmnd=Power%20On --method=POST
    echo -e '\n'
elif [[ "$1" == "toggle" ]]; then
    wget -q -O - http://$SONOFF_IP/cm?cmnd=Power%20TOGGLE --method=POST
    echo -e '\n'
elif [[ "$1" == "show" ]]; then
    wget -q -O - http://$SONOFF_IP/cm?cmnd=Power
    echo -e '\n'
else
    echo -e "\$1 == on|off|show|toggle\nEdit this script to set the sonoff ip."
    echo -e 'Current state:'
    wget -q -O - http://$SONOFF_IP/cm?cmnd=Power
    echo -e '\n'
fi

These are clearly different URLs. Is anyone working on adapting osfv_cli to the new API? This error is preventing me from accurately testing my work on this issue.

macpijan commented 5 months ago

It is adapated already. Which versino are you using?

PLangowski commented 5 months ago

main, tag v0.4.2

macpijan commented 5 months ago

Ok it is here: https://github.com/Dasharo/osfv-scripts/pull/11/files#diff-152929c4b9e899cc69afdcfad33041262ac6bdc8634e5175bfb43cb2962d1bdf

PLangowski commented 5 months ago

Thanks

PLangowski commented 5 months ago

@macpijan both PRs linked to this issue are ready for review. I have tested Flash Read on msi-pro-z690-a-ddr4 and minnowboard turbot. Everything seems to work, including running tests without snipeit (that requires sonoff and pikvm ips to be specified in command line). Here's how to run a test that way:

robot -L TRACE -v snipeit:'no' -v sonoff_ip:192.168.10.170 -v pikvm_ip:192.168.10.99 -v rte_ip:192.168.10.107 -v config:"msi-pro-z690-a-wifi-ddr4" -t "TEST  /path/to/suite

OSFV is no longer dependent on RteCtrl and Sonoff APIs. All the calls were replaced wiith calls to the osfv_cli package, which has been added to requirements.txt.