Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
0c2b535267
commit
b1238272e1
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
BackgroundMigration/AvoidSilentRescueExceptions:
|
||||
Exclude:
|
||||
- 'lib/gitlab/background_migration/backfill_imported_issue_search_data.rb'
|
||||
- 'lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb'
|
||||
- 'lib/gitlab/background_migration/populate_vulnerability_dismissal_fields.rb'
|
||||
- 'lib/gitlab/background_migration/reset_status_on_container_repositories.rb'
|
||||
- 'lib/gitlab/background_migration/migrate_remediations_for_vulnerability_findings.rb'
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
# Cop supports --autocorrect.
|
||||
Style/ZeroLengthPredicate:
|
||||
Exclude:
|
||||
- 'spec/requests/api/graphql/mutations/admin/sidekiq_queues/delete_jobs_spec.rb'
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveUsersStateDuplicatedIndex < Gitlab::Database::Migration[2.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
milestone '16.7'
|
||||
|
||||
INDEX_NAME = :index_users_on_state
|
||||
TABLE_NAME = :users
|
||||
|
||||
def up
|
||||
remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index TABLE_NAME, :state, name: INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1 @@
|
|||
0d9960793ccff476b47508bb9664603573d9bdf09d6ed4c1f341de44855ca4c9
|
||||
|
|
@ -34765,8 +34765,6 @@ CREATE INDEX index_users_on_require_two_factor_authentication_from_group ON user
|
|||
|
||||
CREATE UNIQUE INDEX index_users_on_reset_password_token ON users USING btree (reset_password_token);
|
||||
|
||||
CREATE INDEX index_users_on_state ON users USING btree (state);
|
||||
|
||||
CREATE INDEX index_users_on_state_and_user_type ON users USING btree (state, user_type);
|
||||
|
||||
CREATE UNIQUE INDEX index_users_on_static_object_token ON users USING btree (static_object_token);
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ We are conducting deeper research around this specific problem in [issue 420804]
|
|||
|
||||
The following iteration plan outlines how we intend to arrive at the Organization MVC. We are following the guidelines for [Experiment, Beta, and Generally Available features](../../../policy/experiment-beta-support.md).
|
||||
|
||||
### Iteration 1: Organization Prototype (FY24Q4)
|
||||
### Iteration 1: [Organization Prototype](https://gitlab.com/groups/gitlab-org/-/epics/10018) (FY24Q2-FY25Q1)
|
||||
|
||||
In iteration 1, we introduce the concept of an Organization as a way to group top-level Groups together. Support for Organizations does not require any [Cells](../cells/index.md) work, but having them will make all subsequent iterations of Cells simpler. The goal of iteration 1 will be to generate a prototype that can be used by GitLab teams to test basic functionality within an Organization. The prototype contains the following functionality:
|
||||
|
||||
|
|
@ -314,8 +314,9 @@ In iteration 1, we introduce the concept of an Organization as a way to group to
|
|||
- A User can be part of multiple Organizations.
|
||||
- Users can navigate between the different Organizations they are part of.
|
||||
- Any User within or outside of an Organization can be invited to Groups and Projects contained by the Organization.
|
||||
- Organizations are not fully isolated. We aim to complete [phase 1 of Organization isolation](https://gitlab.com/groups/gitlab-org/-/epics/11837), with the goal to `define sharding_key` and `desired_sharding_key` rules.
|
||||
|
||||
### Iteration 2: Organization MVC Experiment (FY25Q1)
|
||||
### Iteration 2: [Organization MVC Experiment](https://gitlab.com/groups/gitlab-org/-/epics/10650) (FY25Q2)
|
||||
|
||||
In iteration 2, an Organization MVC Experiment will be released. We will test the functionality with a select set of customers and improve the MVC based on these learnings. The MVC Experiment contains the following functionality:
|
||||
|
||||
|
|
@ -325,7 +326,7 @@ In iteration 2, an Organization MVC Experiment will be released. We will test th
|
|||
- Forking across Organizations will be defined.
|
||||
- [Organization Isolation](isolation.md) will be finished to meet the requirements of the initial set of customers
|
||||
|
||||
### Iteration 3: Organization MVC Beta (FY25Q1)
|
||||
### Iteration 3: [Organization MVC Beta](https://gitlab.com/groups/gitlab-org/-/epics/10651) (FY25Q3)
|
||||
|
||||
In iteration 3, the Organization MVC Beta will be released.
|
||||
|
||||
|
|
@ -334,9 +335,9 @@ In iteration 3, the Organization MVC Beta will be released.
|
|||
- Organization Owners can create, edit and delete Groups from the Groups overview.
|
||||
- Organization Owners can create, edit and delete Projects from the Projects overview.
|
||||
- The Organization URL path can be changed.
|
||||
- [Organization Isolation](isolation.md) is available.
|
||||
- Organizations are fully isolated. We aim to complete [phase 2 of Organization isolation](https://gitlab.com/groups/gitlab-org/-/epics/11838), with the goal to implement isolation constraints.
|
||||
|
||||
### Iteration 4: Organization MVC GA (FY25Q2)
|
||||
### Iteration 4: [Organization MVC GA](https://gitlab.com/groups/gitlab-org/-/epics/10652) (FY25Q3)
|
||||
|
||||
In iteration 4, the Organization MVC will be rolled out.
|
||||
|
||||
|
|
@ -346,6 +347,7 @@ After the initial rollout of Organizations, the following functionality will be
|
|||
|
||||
1. [Users can transfer existing top-level Groups into Organizations](https://gitlab.com/groups/gitlab-org/-/epics/11711).
|
||||
1. [Organizations can invite Users](https://gitlab.com/gitlab-org/gitlab/-/issues/420166).
|
||||
1. Complete [phase 3 of Organization isolation](https://gitlab.com/groups/gitlab-org/-/epics/11839), with the goal to allow customers to move existing namespaces out of the default Organization into a new Organization.
|
||||
1. Internal visibility will be made available on Organizations that are part of GitLab.com.
|
||||
1. Restrict inviting Users outside of the Organization.
|
||||
1. Enterprise Users will be made available at the Organization level.
|
||||
|
|
@ -368,12 +370,14 @@ We propose the following steps to successfully roll out Organizations:
|
|||
|
||||
- Phase 1: Rollout
|
||||
- Organizations will be rolled out using the concept of a `default Organization`. All existing top-level groups on GitLab.com are already part of this `default Organization`. The Organization UI is feature flagged and can be enabled for a specific set of users initially, and the global user pool at the end of this phase. This way, users will already become familiar with the concept of an Organization and the Organization UI. No features would be impacted by enabling the `default Organization`. See issue [#418225](https://gitlab.com/gitlab-org/gitlab/-/issues/418225) for more details.
|
||||
- Phase 2: Migrations
|
||||
- GitLab, the organization, will be the first one to bud off into a separate Organization. We move all top-level groups that belong to GitLab into the new GitLab Organization, including the `gitLab-org` and `gitLab-com` top-level Groups. See issue [#418228](https://gitlab.com/gitlab-org/gitlab/-/issues/418228) for more details.
|
||||
- Existing customers can create their own Organization. Creation of an Organization remains optional.
|
||||
- Phase 3: Onboarding changes
|
||||
- New customers will only have the option to start their journey by creating an Organization.
|
||||
- Phase 4: Targeted efforts
|
||||
- Phase 2: Temporary onboarding changes
|
||||
- New customers who were identified to not need personal namespaces and forking can create new Organizations from scratch. Top-level Groups cannot be migrated yet into a new Organization, so all content must be newly created in an Organization.
|
||||
- Phase 3: Migration of existing customers
|
||||
- GitLab, the organization, will be the first one to bud off into a separate Organization. We move all top-level Groups that belong to GitLab into the new GitLab Organization, including the `gitLab-org` and `gitLab-com` top-level Groups. See issue [#418228](https://gitlab.com/gitlab-org/gitlab/-/issues/418228) for more details.
|
||||
- Once top-level Group transfer from the default Organization to another Organization becomes available, existing customers can create their own Organization and migrate their top-level Groups into it. Creation of an Organization remains optional.
|
||||
- Phase 4: Permanent onboarding changes
|
||||
- All new customers will only have the option to start their journey by creating a new Organization.
|
||||
- Phase 5: Targeted efforts
|
||||
- Organizations are promoted, e.g. via a banner message, targeted conversations with large customers via the CSMs. Creating a separate Organization will remain a voluntary action.
|
||||
- We increase the value proposition of the Organization, for instance by moving billing to the Organization level to provide incentives for more customers to move to a separate Organization. Adoption will be monitored.
|
||||
|
||||
|
|
|
|||
|
|
@ -272,16 +272,20 @@ To use exact times on the GitLab UI:
|
|||
|
||||
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/15206) in GitLab 16.6.
|
||||
|
||||
You can customize the format used to display times of activities on your group and project overview pages and user profiles. You can display times as:
|
||||
You can customize the format used to display times of activities on your group and project overview pages and user
|
||||
profiles. You can display times as:
|
||||
|
||||
- 12 hour format. For example: `2:34 PM`.
|
||||
- 24 hour format. For example: `14:34`.
|
||||
|
||||
You can also follow your system's setting.
|
||||
|
||||
To customize the time format:
|
||||
|
||||
1. On the left sidebar, select your avatar.
|
||||
1. Select **Preferences** > **Time preferences**.
|
||||
1. In **Time format**, select either the **12-hour** or **24-hour** option.
|
||||
1. Select **Preferences**.
|
||||
1. Go to the **Time preferences** section.
|
||||
1. Under **Time format**, select either the **System**, **12-hour**, or **24-hour** option.
|
||||
1. Select **Save changes**.
|
||||
|
||||
## User identities in CI job JSON web tokens
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ info: To determine the technical writer assigned to the Stage/Group associated w
|
|||
|
||||
# Import your project from Bitbucket Cloud to GitLab **(FREE ALL)**
|
||||
|
||||
NOTE:
|
||||
The Bitbucket Cloud importer works only with [Bitbucket.org](https://bitbucket.org/), not with Bitbucket
|
||||
Server (aka Stash). If you are trying to import projects from Bitbucket Server, use
|
||||
[the Bitbucket Server importer](bitbucket_server.md).
|
||||
> Parallel imports from Bitbucket Cloud [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/412614) in GitLab 16.6 [with a flag](../../../administration/feature_flags.md) named `bitbucket_parallel_importer`. Disabled by default.
|
||||
|
||||
Import your projects from Bitbucket Cloud to GitLab with minimal effort.
|
||||
Import your projects from Bitbucket Cloud to GitLab.
|
||||
|
||||
FLAG:
|
||||
On self-managed GitLab, parallel imports are not available. Parallel imports can help when importing large projects.
|
||||
To make parallel imports available, an administrator can [enable the feature flag](../../../administration/feature_flags.md)
|
||||
named `bitbucket_parallel_importer`. On GitLab.com, this feature is available.
|
||||
|
||||
The Bitbucket importer can import:
|
||||
|
||||
|
|
@ -30,6 +32,11 @@ When importing:
|
|||
- Repository public access is retained. If a repository is private in Bitbucket, it's created as
|
||||
private in GitLab as well.
|
||||
|
||||
NOTE:
|
||||
The Bitbucket Cloud importer works only with [Bitbucket.org](https://bitbucket.org/), not with Bitbucket
|
||||
Server (aka Stash). If you are trying to import projects from Bitbucket Server, use
|
||||
[the Bitbucket Server importer](bitbucket_server.md).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
> Requirement for Maintainer role instead of Developer role introduced in GitLab 16.0 and backported to GitLab 15.11.1 and GitLab 15.10.5.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module Gitlab
|
|||
def perform
|
||||
each_sub_batch do |sub_batch|
|
||||
update_search_data(sub_batch)
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
rescue ActiveRecord::StatementInvalid => e # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592
|
||||
raise unless e.cause.is_a?(PG::ProgramLimitExceeded) && e.message.include?('string is too long for tsvector')
|
||||
|
||||
update_search_data_individually(sub_batch)
|
||||
|
|
@ -44,7 +44,7 @@ module Gitlab
|
|||
relation.pluck(:id).each do |issue_id|
|
||||
update_search_data(relation.klass.where(id: issue_id))
|
||||
sleep(pause_ms * 0.001)
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
rescue ActiveRecord::StatementInvalid => e # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592
|
||||
raise unless e.cause.is_a?(PG::ProgramLimitExceeded) && e.message.include?('string is too long for tsvector')
|
||||
|
||||
logger.error(
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ module Gitlab
|
|||
def migrate_remediations(findings, existing_links)
|
||||
findings.each do |finding|
|
||||
create_links(build_links_from(finding, existing_links))
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
rescue ActiveRecord::StatementInvalid => e # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592
|
||||
logger.error(
|
||||
message: e.message,
|
||||
class: self.class.name,
|
||||
|
|
@ -76,7 +76,7 @@ module Gitlab
|
|||
return [] if parsed_links.blank?
|
||||
|
||||
parsed_links.select { |link| link.try(:[], 'url').present? }.uniq
|
||||
rescue JSON::ParserError => e
|
||||
rescue JSON::ParserError => e # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592
|
||||
logger.warn(
|
||||
message: e.message,
|
||||
class: self.class.name
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ module Gitlab
|
|||
|
||||
create_finding_remediations(finding.id, result_ids)
|
||||
end
|
||||
rescue StandardError => e
|
||||
rescue StandardError => e # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592
|
||||
logger.error(
|
||||
message: e.message,
|
||||
class: self.class.name,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ module Gitlab
|
|||
|
||||
def populate_for(vulnerability)
|
||||
log_warning(vulnerability) unless vulnerability.copy_dismissal_information
|
||||
rescue StandardError => error
|
||||
rescue StandardError => error # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592
|
||||
log_error(error, vulnerability)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ module Gitlab
|
|||
return DUMMY_TAGS unless response
|
||||
|
||||
response['tags'] || []
|
||||
rescue StandardError
|
||||
rescue StandardError # rubocop:todo BackgroundMigration/AvoidSilentRescueExceptions -- https://gitlab.com/gitlab-org/gitlab/-/issues/431592
|
||||
DUMMY_TAGS
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ module Gitlab
|
|||
raise UnknownEventError, "Unknown event: #{event_name}" unless EventDefinitions.known_event?(event_name)
|
||||
|
||||
increase_total_counter(event_name)
|
||||
increase_weekly_total_counter(event_name)
|
||||
update_unique_counter(event_name, kwargs)
|
||||
trigger_snowplow_event(event_name, kwargs) if send_snowplow_event
|
||||
rescue StandardError => e
|
||||
|
|
@ -28,6 +29,12 @@ module Gitlab
|
|||
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
||||
end
|
||||
|
||||
def increase_weekly_total_counter(event_name)
|
||||
redis_counter_key =
|
||||
Gitlab::Usage::Metrics::Instrumentations::TotalCountMetric.redis_key(event_name, Date.today)
|
||||
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
||||
end
|
||||
|
||||
def update_unique_counter(event_name, kwargs)
|
||||
unique_property = EventDefinitions.unique_property(event_name)
|
||||
return unless unique_property
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module Gitlab
|
|||
private
|
||||
|
||||
def redis
|
||||
primary_store = ::Redis.new(Gitlab::Redis::SharedState.params)
|
||||
primary_store = ::Gitlab::Redis::SharedState.redis
|
||||
secondary_store = ::Redis.new(Gitlab::Redis::Queues.params) # rubocop:disable Cop/RedisQueueUsage
|
||||
|
||||
MultiStore.new(primary_store, secondary_store, name.demodulize)
|
||||
|
|
|
|||
|
|
@ -83,8 +83,6 @@ module Gitlab
|
|||
"::Gitlab::Instrumentation::Redis::#{store_name}".constantize
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def redis
|
||||
::Redis.new(params)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,20 +14,56 @@ module Gitlab
|
|||
#
|
||||
class TotalCountMetric < BaseMetric
|
||||
include Gitlab::UsageDataCounters::RedisCounter
|
||||
extend Gitlab::Usage::TimeSeriesStorable
|
||||
|
||||
KEY_PREFIX = "{event_counters}_"
|
||||
|
||||
def self.redis_key(event_name)
|
||||
KEY_PREFIX + event_name
|
||||
def self.redis_key(event_name, date = nil)
|
||||
base_key = KEY_PREFIX + event_name
|
||||
return base_key unless date
|
||||
|
||||
apply_time_aggregation(base_key, date)
|
||||
end
|
||||
|
||||
def value
|
||||
events.sum do |event|
|
||||
return total_value if time_frame == 'all'
|
||||
|
||||
period_value
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def total_value
|
||||
event_names.sum do |event_name|
|
||||
redis_usage_data do
|
||||
total_count(self.class.redis_key(event[:name]))
|
||||
total_count(self.class.redis_key(event_name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def period_value
|
||||
keys = self.class.keys_for_aggregation(events: event_names, **time_constraint)
|
||||
keys.sum do |key|
|
||||
redis_usage_data do
|
||||
total_count(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def time_constraint
|
||||
case time_frame
|
||||
when '28d'
|
||||
monthly_time_range
|
||||
when '7d'
|
||||
weekly_time_range
|
||||
else
|
||||
raise "Unknown time frame: #{time_frame} for #{self.class} :: #{events}"
|
||||
end
|
||||
end
|
||||
|
||||
def event_names
|
||||
events.pluck(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
|
|||
def each_database(databases, include_geo: false)
|
||||
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |database|
|
||||
next if database == 'embedding'
|
||||
next if database == 'jh'
|
||||
next if !include_geo && database == 'geo'
|
||||
|
||||
yield database
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ RSpec.describe Packages::Pypi::PackagesFinder do
|
|||
|
||||
context 'when package registry is disabled for one project' do
|
||||
before do
|
||||
project2.project_feature.update!(package_registry_access_level: ProjectFeature::DISABLED)
|
||||
project2.update!(package_registry_access_level: 'disabled', packages_enabled: false)
|
||||
end
|
||||
|
||||
it 'filters the packages from the disabled project' do
|
||||
|
|
|
|||
|
|
@ -21,9 +21,11 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
.with(event_name, values: unique_value)
|
||||
end
|
||||
|
||||
def expect_redis_tracking(event_name)
|
||||
expect(redis).to have_received(:incr) do |redis_key|
|
||||
expect(redis_key).to end_with(event_name)
|
||||
def expect_redis_tracking
|
||||
call_index = 0
|
||||
expect(redis).to have_received(:incr).twice do |redis_key|
|
||||
expect(redis_key).to end_with(redis_arguments[call_index])
|
||||
call_index += 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -51,12 +53,13 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
let(:fake_snowplow) { instance_double(Gitlab::Tracking::Destinations::Snowplow) }
|
||||
let(:event_name) { 'g_edit_by_web_ide' }
|
||||
let(:unique_value) { user.id }
|
||||
let(:redis_arguments) { [event_name, Date.today.strftime('%G-%V')] }
|
||||
|
||||
it 'updates Redis, RedisHLL and Snowplow', :aggregate_failures do
|
||||
params = { user: user, project: project, namespace: namespace }
|
||||
described_class.track_event(event_name, **params)
|
||||
|
||||
expect_redis_tracking(event_name)
|
||||
expect_redis_tracking
|
||||
expect_redis_hll_tracking(event_name)
|
||||
expect_snowplow_tracking(event_name) # Add test for arguments
|
||||
end
|
||||
|
|
@ -86,7 +89,7 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
it 'logs error on missing property', :aggregate_failures do
|
||||
expect { described_class.track_event(event_name, merge_request_id: 1) }.not_to raise_error
|
||||
|
||||
expect_redis_tracking(event_name)
|
||||
expect_redis_tracking
|
||||
expect(Gitlab::ErrorTracking).to have_received(:track_and_raise_for_dev_exception)
|
||||
.with(described_class::InvalidPropertyError, event_name: event_name, kwargs: { merge_request_id: 1 })
|
||||
end
|
||||
|
|
@ -100,7 +103,7 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
it 'logs error on missing unique property', :aggregate_failures do
|
||||
expect { described_class.track_event(event_name, merge_request_id: 1) }.not_to raise_error
|
||||
|
||||
expect_redis_tracking(event_name)
|
||||
expect_redis_tracking
|
||||
expect(Gitlab::ErrorTracking).to have_received(:track_and_raise_for_dev_exception)
|
||||
end
|
||||
end
|
||||
|
|
@ -119,7 +122,7 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
it 'is used when logging to RedisHLL', :aggregate_failures do
|
||||
described_class.track_event(event_name, user: user, project: project)
|
||||
|
||||
expect_redis_tracking(event_name)
|
||||
expect_redis_tracking
|
||||
expect_redis_hll_tracking(event_name)
|
||||
expect_snowplow_tracking(event_name)
|
||||
end
|
||||
|
|
@ -137,7 +140,7 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
it 'logs error on missing method' do
|
||||
expect { described_class.track_event(event_name, project: "a_string") }.not_to raise_error
|
||||
|
||||
expect_redis_tracking(event_name)
|
||||
expect_redis_tracking
|
||||
expect(Gitlab::ErrorTracking).to have_received(:track_and_raise_for_dev_exception)
|
||||
.with(described_class::InvalidMethodError, event_name: event_name, kwargs: { project: 'a_string' })
|
||||
end
|
||||
|
|
@ -147,7 +150,7 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
it 'logs to Redis and RedisHLL but not Snowplow' do
|
||||
described_class.track_event(event_name, send_snowplow_event: false, user: user, project: project)
|
||||
|
||||
expect_redis_tracking(event_name)
|
||||
expect_redis_tracking
|
||||
expect_redis_hll_tracking(event_name)
|
||||
expect(fake_snowplow).not_to have_received(:event)
|
||||
end
|
||||
|
|
@ -166,7 +169,7 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
|
|||
it 'logs to Redis and Snowplow but not RedisHLL', :aggregate_failures do
|
||||
described_class.track_event(event_name, user: user, project: project)
|
||||
|
||||
expect_redis_tracking(event_name)
|
||||
expect_redis_tracking
|
||||
expect_snowplow_tracking(event_name)
|
||||
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to have_received(:track_event)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,9 +21,11 @@ RSpec.describe Gitlab::Redis::SidekiqStatus do
|
|||
# Override rails root to avoid having our fixtures overwritten by `redis.yml` if it exists
|
||||
allow(Gitlab::Redis::SharedState).to receive(:rails_root).and_return(rails_root)
|
||||
allow(Gitlab::Redis::Queues).to receive(:rails_root).and_return(rails_root)
|
||||
allow(Gitlab::Redis::ClusterSharedState).to receive(:rails_root).and_return(rails_root)
|
||||
|
||||
allow(Gitlab::Redis::SharedState).to receive(:config_file_name).and_return(config_new_format_host)
|
||||
allow(Gitlab::Redis::Queues).to receive(:config_file_name).and_return(config_new_format_socket)
|
||||
allow(Gitlab::Redis::ClusterSharedState).to receive(:config_file_name).and_return(config_new_format_socket)
|
||||
end
|
||||
|
||||
around do |example|
|
||||
|
|
@ -37,7 +39,8 @@ RSpec.describe Gitlab::Redis::SidekiqStatus do
|
|||
subject.with do |redis_instance|
|
||||
expect(redis_instance).to be_instance_of(::Gitlab::Redis::MultiStore)
|
||||
|
||||
expect(redis_instance.primary_store.connection[:id]).to eq("redis://test-host:6379/99")
|
||||
expect(redis_instance.primary_store.secondary_store.connection[:id]).to eq("redis://test-host:6379/99")
|
||||
expect(redis_instance.primary_store.primary_store.connection[:id]).to eq("unix:///path/to/redis.sock/0")
|
||||
expect(redis_instance.secondary_store.connection[:id]).to eq("unix:///path/to/redis.sock/0")
|
||||
|
||||
expect(redis_instance.instance_name).to eq('SidekiqStatus')
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues, :clean_gitlab_redis_shared_state do
|
||||
RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues,
|
||||
:clean_gitlab_redis_shared_state, :clean_gitlab_redis_cluster_shared_state do
|
||||
shared_examples 'tracking status in redis' do
|
||||
describe '.set' do
|
||||
it 'stores the job ID' do
|
||||
|
|
|
|||
|
|
@ -9,32 +9,112 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::TotalCountMetric, :clea
|
|||
end
|
||||
|
||||
context 'with multiple similar events' do
|
||||
let(:expected_value) { 10 }
|
||||
|
||||
before do
|
||||
last_week = Date.today - 7.days
|
||||
two_weeks_ago = last_week - 1.week
|
||||
|
||||
redis_counter_key = described_class.redis_key('my_event', last_week)
|
||||
2.times do
|
||||
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
||||
end
|
||||
|
||||
redis_counter_key = described_class.redis_key('my_event', two_weeks_ago)
|
||||
3.times do
|
||||
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
||||
end
|
||||
|
||||
10.times do
|
||||
Gitlab::InternalEvents.track_event('my_event')
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', events: [{ name: 'my_event' }] }
|
||||
context "with an 'all' time_frame" do
|
||||
let(:expected_value) { 10 }
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', events: [{ name: 'my_event' }] }
|
||||
end
|
||||
|
||||
context "with a 7d time_frame" do
|
||||
let(:expected_value) { 2 }
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value', { time_frame: '7d', events: [{ name: 'my_event' }] }
|
||||
end
|
||||
|
||||
context "with a 28d time_frame" do
|
||||
let(:expected_value) { 5 }
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value', { time_frame: '28d', events: [{ name: 'my_event' }] }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple different events' do
|
||||
let(:expected_value) { 2 }
|
||||
|
||||
before do
|
||||
last_week = Date.today - 7.days
|
||||
two_weeks_ago = last_week - 1.week
|
||||
|
||||
2.times do
|
||||
redis_counter_key =
|
||||
Gitlab::Usage::Metrics::Instrumentations::TotalCountMetric.redis_key('my_event1', last_week)
|
||||
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
||||
end
|
||||
|
||||
3.times do
|
||||
redis_counter_key =
|
||||
Gitlab::Usage::Metrics::Instrumentations::TotalCountMetric.redis_key('my_event1', two_weeks_ago)
|
||||
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
||||
end
|
||||
|
||||
4.times do
|
||||
redis_counter_key =
|
||||
Gitlab::Usage::Metrics::Instrumentations::TotalCountMetric.redis_key('my_event2', last_week)
|
||||
Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
|
||||
end
|
||||
|
||||
Gitlab::InternalEvents.track_event('my_event1')
|
||||
Gitlab::InternalEvents.track_event('my_event2')
|
||||
end
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value',
|
||||
{ time_frame: 'all', events: [{ name: 'my_event1' }, { name: 'my_event2' }] }
|
||||
context "with an 'all' time_frame" do
|
||||
let(:expected_value) { 2 }
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value',
|
||||
{ time_frame: 'all', events: [{ name: 'my_event1' }, { name: 'my_event2' }] }
|
||||
end
|
||||
|
||||
context "with a 7d time_frame" do
|
||||
let(:expected_value) { 6 }
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value',
|
||||
{ time_frame: '7d', events: [{ name: 'my_event1' }, { name: 'my_event2' }] }
|
||||
end
|
||||
|
||||
context "with a 28d time_frame" do
|
||||
let(:expected_value) { 9 }
|
||||
|
||||
it_behaves_like 'a correct instrumented metric value',
|
||||
{ time_frame: '28d', events: [{ name: 'my_event1' }, { name: 'my_event2' }] }
|
||||
end
|
||||
end
|
||||
|
||||
context "with an invalid time_frame" do
|
||||
let(:metric) { described_class.new(time_frame: '14d', events: [{ name: 'my_event' }]) }
|
||||
|
||||
it 'raises an exception' do
|
||||
expect { metric.value }.to raise_error(/Unknown time frame/)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.redis_key' do
|
||||
it 'adds the key prefix to the event name' do
|
||||
expect(described_class.redis_key('my_event')).to eq('{event_counters}_my_event')
|
||||
end
|
||||
|
||||
context "with a date" do
|
||||
it 'adds the key prefix and suffix to the event name' do
|
||||
expect(described_class.redis_key('my_event', Date.new(2023, 10, 19))).to eq("{event_counters}_my_event-2023-42")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ RSpec.describe 'Deleting Sidekiq jobs', :clean_gitlab_redis_queues, feature_cate
|
|||
'args' => args,
|
||||
'meta.user' => user.username
|
||||
)
|
||||
raise 'Not enqueued!' if Sidekiq::Queue.new(queue).size.zero?
|
||||
|
||||
raise 'Not enqueued!' if Sidekiq::Queue.new(queue).count == 0
|
||||
end
|
||||
|
||||
it 'returns info about the deleted jobs' do
|
||||
|
|
|
|||
|
|
@ -217,9 +217,6 @@ todos:
|
|||
user_callouts:
|
||||
index_user_callouts_on_user_id_and_feature_name:
|
||||
- index_user_callouts_on_user_id
|
||||
users:
|
||||
index_users_on_state_and_user_type:
|
||||
- index_users_on_state
|
||||
vulnerabilities:
|
||||
index_vulnerabilities_project_id_state_severity_default_branch:
|
||||
- index_vulnerabilities_on_project_id_and_state_and_severity
|
||||
|
|
|
|||
|
|
@ -740,6 +740,18 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout, feature_categor
|
|||
.to raise_error(/Don't know how to build task 'gitlab:db:create_dynamic_partitions:geo'/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with jh configured' do
|
||||
before do
|
||||
skip 'Skipping because the jh database is not configured' unless
|
||||
!!ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: 'jh')
|
||||
end
|
||||
|
||||
it 'does not create a task for the jh database' do
|
||||
expect { run_rake_task('gitlab:db:create_dynamic_partitions:jh') }
|
||||
.to raise_error(/Don't know how to build task 'gitlab:db:create_dynamic_partitions:jh'/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'reindex' do
|
||||
|
|
|
|||
Loading…
Reference in New Issue