-
Notifications
You must be signed in to change notification settings - Fork 44
test(gui): fix sync pattern checks #904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5d0991b
test: wait for files sync
saw-jan e3deab9
test: retry folder expansion
saw-jan 672832e
test: check if account is active
saw-jan 1d39e71
test: check sync pattern with force sync for root folder
saw-jan 6f3cb41
test: check sync using file path
saw-jan 61809e0
test: clear sync messages after each scenario
saw-jan 52b74d5
test: raise exception if multiple elements are found
saw-jan bb7792b
test: fix multiple elements
saw-jan 5865cd9
test: fix sync activity checks
saw-jan b41be99
test: fix multiple elements
saw-jan 9465f76
test: wait for toolbar to be enabled
saw-jan d679912
test: add sync pattern for resource deletion
saw-jan ce40f57
test: fix element coordinates
saw-jan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| from selenium.webdriver.support.ui import WebDriverWait | ||
| from selenium.common.exceptions import TimeoutException | ||
|
|
||
| from pageObjects.SyncConnection import SyncConnection | ||
| from helpers.ConfigHelper import get_config, is_linux, is_windows | ||
| from helpers.FilesHelper import sanitize_path | ||
|
|
||
|
|
@@ -74,34 +75,45 @@ | |
| SYNC_STATUS['UPDATE'], | ||
| ], | ||
| # when syncing empty account (hidden files are ignored) | ||
| [SYNC_STATUS['UPDATE'], SYNC_STATUS['OK']], | ||
| [SYNC_STATUS['UPDATE'], SYNC_STATUS['OKAL']], | ||
| # [SYNC_STATUS['UPDATE'], SYNC_STATUS['OK']], | ||
| # [SYNC_STATUS['UPDATE'], SYNC_STATUS['OKAL']], | ||
|
Comment on lines
+78
to
+79
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might need for Windows |
||
| # when syncing an account that has some files/folders | ||
| [SYNC_STATUS['SYNC'], SYNC_STATUS['OK']], | ||
| ], | ||
| 'root_synced': [ | ||
| # [SYNC_STATUS['SYNC'], SYNC_STATUS['OK']], | ||
| # initial root sync | ||
| [ | ||
| SYNC_STATUS['SYNC'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['UPDATE'], | ||
| ], | ||
| ], | ||
| 'root_synced': [ | ||
| [ | ||
| SYNC_STATUS['SYNC'], | ||
| SYNC_STATUS['UPDATE'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['UPDATE'], | ||
| ], | ||
| # used for local resource creation and deletion | ||
| [ | ||
| SYNC_STATUS['OKAL'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['OK'], | ||
| SYNC_STATUS['UPDATE'], | ||
| ], | ||
| # [ | ||
| # SYNC_STATUS['SYNC'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['UPDATE'], | ||
| # ], | ||
| # [ | ||
| # SYNC_STATUS['SYNC'], | ||
| # SYNC_STATUS['UPDATE'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['UPDATE'], | ||
| # ], | ||
| # # used for local resource creation and deletion | ||
| # [ | ||
| # SYNC_STATUS['OKAL'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['OK'], | ||
| # SYNC_STATUS['UPDATE'], | ||
| # ], | ||
| ], | ||
| 'single_synced': [SYNC_STATUS['SYNC'], SYNC_STATUS['OK']], | ||
| 'error': [SYNC_STATUS['ERROR']], | ||
|
|
@@ -226,20 +238,45 @@ def get_current_sync_status(resource, resource_type): | |
| return messages[-1] | ||
|
|
||
|
|
||
| def wait_for_resource_to_sync(resource, resource_type='FOLDER', patterns=None): | ||
| def wait_for_resource_to_sync( | ||
| resource, resource_type='FOLDER', patterns=None, force_sync=False | ||
| ): | ||
| listen_sync_status_for_item(resource, resource_type) | ||
|
|
||
| initial_timeout = 0 | ||
| timeout = get_config('maxSyncTimeout') * 1000 | ||
|
|
||
| if patterns is None: | ||
| patterns = get_synced_pattern(resource) | ||
|
|
||
| if force_sync: | ||
| initial_timeout = 5000 | ||
| # first try with 5 seconds timeout | ||
| synced = wait_for( | ||
| lambda: has_sync_pattern(patterns, resource), | ||
| initial_timeout, | ||
| ) | ||
| if not synced: | ||
| # trigger force sync if the current status is OK | ||
| status = get_current_sync_status(resource, resource_type) | ||
| if status.startswith(SYNC_STATUS['OK']): | ||
| print('[WARN] Retrying sync pattern check with force sync') | ||
| SyncConnection.force_sync() | ||
| else: | ||
| clear_socket_messages(resource) | ||
| return | ||
|
|
||
| synced = wait_for( | ||
| lambda: has_sync_pattern(patterns, resource), | ||
| timeout, | ||
| timeout - initial_timeout, | ||
| ) | ||
|
|
||
| messages = read_and_update_socket_messages() | ||
| messages = filter_messages_for_item(messages, resource) | ||
| clear_socket_messages(resource) | ||
| if not synced: | ||
| if synced: | ||
| return | ||
| elif not force_sync: | ||
| # if the sync pattern doesn't match then check the last sync status | ||
| # and pass the step if the last sync status is STATUS:OK | ||
| status = get_current_sync_status(resource, resource_type) | ||
|
|
@@ -251,18 +288,19 @@ def wait_for_resource_to_sync(resource, resource_type='FOLDER', patterns=None): | |
| + '. So passing the step.' | ||
| ) | ||
| return | ||
| raise TimeoutError( | ||
| 'Timeout while waiting for sync to complete for ' | ||
| + str(timeout) | ||
| + ' milliseconds' | ||
| ) | ||
| raise TimeoutError( | ||
| 'Timeout while waiting for sync to complete for ' | ||
| + str(timeout) | ||
| + ' milliseconds' | ||
| ) | ||
|
|
||
|
|
||
| def wait_for_initial_sync_to_complete(path): | ||
| wait_for_resource_to_sync( | ||
| path, | ||
| 'FOLDER', | ||
| get_initial_sync_patterns(), | ||
| True, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -281,6 +319,7 @@ def has_sync_pattern(patterns, resource=None): | |
| if len(actual_pattern) < pattern_len: | ||
| break | ||
| if pattern_len == len(actual_pattern) and pattern == actual_pattern: | ||
| print("MATCHED SYNC PATTERN:", pattern) | ||
| return True | ||
| # 100 milliseconds polling interval | ||
| time.sleep(0.1) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clicking filter option doesn't work. we need to fix and enable this.