Add :timestamp to publish payload

Now we can track when a particular result occurred.
This commit is contained in:
Rick Bradley 2013-02-26 17:04:18 -06:00
Родитель 2fe56209a9
Коммит 3f4c37e92a
2 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -50,6 +50,8 @@ module Dat
def run
return run_control unless candidate? && enabled?
timestamp = Time.now
if control_runs_first?
control = observe_control
candidate = observe_candidate
@ -59,6 +61,7 @@ module Dat
end
payload = {
:timestamp => timestamp,
:candidate => candidate.payload,
:control => control.payload,
:first => control_runs_first? ? :control : :candidate

Просмотреть файл

@ -106,6 +106,8 @@ class DatScienceExperimentTest < MiniTest::Unit::TestCase
assert_equal "foo", payload[:experiment]
assert_equal :control, payload[:first]
assert (Time.now.to_i - payload[:timestamp].to_i) < 10
assert payload[:control][:duration]
assert_nil payload[:control][:exception]
assert_equal :foo, payload[:control][:value]