Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSawjan Gurung <saw.jan.grg3e@gmail.com>2022-03-03 07:42:50 +0300
committerGitHub <noreply@github.com>2022-03-03 07:42:50 +0300
commitf380b79c1956ae1bad3e7daf795c2f7a3333c309 (patch)
tree893649e04befcff73f5a3d6f1438ddde3493ee3c /test
parent45d2a213b94a376f81bbcd54be286bed1e813841 (diff)
[GUI][tests-only] Validate sync status (#9442)
* validate sync status fix steps check if sync has started or not remove extra changes increase sync wait time wait for sync to start fix test steps * use max and min sync timeout configs
Diffstat (limited to 'test')
-rw-r--r--test/gui/config.sample.ini3
-rw-r--r--test/gui/shared/scripts/bdd_hooks.py8
-rw-r--r--test/gui/shared/steps/steps.py179
-rw-r--r--test/gui/tst_editFiles/test.feature1
-rw-r--r--test/gui/tst_sharing/test.feature31
-rw-r--r--test/gui/tst_syncing/test.feature16
6 files changed, 148 insertions, 90 deletions
diff --git a/test/gui/config.sample.ini b/test/gui/config.sample.ini
index 6f0c18bdd..537519538 100644
--- a/test/gui/config.sample.ini
+++ b/test/gui/config.sample.ini
@@ -3,5 +3,6 @@ BACKEND_HOST=
SECURE_BACKEND_HOST=
MIDDLEWARE_URL=
CLIENT_ROOT_SYNC_PATH=
-CLIENT_SYNC_TIMEOUT=
+MAX_SYNC_TIMEOUT=
+MIN_SYNC_TIMEOUT=
CLIENT_LOG_FILE= \ No newline at end of file
diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py
index 56cf0459c..3b735a720 100644
--- a/test/gui/shared/scripts/bdd_hooks.py
+++ b/test/gui/shared/scripts/bdd_hooks.py
@@ -28,7 +28,8 @@ def hook(context):
CONFIG_ENV_MAP = {
'localBackendUrl': 'BACKEND_HOST',
'secureLocalBackendUrl': 'SECURE_BACKEND_HOST',
- 'clientSyncTimeout': 'CLIENT_SYNC_TIMEOUT',
+ 'maxSyncTimeout': 'MAX_SYNC_TIMEOUT',
+ 'minSyncTimeout': 'MIN_SYNC_TIMEOUT',
'middlewareUrl': 'MIDDLEWARE_URL',
'clientConfigFile': 'CLIENT_LOG_FILE',
'clientRootSyncPath': 'CLIENT_ROOT_SYNC_PATH',
@@ -37,7 +38,8 @@ def hook(context):
DEFAULT_CONFIG = {
'localBackendUrl': 'https://localhost:9200/',
'secureLocalBackendUrl': 'https://localhost:9200/',
- 'clientSyncTimeout': 10,
+ 'maxSyncTimeout': 10,
+ 'minSyncTimeout': 5,
'middlewareUrl': 'http://localhost:3000/',
'clientConfigFile': '-',
'clientRootSyncPath': '/tmp/client-bdd/',
@@ -62,7 +64,7 @@ def hook(context):
for key, value in context.userData.items():
if value == '':
context.userData[key] = DEFAULT_CONFIG[key]
- elif key == 'clientSyncTimeout':
+ elif key == 'maxSyncTimeout':
context.userData[key] = builtins.int(value)
elif key == 'clientRootSyncPath':
# make sure there is always one trailing slash
diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py
index 93f58b37a..a784f42e9 100644
--- a/test/gui/shared/steps/steps.py
+++ b/test/gui/shared/steps/steps.py
@@ -36,6 +36,15 @@ socketConnect = None
stateDataFromMiddleware = None
+# File syncing in client has the following status
+SYNC_STATUS = {
+ 'SYNC': 'STATUS:SYNC', # sync in process
+ 'OK': 'STATUS:OK', # sync completed
+ 'ERROR': 'STATUS:ERROR', # file sync has error
+ 'IGNORE': 'STATUS:IGNORE', # file is igored
+ 'NOP': 'STATUS:NOP', # file yet to be synced
+}
+
def getTestStateFromMiddleware(context):
global stateDataFromMiddleware
@@ -134,7 +143,8 @@ def step(context):
newAccount.selectSyncFolder(context)
-def isItemSynced(type, itemName):
+# Using socket API to check file sync status
+def hasSyncStatus(type, itemName, status):
if type != 'FILE' and type != 'FOLDER':
raise Exception("type must be 'FILE' or 'FOLDER'")
socketConnect = syncstate.SocketConnect()
@@ -143,31 +153,114 @@ def isItemSynced(type, itemName):
if not socketConnect.read_socket_data_with_timeout(0.1):
return False
for line in socketConnect.get_available_responses():
- if line.startswith('STATUS:OK') and line.endswith(itemName):
+ if line.startswith(status) and line.endswith(itemName):
return True
elif line.endswith(itemName):
return False
-def isFolderSynced(folderName):
- return isItemSynced('FOLDER', folderName)
+def folderHasSyncStatus(folderName, status):
+ return hasSyncStatus('FOLDER', folderName, status)
-def isFileSynced(fileName):
- return isItemSynced('FILE', fileName)
+def fileHasSyncStatus(fileName, status):
+ return hasSyncStatus('FILE', fileName, status)
-def waitForFileToBeSynced(context, filePath):
- waitFor(
- lambda: isFileSynced(sanitizePath(filePath)),
- context.userData['clientSyncTimeout'] * 1000,
+def waitForFileOrFolderToHaveSyncStatus(
+ context, resource, resourceType, status=SYNC_STATUS['OK'], timeout=None
+):
+ if not timeout:
+ timeout = context.userData['maxSyncTimeout'] * 1000
+
+ resource = join(context.userData['currentUserSyncPath'], resource)
+ if resourceType.lower() == "file":
+ result = waitFor(
+ lambda: fileHasSyncStatus(sanitizePath(resource), status),
+ timeout,
+ )
+ elif resourceType.lower() == "folder":
+ result = waitFor(
+ lambda: folderHasSyncStatus(sanitizePath(resource), status),
+ timeout,
+ )
+
+ if not result:
+ if status == SYNC_STATUS['ERROR']:
+ expected = "have sync error"
+ elif status == SYNC_STATUS['IGNORE']:
+ expected = "be sync ignored"
+ else:
+ expected = "be synced"
+ raise Exception(
+ "Expected "
+ + resourceType
+ + " '"
+ + resource
+ + "' to "
+ + expected
+ + ", but not."
+ )
+
+
+def waitForSyncToStart(context, resource, resourceType):
+ resource = join(context.userData['currentUserSyncPath'], resource)
+
+ hasStatusNOP = hasSyncStatus(resourceType.upper(), resource, SYNC_STATUS['NOP'])
+ hasStatusSYNC = hasSyncStatus(resourceType.upper(), resource, SYNC_STATUS['SYNC'])
+
+ if hasStatusSYNC:
+ return
+
+ try:
+ if hasStatusNOP:
+ waitForFileOrFolderToHaveSyncStatus(
+ context, resource, resourceType, SYNC_STATUS['SYNC']
+ )
+ else:
+ waitForFileOrFolderToHaveSyncStatus(
+ context,
+ resource,
+ resourceType,
+ SYNC_STATUS['SYNC'],
+ context.userData['minSyncTimeout'] * 1000,
+ )
+ except:
+ hasStatusNOP = hasSyncStatus(resourceType.upper(), resource, SYNC_STATUS['NOP'])
+ if hasStatusNOP:
+ raise Exception(
+ "Expected "
+ + resourceType
+ + " '"
+ + resource
+ + "' to have sync started but not."
+ )
+
+
+def waitForFileOrFolderToSync(context, resource, resourceType):
+ waitForSyncToStart(context, resource, resourceType)
+ waitForFileOrFolderToHaveSyncStatus(
+ context, resource, resourceType, SYNC_STATUS['OK']
)
-def waitForFolderToBeSynced(context, folderPath):
- waitFor(
- lambda: isFolderSynced(sanitizePath(folderPath)),
- context.userData['clientSyncTimeout'] * 1000,
+def waitForRootFolderToSync(context):
+ waitForFileOrFolderToSync(
+ context, context.userData['currentUserSyncPath'], 'folder'
+ )
+
+
+def waitForFileOrFolderToHaveSyncError(context, resource, resourceType):
+ waitForSyncToStart(context, resource, resourceType)
+ waitForFileOrFolderToHaveSyncStatus(
+ context, resource, resourceType, SYNC_STATUS['ERROR']
+ )
+
+
+def waitForFileOrFolderToBeSyncIgnored(context, resource, resourceType):
+ waitForSyncToStart(context, resource, resourceType)
+ waitForFileOrFolderToHaveSyncStatus(
+ context, resource, resourceType, SYNC_STATUS['IGNORE']
)
@@ -327,25 +420,27 @@ def collaboratorShouldBeListed(
@When('the user waits for the files to sync')
def step(context):
- waitForFolderToBeSynced(context, '/')
+ waitForRootFolderToSync(context)
-def waitForResourceToSync(context, resource, resourceType):
- resource = join(context.userData['currentUserSyncPath'], resource)
- if resourceType == "file":
- waitForFileToBeSynced(context, resource)
- elif resourceType == "folder":
- waitForFolderToBeSynced(context, resource)
+@When(r'the user waits for (file|folder) "([^"]*)" to be synced', regexp=True)
+def step(context, type, resource):
+ waitForFileOrFolderToSync(context, resource, type)
-@When(r'the user waits for (file|folder) "([^"]*)" to be synced', regexp=True)
+@When(r'the user waits for (file|folder) "([^"]*)" to have sync error', regexp=True)
def step(context, type, resource):
- waitForResourceToSync(context, resource, type)
+ waitForFileOrFolderToHaveSyncError(context, resource, type)
+
+
+@When(r'the user waits for (file|folder) "([^"]*)" to be sync ignored', regexp=True)
+def step(context, type, resource):
+ waitForFileOrFolderToBeSyncIgnored(context, resource, type)
@Given(r'the user has waited for (file|folder) "([^"]*)" to be synced', regexp=True)
def step(context, type, resource):
- waitForResourceToSync(context, resource, type)
+ waitForFileOrFolderToSync(context, resource, type)
@Given(
@@ -462,11 +557,11 @@ def step(context, resourceType, resource):
resourceExists = False
if resourceType == 'file':
resourceExists = fileExists(
- resourcePath, context.userData['clientSyncTimeout'] * 1000
+ resourcePath, context.userData['maxSyncTimeout'] * 1000
)
elif resourceType == 'folder':
resourceExists = folderExists(
- resourcePath, context.userData['clientSyncTimeout'] * 1000
+ resourcePath, context.userData['maxSyncTimeout'] * 1000
)
else:
raise Exception("Unsupported resource type '" + resourceType + "'")
@@ -498,7 +593,6 @@ def step(context, resourceType, resource):
@Given('the user has paused the file sync')
def step(context):
- waitForFolderToBeSynced(context, '/')
syncWizard = SyncWizard()
syncWizard.performAction("Pause sync")
@@ -602,22 +696,7 @@ def step(context, tabName):
def openSharingDialog(context, resource, itemType='file'):
resource = getResourcePath(context, resource)
-
- if itemType == 'folder':
- waitFor(
- lambda: isFolderSynced(resource),
- context.userData['clientSyncTimeout'] * 1000,
- )
- elif itemType == 'file':
- waitFor(
- lambda: isFileSynced(resource), context.userData['clientSyncTimeout'] * 1000
- )
- else:
- raise Exception("No such item type for resource")
-
- waitFor(
- lambda: shareResource(resource), context.userData['clientSyncTimeout'] * 1000
- )
+ waitFor(lambda: shareResource(resource), context.userData['maxSyncTimeout'] * 1000)
@When('the user opens the public links dialog of "|any|" using the client-UI')
@@ -836,10 +915,7 @@ def step(context, username):
@Given('user "|any|" has logged out of the client-UI')
def step(context, username):
- waitForFolderToBeSynced(context, '/')
- # TODO: find some way to dynamically to check if files are synced
- # It might take some time for all files to sync
- snooze(5)
+ waitForRootFolderToSync(context)
accountStatus = AccountStatus(context, getDisplaynameForUser(context, username))
accountStatus.accountAction("Log out")
isUserSignedOut(context, username)
@@ -868,7 +944,6 @@ def step(context, username, host):
displayname = substituteInLineCodes(context, displayname)
host = substituteInLineCodes(context, host)
- waitForFolderToBeSynced(context, '/')
accountStatus = AccountStatus(context, displayname, host)
accountStatus.removeConnection()
@@ -959,23 +1034,16 @@ def overwriteFile(resource, content):
def tryToOverwriteFile(context, resource, content):
- waitForFileToBeSynced(context, resource)
- waitForFolderToBeSynced(context, '/')
-
try:
overwriteFile(resource, content)
except:
pass
- waitForFileToBeSynced(context, resource)
-
@When('the user overwrites the file "|any|" with content "|any|"')
def step(context, resource, content):
print("starting file overwrite")
resource = join(context.userData['currentUserSyncPath'], resource)
- waitForFileToBeSynced(context, resource)
- waitForFolderToBeSynced(context, '/')
# overwriting the file immediately after it has been synced from the server seems to have some problem.
# The client does not see the change although the changes have already been made thus we are having a race condition
@@ -987,7 +1055,6 @@ def step(context, resource, content):
overwriteFile(resource, content)
print("file has been overwritten")
- waitForFileToBeSynced(context, resource)
@When('the user tries to overwrite the file "|any|" with content "|any|"')
diff --git a/test/gui/tst_editFiles/test.feature b/test/gui/tst_editFiles/test.feature
index 79376aeaf..9855a4e19 100644
--- a/test/gui/tst_editFiles/test.feature
+++ b/test/gui/tst_editFiles/test.feature
@@ -13,4 +13,5 @@ Feature: edit files
Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "S@mpleFile!With,$pecial?Characters.txt" on the server
And user "Alice" has set up a client with default settings
When the user overwrites the file "S@mpleFile!With,$pecial?Characters.txt" with content "overwrite ownCloud test text file"
+ And the user waits for file "S@mpleFile!With,$pecial?Characters.txt" to be synced
Then as "Alice" the file "S@mpleFile!With,$pecial?Characters.txt" on the server should have the content "overwrite ownCloud test text file" \ No newline at end of file
diff --git a/test/gui/tst_sharing/test.feature b/test/gui/tst_sharing/test.feature
index d2253c3ed..df08b821f 100644
--- a/test/gui/tst_sharing/test.feature
+++ b/test/gui/tst_sharing/test.feature
@@ -200,6 +200,7 @@ Feature: Sharing
And user "Brian" has set up a client with default settings
When the user overwrites the file "textfile.txt" with content "overwrite file in the root"
And the user overwrites the file "simple-folder/textfile.txt" with content "overwrite file inside a folder"
+ And the user waits for the files to sync
Then as "Brian" the file "simple-folder/textfile.txt" on the server should have the content "overwrite file inside a folder"
And as "Brian" the file "textfile.txt" on the server should have the content "overwrite file in the root"
And as "Alice" the file "simple-folder/textfile.txt" on the server should have the content "overwrite file inside a folder"
@@ -216,6 +217,7 @@ Feature: Sharing
And user "Brian" has set up a client with default settings
When the user tries to overwrite the file "Parent/textfile.txt" with content "overwrite file inside a folder"
And the user tries to overwrite the file "textfile.txt" with content "overwrite file in the root"
+ And the user waits for the files to sync
Then as "Brian" the file "Parent/textfile.txt" on the server should have the content "file inside a folder"
And as "Brian" the file "textfile.txt" on the server should have the content "file in the root"
And as "Alice" the file "Parent/textfile.txt" on the server should have the content "file inside a folder"
@@ -230,8 +232,7 @@ Feature: Sharing
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "FOLDER" on the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
- When the user waits for the files to sync
- And the user adds another account with
+ When the user adds another account with
| server | %local_server% |
| user | Alice |
| password | 1234 |
@@ -240,6 +241,7 @@ Feature: Sharing
And the user removes permissions "edit" for user "Brian Murphy" of resource "FOLDER" using the client-UI
And user "Brian" tries to overwrite the file "textfile.txt" with content "overwrite ownCloud test text file"
And user "Brian" tries to overwrite the file "FOLDER/simple.txt" with content "overwrite some content"
+ And the user waits for the files to sync
Then as "Brian" the file "textfile.txt" on the server should have the content "ownCloud test text file"
And as "Brian" the file "FOLDER/simple.txt" on the server should have the content "some content"
And as "Alice" the file "textfile.txt" on the server should have the content "ownCloud test text file"
@@ -251,7 +253,7 @@ Feature: Sharing
And user "Brian" has been created on the server with default attributes and without skeleton files
And user "Alice" has shared folder "Parent" on the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
- When the user waits for folder "Parent" to be synced
+ When the user waits for the files to sync
And user "Brian" creates a file "Parent/localFile.txt" with the following content inside the sync folder
"""
test content
@@ -270,13 +272,14 @@ Feature: Sharing
And user "Brian" has been created on the server with default attributes and without skeleton files
And user "Alice" has shared folder "Parent" on the server with user "Brian" with "read" permissions
And user "Brian" has set up a client with default settings
- When the user waits for folder "Parent" to be synced
+ When the user waits for the files to sync
And user "Brian" creates a file "Parent/localFile.txt" with the following content inside the sync folder
"""
test content
"""
And user "Brian" creates a folder "Parent/localFolder" inside the sync folder
- And the user waits for the files to sync
+ And the user waits for file "Parent/localFile.txt" to have sync error
+ And the user waits for folder "Parent/localFolder" to have sync error
Then as "Brian" file "Parent/localFile.txt" should not exist on the server
And as "Brian" folder "Parent/localFolder" should not exist on the server
And as "Alice" file "Parent/localFile.txt" should not exist on the server
@@ -290,8 +293,7 @@ Feature: Sharing
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "FOLDER" on the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
- When the user waits for folder "FOLDER" to be synced
- When the user waits for file "textfile.txt" to be synced
+ When the user waits for the files to sync
And the user renames a file "textfile.txt" to "lorem.txt"
And the user renames a folder "FOLDER" to "PARENT"
And the user waits for folder "PARENT" to be synced
@@ -332,8 +334,7 @@ Feature: Sharing
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "read" permissions
And user "Alice" has shared file "Folder" on the server with user "Brian" with "read" permissions
And user "Brian" has set up a client with default settings
- When the user waits for file "textfile.txt" to be synced
- And the user waits for folder "Folder" to be synced
+ When the user waits for the files to sync
And the user deletes the file "textfile.txt"
And the user deletes the folder "Folder"
And the user waits for the files to sync
@@ -459,18 +460,6 @@ Feature: Sharing
Then as user "Alice" the file "/textfile0.txt" should not have any public link on the server
- Scenario Outline: simple sharing of a file by public link with password
- Given user "Alice" has set up a client with default settings
- And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" on the server
- When the user creates a new public link for file "textfile0.txt" with password "<password>" using the client-UI
- Then as user "Alice" the file "textfile0.txt" should have a public link on the server
- And the public should be able to download the file "textfile0.txt" with password "<password>" from the last created public link by "Alice" on the server
- Examples:
- | password |
- | password1234 |
- | p@$s!23 |
-
-
Scenario: sharing of a file by public link with password and changing the password
Given user "Alice" has set up a client with default settings
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" on the server
diff --git a/test/gui/tst_syncing/test.feature b/test/gui/tst_syncing/test.feature
index 69c26a8a4..3e32e59d5 100644
--- a/test/gui/tst_syncing/test.feature
+++ b/test/gui/tst_syncing/test.feature
@@ -36,7 +36,6 @@ Feature: Syncing files
Scenario: Syncing a file from the server and creating a conflict
Given user "Alice" has uploaded file on the server with content "server content" to "/conflict.txt"
And user "Alice" has set up a client with default settings
- And the user has waited for file "conflict.txt" to be synced
And the user has paused the file sync
And the user has changed the content of local file "conflict.txt" to:
"""
@@ -83,7 +82,6 @@ Feature: Syncing files
| folder |
| simple-folder |
And the user connects the account
- And the user waits for the files to sync
Then the folder "simple-folder" should exist on the file system
But the folder "large-folder" should not exist on the file system
@@ -190,7 +188,7 @@ Feature: Syncing files
"""
test content
"""
- And the user waits for folder "parent" to be synced
+ And the user waits for the files to sync
Then as "Alice" folder "parent/subfolderEmpty1" should exist on the server
And as "Alice" folder "parent/subfolderEmpty2" should exist on the server
And as "Alice" folder "parent/subfolderEmpty3" should exist on the server
@@ -224,7 +222,7 @@ Feature: Syncing files
"""
test content
"""
- And the user waits for file "Folder1/really long folder name with some spaces and special char such as $%ñ&/test.txt" to be synced
+ And the user waits for the files to sync
Then as "Alice" folder "Folder1" should exist on the server
And as "Alice" folder "Folder1/really long folder name with some spaces and special char such as $%ñ&" should exist on the server
And the file "Folder1/really long folder name with some spaces and special char such as $%ñ&/test.txt" should exist on the file system with the following content
@@ -278,11 +276,11 @@ Feature: Syncing files
Scenario: Invalid system names are synced in linux
- Given user "Alice" has set up a client with default settings
- And user "Alice" has created folder "CON" on the server
+ Given user "Alice" has created folder "CON" on the server
And user "Alice" has created folder "test%" on the server
And user "Alice" has uploaded file on the server with content "server content" to "/PRN"
And user "Alice" has uploaded file on the server with content "server content" to "/foo%"
+ And user "Alice" has set up a client with default settings
When the user waits for the files to sync
Then the folder "CON" should exist on the file system
And the folder "test%" should exist on the file system
@@ -295,15 +293,15 @@ Feature: Syncing files
Scenario: various types of files can be synced from server to client
- Given user "Alice" has set up a client with default settings
- And user "Alice" has created folder "simple-folder" on the server
+ Given user "Alice" has created folder "simple-folder" on the server
And user "Alice" has uploaded file "testavatar.png" to "simple-folder/testavatar.png" on the server
And user "Alice" has uploaded file "testavatar.jpg" to "simple-folder/testavatar.jpg" on the server
And user "Alice" has uploaded file "testavatar.jpeg" to "simple-folder/testavatar.jpeg" on the server
And user "Alice" has uploaded file "testimage.mp3" to "simple-folder/testimage.mp3" on the server
And user "Alice" has uploaded file "test_video.mp4" to "simple-folder/test_video.mp4" on the server
And user "Alice" has uploaded file "simple.pdf" to "simple-folder/simple.pdf" on the server
- When the user waits for folder "simple-folder" to be synced
+ And user "Alice" has set up a client with default settings
+ When the user waits for the files to sync
Then the folder "simple-folder" should exist on the file system
And the file "simple-folder/testavatar.png" should exist on the file system
And the file "simple-folder/testavatar.jpg" should exist on the file system