Skip to content

Add logic to reset submit license usage data banner data

What does this MR do and why?

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/353804+

Depends on !89016 (merged) to be merged first

This change introduces a new callout feature name called submit_license_usage_data_banner. It will be used in an upcoming banner to ask an instance admin to submit seat utilization data via email. The banner can be dismissed after exporting the license usage data. But it will be reset each month relative to the license's start date. The new worker ResetSubmitLicenseUsageDataBannerWorker will run every day at midnight for a possible reset.

Screenshots or screen recordings

Does not apply.

How to set up and validate locally

You need to start a rails console to check some things:

  1. Make sure Gitlab::CurrentSettings.should_check_namespace_plan? returns false.
  2. Make sure Feature.enabled?(:automated_email_provision) returns true.
  3. Upload a license into your GitLab instance that fulfills the following conditions:
    1. It's an Offline Cloud License.
    2. It's not for a trial.
    3. The day of the start date equals today's day (if today is June 2nd, the license should start on the 2nd of any month).
  4. Download the license usage data to update the ApplicationSetting flag introduced in !89016 (merged).
  5. Create a callout entry for a random user and for your logged in user: Users::Callout.create(user: user, feature_name: 'submit_license_usage_data_banner', dismissed_at: Time.current)
  6. Verify Gitlab::CurrentSettings.license_usage_data_exported? returns true and that there are two callouts for the feature name Users::Callout.where(feature_name: 'submit_license_usage_data_banner').count == 2
  7. Trigger the worker Licenses::ResetSubmitLicenseUsageDataBannerWorker.new.perform.
  8. Verify Gitlab::CurrentSettings.license_usage_data_exported? returns false and that there are no callouts for the feature name Users::Callout.where(feature_name: 'submit_license_usage_data_banner').count == 0.
  9. If you repeat the test with a license that has the same conditions except for the starting date's day not matching today's date, the reset should not be executed.

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 Amparo Luna

Merge request reports