Skip to content

[E2E] Harden project audit log spec for file export

John McDonnell requested to merge jmd/harden-project-audit-logs-spec into master

What does this MR do and why?

[E2E] Harden project audit log spec for file export

The spec for project audit logs for export file download relies on ProjectExportWor job in sidekiq being complete. The current implementation has a flake, as if the export isn't complete on time we don't retry or refresh the page so the download-export-link is never rendered

Fixes #433546 (closed)

How to set up and validate locally

I found it possible to reproduce this when a simulated delay was added to sidekiq

Simulate sidekiq delay
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index 8df12671f265..469daa53350f 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 module SidekiqLogArguments
   def self.enabled?
     Gitlab::Utils.to_boolean(ENV['SIDEKIQ_LOG_ARGUMENTS'], default: true)
@@ -32,7 +33,17 @@ def enable_semi_reliable_fetch_mode?
 
 enable_json_logs = Gitlab.config.sidekiq.log_format != 'text'
 
+class DelayedProcessingMiddleware
+  def call(_worker, _job, _queue)
+    sleep(3)
+    yield
+  end
+end
+
 Sidekiq.configure_server do |config|
+  config.server_middleware do |chain|
+    chain.add DelayedProcessingMiddleware
+  end
   config[:strict] = false
   config[:queues] = Gitlab::SidekiqConfig.expand_queues(config[:queues])

With the above applied, we should be able to reproduce the flake in the for export file download spec as noted in #433546 (closed), which appears to be resolved via this MR.

  • bundle exec rspec qa/specs/features/ee/browser_ui/10_govern/project/project_audit_logs_spec.rb:9

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by John McDonnell

Merge request reports