Skip to content

Extend epic work item validation checks

Nicolas Dular requested to merge nd/extend-validation-checks into master

What does this MR do and why?

As we now sync more attributes to the work_item, this adds more checks to validate that the epic and the work item are in sync.

We now check for the hierarchy, the start_date, the due_date, and the related epic links.

This change also introduces the optional strict_equal parameter that is false by default now. When strict_equal is true we expect that all relationships are synced. This is the case when we have backfilled all data.

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.

Screenshots or screen recordings

How to set up and validate locally

  1. Restart rails-web and rails-background-job (background jobs often get stuck, and to register new events, rails needs to be restarted)

  2. Feature.enable(:validate_epic_work_item_sync)

  3. Feature.enable(:epic_creation_with_synced_work_item)

  4. Apply the diff to create a mismatch of data:

    diff --git a/ee/app/services/concerns/epics/sync_as_work_item.rb b/ee/app/services/concerns/epics/sync_as_work_item.rb
    index f9822034f2f2..c92193419293 100644
    --- a/ee/app/services/concerns/epics/sync_as_work_item.rb
    +++ b/ee/app/services/concerns/epics/sync_as_work_item.rb
    @@ -15,7 +15,7 @@ def create_work_item_for!(epic)
           service_response = ::WorkItems::CreateService.new(
             container: epic.group,
             current_user: current_user,
    -        params: create_params(epic)
    +        params: create_params(epic).merge(title: "WRONG SYNCED TITLE")
           ).execute_without_rate_limiting
    
           handle_response!(:create, service_response, epic)
    @@ -31,7 +31,7 @@ def update_work_item_for!(epic)
           service_response = ::WorkItems::UpdateService.new(
             container: epic.group,
             current_user: current_user,
    -        params: update_params(epic)
    +        params: update_params(epic).merge(description: "WRONG SYNCED DESCRIPTION")
           ).execute(epic.work_item)
    
           handle_response!(:update, service_response, epic)
  5. Watch the log tail -f log/epic_work_item_sync.log

  6. Create an epic

  7. Update an epic

  8. Watch the log printing out the mismatched attributes

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Nicolas Dular

Merge request reports