Skip to content

Fix a flaky spec in the NPM package presenter

David Fernandez requested to merge 349871-fix-npm-flaky-spec into master

🎈 Context

It seems that !76767 (merged) introduced a flaky spec on the NPM package presenter.

Basically, we have a feature flag that controls if package files in pending_destruction status are returned by the presenter or not.

  1. When the feature flag is enabled, they are not returned.
  2. When they are disabled, they are.

We have a spec for (2.). The spec is as simple as:

  • add a pending_destruction package file to the existing package
  • run the presenter

That second step should consider only the most recent package files, in this case the pending_destruction package file should be returned.

It seems that it's not always the case and this leads to a flaky spec. That's issue #349871 (closed).

🔍 What does this MR do and why?

A quick fix here is to remove all the package files except the pending_destruction package file from the considered package. This way, the presenter is guaranteed to returned the expected package file.

This fix is not that great but the spec that is failing is part of the code that will be removed/cleaned up along with the feature flag

📸 Screenshots or screen recordings

n / a

🛃 How to set up and validate locally

From #349871 (comment 806506959):

$ bin/rspec spec/models/clusters/platforms/kubernetes_spec.rb spec/services/packages/maven/metadata/create_versions_xml_service_spec.rb spec/models/operations/feature_flags/strategy_spec.rb spec/lib/gitlab/ci/templates/templates_spec.rb spec/presenters/packages/npm/package_presenter_spec.rb

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by David Fernandez

Merge request reports