diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-06-05 12:35:21 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-06-05 12:35:21 +0000 |
commit | 40dc82f8628f597548a39a31bddf2aaccc7fc38c (patch) | |
tree | 2baf01a5a796d4eff948546178fe3608006cb86c /spec/support | |
parent | 049519e718d84f06af1510d2236a0819372fea56 (diff) | |
parent | 8f1f73d4e3ca82e3d449e478606f133d19ead7b1 (diff) | |
download | gitlab-ce-40dc82f8628f597548a39a31bddf2aaccc7fc38c.tar.gz |
Merge branch 'add-background-migrations-for-not-archived-traces' into 'master'
Add background migrations to archive legacy job traces
Closes #46642
See merge request gitlab-org/gitlab-ce!19194
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/trace/trace_helpers.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/support/trace/trace_helpers.rb b/spec/support/trace/trace_helpers.rb new file mode 100644 index 00000000000..c7802bbcb94 --- /dev/null +++ b/spec/support/trace/trace_helpers.rb @@ -0,0 +1,27 @@ +module TraceHelpers + def create_legacy_trace(build, content) + File.open(legacy_trace_path(build), 'wb') { |stream| stream.write(content) } + end + + def create_legacy_trace_in_db(build, content) + build.update_column(:trace, content) + end + + def legacy_trace_path(build) + legacy_trace_dir = File.join(Settings.gitlab_ci.builds_path, + build.created_at.utc.strftime("%Y_%m"), + build.project_id.to_s) + + FileUtils.mkdir_p(legacy_trace_dir) + + File.join(legacy_trace_dir, "#{build.id}.log") + end + + def archived_trace_path(job_artifact) + disk_hash = Digest::SHA2.hexdigest(job_artifact.project_id.to_s) + creation_date = job_artifact.created_at.utc.strftime('%Y_%m_%d') + + File.join(Gitlab.config.artifacts.path, disk_hash[0..1], disk_hash[2..3], disk_hash, + creation_date, job_artifact.job_id.to_s, job_artifact.id.to_s, 'job.log') + end +end |