Create the project and user once in the stuck workflows cleanup spec

What does this MR do and why?

ee/spec/services/ai/duo_workflows/clean_stuck_workflows_service_spec.rb created a workflow per example with create(:duo_workflows_workflow, …) and let the factory build a new project (namespace, route, settings…) and a new user (plus its project membership) every time. The service under test only reads workflow.project and workflow.user for the audit and internal events, so the project and user now come from two let_it_be records and every create(:duo_workflows_workflow, …) receives them. The namespace-level example keeps its own group; no example or assertion changed.

Measured on this machine, whole file, same seed, nothing else running (EVENT_PROF=sql.active_record FPROF=1):

before after
examples 33 / 0 failures 33 / 0 failures
run time (after load) 36.4 s 25.0 s and 31.4 s (two runs; the machine was busier during the second)
SQL statements (sql.active_record events) 6,117 1,253
time in factories 11.9 s (183 factory calls) 3.4 s to 3.8 s

On the Test File Runtime Overview dashboard the file runs for about 24 s per default-branch pipeline (agent_foundations group, 30 days).

How to reproduce (on master)

EVENT_PROF=sql.active_record FPROF=1 bin/rspec ee/spec/services/ai/duo_workflows/clean_stuck_workflows_service_spec.rb --seed 1234
# Total events: 6117, Finished in 36.41 seconds, Time spent in factories: 00:11.899, 33 examples, 0 failures

How to verify (on this branch)

EVENT_PROF=sql.active_record FPROF=1 bin/rspec ee/spec/services/ai/duo_workflows/clean_stuck_workflows_service_spec.rb --seed 1234
# Total events: 1253, Finished in 25.0 seconds (31.41 s in a second run), Time spent in factories: 00:03.404, 33 examples, 0 failures

bundle exec rubocop ee/spec/services/ai/duo_workflows/clean_stuck_workflows_service_spec.rb
# no offenses detected

References

Related to #630519 Related to &23524

Merge request reports

Loading
Loading