Skip to content
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

[GUI-tests] Open only one socket connection per test scenario #9948

Merged
merged 1 commit into from
Sep 7, 2022
Merged
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
6 changes: 6 additions & 0 deletions test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ def scenarioFailed():

@OnScenarioEnd
def hook(context):
# close socket connection
global socketConnect
if socketConnect:
socketConnect.connected = False
socketConnect._sock.close()

# Currently, this workaround is needed because we cannot find out a way to determine the pass/fail status of currently running test scenario.
# And, resultCount("errors") and resultCount("fails") return the total number of error/failed test scenarios of a test suite.
global previousFailResultCount
Expand Down
15 changes: 11 additions & 4 deletions test/gui/shared/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# to switch from the built-in interpreter see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/
# if the IDE fails to reference the script, add the folder in Edit->Preferences->PyDev->Interpreters->Libraries
sys.path.append(os.path.realpath('../../../shell_integration/nautilus/'))
import syncstate
from syncstate import SocketConnect
import functools


Expand Down Expand Up @@ -138,11 +138,18 @@ def step(context):
newAccount.addAccountCredential(context)


def getSocketConnection():
global socketConnect
if not socketConnect or not socketConnect.connected:
socketConnect = SocketConnect()
return socketConnect


# 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()
socketConnect = getSocketConnection()
socketConnect.sendCommand("RETRIEVE_" + type + "_STATUS:" + itemName + "\n")

if not socketConnect.read_socket_data_with_timeout(0.1):
Expand Down Expand Up @@ -278,7 +285,7 @@ def sanitizePath(path):


def shareResource(resource):
socketConnect = syncstate.SocketConnect()
socketConnect = getSocketConnection()
socketConnect.sendCommand("SHARE:" + resource + "\n")
if not socketConnect.read_socket_data_with_timeout(0.1):
return False
Expand Down Expand Up @@ -372,7 +379,7 @@ def collaboratorShouldBeListed(
context, receiver, resource, permissions, receiverCount=0
):
resource = getResourcePath(context, resource)
socketConnect = syncstate.SocketConnect()
socketConnect = getSocketConnection()
socketConnect.sendCommand("SHARE:" + resource + "\n")
permissionsList = permissions.split(',')

Expand Down