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+
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:
- Make sure
Gitlab::CurrentSettings.should_check_namespace_plan?
returnsfalse
. - Make sure
Feature.enabled?(:automated_email_provision)
returnstrue
. - Upload a license into your GitLab instance that fulfills the following conditions:
- It's an Offline Cloud License.
- It's not for a trial.
- 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).
- Download the license usage data to update the ApplicationSetting flag introduced in !89016 (merged).
- 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)
- Verify
Gitlab::CurrentSettings.license_usage_data_exported?
returnstrue
and that there are two callouts for the feature nameUsers::Callout.where(feature_name: 'submit_license_usage_data_banner').count == 2
- Trigger the worker
Licenses::ResetSubmitLicenseUsageDataBannerWorker.new.perform
. - Verify
Gitlab::CurrentSettings.license_usage_data_exported?
returnsfalse
and that there are no callouts for the feature nameUsers::Callout.where(feature_name: 'submit_license_usage_data_banner').count == 0
. - 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.
-
I have evaluated the MR acceptance checklist for this MR.