Skip to content

Conversation

@kevinyehk
Copy link
Contributor

@kevinyehk kevinyehk commented Aug 18, 2023

Description

During the setup of Denver Keurig project, I found that when I run the test from Jenkins, wireless_scanning_wlan0 will fail, but when I run the test from the DUT directly, it will pass.
According to past experience, it should be the issue which the test case didn't indicate the user: root.

Resolved issues

Please refer to the failure from Jenkins job

Documentation

N/A

Tests

Connecting to 10.102.160.91:18871. Timeout: 600s
============[ Bootstrap com.canonical.certification::device (1/1) ]=============
-----------------------------[ Running job 3 / 3 ]------------------------------
--------------[ Test system can discover Wi-Fi networks on wlan0 ]--------------
ID: com.canonical.certification::wireless/wireless_scanning_wlan0
Category: Wireless networking tests
--------------------------------------------------------------------------------
Interface wlan0 using module brcmfmac
  Parameters:
    alternative_fw_path:
    debug: 0
    roamoff: 0

Checking kernel ring buffer for brcmfmac messages:


Interface eth0 using module r8152

Checking kernel ring buffer for r8152 messages:


## Cleaning up NM connections
+ nmcli -t -f TYPE,UUID,NAME c

## Calling a rescan
+ nmcli d wifi rescan
Error: Scanning not allowed immediately following previous scan.
Scan request failed, allow other operations to complete (15s)

## List APs
+ nmcli -t -f SSID,CHAN,FREQ,SIGNAL d wifi list ifname wlan0
SSID: cert-bg-open-tel-l5-01 Chan: 6 Freq: 2437 MHz Signal: 100
SSID: Canonical Chan: 11 Freq: 2462 MHz Signal: 95
SSID:  Chan: 1 Freq: 2412 MHz Signal: 92
SSID: ttttttttttttttttttttttt Chan: 9 Freq: 2452 MHz Signal: 87
SSID:  Chan: 1 Freq: 2412 MHz Signal: 84
SSID: Canonical Chan: 6 Freq: 2437 MHz Signal: 84
SSID: Canonical-Guest Chan: 6 Freq: 2437 MHz Signal: 80
SSID:  Chan: 6 Freq: 2437 MHz Signal: 80
SSID: Canonical-Doorbell Chan: 6 Freq: 2437 MHz Signal: 79
SSID: Canonical Chan: 1 Freq: 2412 MHz Signal: 75
SSID: Canonical Chan: 1 Freq: 2412 MHz Signal: 75
SSID: cert-bg-wpa-tel-l3-01 Chan: 11 Freq: 2462 MHz Signal: 75
SSID: Canonical Chan: 11 Freq: 2462 MHz Signal: 74
SSID: cert-n-open-tel-l3-01 Chan: 1 Freq: 2412 MHz Signal: 70
SSID:  Chan: 11 Freq: 2462 MHz Signal: 70
SSID: cert-bg-open-tel-l3-01 Chan: 1 Freq: 2412 MHz Signal: 69
SSID: cert-n-wpa-tel-l3-01 Chan: 1 Freq: 2412 MHz Signal: 67
SSID:  Chan: 6 Freq: 2437 MHz Signal: 62
SSID:  Chan: 6 Freq: 2437 MHz Signal: 54
SSID: Canonical Chan: 1 Freq: 2412 MHz Signal: 50
SSID: Canonical Chan: 6 Freq: 2437 MHz Signal: 45
SSID:  Chan: 6 Freq: 2437 MHz Signal: 42

Found 22 access points
--------------------------------------------------------------------------------
Outcome: job passed

@kevinyehk kevinyehk requested a review from pieqq August 18, 2023 06:54
@pieqq
Copy link
Collaborator

pieqq commented Oct 23, 2023

I'm very late to the game, sorry about this!

I tried to run wireless_scanning_* using Checkbox 2.10.1 in remote mode, and for me it works:

  1. Run Checkbox remote: checkbox.checkbox-cli remote 127.0.0.1
  2. Select the wireless automated test plan ("Automated tests for wireless" aka com.canonical.certification::wireless-automated)
  3. Deselect all the tests (by pressing d) and only select "Test system can discover Wi-Fi networks on ..." (wireless/wireless_scanning_*)

Result:

-----------------------------[ Running job 2 / 2 ]------------------------------
------------[ Test system can discover Wi-Fi networks on wlp0s20f3 ]------------
ID: com.canonical.certification::wireless/wireless_scanning_wlp0s20f3
Category: Wireless networking tests
--------------------------------------------------------------------------------
Interface wlp0s20f3 using module iwlwifi
  Parameters:
    11n_disable: 0
    power_save: N
    swcrypto: 0
    power_level: 0
    amsdu_size: 0
    uapsd_disable: 3
    fw_restart: Y
    disable_11be: N
    led_mode: 0
    disable_11ax: N
Traceback (most recent call last):
  File "/tmp/nest-wq2oqb02.97f962e26658b5d5016583a17072c716ff97496db4f34eb486696f14db1b6866/net_driver_info.py", line 46, in <module>
    print("    {}: {}".format(path.name, f.read().strip()))
PermissionError: [Errno 1] Operation not permitted
/tmp/nest-wq2oqb02.97f962e26658b5d5016583a17072c716ff97496db4f34eb486696f14db1b6866/wifi_nmcli_test.py:20: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.version import LooseVersion
## Cleaning up NM connections
+ nmcli -t -f TYPE,UUID,NAME c
Deleting connection Canonical
+ nmcli c delete 81425de1-a8e8-415f-9f1d-231fc56fa14c
Connection 'Canonical' (81425de1-a8e8-415f-9f1d-231fc56fa14c) successfully deleted.
(...)
## Calling a rescan
+ nmcli d wifi rescan

## List APs
+ nmcli -t -f SSID,CHAN,FREQ,SIGNAL d wifi list ifname wlp0s20f3
SSID: ubuntu-cert-n-wpa-tpelab Chan: 3 Freq: 2422 MHz Signal: 100
SSID: ubuntu-cert-n-open-tpelab Chan: 4 Freq: 2427 MHz Signal: 100
SSID: ubuntu-cert-ax-wpa-tpelab Chan: 153 Freq: 5765 MHz Signal: 100
SSID: ubuntu-cert-ax-wpa3-tpelab Chan: 36 Freq: 5180 MHz Signal: 99
SSID: ubuntu-cert-ac-wpa-tpelab Chan: 157 Freq: 5785 MHz Signal: 94
(...)

Found 80 access points
--------------------------------------------------------------------------------
Outcome: job passed

(don't mind the error in the middle of the output, I logged it as #778 )

Moreover, I don't know how to read the Jenkins log... it seems no Checkbox job was run at all?

@kevinyehk
Copy link
Contributor Author

Updated the link of the failure job, you should be able to see the failure directly.

@pieqq
Copy link
Collaborator

pieqq commented Nov 8, 2023

I've run the following test on a Raspberry Pi 4 running UC22. The wireless module is the same as on the device you're having problems with: brcmfmac.

If I try to run the wireless_scanning test remotely, it passes, even though there is some ugly permission errors in there:

--------------[ Test system can discover Wi-Fi networks on wlan0 ]--------------
ID: com.canonical.certification::wireless/wireless_scanning_wlan0
Category: Wireless networking tests
--------------------------------------------------------------------------------
Interface wlan0 using module brcmfmac
  Parameters:
Traceback (most recent call last):
  File "/tmp/nest-guyj5qrt.429dd6464e481ad6f458ca81d13c3ca40477480dd58d9c837d768ec1d448a9a6/net_driver_info.py", line 45, in <module>
    with open(str(path), 'r') as f:
PermissionError: [Errno 13] Permission denied: '/sys/module/brcmfmac/parameters/alternative_fw_path'
/tmp/nest-guyj5qrt.429dd6464e481ad6f458ca81d13c3ca40477480dd58d9c837d768ec1d448a9a6/wifi_nmcli_test.py:20: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.version import LooseVersion
## Cleaning up NM connections
+ nmcli -t -f TYPE,UUID,NAME c

## Calling a rescan
+ nmcli d wifi rescan

## List APs
+ nmcli -t -f SSID,CHAN,FREQ,SIGNAL d wifi list ifname wlan0
SSID: XXX Chan: 1 Freq: 2412 MHz Signal: 64
SSID: XXX  Chan: 1 Freq: 2412 MHz Signal: 64
SSID: XXX Chan: 149 Freq: 5745 MHz Signal: 40
SSID: XXX Chan: 157 Freq: 5785 MHz Signal: 34

Found 4 access points
--------------------------------------------------------------------------------
Outcome: job passed

If I add user: root to the job, it passes without the permission error (but still some Python deprecation warning):

--------------[ Test system can discover Wi-Fi networks on wlan0 ]--------------
ID: com.canonical.certification::wireless/wireless_scanning_wlan0
Category: Wireless networking tests
--------------------------------------------------------------------------------
Interface wlan0 using module brcmfmac
  Parameters:
    alternative_fw_path: 
    debug: 0
    roamoff: 0

Checking kernel ring buffer for brcmfmac messages:


/tmp/nest-_ww30dic.b08a38f0817249ad243a196090332fbdf543b42c46eb95ae44a0265386481383/wifi_nmcli_test.py:20: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.version import LooseVersion
## Cleaning up NM connections
+ nmcli -t -f TYPE,UUID,NAME c

## Calling a rescan
+ nmcli d wifi rescan

## List APs
+ nmcli -t -f SSID,CHAN,FREQ,SIGNAL d wifi list ifname wlan0
SSID: XXX Chan: 1 Freq: 2412 MHz Signal: 62
SSID: XXX Chan: 1 Freq: 2412 MHz Signal: 59
SSID: XXX Chan: 40 Freq: 5200 MHz Signal: 40
SSID: XXX Chan: 149 Freq: 5745 MHz Signal: 39
SSID: XXX Chan: 40 Freq: 5200 MHz Signal: 37
SSID: XXX Chan: 157 Freq: 5785 MHz Signal: 32

Found 6 access points
--------------------------------------------------------------------------------
Outcome: job passed

It looks indeed like some wireless modules only expose information to the root user. It's the case for this module, for instance:

root@rpi4:~# ls -l /sys/module/brcmfmac/parameters/
total 0
-r-------- 1 root root 4096 Nov  8 08:13 alternative_fw_path
-rw------- 1 root root 4096 Nov  8 08:22 debug
-r-------- 1 root root 4096 Nov  8 08:22 roamoff

In my case, I have not been able to reproduce the issue you were having (cannot create void directory: /var/lib/snapd/void: Permission denied followed by a subprocess.CalledProcessError exception).

So I guess we can, indeed, make sure that this job is executed as root.

@pieqq
Copy link
Collaborator

pieqq commented Nov 8, 2023

@kevinyehk can you:

@kevinyehk kevinyehk force-pushed the fix-wireless_scanning branch from 5388005 to 470cb41 Compare November 17, 2023 02:30
@codecov
Copy link

codecov bot commented Nov 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@8d1089f). Click here to learn what that means.

Additional details and impacted files
@@          Coverage Diff           @@
##             main    #669   +/-   ##
======================================
  Coverage        ?   4.63%           
======================================
  Files           ?     126           
  Lines           ?   14030           
  Branches        ?    2374           
======================================
  Hits            ?     650           
  Misses          ?   13322           
  Partials        ?      58           
Flag Coverage Δ
provider-base 4.61% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kevinyehk kevinyehk changed the title Fix: wireless_scanning needs to be run as root while run it remotely. Fix: wireless_scanning needs to be run as root while run it remotely. (BugFix) Nov 17, 2023
@kevinyehk
Copy link
Contributor Author

@pieqq Done!

Copy link

@yphus yphus left a comment

Choose a reason for hiding this comment

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

+1

@yphus yphus merged commit 9f23c20 into main Dec 8, 2023
@yphus yphus deleted the fix-wireless_scanning branch December 8, 2023 08:03
binli pushed a commit to binli/checkbox that referenced this pull request Mar 22, 2024
… (BugFix) (canonical#669)

Fix: wireless_scanning needs to be run as root while run it remotely.
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.

4 participants