Skip to content

Commit

Permalink
[gui-tests][full-ci] check the keyring and try to unlock if locked (#…
Browse files Browse the repository at this point in the history
…11866)

* test: add all video files

test: fix video file name

test: reverse video list

* test: check and unlock keyring

* ci: pin docker images to specific version

* test: start suffix from 2
  • Loading branch information
saw-jan authored Sep 27, 2024
1 parent 5a3bc20 commit 4ca07fd
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ OC_CI_CLIENT_FEDORA = "owncloudci/client:fedora-39-amd64"
OC_CI_SQUISH = "owncloudci/squish:fedora-39-7.2.1-qt66x-linux64"

PLUGINS_GIT_ACTION = "plugins/git-action:1"
PLUGINS_S3 = "plugins/s3"
PLUGINS_S3 = "plugins/s3:1.4.0"
PLUGINS_SLACK = "plugins/slack"
TOOLHIPPIE_CALENS = "toolhippie/calens:latest"
TOOLHIPPIE_CALENS = "toolhippie/calens:0.4.0"

# npm packages to install
NPM_GHERLINT = "@gherlint/gherlint@1.1.0"
Expand Down
12 changes: 9 additions & 3 deletions test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from helpers.SyncHelper import closeSocketConnection, clearWaitedAfterSync
from helpers.SpaceHelper import delete_project_spaces
from helpers.api.provisioning import delete_created_groups, delete_created_users
from helpers.SetupClientHelper import wait_until_app_killed
from helpers.SetupClientHelper import wait_until_app_killed, unlock_keyring
from helpers.ConfigHelper import (
init_config,
get_config,
Expand Down Expand Up @@ -63,6 +63,7 @@ def hook(context):
# Order: 1
@OnScenarioStart
def hook(context):
unlock_keyring()
clear_scenario_config()


Expand Down Expand Up @@ -170,8 +171,13 @@ def save_screenrecord(filename):
)
if not os.path.exists(screenrecords_dir):
os.makedirs(screenrecords_dir)
if video_files:
shutil.move(video_files[0], os.path.join(screenrecords_dir, filename))
# reverse the list to get the latest video first
video_files.reverse()
for idx, video in enumerate(video_files):
if idx:
file_parts = filename.rsplit(".", 1)
filename = f"{file_parts[0]}_{idx+1}.{file_parts[1]}"
shutil.move(video, os.path.join(screenrecords_dir, filename))

shutil.rmtree(prefix_path_namespace(video_dir))

Expand Down
50 changes: 50 additions & 0 deletions test/gui/shared/scripts/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import uuid
import os
import subprocess
from urllib.parse import urlparse
from os import makedirs
from os.path import exists, join
Expand Down Expand Up @@ -207,3 +209,51 @@ def wait_until_app_killed(pid=0):

def generate_UUIDV4():
return str(uuid.uuid4())


# sometimes the keyring is locked during the test execution
# and we need to unlock it
def unlock_keyring():
if isWindows():
return

stdout, stderr, _ = run_sys_command(
[
'busctl',
'--user',
'get-property',
'org.freedesktop.secrets',
'/org/freedesktop/secrets/collection/login',
'org.freedesktop.Secret.Collection',
'Locked',
]
)
output = ''
if stdout:
output = stdout.decode('utf-8')
if stderr:
output = stderr.decode('utf-8')
test.log(output)
if not output.strip().endswith('false'):
test.log('Unlocking keyring...')
password = os.getenv('VNC_PW')
command = f'echo -n "{password}" | gnome-keyring-daemon -r --unlock'
stdout, stderr, returncode = run_sys_command(command, True)
if stdout:
output = stdout.decode('utf-8')
if stderr:
output = stderr.decode('utf-8')
if returncode:
test.log(f'Failed to unlock keyring:\n{output}')
test.log(output)


def run_sys_command(command=None, shell=False):
cmd = subprocess.run(
command,
shell=shell,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=False,
)
return cmd.stdout, cmd.stderr, cmd.returncode

0 comments on commit 4ca07fd

Please sign in to comment.