Skip to content

Commit

Permalink
disable sending watchdogs during clock tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emiltin committed Dec 13, 2023
1 parent 3e6a447 commit 1381e9d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/site/core/disconnect_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
RSpec.describe 'Site::Core' do
include Validator::CommandHelpers

# Check that the site closed the connection as required when faced with
# various types of incorrect behaviour from our side.
Expand Down Expand Up @@ -45,8 +46,7 @@ def site_proxy.acknowledge original
end

log "Stop sending watchdogs, site should not disconnect"
def site.send_watchdog now=nil
end
stop_sending_watchdogs(site)
wait_task.wait
end
end
Expand Down
11 changes: 11 additions & 0 deletions spec/site/tlc/clock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# Tests related to the clock.
# When you set the clock, the adjusted time should be used
# everywhere you get back a timestamp.
# Note that watchdog messages can be used to synchronize the clock,
# which can interfere with our tests. So we disable sending watchdogs
# during tests.


describe 'Clock' do
CLOCK = Time.new 2020,9,29,17,29,51,'+00:00'
Expand Down Expand Up @@ -50,6 +54,7 @@
it 'is used for S0096 status response', sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
stop_sending_watchdogs(site) # avoid time synchronization by watchdogs
with_clock_set CLOCK do
status_list = { S0096: [
:year,
Expand Down Expand Up @@ -97,6 +102,7 @@
it 'is used for S0096 response timestamp', sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
stop_sending_watchdogs(site) # avoid time synchronization by watchdogs
with_clock_set CLOCK do
status_list = { S0096: [
:year,
Expand Down Expand Up @@ -134,6 +140,7 @@
it 'is used for aggregated status timestamp', core: '>=3.1.5', sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
stop_sending_watchdogs(site) # avoid time synchronization by watchdogs
with_clock_set CLOCK do
result = site.request_aggregated_status Validator.config['main_component'], collect!: {
timeout: Validator.config['timeouts']['status_response']
Expand All @@ -158,6 +165,7 @@
it 'is used for M0001 response timestamp', sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
stop_sending_watchdogs(site) # avoid time synchronization by watchdogs
with_clock_set CLOCK do
result = set_functional_position 'NormalControl'
collector = result[:collector]
Expand All @@ -180,6 +188,7 @@
it 'is used for M0104 response timestamp', sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
stop_sending_watchdogs(site) # avoid time synchronization by watchdogs
with_clock_set CLOCK do
result = set_functional_position 'NormalControl'
collector = result[:collector]
Expand All @@ -206,6 +215,7 @@
it 'is used for alarm timestamp', :programming, sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
stop_sending_watchdogs(site) # avoid time synchronization by watchdogs
with_clock_set CLOCK do # set clock
with_alarm_activated(task, site, 'A0302') do |alarm| # raise alarm, by activating input
alarm_time = Time.parse( alarm.attributes["aTs"] )
Expand All @@ -228,6 +238,7 @@
it 'is used for watchdog timestamp', sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
stop_sending_watchdogs(site) # avoid time synchronization by watchdogs
with_clock_set CLOCK do
log "Checking watchdog timestamp"
collector = RSMP::Collector.new site, task:task, type: "Watchdog", num: 1, timeout: Validator.config['timeouts']['watchdog']
Expand Down
7 changes: 7 additions & 0 deletions spec/support/command_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ def reset_clock
send_command_and_confirm @task, command_list, "Reset clock to #{now}"
end

def stop_sending_watchdogs(site)
# monkey-patch the site object by redefining
# the send_watchdog method to do nothing
def site.send_watchdog now=nil
end
end

def with_clock_set clock, &block
result = set_clock clock
yield result
Expand Down

0 comments on commit 1381e9d

Please sign in to comment.