Project Import Testing: add unit tests for missing relations
Our current Project Import testing is already extensive, but it does not check all the relations we Import/Export.
Expanding those specs could help identify possible issues during the Import refactoring and make us more confident in our code.
For example, adding specs for ci_cd_settings
helped to identify the bug we introduced during the Import refactoring: !20174 (merged)
How do we currently test Import:
- Most of the specs are in:
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
- We restore the project from the fixture JSONs, e.g.
spec/fixtures/lib/gitlab/import_export/complex/project.json
(we use smaller versions as well though I am not sure if we should not merge them into one in the future). - These fixture JSONs are not "complete", they miss some particular relations (though they are pretty extensive)
I created a very rough test that compares all the relations described in import_export.yml
(our Import/Export schema) and those present in the fixtures: !19502 (diffs)
If some relations from import_export.yml
are missing in our fixtures, that means we are not testing against it and don't have "full coverage".
On the current master, we miss at least these relations (result of my test):
["error_tracking_setting", "external_pull_request", "external_pull_requests", "links", "metrics", "metrics_setting", "pipeline_schedules", "prometheus_metrics", "push_event_payload", "releases", "service_desk_setting", "timelogs", "unprotect_access_levels"]
I have auto_devops
and protected_environments
added here (will be extracted): !19502 (diffs)
Ideally, we want all of them added into fixture and, of course, being non-empty.
Biggest struggle / concern: it is not easy to understand how to enable particular features on local environment to make them appear in the export (to copy the data into the spec fixture).
Alternatively, we could get the representation from factories / creating objects in rails console, but I am not sure about its integrity.
Then, we want to have a spec that ensures the integrity of the fixtures: #39540 (closed)