Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .woodpecker/ui-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ steps:
# Cannot handle this tags format inside a container: --tags='@smoke and not @skip'
BEHAVE_PARAMETERS: '--tags=~@skip ${SUITES}'

# - name: crash-log
# image: *alpine_image
# when:
# - status:
# - success
# - failure
# commands:
# - cat test/gui/tmp/OpenCloud-crash.log 2>/dev/null || exit 0

- name: upload-test-reports
image: *minio_image
when:
Expand Down
2 changes: 1 addition & 1 deletion test/gui/config.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ APP_PATH=
BACKEND_HOST=
CLIENT_ROOT_SYNC_PATH=
SYNC_TIMEOUT=
TEMP_FOLDER_PATH=
TEST_TEMP_DIR=
GUI_TEST_REPORT_DIR=
RECORD_VIDEO_ON_FAILURE=false
4 changes: 4 additions & 0 deletions test/gui/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
take_screenshot,
save_app_log,
cleanup_current_app_log,
save_crash_log,
)
from step_types.types import * # register all step types

Expand Down Expand Up @@ -50,6 +51,9 @@ def after_scenario(context, scenario):
):
save_app_log(scenario)

if os.path.exists(get_config('crash_file')):
save_crash_log(scenario)

# clean up sync dir
if os.path.exists(get_config("clientRootSyncPath")):
for entry in os.scandir(get_config("clientRootSyncPath")):
Expand Down
13 changes: 8 additions & 5 deletions test/gui/helpers/ConfigHelper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import platform
import builtins
import tempfile
from tempfile import gettempdir
from configparser import ConfigParser
from pathlib import Path
Expand All @@ -10,6 +9,7 @@
APP_CONFIG_FILE = "opencloud.cfg"
CUMULATIVE_APP_LOG_FILE = "opencloud.log"
CURRENT_APP_LOG_FILE = "app.log"
CRASH_LOG_FILE = "OpenCloud-crash.log"


def is_windows():
Expand All @@ -31,7 +31,7 @@ def get_client_root_path():


def get_config_home_linux():
return os.path.join(tempfile.gettempdir(), 'opencloudtest', '.config')
return os.path.join(gettempdir(), 'opencloudtest', '.config')


def get_config_home_win():
Expand Down Expand Up @@ -65,7 +65,7 @@ def get_app_env():
'localBackendUrl': 'BACKEND_HOST',
'sync_timeout': 'SYNC_TIMEOUT',
'clientRootSyncPath': 'CLIENT_ROOT_SYNC_PATH',
'tempFolderPath': 'TEMP_FOLDER_PATH',
'test_temp_dir': 'TEST_TEMP_DIR',
'guiTestReportDir': 'GUI_TEST_REPORT_DIR',
'record_video_on_failure': 'RECORD_VIDEO_ON_FAILURE',
}
Expand All @@ -83,6 +83,7 @@ def get_app_env():
'min_timeout': 5,
'lowest_timeout': 1,
'files_for_upload': os.path.join(CURRENT_DIR.parent, 'files-for-upload'),
'crash_file': os.path.join(gettempdir(), CRASH_LOG_FILE),
}

# mutable configs
Expand All @@ -91,8 +92,8 @@ def get_app_env():
'localBackendUrl': 'https://localhost:9200/',
'sync_timeout': 60,
'clientRootSyncPath': get_client_root_path(),
'tempFolderPath': os.path.join(get_client_root_path(), 'temp'),
'guiTestReportDir': os.path.join(CURRENT_DIR.parent, 'reports'),
'test_temp_dir': os.path.join(get_client_root_path(), 'temp'),
'record_video_on_failure': False,
'syncConnectionName': 'Personal',
###############################
Expand Down Expand Up @@ -141,7 +142,7 @@ def normalize_configs():
elif key in (
'localBackendUrl',
'clientRootSyncPath',
'tempFolderPath',
'test_temp_dir',
'guiTestReportDir',
):
# make sure there is always one trailing slash
Expand Down Expand Up @@ -174,6 +175,8 @@ def init_config():
CONFIG['appLogFile'] = os.path.join(
CONFIG["guiTestReportDir"], CUMULATIVE_APP_LOG_FILE
)
# file to store cumulative app logs for the entire test run
CONFIG['crash_report_file'] = os.path.join(CONFIG["guiTestReportDir"], 'crash.log')
# create report dir if it not exist
if not os.path.exists(CONFIG['guiTestReportDir']):
os.makedirs(CONFIG['guiTestReportDir'])
Expand Down
13 changes: 13 additions & 0 deletions test/gui/helpers/ReportHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,16 @@ def save_app_log(scenario):
def cleanup_current_app_log():
if os.path.exists(get_config('currentAppLogFile')):
os.remove(get_config('currentAppLogFile'))


def save_crash_log(scenario):
with open(get_config('crash_report_file'), 'a') as log_file:
logs = ["=" * 80]
logs.append(
f"Scenario: {scenario.name}\nLocation: {scenario.filename}:{scenario.line}"
)
logs.append("-" * 80)
logs.append("") # extra line break
log_file.write("\n".join(logs))
with open(get_config('crash_file'), 'r') as current_log:
log_file.write(f"{current_log.read()}\n\n")
2 changes: 1 addition & 1 deletion test/gui/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def parse_username_from_sync_path(sync_path):


def get_temp_resource_path(resource_name):
return join(get_config('tempFolderPath'), resource_name)
return join(get_config('test_temp_dir'), resource_name)


def get_current_user_sync_path():
Expand Down
15 changes: 7 additions & 8 deletions test/gui/steps/file_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ def file_exists(file_path, timeout=get_config('min_timeout')):
)


# To create folders in a temporary directory, we set is_temp_folder True
# And if is_temp_folder is True, the create_folder function create folders in tempFolderPath
# To create folders in a temporary directory, set is_temp_folder True
def create_folder(foldername, username=None, is_temp_folder=False):
if is_temp_folder:
folder_path = join(get_config('tempFolderPath'), foldername)
folder_path = join(get_config('test_temp_dir'), foldername)
else:
folder_path = get_resource_path(foldername, username)
os.makedirs(prefix_path_namespace(convert_path_separators_for_os(folder_path)))
Expand All @@ -60,7 +59,7 @@ def rename_file_folder(source, destination):

def create_file_with_size(filename, filesize, is_temp_folder=False):
if is_temp_folder:
file = join(get_config('tempFolderPath'), filename)
file = join(get_config('test_temp_dir'), filename)
else:
file = get_resource_path(filename)
with open(prefix_path_namespace(file), 'wb') as f:
Expand Down Expand Up @@ -333,7 +332,7 @@ def step(context, username, file):
regexp=True,
)
def step(context, username, resource_type, resource_name):
source_dir = join(get_config('tempFolderPath'), resource_name)
source_dir = join(get_config('test_temp_dir'), resource_name)
move_resource(username, resource_type, source_dir, '/', True)


Expand All @@ -342,7 +341,7 @@ def step(context, username, resource_type, resource_name):
regexp=True,
)
def step(context, username, resource_type, resource_name):
destination = join(get_config('tempFolderPath'), resource_name)
destination = join(get_config('test_temp_dir'), resource_name)
move_resource(username, resource_type, resource_name, destination)


Expand Down Expand Up @@ -394,15 +393,15 @@ def step(context, zip_file_name):

for row in context.table[1:]:
resource_list.append(row[0])
resource = join(get_config('tempFolderPath'), row[0])
resource = join(get_config('test_temp_dir'), row[0])
if row[1] == 'folder':
os.makedirs(resource)
elif row[1] == 'file':
content = ''
if len(row) > 2 and row[2]:
content = row[2]
write_file(resource, content)
create_zip(resource_list, zip_file_name, get_config('tempFolderPath'))
create_zip(resource_list, zip_file_name, get_config('test_temp_dir'))


@When('user "|any|" unzips the zip file "|any|" inside the sync root')
Expand Down
5 changes: 5 additions & 0 deletions test/gui/woodpecker/gui_test_reports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ echo "Test Report: $REPORT_URL/report.html"
echo "Client Log: $REPORT_URL/opencloud.log"
echo "AT_SPI Driver Log: $REPORT_URL/atspi_webdriver.log"

has_crash_log=$(mc find s3/$REPORT_PATH/crash.log 2>/dev/null || true)
if [[ -n "$has_crash_log" ]]; then
echo "Crash Log: $REPORT_URL/crash.log"
fi

screenshots=$(mc find s3/$REPORT_PATH/screenshots/ 2>/dev/null || true)
if [[ -n "$screenshots" ]]; then
echo "Screenshots:"
Expand Down