Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting more variables via command line #219

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

leivos-unikie
Copy link
Collaborator

@leivos-unikie leivos-unikie commented Jan 28, 2025

The purpose of this PR is to bring more flexibility into manual use of ci-test-automation and to make local smoke testing faster. Fully automated setups should not be affected.

CONFIG_PATH (path to test_config.json) can be given via command line. If not given it defaults to the current path.

If CONFIG_PATH is set to None reading config file variables will be ignored which allows setting target IP address from command line. This makes local testing more straightforward, not having to create or modify test_config.json.

Prevents Set Variables from overwriting password (given via cmd line) if /run/secrets/dut-pass does not exist.

Custom test user name and password are now allowed. They can be stored to /etc/secrets/testuser and /etc/secrets/testpw. If those files don't exist test user credentials default to testuser/testpw.

Steps to run smoke tests locally from ghaf-host:

Open terminal and ssh to ghaf-host
cd /home
sudo su
git clone https://github.com/leivos-unikie/ci-test-automation.git
cd ci-test-automation/Robot-Framework/test-suites
nix develop
git checkout optional_config
robot -v CONFIG_PATH:None -v DISABLE_LOGOUT:true -v DEVICE:Lenovo-X1 -v DEVICE_IP_ADDRESS:192.168.100.1 -v PASSWORD:ghaf -i lenovo-x1ANDpre-merge ./

I ran also with
robot -v CONFIG_PATH:None -v DEVICE:Lenovo-X1 -v DEVICE_IP_ADDRESS:192.168.100.1 -v PASSWORD:ghaf -i lenovo-x1ANDbat -i lenovo-x1ANDgui-apps ./
after setting wifi credentials to /run/secrets and all test cases passed except timesync test (in current state it assumes unchanged time on the machine running robot framework).

If running the tests from separate machine just set the target IP to DEVICE_IP_ADDRESS.

If running tests locally from ghaf-host of Lenovo-X1 the result files can be sent to chrome-vm after the tests have finished by python ../lib/send_report.py password and then opened with chrome app by typing /tmp/report.html to the url field.

@milva-unikie
Copy link
Collaborator

Great start! I tested this by running the tests from ghaf host on Lenovo-X1. Few comments:

  • ssh command should be ssh ghaf@ghaf-host-debug and nix develop is missing
  • If you have created your user as something else than testuser tests won't work unless you go and change the username/password in variables.robot
  • At the end tests log out and results in terminal are lost
  • No easy way to check report.html

@leivos-unikie
Copy link
Collaborator Author

Thanks for trying this out. My suggestions to these.

* ssh command should be `ssh ghaf@ghaf-host-debug` and `nix develop` is missing

The first step was meant generally somehow connecting to ghaf-host either from gui-vm or from separate machine over network.

* If you have created your user as something else than testuser tests won't work unless you go and change the username/password in variables.robot

Or is it replacing your previously set user with the testuser?

* At the end tests log out and results in terminal are lost

We could skip all automated Logouts if CONFIG_PATH is set to None.

* No easy way to check report.html

I checked that is actually possible to open the report with chrome if first copying the report files to chrome-vm:/tmp and giving them appuser:users ownership. Or then copying to other machine for study... but this is not very smooth. I try to automate sending the results for chrome to read.

@leivos-unikie leivos-unikie force-pushed the optional_config branch 2 times, most recently from 5e9b23a to bd7a27a Compare February 5, 2025 13:09
If CONFIG_PATH is set to None reading config file
variables will be ignored which allows setting target
IP address from command line. This makes local smoke
testing more straightforward.

Prevent Set Variables from overwriting password if
given via cmd line.

Allow reading test user credentials via /etc/secrets
instead of defaulting to testuser/testpw.

Add script for sending report files to chrome-vm.

Signed-off-by: Samuli Leivo <[email protected]>
Copy link
Collaborator

@milva-unikie milva-unikie left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements! Now this works great. I tested running both pre-merge-tests and bat-tests in Ghaf from ghaf-host and then checked the results in Chrome.

Or is it replacing your previously set user with the testuser?

It won't replace the user. If the username/password are different the tests just won't work.

(As a note about the documentation: python ../lib/send_report.py also required a password to be given :))

@leivos-unikie
Copy link
Collaborator Author

Thanks for the improvements! Now this works great. I tested running both pre-merge-tests and bat-tests in Ghaf from ghaf-host and then checked the results in Chrome.

Or is it replacing your previously set user with the testuser?

It won't replace the user. If the username/password are different the tests just won't work.

(As a note about the documentation: python ../lib/send_report.py also required a password to be given :))

Thanks for testing. Yes, forgot to mention that password. I will add.

@leivos-unikie
Copy link
Collaborator Author

Tested also on dev test pipeline with lenovo-x1
https://ghaf-jenkins-controller-dev.northeurope.cloudapp.azure.com/job/tests/job/x-ghaf-hw-test/415/robot/report/lenovo-x1ANDgui/report.html
(Fail in Wifi test is expected after changing eth interface to net-vm)

@leivos-unikie leivos-unikie merged commit 91421f0 into tiiuae:main Feb 7, 2025
1 check passed
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.

None yet

2 participants