chore_: allow disabling http/ws api from cli (#16118)

* chore_: allow disabling http/ws api from cli

* ci: add env vars to prevent autotests hitting 8545 (#16120)

* chore: increase timeout for saved addresses test

* ci: add env vars to prevent autotests hitting 8545 port

---------

Co-authored-by: Anastasiya <82375995+anastasiyaig@users.noreply.github.com>
This commit is contained in:
Igor Sirotin 2024-08-15 13:44:23 +01:00 committed by GitHub
parent 82d1be9ad8
commit a46a7883e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 15 deletions

View File

@ -69,6 +69,10 @@ pipeline {
SQUISH_DIR = '/opt/squish-runner-7.2.1' SQUISH_DIR = '/opt/squish-runner-7.2.1'
PYTHONPATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/lib/python:${PYTHONPATH}" PYTHONPATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/lib/python:${PYTHONPATH}"
LD_LIBRARY_PATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/python3/lib:${LD_LIBRARY_PATH}" LD_LIBRARY_PATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/python3/lib:${LD_LIBRARY_PATH}"
/* To stop e2e tests using port 8545 */
STATUS_RUNTIME_HTTP_API = 'False'
STATUS_RUNTIME_WS_API = 'False'
/* Avoid race conditions with other builds using virtualenv. */ /* Avoid race conditions with other builds using virtualenv. */
VIRTUAL_ENV = "${WORKSPACE_TMP}/venv" VIRTUAL_ENV = "${WORKSPACE_TMP}/venv"

View File

@ -1,6 +1,7 @@
import json import json, net
include ../../../common/net_utils import ../../../common/net_utils
import ../../../../constants as main_constants
type APIConfig* = object type APIConfig* = object
apiModules*: string apiModules*: string
@ -12,21 +13,15 @@ type APIConfig* = object
wsHost*: string wsHost*: string
wsPort*: int wsPort*: int
proc checkAndSetPort(port: Port, isEnabled: var bool) =
if isPortBusy(port):
isEnabled = false
proc defaultAPIConfig*(): APIConfig = proc defaultAPIConfig*(): APIConfig =
result.apiModules = "connector" result.apiModules = "connector"
result.connectorEnabled = true result.connectorEnabled = true
result.httpEnabled = true result.httpEnabled = main_constants.HTTP_API_ENABLED and not isPortBusy(Port(8545))
checkAndSetPort(Port(8545), result.httpEnabled)
result.httpHost = "127.0.0.1" result.httpHost = "127.0.0.1"
result.httpPort = 8545 result.httpPort = 8545
result.wsEnabled = true result.wsEnabled = main_constants.WS_API_ENABLED and not isPortBusy(Port(8586))
checkAndSetPort(Port(8586), result.wsEnabled)
result.wsHost = "127.0.0.1" result.wsHost = "127.0.0.1"
result.wsPort = 8586 result.wsPort = 8586

View File

@ -70,6 +70,8 @@ let
MIXPANEL_APP_ID* = desktopConfig.mixpanelAppId MIXPANEL_APP_ID* = desktopConfig.mixpanelAppId
MIXPANEL_TOKEN* = desktopConfig.mixpanelToken MIXPANEL_TOKEN* = desktopConfig.mixpanelToken
BUILD_MODE* = if defined(production): "prod" else: "test" BUILD_MODE* = if defined(production): "prod" else: "test"
HTTP_API_ENABLED* = desktopConfig.httpApiEnabled
WS_API_ENABLED* = desktopConfig.wsApiEnabled
proc hasLogLevelOption*(): bool = proc hasLogLevelOption*(): bool =
for p in cliParams: for p in cliParams:

View File

@ -270,7 +270,16 @@ type StatusDesktopConfig = object
desc: "Determines if the app should use mocked keycard" desc: "Determines if the app should use mocked keycard"
name: "USE_MOCKED_KEYCARD" name: "USE_MOCKED_KEYCARD"
abbr: "use-mocked-keycard" .}: bool abbr: "use-mocked-keycard" .}: bool
httpApiEnabled* {.
defaultValue: true
desc: "Enable HTTP RPC API"
name: "HTTP_API"
abbr: "http-api" .}: bool
wsApiEnabled* {.
defaultValue: true
desc: "Enable WebSocket RPC API"
name: "WS_API"
abbr: "ws-api" .}: bool
# On macOS the first time when a user gets the "App downloaded from the # On macOS the first time when a user gets the "App downloaded from the
# internet" warning, and clicks the Open button, the OS passes a unique process # internet" warning, and clicks the Open button, the OS passes a unique process

View File

@ -38,7 +38,7 @@ def test_wallet_settings_add_saved_address(main_screen: MainWindow, address: str
with step('Verify recently added saved address is present in the list'): with step('Verify recently added saved address is present in the list'):
assert driver.waitFor( assert driver.waitFor(
lambda: name in settings_saved_addresses.get_saved_address_names_list(), lambda: name in settings_saved_addresses.get_saved_address_names_list(),
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {name} not found' configs.timeouts.APP_LOAD_TIMEOUT_MSEC), f'Address: {name} not found'
with step('Verify toast message when adding saved address'): with step('Verify toast message when adding saved address'):
messages = main_screen.wait_for_notification() messages = main_screen.wait_for_notification()

View File

@ -65,6 +65,6 @@ def test_manage_saved_address(main_screen: MainWindow, name: str, address: str,
f"Toast message about deleting saved address is not correct or not present. Current list of messages: {messages}" f"Toast message about deleting saved address is not correct or not present. Current list of messages: {messages}"
with step('Verify that saved address with new name is not in the list of saved addresses'): with step('Verify that saved address with new name is not in the list of saved addresses'):
assert not driver.waitFor( assert not driver.waitFor(
lambda: new_name in wallet.left_panel.open_saved_addresses().get_saved_addresses_list(), lambda: new_name in wallet.left_panel.open_saved_addresses().get_saved_addresses_list(),
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {new_name} is still present' configs.timeouts.APP_LOAD_TIMEOUT_MSEC), f'Address: {new_name} is still present'