Skip to content
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
10 changes: 10 additions & 0 deletions framework/python/src/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
MAX_DEVICE_REPORTS_KEY = 'max_device_reports'
ORG_NAME_KEY = 'org_name'
TEST_CONFIG_KEY = 'test_modules'
ALLOW_DISCONNECT_KEY='allow_disconnect'
CERTS_PATH = 'local/root_certs'
CONFIG_FILE_PATH = 'local/system.json'
STATUS_TOPIC = 'status'
Expand Down Expand Up @@ -203,6 +204,7 @@ def _get_default_config(self):
'log_level': 'INFO',
'startup_timeout': 60,
'monitor_period': 30,
'allow_disconnect': False,
'max_device_reports': 0,
'api_url': 'http://localhost',
'api_port': 8000,
Expand Down Expand Up @@ -241,6 +243,10 @@ def _load_config(self):
self._config[MONITOR_PERIOD_KEY] = config_file_json.get(
MONITOR_PERIOD_KEY)

if ALLOW_DISCONNECT_KEY in config_file_json:
self._config[ALLOW_DISCONNECT_KEY] = config_file_json.get(
ALLOW_DISCONNECT_KEY)

if LOG_LEVEL_KEY in config_file_json:
self._config[LOG_LEVEL_KEY] = config_file_json.get(LOG_LEVEL_KEY)

Expand Down Expand Up @@ -509,6 +515,10 @@ def get_all_reports(self):
def add_total_tests(self, no_tests):
self._total_tests += no_tests


def get_allow_disconnect(self):
return self._config.get(ALLOW_DISCONNECT_KEY)

def get_total_tests(self):
return self._total_tests

Expand Down
20 changes: 10 additions & 10 deletions framework/python/src/net_orc/network_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,16 @@ def _start_device_monitor(self, device):
TestrunStatus.CANCELLED):
sniffer.stop()
return

if not self._ip_ctrl.check_interface_status(
self._session.get_device_interface()):
try:
sniffer.stop()
except Scapy_Exception:
LOGGER.error('Device adapter disconnected whilst monitoring.')
finally:
self._session.set_status(TestrunStatus.CANCELLED)
LOGGER.error('Device interface disconnected, cancelling Testrun')
if not self._session.get_allow_disconnect():
if not self._ip_ctrl.check_interface_status(
self._session.get_device_interface()):
try:
sniffer.stop()
except Scapy_Exception:
LOGGER.error('Device adapter disconnected whilst monitoring.')
finally:
self._session.set_status(TestrunStatus.CANCELLED)
LOGGER.error('Device interface disconnected, cancelling Testrun')

LOGGER.debug('Writing packets to monitor.pcap')
wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'),
Expand Down
1 change: 1 addition & 0 deletions local/system.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"log_level": "INFO",
"startup_timeout": 60,
"monitor_period": 300,
"allow_disconnect": false,
"max_device_reports": 0,
"org_name": ""
}