Skip to content

Fix flaky DAST profile schedule audit spec

Sean McGivern requested to merge fix-flaky-dast-profile-schedule-audit-spec into master

In some conditions - the most trivial of which are when this spec is run in isolation with a clean test database - the profile schedule and profile created by this spec could have the same ID, in different tables. The spec would then find the wrong audit event in the audit events table, because it was looking up only by target_id, and fail as a result.

Simple failure reproduction:

bundle exec rake db:test:prepare && bundle exec rspec ee/spec/services/app_sec/dast/profiles/create_service_spec.rb:104

Longer reproduction:

bundle exec rake db:test:prepare && bundle exec rspec ee/spec/workers/app_sec/dast/profile_schedule_worker_spec.rb ee/spec/services/app_sec/dast/profiles/update_service_spec.rb ee/spec/lib/gitlab/ci/templates/dast_latest_gitlab_ci_yaml_spec.rb ee/spec/graphql/mutations/dast/profiles/update_spec.rb ee/spec/services/app_sec/dast/profiles/create_service_spec.rb

For #349295 (closed).

Edited by Sean McGivern

Merge request reports