Module: QAT::Cucumber::Time
Overview
Helper methods for time sync
Constant Summary collapse
- MANDATORY_KEYS =
Mandatory keys for time sync
[:sync]
Instance Method Summary collapse
-
#set_time_zone(time_zone) ⇒ Object
Sets the time zone.
-
#start_time_sync(target, sync_options) ⇒ Object
Does the time sync with the target host.
-
#time_sync ⇒ Object
Does the time synchronization between the host running tests and a target host.
-
#validate_time_options ⇒ Object
validates that the necessary options are present.
Instance Method Details
#set_time_zone(time_zone) ⇒ Object
Sets the time zone
50 51 52 |
# File 'lib/qat/cucumber/time.rb', line 50 def set_time_zone(time_zone) QAT::Time.zone = time_zone if time_zone end |
#start_time_sync(target, sync_options) ⇒ Object
Does the time sync with the target host
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/qat/cucumber/time.rb', line 37 def start_time_sync(target, ) QAT::Time.synchronize(*target) rescue => exception if [:kill_if_failed] raise else log.warn { "Synchronization failed but proceeding anyway! [(#{exception.class}) #{exception.}]" } log.debug exception end end |
#time_sync ⇒ Object
Does the time synchronization between the host running tests and a target host
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/qat/cucumber/time.rb', line 12 def time_sync time = = time[:sync] log.info { "Syncing with host #{[:host]}." } target = .values_at(:host, :method, :opts) start_time_sync(target, ) set_time_zone(time[:zone]) end |
#validate_time_options ⇒ Object
validates that the necessary options are present
25 26 27 28 29 30 31 32 |
# File 'lib/qat/cucumber/time.rb', line 25 def time = QAT.configuration[:time].deep_symbolize_keys missing = MANDATORY_KEYS - time.keys raise InvalidConfiguration.new "Time configuration is not valid! Missing: #{missing.join(', ')}" if missing.any? time end |