Merge ~medicalwei/plainbox-provider-checkbox:fix-audio-test into plainbox-provider-checkbox:master

Proposed by Yao Wei
Status: Rejected
Rejected by: Jonathan Cave
Proposed branch: ~medicalwei/plainbox-provider-checkbox:fix-audio-test
Merge into: plainbox-provider-checkbox:master
Diff against target: 46 lines (+11/-0)
2 files modified
bin/audio_test.py (+7/-0)
bin/pactl_list.sh (+4/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Disapprove
Jonathan Cave (community) Disapprove
jeremyszu Pending
Review via email: mp+405995@code.launchpad.net

Commit message

Set XDG_RUNTIME_DIR before testing audio

Description of the change

This attempts to resolve issue LP:#1904707. By correctly setting XDG_RUNTIME_DIR before running audio test we can work around issue that the terminal environment after test involving reboot (invoked by pm_test.py) cannot connect to pulseaudio.

To post a comment you must log in.
Revision history for this message
jeremyszu (os369510) wrote :

@Wei,

Would you please share your test result with/without your patch here?

619bf66... by Yao Wei

Add XDG_RUNTIME_DIR check in pactl_list.sh

Revision history for this message
Yao Wei (medicalwei) wrote :
Download full text (3.6 KiB)

I am not able to reproduce the original bug because I returned the machine where the bug occurs.

It seems the reboot is triggered by the fact that it has NVIDIA dGPU, and dGPU switching was the reboot criteria.

However, by manually doing `sudo -s` to root then `sudo -s -u user` to user account I can recreate the symptom:

--------------[ Running job 1 / 2. Estimated time left: 0:00:11 ]---------------
-------------------------[ audio/detect_sinks_sources ]-------------------------
ID: com.canonical.certification::audio/detect_sinks_sources
Category: com.canonical.plainbox::audio
... 8< -------------------------------------------------------------------------
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
No available sources found
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
No available sinks found
------------------------------------------------------------------------- >8 ---
Outcome: job failed
--------------[ Running job 2 / 2. Estimated time left: 0:00:10 ]---------------
--------------------[ audio/alsa_record_playback_automated ]--------------------
ID: com.canonical.certification::audio/alsa_record_playback_automated
Category: com.canonical.plainbox::audio
Job cannot be started because:
 - required dependency 'com.canonical.certification::audio/detect_sinks_sources' has failed
Outcome: job cannot be started

then at the same environment running the audio test with the patch, the audio tests are passed:

--------------[ Running job 2 / 3. Estimated time left: 0:00:11 ]---------------
-------------------------[ audio/detect_sinks_sources ]-------------------------
ID: com.canonical.certification::audio/detect_sinks_sources
Category: com.canonical.plainbox::audio
... 8< -------------------------------------------------------------------------
5alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sourcemodule-alsa-card.cs16le 2ch 48000HzSUSPENDED
6alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_6__sourcemodule-alsa-card.cs16le 2ch 48000HzSUSPENDED
1alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sinkmodule-alsa-card.cs16le 2ch 48000HzSUSPENDED
2alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sinkmodule-alsa-card.cs16le 2ch 48000HzSUSPENDED
3alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sinkmodule-alsa-card.cs16le 2ch 48000HzSUSPENDED
4alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sinkmodule-alsa-card.cs16le 2ch 48000HzSUSPENDED
------------------------------------------------------------------------- >8 ---
Outcome: job passed
--------------[ Running job 3 / 3. Estimated time left: 0:00:10 ]---------------
--------------------[ audio/alsa_record_playback_automated ]--------------------
ID: com.canonical.certification::audio/alsa_record_playback_automated
Category: com.canonical.plainbox::audio
... 8< -------------------------------------------------------------------------
INFO:root:Using PulseAudio identifier 5 (alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi...

Read more...

Revision history for this message
Jonathan Cave (jocave) wrote :

Typically environment setup like should not need to happen in the job itself. It suggests that something else is going wrong during the running of the test plan. I gather there is some other context to this problem that other people are aware of so I will leave it to them to contribute.

review: Disapprove
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

The issue you're facing here is all because pm_test and its way to restart sessions:
https://git.launchpad.net/plainbox-provider-checkbox/tree/bin/pm_test.py#n288

When restarting checkbox after a reboot it opens a terminal and run sudo -u $USER basically. That does not preserve all the desktop env vars we used to get from a genuine desktop user session.

It's something that we do support via checkbox remote.

The checkbox-ng remote service takes care of that: https://git.launchpad.net/checkbox-ng/commit/plainbox/impl/session/remote_assistant.py?id=2938b1da085ae093fedc30114e91f0792133a409

We're planning to kill pm_test.py from all our jobs and push to adopt REMOTE for all QA testing.

So needless to fix anything at audio_test level, definitely not the right place. Please give remote a go, all com.canonical.certification::audio jobs should work just fine after a reboot of the DUT.

review: Disapprove
Revision history for this message
Yao Wei (medicalwei) wrote :

Here at SWE we mostly run checkbox locally. Are we pushing all local use case to remote?

Unmerged commits

619bf66... by Yao Wei

Add XDG_RUNTIME_DIR check in pactl_list.sh

4dff6ad... by Yao Wei

Set XDG_RUNTIME_DIR before testing audio

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/audio_test.py b/bin/audio_test.py
2index 4b3f89c..cd60f15 100755
3--- a/bin/audio_test.py
4+++ b/bin/audio_test.py
5@@ -10,6 +10,7 @@ import re
6 import subprocess
7 import sys
8 import time
9+import os
10 try:
11 import gi
12 gi.require_version('GLib', '2.0')
13@@ -518,12 +519,18 @@ def process_arguments():
14 (one frequency/magnitude pair per line)""")
15 return parser.parse_args()
16
17+def set_xdg_runtime_dir():
18+ if "XDG_RUNTIME_DIR" not in os.environ:
19+ os.environ["XDG_RUNTIME_DIR"] = "/run/user/{uid}".format(uid=os.getuid())
20
21 #
22 def main():
23 # Get arguments.
24 args = process_arguments()
25
26+ # Set XDG_RUNTIME_DIR if unset
27+ set_xdg_runtime_dir()
28+
29 # Setup logging
30 level = logging.INFO
31 if args.debug:
32diff --git a/bin/pactl_list.sh b/bin/pactl_list.sh
33index a7abb87..2f26cc4 100755
34--- a/bin/pactl_list.sh
35+++ b/bin/pactl_list.sh
36@@ -2,6 +2,10 @@
37
38 EXIT_CODE=0
39
40+if [ -z "$XDG_RUNTIME_DIR" ] ; then
41+ export XDG_RUNTIME_DIR="/run/user/${UID}"
42+fi
43+
44 for device in "sources" "sinks"
45 do
46 if ! pactl list $device short | grep -v -E "monitor|auto_null"

Subscribers

People subscribed via source and target branches