X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5aecf0f1c591bc1f473b6bb56715ce8db5013268..0eb72b526bf8bbb011551ecf019f604e17a534f1:/services/api/lib/simulate_job_log.rb diff --git a/services/api/lib/simulate_job_log.rb b/services/api/lib/simulate_job_log.rb index fc124c8f77..abcf42eaa7 100644 --- a/services/api/lib/simulate_job_log.rb +++ b/services/api/lib/simulate_job_log.rb @@ -1,4 +1,11 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + +require 'current_api_client' + module SimulateJobLog + include CurrentApiClient def replay(filename, multiplier = 1, simulated_job_uuid = nil) raise "Environment must be development or test" unless [ 'test', 'development' ].include? ENV['RAILS_ENV'] @@ -8,6 +15,12 @@ module SimulateJobLog actual_start_time = Time.now log_start_time = nil + if simulated_job_uuid and (job = Job.where(uuid: simulated_job_uuid).first) + job_owner_uuid = job.owner_uuid + else + job_owner_uuid = system_user_uuid + end + act_as_system_user do File.open(filename).each.with_index do |line, index| cols = {} @@ -34,9 +47,9 @@ module SimulateJobLog modified_elapsed_time = log_elapsed_time / multiplier pause_time = modified_elapsed_time - actual_elapsed_time sleep pause_time if pause_time > 0 - # output log entry for debugging and create it in the current environment's database - puts "#{index} #{cols.to_yaml}\n" + Log.new({ + owner_uuid: job_owner_uuid, event_at: Time.zone.local_to_utc(cols[:timestamp]), object_uuid: cols[:job_uuid], event_type: cols[:event_type],