Geofence

These scenarios check the basic GPS functions operate correctly.

Test Geofence

Description

Test suite to check geofence sub-service. Geofence service acts as a tcp client for the GPS server. In this scenario, two zones with an alarm each one will be used. Also, the test will check the three possible stages of the zones: no data yet, data and no coverage. The purpose of this test is validate if the alarms are activated or deactivated after a certain time when the zones go through the different stages.

Scenario

Step 1: Set the following configuration in DUT0 :

set controllers gps gps0
set interfaces ethernet eth2 address 10.0.0.1/24
set service gps gps0 geofence zone 1 alarm ZONE1
set service gps gps0 geofence zone 1 coverage-fail-state false-time-true
set service gps gps0 geofence zone 1 coverage-fail-state-time '00:00:03'
set service gps gps0 geofence zone 1 initial-state false
set service gps gps0 geofence zone 1 initial-state-time '00:00:03'
set service gps gps0 geofence zone 1 latitude 40º35.8833N to 40º35.9683N
set service gps gps0 geofence zone 1 longitude 3º43.01W to 3º42.9116W
set service gps gps0 geofence zone 1 time-to-false '00:00:03'
set service gps gps0 geofence zone 1 time-to-true '00:00:03'
set service gps gps0 geofence zone 2 alarm ZONE2
set service gps gps0 geofence zone 2 coverage-fail-state false-time-true
set service gps gps0 geofence zone 2 coverage-fail-state-time '00:00:03'
set service gps gps0 geofence zone 2 initial-state true
set service gps gps0 geofence zone 2 initial-state-time '00:00:03'
set service gps gps0 geofence zone 2 latitude 40º35.8466N to 40º35.8833N
set service gps gps0 geofence zone 2 longitude 3º42.9500W to 3º42.8866W
set service gps gps0 geofence zone 2 time-to-false '00:00:03'
set service gps gps0 geofence zone 2 time-to-true '00:00:03'
set service gps gps0 log-level warning
set service gps gps0 source gps0
set system alarm ZONE1
set system alarm ZONE2
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Note

For obtain the times, we need the log traces from syslog, so the traces will be redirected to a file.

Step 2: Modify the following configuration lines in DUT0 :

set system syslog file gps archive size 5000
set system syslog file gps filter filter_gps app osdx-geofence
set system syslog file gps filter filter_gps level warning

Step 3: Run command file show running://log/user/gps/gps at DUT0 and expect this output:

Show output
2026-03-06 17:46:42.699681 user-warning , osdx-geofence[525843]:  No GPS data yet
2026-03-06 17:46:42.700930 user-warning , osdx-geofence[525843]:  Alarm ZONE2 has been activated because of no data yet after 0.000000 in zone with id 2
2026-03-06 17:46:44.815725 user-warning , osdx-geofence[525843]:  Receiving GPS data after 2.115623 seconds
2026-03-06 17:46:46.418496 user-warning , osdx-geofence[525843]:  Entering zone with id 1
2026-03-06 17:46:46.418617 user-warning , osdx-geofence[525843]:  Leaving zone with id 2
2026-03-06 17:46:49.424280 user-warning , osdx-geofence[525843]:  Alarm ZONE1 has been activated because of position after 3.005147 in zone with id 1
2026-03-06 17:46:49.424676 user-warning , osdx-geofence[525843]:  Alarm ZONE2 has been deactivated because of position after 3.005147 in zone with id 2
2026-03-06 17:46:49.823827 user-warning , osdx-geofence[525843]:  Coverage has been lost
2026-03-06 17:46:49.831598 user-warning , osdx-geofence[525843]:  Alarm ZONE1 has been deactivated because of no coverage after 0.000000 in zone with id 1
2026-03-06 17:46:52.836005 user-warning , osdx-geofence[525843]:  Alarm ZONE1 has been activated because of no coverage after 3.011144 in zone with id 1
2026-03-06 17:46:52.837586 user-warning , osdx-geofence[525843]:  Alarm ZONE2 has been activated because of no coverage after 3.011144 in zone with id 2

Step 4: Run command system alarm ZONE1 show log at DUT0 and expect this output:

Show output
----------------------------------------
              Date                Status
----------------------------------------
2026-03-06 17:46:49.423632+00:00  true
2026-03-06 17:46:49.831255+00:00  false
2026-03-06 17:46:52.835333+00:00  true

Step 5: Run command system alarm ZONE2 show log at DUT0 and expect this output:

Show output
----------------------------------------
              Date                Status
----------------------------------------
2026-03-06 17:46:42.698242+00:00  false
2026-03-06 17:46:42.700605+00:00  true
2026-03-06 17:46:49.424411+00:00  false
2026-03-06 17:46:52.837284+00:00  true

Note

When an alarm is off, it means that the device is outside the zone and when is on, the device is inside the zone.

Based on the configuration, alarm for zone 2 should be activated after 0s approx because of no data yet. So the time to take into account is from message “No GPS data yet” to “Alarm ZONE2 has been activated because of no data yet” and compare it to the time when the alarm was activated. The times used are Time 1 and Time 3 (when the alarm was already launched).

From syslog:

Time 1: 2026-03-06 17:46:42.699681 user-warning , osdx-geofence[525843]:  No GPS data yet
Time 2: 2026-03-06 17:46:42.700930 user-warning , osdx-geofence[525843]:  Alarm ZONE2 has been activated because of no data yet after 0.000000 in zone with id 2

From log of the alarm ZONE2:

Time 3: 17:46:42.700605+00:00  true

Note

The comparission of times in the test are made calculating the total amount of seconds including microseconds.

First time is 64002.700605 and second time is 64002.699681, the difference is 0.0009240 and the aproximation is 0.0 which means that the alarm was activated almost immediately.

Note

It’s not possible to obtain exactly times like 3.000 seconds because of computational time.

A message like “Alarm ZONE1 has been deactivated because of no data yet” shouldn’t appear because initial state of the device is been outside the zone and the initial state of the alarm is been deactivated.

Once the GPS module is receiving data, the coordiantes will belong to zone 1 for more that 3 seconds so alarm for zone 1 should be activated after 3s approx. The time to take into account is from message “Entering zone with id 1” to “Alarm ZONE1 has been activated because of position” and compare it to the time the alarm was activated. The times used are Time 1 and Time 3 (when the alarm was already launched).

From syslog:

Time 1: 2026-03-06 17:46:46.418496 user-warning , osdx-geofence[525843]:  Entering zone with id 1
Time 2: 2026-03-06 17:46:49.424280 user-warning , osdx-geofence[525843]:  Alarm ZONE1 has been activated because of position after 3.005147 in zone with id 1

From log of the alarm ZONE1:

Time 3: 17:46:49.423632+00:00  true

Calculate operation 64009.423632-64006.418496 and check if result is greater or equal to 2.9 and smaller or equal to 3.1:

64009.423632-64006.418496=3.0051360

Once the GPS module is receiving data, the coordinates will not belong to zone 2 for more that 3 seconds so alarm for zone 2 should be deactivated after 3s approx. The time to take into account is from message “Leaving zone with id 2” to “Alarm ZONE2 has been deactivated because of position” and compare it to the time the alarm was deactivated. The times used are Time 1 and Time 3 (when the alarm was already launched). From syslog:

Time 1: 2026-03-06 17:46:46.418617 user-warning , osdx-geofence[525843]:  Leaving zone with id 2
Time 2: 2026-03-06 17:46:49.424676 user-warning , osdx-geofence[525843]:  Alarm ZONE2 has been deactivated because of position after 3.005147 in zone with id 2

From log of the alarm ZONE2:

Time 3: 17:46:49.424411+00:00  false

Calculate operation 64009.424411-64006.418617 and check if result is greater or equal to 2.9 and smaller or equal to 3.1:

64009.424411-64006.418617=3.0057940

Last stage of the zones is to lose the coverage. Alarm for zone 1 should be deactivated after 0s. The time to take into account is from mesage “Coverage has been lost” to “Alarm ZONE1 has been deactivated because of no coverage”. The times used are Time 1 and Time 3 (when the alarm was already launched).

From syslog:

Time 1: 2026-03-06 17:46:49.823827 user-warning , osdx-geofence[525843]:  Coverage has been lost
Time 2: 2026-03-06 17:46:49.831598 user-warning , osdx-geofence[525843]:  Alarm ZONE1 has been deactivated because of no coverage after 0.000000 in zone with id 1

From log of the alarm ZONE2:

Time 3: 17:46:49.831255+00:00  false

First time is 64009.831255 and second time is 64009.823827, the difference is 0.0074280 and the aproximation is 0.0 which means that the alarm was deactivated almost immediately.

Alarm for zone 1 should be activated after 3s aprox. The time to take into account is from mesage “Coverage has been lost” to “Alarm ZONE1 has been activated because of no coverage” and compare it to the time the alarm was activated. The times used are Time 1 and Time 3 (when the alarm was already launched).

From syslog:

Time 1: 2026-03-06 17:46:49.823827 user-warning , osdx-geofence[525843]:  Coverage has been lost
Time 2: 2026-03-06 17:46:52.836005 user-warning , osdx-geofence[525843]:  Alarm ZONE1 has been activated because of no coverage after 3.011144 in zone with id 1

From log of the alarm ZONE1:

Time 3: 17:46:52.835333+00:00  true

Calculate operation 64012.835333-64009.823827 and check if result is greater or equal to 2.9 and smaller or equal to 3.1:

64012.835333-64009.823827=3.0115060

A message like “Alarm ZONE2 has been deactivated because of no coverage” shouldn’t appear because the device was outside zone 2 before losing the coverage so alarm is already off. Alarm for zone 2 should be activated after 3s aprox. The time to take into account is from mesage “Coverage has been lost” to “Alarm ZONE2 has been activated because of no coverage” and compare it to the time the alarm was activated. The times used are Time 1 and Time 3 (when the alarm was already launched).

From syslog:

Time 1: 2026-03-06 17:46:49.823827 user-warning , osdx-geofence[525843]:  Coverage has been lost
Time 2: 2026-03-06 17:46:52.837586 user-warning , osdx-geofence[525843]:  Alarm ZONE2 has been activated because of no coverage after 3.011144 in zone with id 2

From log of the alarm ZONE2:

Time 3: 17:46:52.837284+00:00  true

Calculate operation 64012.837284-64009.823827 and check if result is greater or equal to 2.9 and smaller or equal to 3.1:

64012.837284-64009.823827=3.0134570