Skip to content

Fix wrong redis key #1504

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 19 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 7 additions & 6 deletions packages/service-library/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ def pylintrc(osparc_simcore_root_dir):


def test_run_pylint(pylintrc, package_dir):
try:
AUTODETECT = 0
cmd = f"pylint --jobs={AUTODETECT} --rcfile {pylintrc} -v {package_dir}".split()
assert subprocess.check_call(cmd) == 0
except subprocess.CalledProcessError as err:
pytest.fail("Linting error. Linter existed with code %d" % err.returncode)
AUTODETECT = 0
cmd = f"pylint --jobs={AUTODETECT} --rcfile {pylintrc} -v {package_dir}".split()
pipes = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
std_out, _ = pipes.communicate()
if pipes.returncode != 0:
print(std_out.decode('utf-8'))
assert False, "Pylint failed with error, check this test's stdout to fix it"


def test_no_pdbs_in_place(package_dir):
Expand Down
6 changes: 5 additions & 1 deletion services/api-gateway/tests/unit/test_code_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def pylintrc(osparc_simcore_root_dir):

def test_run_pylint(pylintrc, package_dir):
cmd = "pylint --jobs 0 --rcfile {} -v {}".format(pylintrc, package_dir)
assert subprocess.check_call(cmd.split()) == 0
pipes = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
std_out, _ = pipes.communicate()
if pipes.returncode != 0:
print(std_out.decode('utf-8'))
assert False, "Pylint failed with error, check this test's stdout to fix it"


def test_no_pdbs_in_place(package_dir):
Expand Down
6 changes: 5 additions & 1 deletion services/catalog/tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def pylintrc(project_slug_dir, osparc_simcore_root_dir):

def test_run_pylint(pylintrc, package_dir):
cmd = "pylint --jobs 0 --rcfile {} -v {}".format(pylintrc, package_dir)
assert subprocess.check_call(cmd.split()) == 0
pipes = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
std_out, _ = pipes.communicate()
if pipes.returncode != 0:
print(std_out.decode('utf-8'))
assert False, "Pylint failed with error, check this test's stdout to fix it"


# FIXME: main entrypoint
Expand Down
9 changes: 6 additions & 3 deletions services/sidecar/tests/unit/test_code_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ def pylintrc(osparc_simcore_root_dir):

def test_run_pylint(pylintrc, package_dir):
cmd = "pylint --jobs 0 --rcfile {} -v {}".format(pylintrc, package_dir)
proc: subprocess.CompletedProcess = subprocess.run(cmd.split(), check=True)
assert proc.returncode == 0, f"pylint error: {proc.stdout}"
pipes = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
std_out, _ = pipes.communicate()
if pipes.returncode != 0:
print(std_out.decode('utf-8'))
assert False, "Pylint failed with error, check this test's stdout to fix it"


def test_no_pdbs_in_place(package_dir):
Expand All @@ -33,4 +36,4 @@ def test_no_pdbs_in_place(package_dir):
code = pypth.read_text()
found = MATCH.findall(code)
assert not found, "pbd.set_trace found in %s" % pypth
dirs[:] = [d for d in dirs if d not in EXCLUDE]
dirs[:] = [d for d in dirs if d not in EXCLUDE]
13 changes: 7 additions & 6 deletions services/storage/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ def pylintrc(osparc_simcore_root_dir):


def test_run_pylint(pylintrc, package_dir):
try:
AUTODETECT = 0
cmd = f"pylint --jobs={AUTODETECT} --rcfile {pylintrc} -v {package_dir}".split()
assert subprocess.check_call(cmd) == 0
except subprocess.CalledProcessError as err:
pytest.fail("Linting error. Linter existed with code %d" % err.returncode)
AUTODETECT = 0
cmd = f"pylint --jobs={AUTODETECT} --rcfile {pylintrc} -v {package_dir}".split()
pipes = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
std_out, _ = pipes.communicate()
if pipes.returncode != 0:
print(std_out.decode('utf-8'))
assert False, "Pylint failed with error, check this test's stdout to fix it"


def test_main(here): # pylint: disable=unused-variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ async def remove_socket_id(self) -> None:
self._resource_key(), False, get_service_deletion_timeout(self.app)
)

async def set_heartbeat(self) -> None:
"""Refreshes heartbeat """
registry = get_registry(self.app)
await registry.set_key_alive(
self._resource_key(), False, get_service_deletion_timeout(self.app)
)

async def find_socket_ids(self) -> List[str]:
log.debug(
"user %s/tab %s finding %s from registry...",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from socketio.exceptions import ConnectionRefusedError as SocketIOConnectionError

from ..login.decorators import RQT_USERID_KEY, login_required
from ..resource_manager.websocket_manager import managed_resource, get_registry
from ..resource_manager.websocket_manager import managed_resource
from ..resource_manager.config import get_service_deletion_timeout
from .config import get_socket_server
from .handlers_utils import register_socketio_handler
Expand Down Expand Up @@ -57,7 +57,7 @@ async def connect(sid: str, environ: Dict, app: web.Application) -> bool:
log.info("Sending set_heartbeat_emit_interval with %s", emit_interval)

user_id = request.get(RQT_USERID_KEY, ANONYMOUS_USER_ID)
await post_messages(app, user_id, {'set_heartbeat_emit_interval': emit_interval})
await post_messages(app, user_id, {"set_heartbeat_emit_interval": emit_interval})

return True

Expand Down Expand Up @@ -147,6 +147,7 @@ async def disconnect(sid: str, app: web.Application) -> None:
str(socketio_session),
)


@register_socketio_handler
async def client_heartbeat(sid: str, _: Any, app: web.Application) -> None:
"""JS client invokes this handler to signal its presence.
Expand All @@ -161,7 +162,10 @@ async def client_heartbeat(sid: str, _: Any, app: web.Application) -> None:
"""
sio = get_socket_server(app)
async with sio.session(sid) as socketio_session:
registry = get_registry(app)
await registry.set_key_alive(
socketio_session, False, get_service_deletion_timeout(app)
)
if "user_id" not in socketio_session:
return

user_id = socketio_session["user_id"]
client_session_id = socketio_session["client_session_id"]
with managed_resource(user_id, client_session_id, app) as rt:
await rt.set_heartbeat()
15 changes: 9 additions & 6 deletions services/web/server/tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ def pylintrc(osparc_simcore_root_dir):


def test_run_pylint(pylintrc, package_dir):
try:
AUTODETECT = 0
cmd = f"pylint --jobs={AUTODETECT} --rcfile {pylintrc} -v {package_dir}".split()
assert subprocess.check_call(cmd) == 0
except subprocess.CalledProcessError as err:
pytest.fail("Linting error. Linter existed with code %d" % err.returncode)
AUTODETECT = 0
cmd = f"pylint --jobs={AUTODETECT} --rcfile {pylintrc} -v {package_dir}".split()

pipes = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
std_out, _ = pipes.communicate()
if pipes.returncode != 0:
print(std_out.decode('utf-8'))
assert False, "Pylint failed with error, check this test's stdout to fix it"



def test_main(here): # pylint: disable=unused-variable
Expand Down