From 2982b1df5571a5498975c24c42431a562cab7f9b Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Thu, 8 Aug 2024 10:16:42 +0100 Subject: [PATCH 1/8] Add a timeout to the command --- framework/python/src/net_orc/ip_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/python/src/net_orc/ip_control.py b/framework/python/src/net_orc/ip_control.py index abefe6b09..e53dfff70 100644 --- a/framework/python/src/net_orc/ip_control.py +++ b/framework/python/src/net_orc/ip_control.py @@ -242,7 +242,7 @@ def configure_container_interface(self, def ping_via_gateway(self, host): """Ping the host trough the gateway container""" - command = f'docker exec tr-ct-gateway ping -W 1 -c 1 {host}' + command = f'timeout 3 docker exec tr-ct-gateway ping -W 1 -c 1 {host}' output = util.run_command(command) if '0% packet loss' in output[0]: return True From c80e252ba741df94ca59e6955c98861376becf75 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Fri, 9 Aug 2024 22:00:36 +0200 Subject: [PATCH 2/8] move single-intf check to scheduler --- framework/python/src/common/tasks.py | 21 +++++++++-------- .../src/net_orc/network_orchestrator.py | 23 ++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/framework/python/src/common/tasks.py b/framework/python/src/common/tasks.py index c71742ced..f53e78239 100644 --- a/framework/python/src/common/tasks.py +++ b/framework/python/src/common/tasks.py @@ -24,6 +24,7 @@ # Check adapters period seconds CHECK_NETWORK_ADAPTERS_PERIOD = 5 +CHECK_INTERNET_PERIOD = 2 INTERNET_CONNECTION_TOPIC = 'events/internet' NETWORK_ADAPTERS_TOPIC = 'events/adapter' @@ -60,14 +61,16 @@ async def start(self, app: FastAPI): # pylint: disable=unused-argument trigger='interval', seconds=CHECK_NETWORK_ADAPTERS_PERIOD, ) - self._scheduler.add_job( - func=self._testrun.get_net_orc().internet_conn_checker, - kwargs={ - 'mqtt_client': self._mqtt_client, - 'topic': INTERNET_CONNECTION_TOPIC - }, - trigger='interval', - seconds=CHECK_NETWORK_ADAPTERS_PERIOD, - ) + # add internet connection cheking job only in single-intf mode + if 'single_intf' not in self._testrun.get_session().get_runtime_params(): + self._scheduler.add_job( + func=self._testrun.get_net_orc().internet_conn_checker, + kwargs={ + 'mqtt_client': self._mqtt_client, + 'topic': INTERNET_CONNECTION_TOPIC + }, + trigger='interval', + seconds=CHECK_INTERNET_PERIOD, + ) self._scheduler.start() yield diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index b5bc995bf..bbc631c8d 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -799,17 +799,14 @@ def network_adapters_checker(self, mqtt_client: mqtt.MQTT, topic: str): def internet_conn_checker(self, mqtt_client: mqtt.MQTT, topic: str): """Checks internet connection and sends a status to frontend""" - # Default message - message = {'connection': False} - - # Only check if Testrun is running - if self.get_session().get_status() not in [ - 'Waiting for Device', 'Monitoring', 'In Progress' - ]: - message['connection'] = None - - # Only run if single intf mode not used - elif 'single_intf' not in self._session.get_runtime_params(): + # Only check if Testrun is running not in single-intf mode + if (self.get_session().get_status() in [ + 'Waiting for Device', + 'Monitoring', + 'In Progress' + ]): + # Default message + message = {'connection': False} iface = self._session.get_internet_interface() # Check that an internet intf has been selected @@ -822,8 +819,8 @@ def internet_conn_checker(self, mqtt_client: mqtt.MQTT, topic: str): if internet_connection: message['connection'] = True - # Broadcast via MQTT client - mqtt_client.send_message(topic, message) + # Broadcast via MQTT client + mqtt_client.send_message(topic, message) class NetworkModule: From 659b58e48456748e36209c613a35916f06fbb280 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Fri, 9 Aug 2024 22:10:24 +0200 Subject: [PATCH 3/8] add timeout arg to run_command --- framework/python/src/common/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/python/src/common/util.py b/framework/python/src/common/util.py index 0668d2776..7c31631fb 100644 --- a/framework/python/src/common/util.py +++ b/framework/python/src/common/util.py @@ -24,7 +24,7 @@ LOGGER = logger.get_logger('util') -def run_command(cmd, output=True): +def run_command(cmd, output=True, timeout=None): """Runs a process at the os level By default, returns the standard output and error output If the caller sets optional output parameter to False, @@ -36,7 +36,7 @@ def run_command(cmd, output=True): with subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE) as process: - stdout, stderr = process.communicate() + stdout, stderr = process.communicate(timeout) if process.returncode != 0 and output: err_msg = f'{stderr.strip()}. Code: {process.returncode}' From 241c5c53d07b2d6b2d570a17e44b6dd8df6ea1c7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Fri, 9 Aug 2024 22:20:41 +0200 Subject: [PATCH 4/8] move jobs to constructor --- framework/python/src/common/tasks.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/framework/python/src/common/tasks.py b/framework/python/src/common/tasks.py index f53e78239..a3d004785 100644 --- a/framework/python/src/common/tasks.py +++ b/framework/python/src/common/tasks.py @@ -44,15 +44,7 @@ def __init__( # Prevent scheduler warnings self._scheduler._logger.setLevel(logging.ERROR) - @asynccontextmanager - async def start(self, app: FastAPI): # pylint: disable=unused-argument - """Start background tasks - - Args: - app (FastAPI): app instance - """ - # Job that checks for changes in network adapters - self._scheduler.add_job( + self.adapters_checker_job = self._scheduler.add_job( func=self._testrun.get_net_orc().network_adapters_checker, kwargs={ 'mqtt_client': self._mqtt_client, @@ -63,7 +55,7 @@ async def start(self, app: FastAPI): # pylint: disable=unused-argument ) # add internet connection cheking job only in single-intf mode if 'single_intf' not in self._testrun.get_session().get_runtime_params(): - self._scheduler.add_job( + self.internet_shecker = self._scheduler.add_job( func=self._testrun.get_net_orc().internet_conn_checker, kwargs={ 'mqtt_client': self._mqtt_client, @@ -72,5 +64,14 @@ async def start(self, app: FastAPI): # pylint: disable=unused-argument trigger='interval', seconds=CHECK_INTERNET_PERIOD, ) + + @asynccontextmanager + async def start(self, app: FastAPI): # pylint: disable=unused-argument + """Start background tasks + + Args: + app (FastAPI): app instance + """ + # Job that checks for changes in network adapters self._scheduler.start() yield From f7bc207896cc9488ee1c3a73b8e189b4e73acee4 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Sat, 10 Aug 2024 15:49:14 +0200 Subject: [PATCH 5/8] fping for internet connection checking --- framework/python/src/net_orc/ip_control.py | 7 ++++--- modules/network/gateway/gateway.Dockerfile | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/framework/python/src/net_orc/ip_control.py b/framework/python/src/net_orc/ip_control.py index 04686f0cd..460a61858 100644 --- a/framework/python/src/net_orc/ip_control.py +++ b/framework/python/src/net_orc/ip_control.py @@ -239,9 +239,10 @@ def configure_container_interface(self, def ping_via_gateway(self, host): """Ping the host trough the gateway container""" - command = f'timeout 3 docker exec tr-ct-gateway ping -W 1 -c 1 {host}' - output = util.run_command(command) - if '0% packet loss' in output[0]: + + command = f'docker exec tr-ct-gateway fping -r0 -4 {host}' + output = util.run_command(command, output=True, timeout=1) + if 'alive' in output[0]: return True return False diff --git a/modules/network/gateway/gateway.Dockerfile b/modules/network/gateway/gateway.Dockerfile index 885e4a9f0..8d939d5b3 100644 --- a/modules/network/gateway/gateway.Dockerfile +++ b/modules/network/gateway/gateway.Dockerfile @@ -19,7 +19,7 @@ ARG MODULE_NAME=gateway ARG MODULE_DIR=modules/network/$MODULE_NAME # Install required packages -RUN apt-get update && apt-get install -y iptables isc-dhcp-client +RUN apt-get update && apt-get install -y iptables isc-dhcp-client fping # Copy over all configuration files COPY $MODULE_DIR/conf /testrun/conf From d00c295660dc8a4da761575e43dffcf452d52b4f Mon Sep 17 00:00:00 2001 From: Sofia Kurilova Date: Tue, 13 Aug 2024 10:29:31 +0200 Subject: [PATCH 6/8] Update internet connection when device is In Progress, Monitoring, Waiting for Device status (#677) * Update internet connection when device is In Progress, Monitoring, Waiting for Device status --- modules/ui/src/app/app.component.spec.ts | 7 +++--- modules/ui/src/app/app.component.ts | 1 - modules/ui/src/app/app.store.spec.ts | 23 +++-------------- modules/ui/src/app/app.store.ts | 29 +++------------------- modules/ui/src/app/store/actions.ts | 5 ++++ modules/ui/src/app/store/effects.spec.ts | 14 ++++++++++- modules/ui/src/app/store/effects.ts | 22 ++++++++++++++++ modules/ui/src/app/store/reducers.spec.ts | 13 ++++++++++ modules/ui/src/app/store/reducers.ts | 6 +++++ modules/ui/src/app/store/selectors.spec.ts | 7 ++++++ modules/ui/src/app/store/selectors.ts | 5 ++++ modules/ui/src/app/store/state.ts | 2 ++ 12 files changed, 83 insertions(+), 51 deletions(-) diff --git a/modules/ui/src/app/app.component.spec.ts b/modules/ui/src/app/app.component.spec.ts index e54eece26..df531c8b7 100644 --- a/modules/ui/src/app/app.component.spec.ts +++ b/modules/ui/src/app/app.component.spec.ts @@ -56,6 +56,7 @@ import { selectHasDevices, selectHasRiskProfiles, selectInterfaces, + selectInternetConnection, selectIsOpenStartTestrun, selectIsOpenWaitSnackBar, selectMenuOpened, @@ -124,10 +125,7 @@ describe('AppComponent', () => { 'focusFirstElementInContainer', ]); mockLiveAnnouncer = jasmine.createSpyObj('mockLiveAnnouncer', ['announce']); - mockMqttService = jasmine.createSpyObj([ - 'getNetworkAdapters', - 'getInternetConnection', - ]); + mockMqttService = jasmine.createSpyObj(['getNetworkAdapters']); TestBed.configureTestingModule({ imports: [ @@ -166,6 +164,7 @@ describe('AppComponent', () => { selectors: [ { selector: selectInterfaces, value: {} }, { selector: selectHasConnectionSettings, value: true }, + { selector: selectInternetConnection, value: true }, { selector: selectError, value: null }, { selector: selectMenuOpened, value: false }, { selector: selectHasDevices, value: false }, diff --git a/modules/ui/src/app/app.component.ts b/modules/ui/src/app/app.component.ts index e80f04ad0..2214b8927 100644 --- a/modules/ui/src/app/app.component.ts +++ b/modules/ui/src/app/app.component.ts @@ -83,7 +83,6 @@ export class AppComponent { this.appStore.getReports(); this.appStore.getTestModules(); this.appStore.getNetworkAdapters(); - this.appStore.getInternetConnection(); this.matIconRegistry.addSvgIcon( 'devices', this.domSanitizer.bypassSecurityTrustResourceUrl(DEVICES_LOGO_URL) diff --git a/modules/ui/src/app/app.store.spec.ts b/modules/ui/src/app/app.store.spec.ts index 7d114e8be..e26db7eb3 100644 --- a/modules/ui/src/app/app.store.spec.ts +++ b/modules/ui/src/app/app.store.spec.ts @@ -24,6 +24,7 @@ import { selectHasDevices, selectHasRiskProfiles, selectInterfaces, + selectInternetConnection, selectIsOpenWaitSnackBar, selectMenuOpened, selectReports, @@ -85,10 +86,7 @@ describe('AppStore', () => { mockFocusManagerService = jasmine.createSpyObj([ 'focusFirstElementInContainer', ]); - mockMqttService = jasmine.createSpyObj([ - 'getNetworkAdapters', - 'getInternetConnection', - ]); + mockMqttService = jasmine.createSpyObj(['getNetworkAdapters']); TestBed.configureTestingModule({ providers: [ @@ -98,6 +96,7 @@ describe('AppStore', () => { { selector: selectStatus, value: null }, { selector: selectIsOpenWaitSnackBar, value: false }, { selector: selectTestModules, value: MOCK_TEST_MODULES }, + { selector: selectInternetConnection, value: false }, ], }), { provide: TestRunService, useValue: mockService }, @@ -165,7 +164,7 @@ describe('AppStore', () => { isMenuOpen: true, interfaces: {}, settingMissedError: null, - hasInternetConnection: null, + hasInternetConnection: false, }); done(); }); @@ -307,19 +306,5 @@ describe('AppStore', () => { ); }); }); - - describe('getInternetConnection', () => { - it('should update store', done => { - mockMqttService.getInternetConnection.and.returnValue( - of({ connection: false }) - ); - appStore.getInternetConnection(); - - appStore.viewModel$.pipe(take(1)).subscribe(store => { - expect(store.hasInternetConnection).toEqual(false); - done(); - }); - }); - }); }); }); diff --git a/modules/ui/src/app/app.store.ts b/modules/ui/src/app/app.store.ts index 3584ec8d1..6e338968f 100644 --- a/modules/ui/src/app/app.store.ts +++ b/modules/ui/src/app/app.store.ts @@ -16,13 +16,14 @@ import { Injectable } from '@angular/core'; import { ComponentStore } from '@ngrx/component-store'; -import { tap, withLatestFrom } from 'rxjs/operators'; +import { tap } from 'rxjs/operators'; import { selectError, selectHasConnectionSettings, selectHasDevices, selectHasRiskProfiles, selectInterfaces, + selectInternetConnection, selectMenuOpened, selectReports, selectStatus, @@ -55,16 +56,13 @@ export const CONSENT_SHOWN_KEY = 'CONSENT_SHOWN'; export interface AppComponentState { consentShown: boolean; isStatusLoaded: boolean; - hasInternetConnection: boolean | null; systemStatus: TestrunStatus | null; } @Injectable() export class AppStore extends ComponentStore { private consentShown$ = this.select(state => state.consentShown); private isStatusLoaded$ = this.select(state => state.isStatusLoaded); - private hasInternetConnection$ = this.select( - state => state.hasInternetConnection - ); + private hasInternetConnection$ = this.store.select(selectInternetConnection); private hasDevices$ = this.store.select(selectHasDevices); private hasRiskProfiles$ = this.store.select(selectHasRiskProfiles); private reports$ = this.store.select(selectReports); @@ -102,13 +100,6 @@ export class AppStore extends ComponentStore { isStatusLoaded, })); - updateHasInternetConnection = this.updater( - (state, hasInternetConnection: boolean | null) => ({ - ...state, - hasInternetConnection, - }) - ); - setContent = this.effect(trigger$ => { return trigger$.pipe( tap(() => { @@ -170,19 +161,6 @@ export class AppStore extends ComponentStore { ); }); - getInternetConnection = this.effect(trigger$ => { - return trigger$.pipe( - exhaustMap(() => { - return this.testRunMqttService.getInternetConnection().pipe( - withLatestFrom(this.hasInternetConnection$), - tap(([{ connection }]) => { - this.updateHasInternetConnection(connection); - }) - ); - }) - ); - }); - private notifyAboutTheAdapters(adapters: SystemInterfaces) { this.notificationService.notify( `New network adapter(s) ${Object.keys(adapters).join(', ')} has been detected. You can switch to using it in the System settings menu` @@ -250,7 +228,6 @@ export class AppStore extends ComponentStore { consentShown: sessionStorage.getItem(CONSENT_SHOWN_KEY) !== null, isStatusLoaded: false, systemStatus: null, - hasInternetConnection: null, }); } } diff --git a/modules/ui/src/app/store/actions.ts b/modules/ui/src/app/store/actions.ts index 9235f980f..806618932 100644 --- a/modules/ui/src/app/store/actions.ts +++ b/modules/ui/src/app/store/actions.ts @@ -142,3 +142,8 @@ export const setTestModules = createAction( '[Shared] Set Test Modules', props<{ testModules: TestModule[] }>() ); + +export const updateInternetConnection = createAction( + '[Shared] Fetch internet connection', + props<{ internetConnection: boolean | null }>() +); diff --git a/modules/ui/src/app/store/effects.spec.ts b/modules/ui/src/app/store/effects.spec.ts index 9d7984dd7..7d33cc209 100644 --- a/modules/ui/src/app/store/effects.spec.ts +++ b/modules/ui/src/app/store/effects.spec.ts @@ -67,7 +67,10 @@ describe('Effects', () => { 'openSnackBar', ]); const mockMqttService: jasmine.SpyObj = - jasmine.createSpyObj('mockMqttService', ['getStatus']); + jasmine.createSpyObj('mockMqttService', [ + 'getStatus', + 'getInternetConnection', + ]); beforeEach(() => { testRunServiceMock = jasmine.createSpyObj('testRunServiceMock', [ @@ -88,6 +91,9 @@ describe('Effects', () => { ); testRunServiceMock.fetchProfiles.and.returnValue(of([])); testRunServiceMock.getHistory.and.returnValue(of([])); + mockMqttService.getInternetConnection.and.returnValue( + of({ connection: false }) + ); mockMqttService.getStatus.and.returnValue( of(MOCK_PROGRESS_DATA_IN_PROGRESS) @@ -445,6 +451,12 @@ describe('Effects', () => { done(); }); }); + + it('should call fetchInternetConnection for status "in progress"', () => { + effects.onFetchSystemStatusSuccess$.subscribe(() => { + expect(mockMqttService.getInternetConnection).toHaveBeenCalled(); + }); + }); }); describe('with status "waiting for device"', () => { diff --git a/modules/ui/src/app/store/effects.ts b/modules/ui/src/app/store/effects.ts index c5528c695..5fdb4d461 100644 --- a/modules/ui/src/app/store/effects.ts +++ b/modules/ui/src/app/store/effects.ts @@ -51,17 +51,20 @@ import { setStatus, setTestrunStatus, stopInterval, + updateInternetConnection, } from './actions'; import { takeUntil } from 'rxjs/internal/operators/takeUntil'; import { NotificationService } from '../services/notification.service'; import { Profile } from '../model/profile'; import { TestRunMqttService } from '../services/test-run-mqtt.service'; +import { InternetConnection } from '../model/topic'; const WAIT_TO_OPEN_SNACKBAR_MS = 60 * 1000; @Injectable() export class AppEffects { private statusSubscription: Subscription | undefined; + private internetSubscription: Subscription | undefined; private destroyWaitDeviceInterval$: Subject = new Subject(); checkInterfacesInConfig$ = createEffect(() => @@ -208,6 +211,7 @@ export class AppEffects { ofType(AppActions.stopInterval), tap(() => { this.statusSubscription?.unsubscribe(); + this.internetSubscription?.unsubscribe(); }) ); }, @@ -221,6 +225,7 @@ export class AppEffects { tap(({ systemStatus }) => { if (this.testrunService.testrunInProgress(systemStatus.status)) { this.pullingSystemStatusData(); + this.fetchInternetConnection(); } else if ( !this.testrunService.testrunInProgress(systemStatus.status) ) { @@ -358,6 +363,23 @@ export class AppEffects { } } + private fetchInternetConnection() { + if ( + this.internetSubscription === undefined || + this.internetSubscription?.closed + ) { + this.internetSubscription = this.testrunMqttService + .getInternetConnection() + .subscribe((internetConnection: InternetConnection) => { + this.store.dispatch( + updateInternetConnection({ + internetConnection: internetConnection.connection, + }) + ); + }); + } + } + constructor( private actions$: Actions, private testrunService: TestRunService, diff --git a/modules/ui/src/app/store/reducers.spec.ts b/modules/ui/src/app/store/reducers.spec.ts index 7d7d5219c..b6fe9d675 100644 --- a/modules/ui/src/app/store/reducers.spec.ts +++ b/modules/ui/src/app/store/reducers.spec.ts @@ -34,6 +34,7 @@ import { updateAdapters, updateError, updateFocusNavigation, + updateInternetConnection, } from './actions'; import { device, MOCK_TEST_MODULES } from '../mocks/device.mock'; import { MOCK_PROGRESS_DATA_CANCELLING } from '../mocks/testrun.mock'; @@ -314,4 +315,16 @@ describe('Reducer', () => { expect(state).not.toBe(initialState); }); }); + + describe('updateInternetConnection action', () => { + it('should update state', () => { + const initialState = initialSharedState; + const action = updateInternetConnection({ internetConnection: true }); + const state = fromReducer.sharedReducer(initialState, action); + const newState = { ...initialState, ...{ internetConnection: true } }; + + expect(state).toEqual(newState); + expect(state).not.toBe(initialState); + }); + }); }); diff --git a/modules/ui/src/app/store/reducers.ts b/modules/ui/src/app/store/reducers.ts index 9d8bc7cde..dfc54b11f 100644 --- a/modules/ui/src/app/store/reducers.ts +++ b/modules/ui/src/app/store/reducers.ts @@ -124,6 +124,12 @@ export const sharedReducer = createReducer( ...state, adapters, }; + }), + on(Actions.updateInternetConnection, (state, { internetConnection }) => { + return { + ...state, + internetConnection, + }; }) ); diff --git a/modules/ui/src/app/store/selectors.spec.ts b/modules/ui/src/app/store/selectors.spec.ts index b6c709c57..facc8bb74 100644 --- a/modules/ui/src/app/store/selectors.spec.ts +++ b/modules/ui/src/app/store/selectors.spec.ts @@ -33,6 +33,7 @@ import { selectStatus, selectSystemStatus, selectTestModules, + selectInternetConnection, } from './selectors'; describe('Selectors', () => { @@ -61,6 +62,7 @@ describe('Selectors', () => { reports: [], testModules: [], adapters: {}, + internetConnection: null, }, }; @@ -148,4 +150,9 @@ describe('Selectors', () => { const result = selectAdapters.projector(initialState); expect(result).toEqual({}); }); + + it('should select internetConnection', () => { + const result = selectInternetConnection.projector(initialState); + expect(result).toEqual(null); + }); }); diff --git a/modules/ui/src/app/store/selectors.ts b/modules/ui/src/app/store/selectors.ts index 9671bcd10..383fee1b9 100644 --- a/modules/ui/src/app/store/selectors.ts +++ b/modules/ui/src/app/store/selectors.ts @@ -108,3 +108,8 @@ export const selectAdapters = createSelector( selectAppState, (state: AppState) => state.shared.adapters ); + +export const selectInternetConnection = createSelector( + selectAppState, + (state: AppState) => state.shared.internetConnection +); diff --git a/modules/ui/src/app/store/state.ts b/modules/ui/src/app/store/state.ts index 63e0c5eff..76e2d3254 100644 --- a/modules/ui/src/app/store/state.ts +++ b/modules/ui/src/app/store/state.ts @@ -61,6 +61,7 @@ export interface SharedState { reports: TestrunStatus[]; testModules: TestModule[]; adapters: Adapters; + internetConnection: boolean | null; } export const initialAppComponentState: AppComponentState = { @@ -88,4 +89,5 @@ export const initialSharedState: SharedState = { reports: [], testModules: [], adapters: {}, + internetConnection: null, }; From 289ec34ef03e275ca6fa6b874a5f94734e9859a5 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Tue, 13 Aug 2024 14:16:52 +0200 Subject: [PATCH 7/8] check if interface physically connected --- framework/python/src/net_orc/network_orchestrator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index 89f7ed32d..a94bca89b 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -816,7 +816,7 @@ def internet_conn_checker(self, mqtt_client: mqtt.MQTT, topic: str): iface = self._session.get_internet_interface() # Check that an internet intf has been selected - if iface and iface in self._session.get_ifaces(): + if iface and iface in self._ip_ctrl.get_sys_interfaces(): # Ping google.com from gateway container internet_connection = self._ip_ctrl.ping_via_gateway( From 0ca35c519c9f7169291b95adec4197090aa33c24 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Wed, 14 Aug 2024 10:54:33 +0200 Subject: [PATCH 8/8] Revert "fping for internet connection checking" --- framework/python/src/net_orc/ip_control.py | 7 +++---- modules/network/gateway/gateway.Dockerfile | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/framework/python/src/net_orc/ip_control.py b/framework/python/src/net_orc/ip_control.py index 460a61858..04686f0cd 100644 --- a/framework/python/src/net_orc/ip_control.py +++ b/framework/python/src/net_orc/ip_control.py @@ -239,10 +239,9 @@ def configure_container_interface(self, def ping_via_gateway(self, host): """Ping the host trough the gateway container""" - - command = f'docker exec tr-ct-gateway fping -r0 -4 {host}' - output = util.run_command(command, output=True, timeout=1) - if 'alive' in output[0]: + command = f'timeout 3 docker exec tr-ct-gateway ping -W 1 -c 1 {host}' + output = util.run_command(command) + if '0% packet loss' in output[0]: return True return False diff --git a/modules/network/gateway/gateway.Dockerfile b/modules/network/gateway/gateway.Dockerfile index 8d939d5b3..885e4a9f0 100644 --- a/modules/network/gateway/gateway.Dockerfile +++ b/modules/network/gateway/gateway.Dockerfile @@ -19,7 +19,7 @@ ARG MODULE_NAME=gateway ARG MODULE_DIR=modules/network/$MODULE_NAME # Install required packages -RUN apt-get update && apt-get install -y iptables isc-dhcp-client fping +RUN apt-get update && apt-get install -y iptables isc-dhcp-client # Copy over all configuration files COPY $MODULE_DIR/conf /testrun/conf