From 365f83176b411f80b22141c92fed047d8c2b1c77 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 10 Sep 2024 11:22:19 +0545 Subject: [PATCH 1/4] test: add all video files test: fix video file name test: reverse video list --- .drone.star | 25 ++++--- test/gui/shared/scripts/bdd_hooks.py | 9 ++- test/gui/tst_loginLogout/test.feature | 100 +++++++++++++++++++++----- 3 files changed, 105 insertions(+), 29 deletions(-) diff --git a/.drone.star b/.drone.star index 52cd3c46343..8057a5bf806 100644 --- a/.drone.star +++ b/.drone.star @@ -24,7 +24,8 @@ OC_UBUNTU = "owncloud/ubuntu:20.04" # Todo: update or remove the following images # https://github.com/owncloud/client/issues/10070 OC_CI_CLIENT_FEDORA = "owncloudci/client:fedora-39-amd64" -OC_CI_SQUISH = "owncloudci/squish:fedora-39-7.2.1-qt66x-linux64" +OC_CI_SQUISH = "sawjan/squish:unlock" +OC_CI_SQUISH_UP = "owncloudci/squish:fedora-39-7.2.1-qt66x-linux64" PLUGINS_GIT_ACTION = "plugins/git-action:1" PLUGINS_S3 = "plugins/s3" @@ -127,6 +128,12 @@ config = { "tags": "~@skipOnOCIS", "skip": False, }, + "ocis-2": { + "version": "latest", + # comma separated list of tags to be used for filtering. E.g. "@tag1,@tag2" + "tags": "~@skipOnOCIS", + "skip": False, + }, }, }, } @@ -138,10 +145,11 @@ def main(ctx): unit_tests = unit_test_pipeline(ctx) gui_tests = gui_test_pipeline(ctx) - return pipelines + \ - unit_tests + \ - gui_tests + \ - pipelinesDependsOn(notification(), unit_tests + gui_tests) + return gui_tests + # return pipelines + \ + # unit_tests + \ + # gui_tests + \ + # pipelinesDependsOn(notification(), unit_tests + gui_tests) def from_secret(name): return { @@ -203,6 +211,7 @@ def gui_test_pipeline(ctx): for server, params in config["gui-tests"]["servers"].items(): squish_parameters = [ "--testsuite %s" % dir["guiTest"], + "--testcase %s/tst_loginLogout" % dir["guiTest"], "--reportgen html,%s" % dir["guiTestReport"], "--envvar QT_LOGGING_RULES=sync.httplogger=true;gui.socketapi=false", "--tags ~@skip", @@ -320,7 +329,7 @@ def unit_tests(image = OC_CI_CLIENT): def gui_tests(squish_parameters = "", server_type = "oc10"): return [{ "name": "GUItests", - "image": OC_CI_SQUISH, + "image": OC_CI_SQUISH if server_type == "ocis" else OC_CI_SQUISH_UP, "environment": { "LICENSEKEY": from_secret("SQUISH_LICENSEKEY"), "GUI_TEST_REPORT_DIR": dir["guiTestReport"], @@ -328,7 +337,7 @@ def gui_tests(squish_parameters = "", server_type = "oc10"): "MIDDLEWARE_URL": "http://testmiddleware:3000/", "BACKEND_HOST": "http://owncloud/" if server_type == "oc10" else "https://ocis:9200", "SECURE_BACKEND_HOST": "https://owncloud/" if server_type == "oc10" else "https://ocis:9200", - "OCIS": "true" if server_type == "ocis" else "false", + "OCIS": "true" if "ocis" in server_type else "false", "SERVER_INI": "%s/drone/server.ini" % dir["guiTest"], "SQUISH_PARAMETERS": squish_parameters, "STACKTRACE_FILE": "%s/stacktrace.log" % dir["guiTestReport"], @@ -578,7 +587,7 @@ def testMiddlewareService(server_type = "oc10"): "REMOTE_UPLOAD_DIR": "/uploads", } - if server_type == "ocis": + if "ocis" in server_type: environment["BACKEND_HOST"] = "https://ocis:9200" environment["TEST_WITH_GRAPH_API"] = "true" environment["RUN_ON_OCIS"] = "true" diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py index c3a80ee4145..6fa8ba7a710 100644 --- a/test/gui/shared/scripts/bdd_hooks.py +++ b/test/gui/shared/scripts/bdd_hooks.py @@ -18,6 +18,7 @@ import shutil import os import glob +import subprocess from urllib import request, error from datetime import datetime @@ -170,8 +171,12 @@ 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)) + 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)) diff --git a/test/gui/tst_loginLogout/test.feature b/test/gui/tst_loginLogout/test.feature index 98bdca4091b..f8fc2bb40c3 100644 --- a/test/gui/tst_loginLogout/test.feature +++ b/test/gui/tst_loginLogout/test.feature @@ -12,6 +12,60 @@ Feature: Logout users When the user "Alice" logs out using the client-UI Then user "Alice" should be signed out + Scenario: login after logging out normal Account + Given the user has started the client + When the user adds the following account: + | server | %local_server% | + | user | Alice | + | password | 1234 | + Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed + When the user quits the client + And the user starts the client + Then user "Alice" should be connected to the server + + Scenario: login after logging out normal Account + Given the user has started the client + When the user adds the following account: + | server | %local_server% | + | user | Alice | + | password | 1234 | + Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed + When the user quits the client + And the user starts the client + Then user "Alice" should be connected to the server + + Scenario: login after logging out normal Account + Given the user has started the client + When the user adds the following account: + | server | %local_server% | + | user | Alice | + | password | 1234 | + Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed + When the user quits the client + And the user starts the client + Then user "Alice" should be connected to the server + + Scenario: login after logging out normal Account + Given the user has started the client + When the user adds the following account: + | server | %local_server% | + | user | Alice | + | password | 1234 | + Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed + When the user quits the client + And the user starts the client + Then user "Alice" should be connected to the server + + Scenario: login after logging out normal Account + Given the user has started the client + When the user adds the following account: + | server | %local_server% | + | user | Alice | + | password | 1234 | + Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed + When the user quits the client + And the user starts the client + Then user "Alice" should be connected to the server Scenario: login after logging out Given user "Alice" has set up a client with default settings @@ -22,29 +76,37 @@ Feature: Logout users And the user starts the client Then user "Alice" should be connected to the server - @skipOnOCIS - Scenario: login with incorrect and correct password after log out + Scenario: login after logging out Given user "Alice" has set up a client with default settings And user "Alice" has logged out from the client-UI - When user "ALice" opens login dialog - And user "ALice" enters the password "invalid" - And user "Alice" logs out from the login required dialog - And user "Alice" logs in using the client-UI + When user "Alice" logs in using the client-UI + Then user "Alice" should be connected to the server + When the user quits the client + And the user starts the client Then user "Alice" should be connected to the server - @skipOnOCIS @issue-11619 - Scenario: login, logout and restart with oauth2 authentication - Given app "oauth2" has been "enabled" in the server - And the user has started the client - When the user adds the following oauth2 account: - | server | %local_server% | - | user | Alice | - | password | 1234 | - Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed - And user "Alice" should be connected to the server - When the user "Alice" logs out using the client-UI - Then user "Alice" should be signed out - When user "Alice" logs in using the client-UI with oauth2 + Scenario: login after logging out + Given user "Alice" has set up a client with default settings + And user "Alice" has logged out from the client-UI + When user "Alice" logs in using the client-UI + Then user "Alice" should be connected to the server + When the user quits the client + And the user starts the client + Then user "Alice" should be connected to the server + + Scenario: login after logging out + Given user "Alice" has set up a client with default settings + And user "Alice" has logged out from the client-UI + When user "Alice" logs in using the client-UI + Then user "Alice" should be connected to the server + When the user quits the client + And the user starts the client + Then user "Alice" should be connected to the server + + Scenario: login after logging out + Given user "Alice" has set up a client with default settings + And user "Alice" has logged out from the client-UI + When user "Alice" logs in using the client-UI Then user "Alice" should be connected to the server When the user quits the client And the user starts the client From 8ee1cfae2179137c4aa1fcd52733224462f936cc Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Fri, 20 Sep 2024 15:35:07 +0545 Subject: [PATCH 2/4] test: check and unlock keyring --- .drone.star | 25 ++--- test/gui/shared/scripts/bdd_hooks.py | 7 +- .../scripts/helpers/SetupClientHelper.py | 50 +++++++++ test/gui/tst_loginLogout/test.feature | 100 ++++-------------- 4 files changed, 81 insertions(+), 101 deletions(-) diff --git a/.drone.star b/.drone.star index 8057a5bf806..627cb1c78cd 100644 --- a/.drone.star +++ b/.drone.star @@ -24,8 +24,7 @@ OC_UBUNTU = "owncloud/ubuntu:20.04" # Todo: update or remove the following images # https://github.com/owncloud/client/issues/10070 OC_CI_CLIENT_FEDORA = "owncloudci/client:fedora-39-amd64" -OC_CI_SQUISH = "sawjan/squish:unlock" -OC_CI_SQUISH_UP = "owncloudci/squish:fedora-39-7.2.1-qt66x-linux64" +OC_CI_SQUISH = "sawjan/squish:export-session" PLUGINS_GIT_ACTION = "plugins/git-action:1" PLUGINS_S3 = "plugins/s3" @@ -128,12 +127,6 @@ config = { "tags": "~@skipOnOCIS", "skip": False, }, - "ocis-2": { - "version": "latest", - # comma separated list of tags to be used for filtering. E.g. "@tag1,@tag2" - "tags": "~@skipOnOCIS", - "skip": False, - }, }, }, } @@ -145,11 +138,10 @@ def main(ctx): unit_tests = unit_test_pipeline(ctx) gui_tests = gui_test_pipeline(ctx) - return gui_tests - # return pipelines + \ - # unit_tests + \ - # gui_tests + \ - # pipelinesDependsOn(notification(), unit_tests + gui_tests) + return pipelines + \ + unit_tests + \ + gui_tests + \ + pipelinesDependsOn(notification(), unit_tests + gui_tests) def from_secret(name): return { @@ -211,7 +203,6 @@ def gui_test_pipeline(ctx): for server, params in config["gui-tests"]["servers"].items(): squish_parameters = [ "--testsuite %s" % dir["guiTest"], - "--testcase %s/tst_loginLogout" % dir["guiTest"], "--reportgen html,%s" % dir["guiTestReport"], "--envvar QT_LOGGING_RULES=sync.httplogger=true;gui.socketapi=false", "--tags ~@skip", @@ -329,7 +320,7 @@ def unit_tests(image = OC_CI_CLIENT): def gui_tests(squish_parameters = "", server_type = "oc10"): return [{ "name": "GUItests", - "image": OC_CI_SQUISH if server_type == "ocis" else OC_CI_SQUISH_UP, + "image": OC_CI_SQUISH, "environment": { "LICENSEKEY": from_secret("SQUISH_LICENSEKEY"), "GUI_TEST_REPORT_DIR": dir["guiTestReport"], @@ -337,7 +328,7 @@ def gui_tests(squish_parameters = "", server_type = "oc10"): "MIDDLEWARE_URL": "http://testmiddleware:3000/", "BACKEND_HOST": "http://owncloud/" if server_type == "oc10" else "https://ocis:9200", "SECURE_BACKEND_HOST": "https://owncloud/" if server_type == "oc10" else "https://ocis:9200", - "OCIS": "true" if "ocis" in server_type else "false", + "OCIS": "true" if server_type == "ocis" else "false", "SERVER_INI": "%s/drone/server.ini" % dir["guiTest"], "SQUISH_PARAMETERS": squish_parameters, "STACKTRACE_FILE": "%s/stacktrace.log" % dir["guiTestReport"], @@ -587,7 +578,7 @@ def testMiddlewareService(server_type = "oc10"): "REMOTE_UPLOAD_DIR": "/uploads", } - if "ocis" in server_type: + if server_type == "ocis": environment["BACKEND_HOST"] = "https://ocis:9200" environment["TEST_WITH_GRAPH_API"] = "true" environment["RUN_ON_OCIS"] = "true" diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py index 6fa8ba7a710..4e7aba6c5b1 100644 --- a/test/gui/shared/scripts/bdd_hooks.py +++ b/test/gui/shared/scripts/bdd_hooks.py @@ -18,7 +18,6 @@ import shutil import os import glob -import subprocess from urllib import request, error from datetime import datetime @@ -26,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, @@ -64,6 +63,7 @@ def hook(context): # Order: 1 @OnScenarioStart def hook(context): + unlock_keyring() clear_scenario_config() @@ -171,11 +171,12 @@ def save_screenrecord(filename): ) if not os.path.exists(screenrecords_dir): os.makedirs(screenrecords_dir) + # 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]}" + filename = f"{file_parts[0]}_{idx}.{file_parts[1]}" shutil.move(video, os.path.join(screenrecords_dir, filename)) shutil.rmtree(prefix_path_namespace(video_dir)) diff --git a/test/gui/shared/scripts/helpers/SetupClientHelper.py b/test/gui/shared/scripts/helpers/SetupClientHelper.py index a32dc38d46d..32584508e12 100644 --- a/test/gui/shared/scripts/helpers/SetupClientHelper.py +++ b/test/gui/shared/scripts/helpers/SetupClientHelper.py @@ -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 @@ -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 diff --git a/test/gui/tst_loginLogout/test.feature b/test/gui/tst_loginLogout/test.feature index f8fc2bb40c3..98bdca4091b 100644 --- a/test/gui/tst_loginLogout/test.feature +++ b/test/gui/tst_loginLogout/test.feature @@ -12,78 +12,6 @@ Feature: Logout users When the user "Alice" logs out using the client-UI Then user "Alice" should be signed out - Scenario: login after logging out normal Account - Given the user has started the client - When the user adds the following account: - | server | %local_server% | - | user | Alice | - | password | 1234 | - Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed - When the user quits the client - And the user starts the client - Then user "Alice" should be connected to the server - - Scenario: login after logging out normal Account - Given the user has started the client - When the user adds the following account: - | server | %local_server% | - | user | Alice | - | password | 1234 | - Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed - When the user quits the client - And the user starts the client - Then user "Alice" should be connected to the server - - Scenario: login after logging out normal Account - Given the user has started the client - When the user adds the following account: - | server | %local_server% | - | user | Alice | - | password | 1234 | - Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed - When the user quits the client - And the user starts the client - Then user "Alice" should be connected to the server - - Scenario: login after logging out normal Account - Given the user has started the client - When the user adds the following account: - | server | %local_server% | - | user | Alice | - | password | 1234 | - Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed - When the user quits the client - And the user starts the client - Then user "Alice" should be connected to the server - - Scenario: login after logging out normal Account - Given the user has started the client - When the user adds the following account: - | server | %local_server% | - | user | Alice | - | password | 1234 | - Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed - When the user quits the client - And the user starts the client - Then user "Alice" should be connected to the server - - Scenario: login after logging out - Given user "Alice" has set up a client with default settings - And user "Alice" has logged out from the client-UI - When user "Alice" logs in using the client-UI - Then user "Alice" should be connected to the server - When the user quits the client - And the user starts the client - Then user "Alice" should be connected to the server - - Scenario: login after logging out - Given user "Alice" has set up a client with default settings - And user "Alice" has logged out from the client-UI - When user "Alice" logs in using the client-UI - Then user "Alice" should be connected to the server - When the user quits the client - And the user starts the client - Then user "Alice" should be connected to the server Scenario: login after logging out Given user "Alice" has set up a client with default settings @@ -94,19 +22,29 @@ Feature: Logout users And the user starts the client Then user "Alice" should be connected to the server - Scenario: login after logging out + @skipOnOCIS + Scenario: login with incorrect and correct password after log out Given user "Alice" has set up a client with default settings And user "Alice" has logged out from the client-UI - When user "Alice" logs in using the client-UI - Then user "Alice" should be connected to the server - When the user quits the client - And the user starts the client + When user "ALice" opens login dialog + And user "ALice" enters the password "invalid" + And user "Alice" logs out from the login required dialog + And user "Alice" logs in using the client-UI Then user "Alice" should be connected to the server - Scenario: login after logging out - Given user "Alice" has set up a client with default settings - And user "Alice" has logged out from the client-UI - When user "Alice" logs in using the client-UI + @skipOnOCIS @issue-11619 + Scenario: login, logout and restart with oauth2 authentication + Given app "oauth2" has been "enabled" in the server + And the user has started the client + When the user adds the following oauth2 account: + | server | %local_server% | + | user | Alice | + | password | 1234 | + Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed + And user "Alice" should be connected to the server + When the user "Alice" logs out using the client-UI + Then user "Alice" should be signed out + When user "Alice" logs in using the client-UI with oauth2 Then user "Alice" should be connected to the server When the user quits the client And the user starts the client From c20b7fa396b4abe7fa522a0d351276602e089ba0 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 24 Sep 2024 17:08:57 +0545 Subject: [PATCH 3/4] ci: pin docker images to specific version --- .drone.star | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.star b/.drone.star index 627cb1c78cd..ca36c9a880a 100644 --- a/.drone.star +++ b/.drone.star @@ -24,12 +24,12 @@ OC_UBUNTU = "owncloud/ubuntu:20.04" # Todo: update or remove the following images # https://github.com/owncloud/client/issues/10070 OC_CI_CLIENT_FEDORA = "owncloudci/client:fedora-39-amd64" -OC_CI_SQUISH = "sawjan/squish:export-session" +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" From 0a175a4dc45041971b13bbfb468841d80af24d82 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 24 Sep 2024 17:11:00 +0545 Subject: [PATCH 4/4] test: start suffix from 2 --- test/gui/shared/scripts/bdd_hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py index 4e7aba6c5b1..101e135e92d 100644 --- a/test/gui/shared/scripts/bdd_hooks.py +++ b/test/gui/shared/scripts/bdd_hooks.py @@ -176,7 +176,7 @@ def save_screenrecord(filename): for idx, video in enumerate(video_files): if idx: file_parts = filename.rsplit(".", 1) - filename = f"{file_parts[0]}_{idx}.{file_parts[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))