summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-09 12:07:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-09 12:07:48 +0000
commit7c41737ae53e3a237f356480ae04ec3ba182447b (patch)
tree766189eea19b2d44460a7e77dae19cd0b43d24f2 /spec
parent44d4b37b52c678a0b6a3c18c8c87319553ce84a3 (diff)
downloadgitlab-ce-7c41737ae53e3a237f356480ae04ec3ba182447b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap2
-rw-r--r--spec/frontend/projects/components/shared/__snapshots__/delete_button_spec.js.snap2
-rw-r--r--spec/frontend/vue_merge_request_widget/components/states/__snapshots__/mr_widget_auto_merge_enabled_spec.js.snap8
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb61
-rw-r--r--spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb33
-rw-r--r--spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb35
6 files changed, 99 insertions, 42 deletions
diff --git a/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap b/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap
index 736d149f06d..974650a2c7c 100644
--- a/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap
+++ b/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap
@@ -19,6 +19,7 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
<gl-button-stub
buttontextclasses=""
category="primary"
+ data-qa-selector="delete_button"
icon=""
role="button"
size="medium"
@@ -102,6 +103,7 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
</p>
<gl-form-input-stub
+ data-qa-selector="confirm_name_field"
id="confirm_name_input"
name="confirm_name_input"
type="text"
diff --git a/spec/frontend/projects/components/shared/__snapshots__/delete_button_spec.js.snap b/spec/frontend/projects/components/shared/__snapshots__/delete_button_spec.js.snap
index 26495fbcf83..ac020fe6915 100644
--- a/spec/frontend/projects/components/shared/__snapshots__/delete_button_spec.js.snap
+++ b/spec/frontend/projects/components/shared/__snapshots__/delete_button_spec.js.snap
@@ -20,6 +20,7 @@ exports[`Project remove modal intialized matches the snapshot 1`] = `
<gl-button-stub
buttontextclasses=""
category="primary"
+ data-qa-selector="delete_button"
icon=""
role="button"
size="medium"
@@ -103,6 +104,7 @@ exports[`Project remove modal intialized matches the snapshot 1`] = `
</p>
<gl-form-input-stub
+ data-qa-selector="confirm_name_field"
id="confirm_name_input"
name="confirm_name_input"
type="text"
diff --git a/spec/frontend/vue_merge_request_widget/components/states/__snapshots__/mr_widget_auto_merge_enabled_spec.js.snap b/spec/frontend/vue_merge_request_widget/components/states/__snapshots__/mr_widget_auto_merge_enabled_spec.js.snap
index 43f63d9fbf1..8c3a4978bb8 100644
--- a/spec/frontend/vue_merge_request_widget/components/states/__snapshots__/mr_widget_auto_merge_enabled_spec.js.snap
+++ b/spec/frontend/vue_merge_request_widget/components/states/__snapshots__/mr_widget_auto_merge_enabled_spec.js.snap
@@ -44,7 +44,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have
class="gl-display-flex gl-w-full"
>
<div
- class="media-body gl-display-flex"
+ class="media-body gl-display-flex gl-align-items-center"
>
<h4
@@ -70,7 +70,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have
</h4>
<div
- class="gl-display-flex gl-md-display-block gl-font-size-0 gl-ml-auto"
+ class="gl-display-flex gl-font-size-0 gl-ml-auto gl-gap-3"
>
<div
class="gl-display-flex gl-align-items-flex-start"
@@ -221,7 +221,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c
class="gl-display-flex gl-w-full"
>
<div
- class="media-body gl-display-flex"
+ class="media-body gl-display-flex gl-align-items-center"
>
<h4
@@ -247,7 +247,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c
</h4>
<div
- class="gl-display-flex gl-md-display-block gl-font-size-0 gl-ml-auto"
+ class="gl-display-flex gl-font-size-0 gl-ml-auto gl-gap-3"
>
<div
class="gl-display-flex gl-align-items-flex-start"
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index a12cab11293..470196ac1c5 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -469,6 +469,37 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
model.remove_concurrent_index(:users, :foo)
end
+ context 'when targeting a partition table' do
+ let(:schema) { 'public' }
+ let(:partition_table_name) { '_test_partition_01' }
+ let(:identifier) { "#{schema}.#{partition_table_name}" }
+ let(:index_name) { '_test_partitioned_index' }
+ let(:partition_index_name) { '_test_partition_01_partition_id_idx' }
+ let(:column_name) { 'partition_id' }
+
+ before do
+ model.execute(<<~SQL)
+ CREATE TABLE public._test_partitioned_table (
+ id serial NOT NULL,
+ partition_id serial NOT NULL,
+ PRIMARY KEY (id, partition_id)
+ ) PARTITION BY LIST(partition_id);
+
+ CREATE INDEX #{index_name} ON public._test_partitioned_table(#{column_name});
+
+ CREATE TABLE #{identifier} PARTITION OF public._test_partitioned_table
+ FOR VALUES IN (1);
+ SQL
+ end
+
+ context 'when dropping an index on the partition table' do
+ it 'raises ArgumentError' do
+ expect { model.remove_concurrent_index(partition_table_name, column_name) }
+ .to raise_error(ArgumentError, /use remove_concurrent_partitioned_index_by_name/)
+ end
+ end
+ end
+
describe 'by index name' do
before do
allow(model).to receive(:index_exists_by_name?).with(:users, "index_x_by_y").and_return(true)
@@ -510,6 +541,36 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
model.remove_concurrent_index_by_name(:users, "index_x_by_y")
end
+
+ context 'when targeting a partition table' do
+ let(:schema) { 'public' }
+ let(:partition_table_name) { '_test_partition_01' }
+ let(:identifier) { "#{schema}.#{partition_table_name}" }
+ let(:index_name) { '_test_partitioned_index' }
+ let(:partition_index_name) { '_test_partition_01_partition_id_idx' }
+
+ before do
+ model.execute(<<~SQL)
+ CREATE TABLE public._test_partitioned_table (
+ id serial NOT NULL,
+ partition_id serial NOT NULL,
+ PRIMARY KEY (id, partition_id)
+ ) PARTITION BY LIST(partition_id);
+
+ CREATE INDEX #{index_name} ON public._test_partitioned_table(partition_id);
+
+ CREATE TABLE #{identifier} PARTITION OF public._test_partitioned_table
+ FOR VALUES IN (1);
+ SQL
+ end
+
+ context 'when dropping an index on the partition table' do
+ it 'raises ArgumentError' do
+ expect { model.remove_concurrent_index_by_name(partition_table_name, partition_index_name) }
+ .to raise_error(ArgumentError, /use remove_concurrent_partitioned_index_by_name/)
+ end
+ end
+ end
end
end
end
diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb
index 6532a304b2e..f1ecc8c8ab5 100644
--- a/spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb
+++ b/spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb
@@ -3,8 +3,10 @@
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
+ let(:database_metric_class) { Class.new(described_class) }
+
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :count
metric_class.start { Issue.minimum(:id) }
@@ -38,7 +40,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with metric options specified with custom batch_size' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :count
metric_class.start { Issue.minimum(:id) }
@@ -60,7 +62,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with start and finish not called' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :count
end.new(time_frame: 'all')
@@ -73,7 +75,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with availability defined' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :count
metric_class.available? { false }
@@ -87,7 +89,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with availability not defined' do
subject do
- Class.new(described_class) do
+ database_metric_class do
relation { Issue }
operation :count
end.new(time_frame: 'all')
@@ -100,7 +102,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with cache_start_and_finish_as called' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :count
metric_class.start { Issue.minimum(:id) }
@@ -123,7 +125,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with estimate_batch_distinct_count' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation(:estimate_batch_distinct_count)
metric_class.start { Issue.minimum(:id) }
@@ -139,7 +141,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
let(:buckets) { double('Buckets').as_null_object }
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation(:estimate_batch_distinct_count) do |result|
result.foo
@@ -163,7 +165,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with custom timestamp column' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :count
metric_class.timestamp_column :last_edited_at
@@ -171,6 +173,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
end
it 'calculates a correct result' do
+ create(:issue, last_edited_at: 40.days.ago)
create(:issue, last_edited_at: 5.days.ago)
expect(subject.value).to eq(1)
@@ -179,14 +182,14 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with default timestamp column' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :count
end.new(time_frame: '28d')
end
it 'calculates a correct result' do
- create(:issue, last_edited_at: 5.days.ago)
+ create(:issue, created_at: 40.days.ago)
create(:issue, created_at: 5.days.ago)
expect(subject.value).to eq(1)
@@ -195,15 +198,15 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with additional parameters passed via options' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation ->(options) { Issue.where(confidential: options[:confidential]) }
metric_class.operation :count
end.new(time_frame: '28d', options: { confidential: true })
end
it 'calculates a correct result' do
- create(:issue, last_edited_at: 5.days.ago, confidential: true)
- create(:issue, last_edited_at: 5.days.ago, confidential: false)
+ create(:issue, created_at: 5.days.ago, confidential: true)
+ create(:issue, created_at: 5.days.ago, confidential: false)
expect(subject.value).to eq(1)
end
@@ -212,7 +215,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::DatabaseMetric do
context 'with unimplemented operation method used' do
subject do
- described_class.tap do |metric_class|
+ database_metric_class.tap do |metric_class|
metric_class.relation { Issue }
metric_class.operation :invalid_operation
end.new(time_frame: 'all')
diff --git a/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb
index 1ca0bb0e9ea..f1115a8813d 100644
--- a/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb
+++ b/spec/lib/gitlab/usage_data_counters/ci_template_unique_counter_spec.rb
@@ -12,6 +12,10 @@ RSpec.describe Gitlab::UsageDataCounters::CiTemplateUniqueCounter do
shared_examples 'tracks template' do
let(:subject) { described_class.track_unique_project_event(project: project, template: template_path, config_source: config_source, user: user) }
+ let(:template_name) do
+ expanded_template_name = described_class.expand_template_name(template_path)
+ described_class.ci_template_event_name(expanded_template_name, config_source)
+ end
it "has an event defined for template" do
expect do
@@ -20,33 +24,18 @@ RSpec.describe Gitlab::UsageDataCounters::CiTemplateUniqueCounter do
end
it "tracks template" do
- expanded_template_name = described_class.expand_template_name(template_path)
- expected_template_event_name = described_class.ci_template_event_name(expanded_template_name, config_source)
- expect(Gitlab::UsageDataCounters::HLLRedisCounter).to(receive(:track_event)).with(expected_template_event_name, values: project.id)
+ expect(Gitlab::UsageDataCounters::HLLRedisCounter).to(receive(:track_event)).with(template_name, values: project.id)
subject
end
- context 'Snowplow' do
- it 'event is not tracked if FF is disabled' do
- stub_feature_flags(route_hll_to_snowplow: false)
-
- subject
-
- expect_no_snowplow_event
- end
-
- it 'tracks event' do
- subject
-
- expect_snowplow_event(
- category: described_class.to_s,
- action: 'ci_templates_unique',
- namespace: project.namespace,
- user: user,
- project: project
- )
- end
+ it_behaves_like 'Snowplow event tracking with RedisHLL context' do
+ let(:feature_flag_name) { :route_hll_to_snowplow }
+ let(:category) { described_class.to_s }
+ let(:action) { 'ci_templates_unique' }
+ let(:namespace) { project.namespace }
+ let(:label) { 'redis_hll_counters.ci_templates.ci_templates_total_unique_counts_monthly' }
+ let(:context) { [Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: template_name).to_context] }
end
end