From fea53f4bc5bd6da50efd15e40e9d387d87bdde72 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 15 Jan 2025 15:34:39 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .rubocop_todo/layout/space_inside_parens.yml | 20 ---- Gemfile | 4 + Gemfile.checksum | 3 + Gemfile.lock | 12 ++- Gemfile.next.checksum | 1 + Gemfile.next.lock | 10 +- .../work_items/pages/create_work_item.vue | 1 + ...16175550_ci_pipeline_config_repository.yml | 1 + .../20210216175552_ci_pipeline_schedules.yml | 1 + .../20210216175554_ci_pipelines.yml | 1 + ..._users_committing_ciconfigfile_monthly.yml | 1 + ...om_create_ci_internal_pipeline_monthly.yml | 3 +- ..._commit_change_to_ciconfigfile_monthly.yml | 3 +- .../count_total_create_ci_build_monthly.yml | 3 +- ...16175518_ci_pipeline_config_repository.yml | 1 + .../20210216175523_ci_pipeline_schedules.yml | 1 + ...16175533_ci_pipeline_config_repository.yml | 1 + .../20210216175535_ci_pipeline_schedules.yml | 1 + ...pproval_group_rules_protected_branches.yml | 12 +-- db/docs/audit_events_streaming_headers.yml | 12 +-- .../backfill_p_ci_pipelines_trigger_id.yml | 6 +- db/docs/boards_epic_user_preferences.yml | 12 +-- db/docs/vulnerability_flags.yml | 12 +-- ...references_group_id_not_null_constraint.rb | 14 +++ ...ty_flags_project_id_not_null_constraint.rb | 14 +++ ...ng_headers_group_id_not_null_constraint.rb | 14 +++ ...d_branches_group_id_not_null_constraint.rb | 14 +++ ...ueue_backfill_p_ci_pipelines_trigger_id.rb | 23 +++++ db/schema_migrations/20250109042405 | 1 + db/schema_migrations/20250109073014 | 1 + db/schema_migrations/20250109074542 | 1 + db/schema_migrations/20250110082946 | 1 + db/schema_migrations/20250114055621 | 1 + db/structure.sql | 8 +- doc/user/project/pages/introduction.md | 9 ++ gems/gitlab-active-context/Gemfile.lock | 19 ++++ .../gitlab-active-context.gemspec | 3 + .../databases/opensearch/adapter.rb | 15 +++ .../databases/opensearch/client.rb | 67 ++++++++++++++ .../databases/opensearch/query_result.rb | 31 +++++++ .../databases/opensearch/adapter_spec.rb | 14 +++ .../databases/opensearch/client_spec.rb | 92 +++++++++++++++++++ .../databases/opensearch/query_result_spec.rb | 45 +++++++++ .../gitlab-active-context/spec/spec_helper.rb | 2 + gems/gitlab-secret_detection/Gemfile.lock | 4 +- .../gitlab-secret_detection.gemspec | 2 +- .../backfill_p_ci_pipelines_trigger_id.rb | 51 +++++++--- lib/gitlab/cycle_analytics/metrics_tables.rb | 4 - qa/qa/page/registration/sign_up.rb | 17 ++++ spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb | 2 +- ...backfill_p_ci_pipelines_trigger_id_spec.rb | 64 +++++++------ .../gitlab/database/migrations/runner_spec.rb | 2 +- .../reindexing/reindex_concurrently_spec.rb | 2 +- spec/lib/gitlab/diff/highlight_cache_spec.rb | 2 +- .../gitlab/exclusive_lease_helpers_spec.rb | 2 +- spec/lib/gitlab/git/blob_spec.rb | 4 +- spec/lib/gitlab/git/commit_spec.rb | 4 +- spec/lib/gitlab/git/diff_spec.rb | 4 +- spec/lib/gitlab/git/repository_spec.rb | 2 +- .../instrumentations/generic_metric_spec.rb | 2 +- spec/lib/gitlab/usage_data_spec.rb | 2 +- .../delegator_override/validator_spec.rb | 4 +- spec/lib/gitlab/utils/usage_data_spec.rb | 2 +- spec/lib/gitlab/x509/commit_spec.rb | 2 +- .../container_scanning_build_action_spec.rb | 2 +- .../sast_build_action_spec.rb | 74 +++++++-------- .../sast_iac_build_action_spec.rb | 2 +- .../secret_detection_build_action_spec.rb | 2 +- ...backfill_p_ci_pipelines_trigger_id_spec.rb | 26 ++++++ spec/models/ml/candidate_metric_spec.rb | 4 +- spec/models/ml/candidate_spec.rb | 4 +- vendor/gems/cloud_profiler_agent/Gemfile.lock | 14 +-- .../cloud_profiler_agent.gemspec | 2 +- 73 files changed, 628 insertions(+), 191 deletions(-) create mode 100644 db/post_migrate/20250109042405_add_boards_epic_user_preferences_group_id_not_null_constraint.rb create mode 100644 db/post_migrate/20250109073014_add_vulnerability_flags_project_id_not_null_constraint.rb create mode 100644 db/post_migrate/20250109074542_add_audit_events_streaming_headers_group_id_not_null_constraint.rb create mode 100644 db/post_migrate/20250110082946_add_approval_group_rules_protected_branches_group_id_not_null_constraint.rb create mode 100644 db/post_migrate/20250114055621_requeue_backfill_p_ci_pipelines_trigger_id.rb create mode 100644 db/schema_migrations/20250109042405 create mode 100644 db/schema_migrations/20250109073014 create mode 100644 db/schema_migrations/20250109074542 create mode 100644 db/schema_migrations/20250110082946 create mode 100644 db/schema_migrations/20250114055621 create mode 100644 gems/gitlab-active-context/lib/active_context/databases/opensearch/adapter.rb create mode 100644 gems/gitlab-active-context/lib/active_context/databases/opensearch/client.rb create mode 100644 gems/gitlab-active-context/lib/active_context/databases/opensearch/query_result.rb create mode 100644 gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/adapter_spec.rb create mode 100644 gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/client_spec.rb create mode 100644 gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/query_result_spec.rb create mode 100644 spec/migrations/20250102002809_requeue_backfill_p_ci_pipelines_trigger_id_spec.rb diff --git a/.rubocop_todo/layout/space_inside_parens.yml b/.rubocop_todo/layout/space_inside_parens.yml index 2258e83fbdd..00ef85b4d95 100644 --- a/.rubocop_todo/layout/space_inside_parens.yml +++ b/.rubocop_todo/layout/space_inside_parens.yml @@ -2,26 +2,6 @@ # Cop supports --autocorrect. Layout/SpaceInsideParens: Exclude: - - 'spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb' - - 'spec/lib/gitlab/database/migrations/runner_spec.rb' - - 'spec/lib/gitlab/database/reindexing/reindex_concurrently_spec.rb' - - 'spec/lib/gitlab/diff/highlight_cache_spec.rb' - - 'spec/lib/gitlab/exclusive_lease_helpers_spec.rb' - - 'spec/lib/gitlab/git/blob_spec.rb' - - 'spec/lib/gitlab/git/commit_spec.rb' - - 'spec/lib/gitlab/git/diff_spec.rb' - - 'spec/lib/gitlab/git/repository_spec.rb' - - 'spec/lib/gitlab/usage/metrics/instrumentations/generic_metric_spec.rb' - - 'spec/lib/gitlab/usage_data_spec.rb' - - 'spec/lib/gitlab/utils/delegator_override/validator_spec.rb' - - 'spec/lib/gitlab/utils/usage_data_spec.rb' - - 'spec/lib/gitlab/x509/commit_spec.rb' - - 'spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb' - - 'spec/lib/security/ci_configuration/sast_build_action_spec.rb' - - 'spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb' - - 'spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb' - - 'spec/models/ml/candidate_metric_spec.rb' - - 'spec/models/ml/candidate_spec.rb' - 'spec/policies/clusters/agent_policy_spec.rb' - 'spec/presenters/ci/build_presenter_spec.rb' - 'spec/presenters/packages/conan/package_presenter_spec.rb' diff --git a/Gemfile b/Gemfile index f82718e24e0..d4ed3e72d6b 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,10 @@ else end gem 'activerecord-gitlab', path: 'gems/activerecord-gitlab', feature_category: :shared +# This can be dropped after upgrading to Rails 7.2: https://github.com/rails/rails/pull/49674 +gem 'mutex_m', '~> 0.3', feature_category: :shared +# Need by Rails +gem 'drb', '~> 2.2', feature_category: :shared gem 'bootsnap', '~> 1.18.3', require: false, feature_category: :shared diff --git a/Gemfile.checksum b/Gemfile.checksum index 308cad0bdcb..6f639a2052e 100644 --- a/Gemfile.checksum +++ b/Gemfile.checksum @@ -132,6 +132,7 @@ {"name":"doorkeeper-device_authorization_grant","version":"1.0.3","platform":"ruby","checksum":"94c3ac12a0d50942850ecd58ed64298b397a5e903e8880cb68d4085600932679"}, {"name":"doorkeeper-openid_connect","version":"1.8.10","platform":"ruby","checksum":"b28efaa9b52cbe9aca4efc825a7ef63cc950ae6a96f4a72ed8362f278a453742"}, {"name":"dotenv","version":"2.7.6","platform":"ruby","checksum":"2451ed5e8e43776d7a787e51d6f8903b98e446146c7ad143d5678cc2c409d547"}, +{"name":"drb","version":"2.2.1","platform":"ruby","checksum":"e9d472bf785f558b96b25358bae115646da0dbfd45107ad858b0bc0d935cb340"}, {"name":"dry-cli","version":"1.0.0","platform":"ruby","checksum":"28ead169f872954dd08910eb8ead59cf86cd18b4aab321e8eeefe945749569f0"}, {"name":"dry-core","version":"1.0.1","platform":"ruby","checksum":"f32f4245e0f54e787f3708584ed8f7545aaf8dd99072e36f169312468ec5450d"}, {"name":"dry-inflector","version":"1.0.0","platform":"ruby","checksum":"6ad22361ca2d6f3f001ae3037ffcfea01163f644280d13a9195d3c3a94dd1626"}, @@ -409,6 +410,7 @@ {"name":"murmurhash3","version":"0.1.7","platform":"ruby","checksum":"370a2ce2e9ab0711e51554e530b5f63956927a6554a296855f42a1a4a5ed0936"}, {"name":"mustermann","version":"3.0.0","platform":"ruby","checksum":"6d3569aa3c3b2f048c60626f48d9b2d561cc8d2ef269296943b03da181c08b67"}, {"name":"mustermann-grape","version":"1.0.2","platform":"ruby","checksum":"6f5309d6a338f801f211c644e8c2d3cc2577a8693f9cd51dadfdb29c1260f5fe"}, +{"name":"mutex_m","version":"0.3.0","platform":"ruby","checksum":"cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751"}, {"name":"nap","version":"1.1.0","platform":"ruby","checksum":"949691660f9d041d75be611bb2a8d2fd559c467537deac241f4097d9b5eea576"}, {"name":"neighbor","version":"0.3.2","platform":"ruby","checksum":"b795bbcc24b1b9ae82d9f7e97a3461b0b3607d24a85a7acbed776bd498e7eba8"}, {"name":"nenv","version":"0.3.0","platform":"ruby","checksum":"d9de6d8fb7072228463bf61843159419c969edb34b3cef51832b516ae7972765"}, @@ -459,6 +461,7 @@ {"name":"omniauth_openid_connect","version":"0.8.0","platform":"ruby","checksum":"1f2f3890386e2a742221cee0d2e903b78d874e6fab9ea3bfa31c1462f4793d25"}, {"name":"open4","version":"1.3.4","platform":"ruby","checksum":"a1df037310624ecc1ea1d81264b11c83e96d0c3c1c6043108d37d396dcd0f4b1"}, {"name":"openid_connect","version":"2.3.0","platform":"ruby","checksum":"0dbb9cefeb11e0a65e706349266355bbbb060382ae138fc9e199ab1aa622744c"}, +{"name":"opensearch-ruby","version":"3.4.0","platform":"ruby","checksum":"0a8621686bed3c59b4c23e08cbaef873685a3fe4568e9d2703155ca92b8ca05d"}, {"name":"openssl","version":"3.2.0","platform":"java","checksum":"9a1c870b4175ee90bcd233b5041a5ca8072f5f5f06d404ab3c786aa31daffa02"}, {"name":"openssl","version":"3.2.0","platform":"ruby","checksum":"3c4bb8760977b4becd2819c6c2569bcf5c6f48b32b9f7a4ce1fd37f996378d14"}, {"name":"openssl-signature_algorithm","version":"1.3.0","platform":"ruby","checksum":"a3b40b5e8276162d4a6e50c7c97cdaf1446f9b2c3946a6fa2c14628e0c957e80"}, diff --git a/Gemfile.lock b/Gemfile.lock index bf6e8642bb9..8859b26960d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,6 +30,7 @@ PATH activesupport connection_pool elasticsearch + opensearch-ruby pg zeitwerk @@ -113,7 +114,7 @@ PATH grpc (= 1.63.0) grpc-tools (= 1.63.0) parallel (~> 1.22) - re2 (~> 2.4) + re2 (~> 2.7) toml-rb (~> 2.2) PATH @@ -155,7 +156,7 @@ PATH specs: cloud_profiler_agent (0.0.1.pre) google-cloud-profiler-v2 (~> 0.3) - google-protobuf (~> 3.13) + google-protobuf (~> 3.25) googleauth (>= 0.14) stackprof (~> 0.2) @@ -556,6 +557,7 @@ GEM doorkeeper (>= 5.5, < 5.9) jwt (>= 2.5) dotenv (2.7.6) + drb (2.2.1) dry-cli (1.0.0) dry-core (1.0.1) concurrent-ruby (~> 1.0) @@ -1184,6 +1186,7 @@ GEM ruby2_keywords (~> 0.0.1) mustermann-grape (1.0.2) mustermann (>= 1.0.0) + mutex_m (0.3.0) nap (1.1.0) neighbor (0.3.2) activerecord (>= 6.1) @@ -1293,6 +1296,9 @@ GEM tzinfo validate_url webfinger (~> 2.0) + opensearch-ruby (3.4.0) + faraday (>= 1.0, < 3) + multi_json (>= 1.0) openssl (3.2.0) openssl-signature_algorithm (1.3.0) openssl (> 2.0) @@ -2048,6 +2054,7 @@ DEPENDENCIES doorkeeper (~> 5.8, >= 5.8.1) doorkeeper-device_authorization_grant (~> 1.0.0) doorkeeper-openid_connect (~> 1.8.10) + drb (~> 2.2) duo_api (~> 1.3) ed25519 (~> 1.3.0) elasticsearch-api (= 7.17.11) @@ -2185,6 +2192,7 @@ DEPENDENCIES mini_magick (~> 4.12) minitest (~> 5.11.0) multi_json (~> 1.14.1) + mutex_m (~> 0.3) neighbor (~> 0.3.2) net-http (= 0.6.0) net-ldap (~> 0.17.1) diff --git a/Gemfile.next.checksum b/Gemfile.next.checksum index ea815bf91f8..e2f5dff3dca 100644 --- a/Gemfile.next.checksum +++ b/Gemfile.next.checksum @@ -464,6 +464,7 @@ {"name":"omniauth_openid_connect","version":"0.8.0","platform":"ruby","checksum":"1f2f3890386e2a742221cee0d2e903b78d874e6fab9ea3bfa31c1462f4793d25"}, {"name":"open4","version":"1.3.4","platform":"ruby","checksum":"a1df037310624ecc1ea1d81264b11c83e96d0c3c1c6043108d37d396dcd0f4b1"}, {"name":"openid_connect","version":"2.3.0","platform":"ruby","checksum":"0dbb9cefeb11e0a65e706349266355bbbb060382ae138fc9e199ab1aa622744c"}, +{"name":"opensearch-ruby","version":"3.4.0","platform":"ruby","checksum":"0a8621686bed3c59b4c23e08cbaef873685a3fe4568e9d2703155ca92b8ca05d"}, {"name":"openssl","version":"3.2.0","platform":"java","checksum":"9a1c870b4175ee90bcd233b5041a5ca8072f5f5f06d404ab3c786aa31daffa02"}, {"name":"openssl","version":"3.2.0","platform":"ruby","checksum":"3c4bb8760977b4becd2819c6c2569bcf5c6f48b32b9f7a4ce1fd37f996378d14"}, {"name":"openssl-signature_algorithm","version":"1.3.0","platform":"ruby","checksum":"a3b40b5e8276162d4a6e50c7c97cdaf1446f9b2c3946a6fa2c14628e0c957e80"}, diff --git a/Gemfile.next.lock b/Gemfile.next.lock index fcad980609e..4af9feb4172 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -30,6 +30,7 @@ PATH activesupport connection_pool elasticsearch + opensearch-ruby pg zeitwerk @@ -113,7 +114,7 @@ PATH grpc (= 1.63.0) grpc-tools (= 1.63.0) parallel (~> 1.22) - re2 (~> 2.4) + re2 (~> 2.7) toml-rb (~> 2.2) PATH @@ -155,7 +156,7 @@ PATH specs: cloud_profiler_agent (0.0.1.pre) google-cloud-profiler-v2 (~> 0.3) - google-protobuf (~> 3.13) + google-protobuf (~> 3.25) googleauth (>= 0.14) stackprof (~> 0.2) @@ -1311,6 +1312,9 @@ GEM tzinfo validate_url webfinger (~> 2.0) + opensearch-ruby (3.4.0) + faraday (>= 1.0, < 3) + multi_json (>= 1.0) openssl (3.2.0) openssl-signature_algorithm (1.3.0) openssl (> 2.0) @@ -2081,6 +2085,7 @@ DEPENDENCIES doorkeeper (~> 5.8, >= 5.8.1) doorkeeper-device_authorization_grant (~> 1.0.0) doorkeeper-openid_connect (~> 1.8.10) + drb (~> 2.2) duo_api (~> 1.3) ed25519 (~> 1.3.0) elasticsearch-api (= 7.17.11) @@ -2218,6 +2223,7 @@ DEPENDENCIES mini_magick (~> 4.12) minitest (~> 5.11.0) multi_json (~> 1.14.1) + mutex_m (~> 0.3) neighbor (~> 0.3.2) net-http (= 0.6.0) net-ldap (~> 0.17.1) diff --git a/app/assets/javascripts/work_items/pages/create_work_item.vue b/app/assets/javascripts/work_items/pages/create_work_item.vue index aea141f7bbf..374956f7c4e 100644 --- a/app/assets/javascripts/work_items/pages/create_work_item.vue +++ b/app/assets/javascripts/work_items/pages/create_work_item.vue @@ -118,6 +118,7 @@ export default { @workItemCreated="workItemCreated" /> = 2.0.2, < 7.0) ast (2.4.2) + aws-eventstream (1.3.0) + aws-partitions (1.1001.0) + aws-sdk-core (3.214.0) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.992.0) + aws-sigv4 (~> 1.9) + jmespath (~> 1, >= 1.6.1) + aws-sigv4 (1.9.1) + aws-eventstream (~> 1, >= 1.0.2) base64 (0.2.0) benchmark (0.4.0) bigdecimal (3.1.8) @@ -73,6 +83,9 @@ GEM logger faraday-net_http (3.4.0) net-http (>= 0.5.0) + faraday_middleware-aws-sigv4 (1.0.1) + aws-sigv4 (~> 1.0) + faraday (>= 2.0, < 3) gitlab-styles (13.0.2) rubocop (~> 1.68.0) rubocop-capybara (~> 2.21.0) @@ -89,6 +102,7 @@ GEM irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) + jmespath (1.6.2) json (2.9.0) language_server-protocol (3.17.0.3) logger (1.6.2) @@ -105,6 +119,9 @@ GEM racc (~> 1.4) nokogiri (1.17.1-arm64-darwin) racc (~> 1.4) + opensearch-ruby (3.4.0) + faraday (>= 1.0, < 3) + multi_json (>= 1.0) parallel (1.26.3) parser (3.3.6.0) ast (~> 2.4.1) @@ -218,7 +235,9 @@ PLATFORMS DEPENDENCIES activesupport + aws-sdk-core byebug + faraday_middleware-aws-sigv4 gitlab-active-context! gitlab-styles rake (~> 13.0) diff --git a/gems/gitlab-active-context/gitlab-active-context.gemspec b/gems/gitlab-active-context/gitlab-active-context.gemspec index 1fcd37891df..85dcb86381c 100644 --- a/gems/gitlab-active-context/gitlab-active-context.gemspec +++ b/gems/gitlab-active-context/gitlab-active-context.gemspec @@ -22,9 +22,12 @@ Gem::Specification.new do |spec| spec.add_dependency 'activesupport' spec.add_dependency 'connection_pool' spec.add_dependency 'elasticsearch' + spec.add_dependency 'opensearch-ruby' spec.add_dependency 'pg' spec.add_dependency 'zeitwerk' + spec.add_development_dependency 'aws-sdk-core' + spec.add_development_dependency 'faraday_middleware-aws-sigv4' spec.add_development_dependency 'gitlab-styles' spec.add_development_dependency 'rspec-rails' spec.add_development_dependency 'rubocop-rspec' diff --git a/gems/gitlab-active-context/lib/active_context/databases/opensearch/adapter.rb b/gems/gitlab-active-context/lib/active_context/databases/opensearch/adapter.rb new file mode 100644 index 00000000000..7c685b7bba0 --- /dev/null +++ b/gems/gitlab-active-context/lib/active_context/databases/opensearch/adapter.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module ActiveContext + module Databases + module Opensearch + class Adapter + include ActiveContext::Databases::Concerns::Adapter + + def client_klass + ActiveContext::Databases::Opensearch::Client + end + end + end + end +end diff --git a/gems/gitlab-active-context/lib/active_context/databases/opensearch/client.rb b/gems/gitlab-active-context/lib/active_context/databases/opensearch/client.rb new file mode 100644 index 00000000000..310a724499d --- /dev/null +++ b/gems/gitlab-active-context/lib/active_context/databases/opensearch/client.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'opensearch' +require 'faraday_middleware/aws_sigv4' + +module ActiveContext + module Databases + module Opensearch + class Client + include ActiveContext::Databases::Concerns::Client + + OPEN_TIMEOUT = 5 + NO_RETRY = 0 + + def initialize(options) + @options = options + end + + def search(_query) + res = client.search + QueryResult.new(res) + end + + def client + ::OpenSearch::Client.new(opensearch_config) do |fmid| + next unless options[:aws] + + fmid.request( + :aws_sigv4, + credentials_provider: aws_credentials, + service: 'es', + region: options[:aws_region] + ) + end + end + + def aws_credentials + static_credentials = ::Aws::Credentials.new(options[:aws_access_key], options[:aws_secret_access_key]) + + return static_credentials if static_credentials&.set? + + aws_credential_provider = ::Aws::CredentialProviderChain.new.resolve + aws_credential_provider if aws_credential_provider&.set? + end + + private + + def opensearch_config + { + adapter: :net_http, + urls: options[:url], + transport_options: { + request: { + timeout: options[:client_request_timeout], + open_timeout: OPEN_TIMEOUT + } + }, + randomize_hosts: true, + retry_on_failure: options[:retry_on_failure] || NO_RETRY, + log: options[:debug], + debug: options[:debug] + }.compact + end + end + end + end +end diff --git a/gems/gitlab-active-context/lib/active_context/databases/opensearch/query_result.rb b/gems/gitlab-active-context/lib/active_context/databases/opensearch/query_result.rb new file mode 100644 index 00000000000..1d2170e7da5 --- /dev/null +++ b/gems/gitlab-active-context/lib/active_context/databases/opensearch/query_result.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module ActiveContext + module Databases + module Opensearch + class QueryResult + include ActiveContext::Databases::Concerns::QueryResult + + def initialize(result) + @result = result + end + + def count + result['hits']['total']['value'] + end + + def each + return enum_for(:each) unless block_given? + + result['hits']['hits'].each do |hit| + yield hit['_source'] + end + end + + private + + attr_reader :result + end + end + end +end diff --git a/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/adapter_spec.rb b/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/adapter_spec.rb new file mode 100644 index 00000000000..1afba9a992b --- /dev/null +++ b/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/adapter_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +RSpec.describe ActiveContext::Databases::Opensearch::Adapter do + let(:options) { { url: 'http://localhost:9200' } } + + subject(:adapter) { described_class.new(options) } + + it 'delegates search to client' do + query = ActiveContext::Query.filter(foo: :bar) + expect(adapter.client).to receive(:search).with(query) + + adapter.search(query) + end +end diff --git a/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/client_spec.rb b/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/client_spec.rb new file mode 100644 index 00000000000..40cba13c933 --- /dev/null +++ b/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/client_spec.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true + +RSpec.describe ActiveContext::Databases::Opensearch::Client do + let(:options) { { url: 'http://localhost:9200' } } + + subject(:client) { described_class.new(options) } + + describe '#search' do + let(:opensearch_client) { instance_double(OpenSearch::Client) } + let(:search_response) { { 'hits' => { 'total' => 5, 'hits' => [] } } } + + before do + allow(client).to receive(:client).and_return(opensearch_client) + allow(opensearch_client).to receive(:search).and_return(search_response) + end + + it 'calls search on the Opensearch client' do + expect(opensearch_client).to receive(:search) + client.search('query') + end + + it 'returns a QueryResult object' do + result = client.search('query') + expect(result).to be_a(ActiveContext::Databases::Opensearch::QueryResult) + end + end + + describe '#client' do + it 'returns an instance of OpenSearch::Client' do + expect(OpenSearch::Client).to receive(:new).with(client.send(:opensearch_config)) + client.client + end + end + + describe '#aws_credentials' do + context 'when static credentials are provided' do + let(:options) do + { + url: 'http://localhost:9200', + aws: true, + aws_access_key: 'access_key', + aws_secret_access_key: 'secret_key' + } + end + + it 'returns static credentials' do + credentials = client.aws_credentials + expect(credentials).to be_a(Aws::Credentials) + expect(credentials.access_key_id).to eq('access_key') + expect(credentials.secret_access_key).to eq('secret_key') + end + end + + context 'when static credentials are not provided' do + let(:options) { { url: 'http://localhost:9200', aws: true } } + let(:mock_provider) { instance_double(Aws::Credentials, set?: true) } + let(:mock_chain) { instance_double(Aws::CredentialProviderChain, resolve: mock_provider) } + + before do + allow(Aws::CredentialProviderChain).to receive(:new).and_return(mock_chain) + end + + it 'uses the AWS credential provider chain' do + expect(client.aws_credentials).to eq(mock_provider) + end + end + + context 'when no valid credentials are found' do + let(:options) { { url: 'http://localhost:9200', aws: true } } + let(:mock_chain) { instance_double(Aws::CredentialProviderChain, resolve: nil) } + + before do + allow(Aws::CredentialProviderChain).to receive(:new).and_return(mock_chain) + end + + it 'returns nil' do + expect(client.aws_credentials).to be_nil + end + end + end + + describe '#prefix' do + it 'returns default prefix when not specified' do + expect(client.prefix).to eq('gitlab_active_context') + end + + it 'returns configured prefix' do + client = described_class.new(options.merge(prefix: 'custom')) + expect(client.prefix).to eq('custom') + end + end +end diff --git a/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/query_result_spec.rb b/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/query_result_spec.rb new file mode 100644 index 00000000000..250f8385fe8 --- /dev/null +++ b/gems/gitlab-active-context/spec/lib/active_context/databases/opensearch/query_result_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +RSpec.describe ActiveContext::Databases::Opensearch::QueryResult do + let(:elasticsearch_result) do + { + 'hits' => { + 'total' => { 'value' => 2 }, + 'hits' => [ + { '_source' => { 'id' => 1, 'name' => 'test1' } }, + { '_source' => { 'id' => 2, 'name' => 'test2' } } + ] + } + } + end + + subject(:query_result) { described_class.new(elasticsearch_result) } + + describe '#count' do + it 'returns the total number of hits' do + expect(query_result.count).to eq(2) + end + end + + describe '#each' do + it 'yields each hit source' do + expected_sources = [ + { 'id' => 1, 'name' => 'test1' }, + { 'id' => 2, 'name' => 'test2' } + ] + + expect { |b| query_result.each(&b) }.to yield_successive_args(*expected_sources) + end + + it 'returns an enumerator when no block is given' do + expect(query_result.each).to be_a(Enumerator) + end + end + + describe 'enumerable behavior' do + it 'implements Enumerable methods' do + expect(query_result.map { |hit| hit['id'] }).to eq([1, 2]) # rubocop: disable Rails/Pluck -- pluck not implemented + expect(query_result.select { |hit| hit['id'] == 1 }).to eq([{ 'id' => 1, 'name' => 'test1' }]) + end + end +end diff --git a/gems/gitlab-active-context/spec/spec_helper.rb b/gems/gitlab-active-context/spec/spec_helper.rb index 24c11cbbb41..dcfec747cbb 100644 --- a/gems/gitlab-active-context/spec/spec_helper.rb +++ b/gems/gitlab-active-context/spec/spec_helper.rb @@ -3,6 +3,8 @@ require "active_context" require 'logger' require 'elasticsearch' +require 'opensearch' +require 'aws-sdk-core' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure diff --git a/gems/gitlab-secret_detection/Gemfile.lock b/gems/gitlab-secret_detection/Gemfile.lock index 7f6f6892b15..435e56d60e6 100644 --- a/gems/gitlab-secret_detection/Gemfile.lock +++ b/gems/gitlab-secret_detection/Gemfile.lock @@ -5,7 +5,7 @@ PATH grpc (= 1.63.0) grpc-tools (= 1.63.0) parallel (~> 1.22) - re2 (~> 2.4) + re2 (~> 2.7) toml-rb (~> 2.2) GEM @@ -73,7 +73,7 @@ GEM racc (1.7.3) rack (3.1.8) rainbow (3.1.1) - re2 (2.4.3) + re2 (2.10.0) mini_portile2 (~> 2.8.5) regexp_parser (2.8.2) rexml (3.3.9) diff --git a/gems/gitlab-secret_detection/gitlab-secret_detection.gemspec b/gems/gitlab-secret_detection/gitlab-secret_detection.gemspec index c3869fcacfd..6bb3deac271 100644 --- a/gems/gitlab-secret_detection/gitlab-secret_detection.gemspec +++ b/gems/gitlab-secret_detection/gitlab-secret_detection.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "grpc", "= 1.63.0" spec.add_runtime_dependency "grpc-tools", "= 1.63.0" spec.add_runtime_dependency "parallel", "~> 1.22" - spec.add_runtime_dependency "re2", "~> 2.4" + spec.add_runtime_dependency "re2", "~> 2.7" spec.add_runtime_dependency "toml-rb", "~> 2.2" spec.add_development_dependency "benchmark-malloc", "~> 0.2" diff --git a/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id.rb b/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id.rb index 18b686b8f61..2096254e2f1 100644 --- a/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id.rb +++ b/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id.rb @@ -8,21 +8,46 @@ module Gitlab def perform each_sub_batch do |sub_batch| - sub_query = - sub_batch - .select('p_ci_builds.commit_id AS pipeline_id, p_ci_builds.partition_id, ci_trigger_requests.trigger_id') - .joins('INNER JOIN p_ci_builds ON p_ci_builds.id = ci_trigger_requests.commit_id') - .order(trigger_id: :asc) - - connection.execute(<<~SQL) - UPDATE p_ci_pipelines - SET trigger_id = sub_trigger_query.trigger_id - FROM (#{sub_query.to_sql}) AS sub_trigger_query - WHERE p_ci_pipelines.id = sub_trigger_query.pipeline_id - AND p_ci_pipelines.partition_id = sub_trigger_query.partition_id - SQL + correct_existing_trigger_id_for(sub_batch) + backfill_trigger_id_from_commit_id(sub_batch) end end + + private + + def correct_existing_trigger_id_for(sub_batch) + prev_incorrect_sub_query = + sub_batch + .select('p_ci_builds.commit_id AS pipeline_id, p_ci_builds.partition_id') + .joins('INNER JOIN p_ci_builds ON p_ci_builds.id = ci_trigger_requests.commit_id') + + connection.execute(<<~SQL) + UPDATE p_ci_pipelines + SET trigger_id = ( + SELECT trigger_id + FROM ci_trigger_requests + WHERE commit_id = p_ci_pipelines.id + LIMIT 1 + ) + FROM (#{prev_incorrect_sub_query.to_sql}) AS sub_trigger_query + WHERE p_ci_pipelines.id = sub_trigger_query.pipeline_id + AND p_ci_pipelines.partition_id = sub_trigger_query.partition_id + SQL + end + + def backfill_trigger_id_from_commit_id(sub_batch) + sub_query = + sub_batch + .select('commit_id AS pipeline_id, trigger_id') + .where.not(commit_id: nil) + + connection.execute(<<~SQL) + UPDATE p_ci_pipelines + SET trigger_id = sub_trigger_query.trigger_id + FROM (#{sub_query.to_sql}) AS sub_trigger_query + WHERE p_ci_pipelines.id = sub_trigger_query.pipeline_id + SQL + end end end end diff --git a/lib/gitlab/cycle_analytics/metrics_tables.rb b/lib/gitlab/cycle_analytics/metrics_tables.rb index 015f7bfde24..7842da4bff2 100644 --- a/lib/gitlab/cycle_analytics/metrics_tables.rb +++ b/lib/gitlab/cycle_analytics/metrics_tables.rb @@ -15,10 +15,6 @@ module Gitlab MergeRequestDiff.arel_table end - def mr_diff_commits_table - MergeRequestDiffCommit.arel_table - end - def mr_closing_issues_table MergeRequestsClosingIssues.arel_table end diff --git a/qa/qa/page/registration/sign_up.rb b/qa/qa/page/registration/sign_up.rb index 7bb5d434f50..c102577a0d9 100644 --- a/qa/qa/page/registration/sign_up.rb +++ b/qa/qa/page/registration/sign_up.rb @@ -36,10 +36,27 @@ module QA Support::Waiter.wait_until(sleep_interval: 0.5) do page.has_content?("Username is available.") + + network_password_requirements.each do |requirement| + page_has_success_requirement?(requirement) if page.has_content?(requirement, wait: 0.5) + end end click_element 'new-user-register-button' if has_element?('new-user-register-button') end + + private + + def network_password_requirements + [ + 'Cannot use common phrases (e.g. "password")', + 'Cannot include your name, username, or email' + ] + end + + def page_has_success_requirement?(requirement) + has_element?('password-rule-text', class: 'gl-text-success', text: requirement) + end end end end diff --git a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb index ac7f5df8726..9c0fba63c76 100644 --- a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb @@ -76,7 +76,7 @@ RSpec.describe Gitlab::Auth::OAuth::AuthHash, :aggregate_failures, feature_categ end it 'generates a temp email' do - expect( auth_hash.email).to start_with('temp-email-for-oauth') + expect(auth_hash.email).to start_with('temp-email-for-oauth') end end diff --git a/spec/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id_spec.rb b/spec/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id_spec.rb index 0887183059f..c203ffa4dd2 100644 --- a/spec/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id_spec.rb +++ b/spec/lib/gitlab/background_migration/backfill_p_ci_pipelines_trigger_id_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' -RSpec.describe Gitlab::BackgroundMigration::BackfillPCiPipelinesTriggerId, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/510352', +RSpec.describe Gitlab::BackgroundMigration::BackfillPCiPipelinesTriggerId, migration: :gitlab_ci, feature_category: :continuous_integration do - let!(:migration) do + let(:migration) do described_class.new( batch_table: :ci_trigger_requests, batch_column: :id, @@ -25,8 +25,8 @@ RSpec.describe Gitlab::BackgroundMigration::BackfillPCiPipelinesTriggerId, quara let!(:trigger3) { ci_trigger.create!(owner_id: 1) } let!(:trigger4) { ci_trigger.create!(owner_id: 1) } let!(:pipeline1) { ci_pipeline.create!(partition_id: 100, project_id: 1) } - let!(:pipeline2) { ci_pipeline.create!(partition_id: 101, project_id: 1) } - let!(:pipeline3) { ci_pipeline.create!(partition_id: 102, project_id: 1) } + let!(:pipeline2) { ci_pipeline.create!(partition_id: 100, project_id: 1) } + let!(:pipeline3) { ci_pipeline.create!(partition_id: 100, project_id: 1) } let!(:build1) { ci_build.create!(partition_id: pipeline1.partition_id, commit_id: pipeline1.id, project_id: 1) } let!(:build11) { ci_build.create!(partition_id: pipeline1.partition_id, commit_id: pipeline1.id, project_id: 1) } @@ -37,11 +37,39 @@ RSpec.describe Gitlab::BackgroundMigration::BackfillPCiPipelinesTriggerId, quara context 'when ci_trigger_requests belongs to only one pipeline' do before do - ci_trigger_request.create!(commit_id: build1.id, trigger_id: trigger1.id) - ci_trigger_request.create!(commit_id: build11.id, trigger_id: trigger1.id) - ci_trigger_request.create!(commit_id: build2.id, trigger_id: trigger2.id) - ci_trigger_request.create!(commit_id: build22.id, trigger_id: trigger2.id) - ci_trigger_request.create!(commit_id: build3.id, trigger_id: trigger3.id) + ci_trigger_request.create!(commit_id: pipeline1.id, trigger_id: trigger1.id) + ci_trigger_request.create!(commit_id: pipeline2.id, trigger_id: trigger2.id) + ci_trigger_request.create!(commit_id: pipeline3.id, trigger_id: trigger3.id) + ci_trigger_request.create!(commit_id: nil, trigger_id: trigger4.id) + end + + it 'updates p_ci_pipelines.trigger_id' do + expect { migration.perform } + .to change { pipeline1.reload.trigger_id }.from(nil).to(trigger1.id) + .and change { pipeline2.reload.trigger_id }.from(nil).to(trigger2.id) + .and change { pipeline3.reload.trigger_id }.from(nil).to(trigger3.id) + end + + context 'when pipeline has incorrect trigger_id' do + let!(:pipeline1) { ci_pipeline.create!(partition_id: 100, project_id: 1, trigger_id: trigger3.id) } + let!(:pipeline2) { ci_pipeline.create!(partition_id: 100, project_id: 1, trigger_id: trigger1.id) } + + it 'updates p_ci_pipelines.trigger_id' do + expect { migration.perform } + .to change { pipeline1.reload.trigger_id }.from(trigger3.id).to(trigger1.id) + .and change { pipeline2.reload.trigger_id }.from(trigger1.id).to(trigger2.id) + .and change { pipeline3.reload.trigger_id }.from(nil).to(trigger3.id) + end + end + end + + context 'when ci_trigger_requests belongs to multiple pipelines' do + before do + ci_trigger_request.create!(commit_id: pipeline1.id, trigger_id: trigger1.id) + ci_trigger_request.create!(commit_id: pipeline1.id, trigger_id: trigger1.id) + ci_trigger_request.create!(commit_id: pipeline1.id, trigger_id: trigger1.id) + ci_trigger_request.create!(commit_id: pipeline2.id, trigger_id: trigger2.id) + ci_trigger_request.create!(commit_id: pipeline3.id, trigger_id: trigger3.id) ci_trigger_request.create!(commit_id: nil, trigger_id: trigger4.id) end @@ -52,22 +80,4 @@ RSpec.describe Gitlab::BackgroundMigration::BackfillPCiPipelinesTriggerId, quara .and change { pipeline3.reload.trigger_id }.from(nil).to(trigger3.id) end end - - context 'when ci_trigger_requests belongs to multiple pipelines' do - before do - ci_trigger_request.create!(commit_id: build1.id, trigger_id: trigger1.id) - ci_trigger_request.create!(commit_id: build11.id, trigger_id: trigger2.id) - ci_trigger_request.create!(commit_id: build2.id, trigger_id: trigger2.id) - ci_trigger_request.create!(commit_id: build22.id, trigger_id: trigger3.id) - ci_trigger_request.create!(commit_id: build3.id, trigger_id: trigger3.id) - ci_trigger_request.create!(commit_id: nil, trigger_id: trigger4.id) - end - - it 'updates p_ci_pipelines.trigger_id with the first trigger' do - expect { migration.perform } - .to change { pipeline1.reload.trigger_id }.from(nil).to(trigger1.id) - .and change { pipeline2.reload.trigger_id }.from(nil).to(trigger2.id) - .and change { pipeline3.reload.trigger_id }.from(nil).to(trigger3.id) - end - end end diff --git a/spec/lib/gitlab/database/migrations/runner_spec.rb b/spec/lib/gitlab/database/migrations/runner_spec.rb index 7c71076e8f3..29b6040bd3e 100644 --- a/spec/lib/gitlab/database/migrations/runner_spec.rb +++ b/spec/lib/gitlab/database/migrations/runner_spec.rb @@ -192,7 +192,7 @@ RSpec.describe Gitlab::Database::Migrations::Runner, :reestablished_active_recor it 'is configured with a result dir of /background_migrations' do runner = described_class.background_migrations - expect(runner.result_dir).to eq(described_class::BASE_RESULT_DIR.join( 'background_migrations')) + expect(runner.result_dir).to eq(described_class::BASE_RESULT_DIR.join('background_migrations')) end end diff --git a/spec/lib/gitlab/database/reindexing/reindex_concurrently_spec.rb b/spec/lib/gitlab/database/reindexing/reindex_concurrently_spec.rb index ddd48ff564e..0ba87a07bd7 100644 --- a/spec/lib/gitlab/database/reindexing/reindex_concurrently_spec.rb +++ b/spec/lib/gitlab/database/reindexing/reindex_concurrently_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Gitlab::Database::Reindexing::ReindexConcurrently, '#perform' do let(:column_name) { '_test_column' } let(:index_name) { '_test_reindex_index' } let(:index) { Gitlab::Database::PostgresIndex.by_identifier("public.#{iname(index_name)}") } - let(:logger) { double('logger', debug: nil, info: nil, error: nil ) } + let(:logger) { double('logger', debug: nil, info: nil, error: nil) } let(:connection) { ActiveRecord::Base.connection } before do diff --git a/spec/lib/gitlab/diff/highlight_cache_spec.rb b/spec/lib/gitlab/diff/highlight_cache_spec.rb index 94a5d30283c..23d14716972 100644 --- a/spec/lib/gitlab/diff/highlight_cache_spec.rb +++ b/spec/lib/gitlab/diff/highlight_cache_spec.rb @@ -88,7 +88,7 @@ RSpec.describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache, feature_ # diff_file_size_kb = (diff_file.diff.diff.bytesize * 10) - stub_const("#{diff_file.diff.class}::DEFAULT_MAX_PATCH_BYTES", diff_file_size_kb - 1 ) + stub_const("#{diff_file.diff.class}::DEFAULT_MAX_PATCH_BYTES", diff_file_size_kb - 1) expect(diff_file.diff.class).to receive(:patch_safe_limit_bytes).and_return(diff_file_size_kb + 1) expect(diff_file.diff.class) .to receive(:patch_safe_limit_bytes) diff --git a/spec/lib/gitlab/exclusive_lease_helpers_spec.rb b/spec/lib/gitlab/exclusive_lease_helpers_spec.rb index 52de4220ba5..6f409a8de32 100644 --- a/spec/lib/gitlab/exclusive_lease_helpers_spec.rb +++ b/spec/lib/gitlab/exclusive_lease_helpers_spec.rb @@ -58,7 +58,7 @@ RSpec.describe Gitlab::ExclusiveLeaseHelpers, :clean_gitlab_redis_shared_state d let(:options) { { ttl: 10.minutes } } it 'receives the specified argument' do - expect(Gitlab::ExclusiveLease).to receive(:new).with(unique_key, { timeout: 10.minutes } ) + expect(Gitlab::ExclusiveLease).to receive(:new).with(unique_key, { timeout: 10.minutes }) expect { subject }.to raise_error('Failed to obtain a lock') end diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index 02385aa9024..06d6f148919 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -312,7 +312,7 @@ RSpec.describe Gitlab::Git::Blob do blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id]) expect(blobs.count).to eq(1) - expect(blobs).to all( be_a(described_class) ) + expect(blobs).to all(be_a(described_class)) expect(blobs).to be_an(Array) end @@ -320,7 +320,7 @@ RSpec.describe Gitlab::Git::Blob do blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id].lazy) expect(blobs.count).to eq(1) - expect(blobs).to all( be_a(described_class) ) + expect(blobs).to all(be_a(described_class)) end it 'handles empty list of IDs gracefully' do diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 1d2d260bf6d..695f0b9d3bd 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -407,7 +407,7 @@ RSpec.describe Gitlab::Git::Commit, feature_category: :source_code_management do it 'returns a collection of commits' do commits = described_class.find_all(repository) - expect(commits).to all( be_a_kind_of(described_class) ) + expect(commits).to all(be_a_kind_of(described_class)) end context 'max_count' do @@ -504,7 +504,7 @@ RSpec.describe Gitlab::Git::Commit, feature_category: :source_code_management do commits = described_class.batch_by_oid(repository, oids) expect(commits.count).to eq(2) - expect(commits).to all( be_a(described_class) ) + expect(commits).to all(be_a(described_class)) expect(commits.first.sha).to eq(SeedRepo::Commit::ID) expect(commits.second.sha).to eq(SeedRepo::FirstCommit::ID) end diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index c04ad13953d..def52bd16c1 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -288,8 +288,8 @@ EOT end context 'when replace_invalid_utf8_chars is false' do - let(:not_replaced_diff) { described_class.new(@raw_diff_hash.merge({ diff: bad_string, replace_invalid_utf8_chars: false }) ) } - let(:not_replaced_diff_two) { described_class.new(@raw_diff_hash.merge({ diff: bad_string_two, replace_invalid_utf8_chars: false }) ) } + let(:not_replaced_diff) { described_class.new(@raw_diff_hash.merge({ diff: bad_string, replace_invalid_utf8_chars: false })) } + let(:not_replaced_diff_two) { described_class.new(@raw_diff_hash.merge({ diff: bad_string_two, replace_invalid_utf8_chars: false })) } it 'will not try to convert invalid characters' do expect(Gitlab::EncodingHelper).not_to receive(:encode_utf8_with_replacement_character?) diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index f04384e793a..008d00dbd6f 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -649,7 +649,7 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen end it 'has valid commit ids as keys' do - expect(subject.keys).to all( match(Commit::COMMIT_SHA_PATTERN) ) + expect(subject.keys).to all(match(Commit::COMMIT_SHA_PATTERN)) end it 'does not error when dereferenced_target is nil' do diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/generic_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/generic_metric_spec.rb index e65d5d30d9d..4fdab6b5fd1 100644 --- a/spec/lib/gitlab/usage/metrics/instrumentations/generic_metric_spec.rb +++ b/spec/lib/gitlab/usage/metrics/instrumentations/generic_metric_spec.rb @@ -50,7 +50,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::GenericMetric, feature_ describe '#value' do it 'gives the correct value' do - expect(subject.value).to eq(ApplicationRecord.database.version ) + expect(subject.value).to eq(ApplicationRecord.database.version) end context 'when raising an exception' do diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 85b6f75a048..7dcdfe8a302 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -80,7 +80,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic describe 'usage_activity_by_stage_package' do it 'includes accurate usage_activity_by_stage data' do for_defined_days_back do - create(:project, packages: [create(:package)] ) + create(:project, packages: [create(:package)]) end expect(described_class.usage_activity_by_stage_package({})).to eq( diff --git a/spec/lib/gitlab/utils/delegator_override/validator_spec.rb b/spec/lib/gitlab/utils/delegator_override/validator_spec.rb index 4fcf01ea256..f8263927bef 100644 --- a/spec/lib/gitlab/utils/delegator_override/validator_spec.rb +++ b/spec/lib/gitlab/utils/delegator_override/validator_spec.rb @@ -58,7 +58,7 @@ RSpec.describe Gitlab::Utils::DelegatorOverride::Validator do it 'adds the allowlist in the ancestors' do ancestor_validator = described_class.new(ee_delegator_extension) ancestor_validator.add_allowlist([:bar]) - validator.expand_on_ancestors( { ee_delegator_extension => ancestor_validator }) + validator.expand_on_ancestors({ ee_delegator_extension => ancestor_validator }) expect(validator.allowed_method_names).to contain_exactly(:bar) end @@ -73,7 +73,7 @@ RSpec.describe Gitlab::Utils::DelegatorOverride::Validator do validator.add_allowlist([:foo]) ancestor_validator = described_class.new(ee_delegator_extension) ancestor_validator.add_allowlist([:bar]) - validator.expand_on_ancestors( { ee_delegator_extension => ancestor_validator }) + validator.expand_on_ancestors({ ee_delegator_extension => ancestor_validator }) expect { validator.validate_overrides! }.not_to raise_error end diff --git a/spec/lib/gitlab/utils/usage_data_spec.rb b/spec/lib/gitlab/utils/usage_data_spec.rb index 85976b51a7d..b235b461215 100644 --- a/spec/lib/gitlab/utils/usage_data_spec.rb +++ b/spec/lib/gitlab/utils/usage_data_spec.rb @@ -461,7 +461,7 @@ RSpec.describe Gitlab::Utils::UsageData do end it 'returns the evaluated block when give' do - expect(described_class.alt_usage_data { Gitlab::CurrentSettings.uuid } ).to eq(Gitlab::CurrentSettings.uuid) + expect(described_class.alt_usage_data { Gitlab::CurrentSettings.uuid }).to eq(Gitlab::CurrentSettings.uuid) end it 'returns the value when given' do diff --git a/spec/lib/gitlab/x509/commit_spec.rb b/spec/lib/gitlab/x509/commit_spec.rb index 2766a1a9bac..bb263ec0181 100644 --- a/spec/lib/gitlab/x509/commit_spec.rb +++ b/spec/lib/gitlab/x509/commit_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Gitlab::X509::Commit, feature_category: :source_code_management d let(:commit_sha) { '189a6c924013fc3fe40d6f1ec1dc20214183bc97' } let_it_be(:user) { create(:user, email: X509Helpers::User1.certificate_email) } let_it_be(:project) { create(:project, :repository, path: X509Helpers::User1.path, creator: user) } - let(:commit) { project.commit_by(oid: commit_sha ) } + let(:commit) { project.commit_by(oid: commit_sha) } let(:signature) { described_class.new(commit).signature } let(:store) { OpenSSL::X509::Store.new } let(:certificate) { OpenSSL::X509::Certificate.new(X509Helpers::User1.trust_cert) } diff --git a/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb b/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb index 879b6535275..5707a896f4e 100644 --- a/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb @@ -185,7 +185,7 @@ RSpec.describe Security::CiConfiguration::ContainerScanningBuildAction do # stubbing this method allows this spec file to use fast_spec_helper def fast_auto_devops_stages - auto_devops_template = YAML.safe_load( File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml') ) + auto_devops_template = YAML.safe_load(File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml')) auto_devops_template['stages'] end end diff --git a/spec/lib/security/ci_configuration/sast_build_action_spec.rb b/spec/lib/security/ci_configuration/sast_build_action_spec.rb index 086925d9495..0ffd652aa2b 100644 --- a/spec/lib/security/ci_configuration/sast_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/sast_build_action_spec.rb @@ -30,47 +30,43 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do end let(:params_with_analyzer_info) do - params.merge( { analyzers: - [ - { - name: "bandit", - enabled: false - }, - { - name: "brakeman", - enabled: true, - variables: [ - { field: "SAST_BRAKEMAN_LEVEL", - default_value: "1", - value: "2" } - ] - }, - { - name: "flawfinder", - enabled: true, - variables: [ - { field: "SAST_FLAWFINDER_LEVEL", - default_value: "1", - value: "1" } - ] - } - ] } - ) + params.merge({ + analyzers: [ + { + name: "bandit", + enabled: false + }, + { + name: "brakeman", + enabled: true, + variables: [ + { field: "SAST_BRAKEMAN_LEVEL", default_value: "1", value: "2" } + ] + }, + { + name: "flawfinder", + enabled: true, + variables: [ + { field: "SAST_FLAWFINDER_LEVEL", default_value: "1", value: "1" } + ] + } + ] + }) end let(:params_with_all_analyzers_enabled) do - params.merge( { analyzers: - [ - { - name: "flawfinder", - enabled: true - }, - { - name: "brakeman", - enabled: true - } - ] } - ) + params.merge({ + analyzers: [ + { + name: "flawfinder", + enabled: true + }, + { + name: "brakeman", + enabled: true + } + ] + }) end context 'with existing .gitlab-ci.yml' do @@ -314,7 +310,7 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do # stubbing this method allows this spec file to use fast_spec_helper def fast_auto_devops_stages - auto_devops_template = YAML.safe_load( File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml') ) + auto_devops_template = YAML.safe_load(File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml')) auto_devops_template['stages'] end diff --git a/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb b/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb index b3e4b8c2651..baa1784c4ab 100644 --- a/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb @@ -175,7 +175,7 @@ RSpec.describe Security::CiConfiguration::SastIacBuildAction do # stubbing this method allows this spec file to use fast_spec_helper def fast_auto_devops_stages - auto_devops_template = YAML.safe_load( File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml') ) + auto_devops_template = YAML.safe_load(File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml')) auto_devops_template['stages'] end end diff --git a/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb b/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb index 438ab01b2df..dc28e8327ca 100644 --- a/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb @@ -161,7 +161,7 @@ RSpec.describe Security::CiConfiguration::SecretDetectionBuildAction do # stubbing this method allows this spec file to use fast_spec_helper def fast_auto_devops_stages - auto_devops_template = YAML.safe_load( File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml') ) + auto_devops_template = YAML.safe_load(File.read('lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml')) auto_devops_template['stages'] end end diff --git a/spec/migrations/20250102002809_requeue_backfill_p_ci_pipelines_trigger_id_spec.rb b/spec/migrations/20250102002809_requeue_backfill_p_ci_pipelines_trigger_id_spec.rb new file mode 100644 index 00000000000..f458830cff4 --- /dev/null +++ b/spec/migrations/20250102002809_requeue_backfill_p_ci_pipelines_trigger_id_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe RequeueBackfillPCiPipelinesTriggerId, + migration: :gitlab_ci, feature_category: :continuous_integration do + let!(:batched_migration) { described_class::MIGRATION } + + it 'schedules a new batched migration' do + reversible_migration do |migration| + migration.before -> { + expect(batched_migration).not_to have_scheduled_batched_migration + } + + migration.after -> { + expect(batched_migration).to have_scheduled_batched_migration( + gitlab_schema: :gitlab_ci, + table_name: :ci_trigger_requests, + column_name: :id, + interval: described_class::DELAY_INTERVAL + ) + } + end + end +end diff --git a/spec/models/ml/candidate_metric_spec.rb b/spec/models/ml/candidate_metric_spec.rb index 9ceaa83a6fa..3a6effe7e9f 100644 --- a/spec/models/ml/candidate_metric_spec.rb +++ b/spec/models/ml/candidate_metric_spec.rb @@ -10,13 +10,13 @@ RSpec.describe Ml::CandidateMetric, feature_category: :mlops do describe 'scope :latest' do let_it_be(:candidate) { create(:ml_candidates) } let!(:metric1) { create(:ml_candidate_metrics, candidate: candidate) } - let!(:metric2) { create(:ml_candidate_metrics, candidate: candidate ) } + let!(:metric2) { create(:ml_candidate_metrics, candidate: candidate) } let!(:metric3) { create(:ml_candidate_metrics, name: metric1.name, candidate: candidate) } subject { described_class.latest } it 'fetches only the last metric for the name' do - expect(subject).to match_array([metric2, metric3] ) + expect(subject).to match_array([metric2, metric3]) end end end diff --git a/spec/models/ml/candidate_spec.rb b/spec/models/ml/candidate_spec.rb index 1802c4331b7..3a0e89f198a 100644 --- a/spec/models/ml/candidate_spec.rb +++ b/spec/models/ml/candidate_spec.rb @@ -282,13 +282,13 @@ RSpec.describe Ml::Candidate, factory_default: :keep, feature_category: :mlops d describe "#latest_metrics" do let_it_be(:candidate3) { create(:ml_candidates, experiment: candidate.experiment) } let_it_be(:metric1) { create(:ml_candidate_metrics, candidate: candidate3) } - let_it_be(:metric2) { create(:ml_candidate_metrics, candidate: candidate3 ) } + let_it_be(:metric2) { create(:ml_candidate_metrics, candidate: candidate3) } let_it_be(:metric3) { create(:ml_candidate_metrics, name: metric1.name, candidate: candidate3) } subject { candidate3.latest_metrics } it 'fetches only the last metric for the name' do - expect(subject).to match_array([metric2, metric3] ) + expect(subject).to match_array([metric2, metric3]) end end diff --git a/vendor/gems/cloud_profiler_agent/Gemfile.lock b/vendor/gems/cloud_profiler_agent/Gemfile.lock index 47087362534..12439188ee9 100644 --- a/vendor/gems/cloud_profiler_agent/Gemfile.lock +++ b/vendor/gems/cloud_profiler_agent/Gemfile.lock @@ -3,7 +3,7 @@ PATH specs: cloud_profiler_agent (0.0.1.pre) google-cloud-profiler-v2 (~> 0.3) - google-protobuf (~> 3.13) + google-protobuf (~> 3.25) googleauth (>= 0.14) stackprof (~> 0.2) @@ -37,7 +37,7 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - gapic-common (0.17.1) + gapic-common (0.20.0) faraday (>= 1.9, < 3.a) faraday-retry (>= 1.0, < 3.a) google-protobuf (~> 3.14) @@ -46,10 +46,10 @@ GEM googleauth (~> 1.0) grpc (~> 1.36) google-cloud-errors (1.3.0) - google-cloud-profiler-v2 (0.3.0) - gapic-common (>= 0.10, < 2.a) + google-cloud-profiler-v2 (0.8.0) + gapic-common (>= 0.20.0, < 2.a) google-cloud-errors (~> 1.0) - google-protobuf (3.22.0) + google-protobuf (3.25.5) googleapis-common-protos (1.4.0) google-protobuf (~> 3.14) googleapis-common-protos-types (~> 1.2) @@ -63,8 +63,8 @@ GEM multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) - grpc (1.52.0) - google-protobuf (~> 3.21) + grpc (1.69.0) + google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) json (2.6.2) jwt (2.1.0) diff --git a/vendor/gems/cloud_profiler_agent/cloud_profiler_agent.gemspec b/vendor/gems/cloud_profiler_agent/cloud_profiler_agent.gemspec index 82e5041491d..08dbfe69dfa 100644 --- a/vendor/gems/cloud_profiler_agent/cloud_profiler_agent.gemspec +++ b/vendor/gems/cloud_profiler_agent/cloud_profiler_agent.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'googleauth', '>= 0.14' spec.add_runtime_dependency 'google-cloud-profiler-v2', '~> 0.3' - spec.add_runtime_dependency 'google-protobuf', '~> 3.13' + spec.add_runtime_dependency 'google-protobuf', '~> 3.25' spec.add_runtime_dependency 'stackprof', '~> 0.2' spec.add_development_dependency 'rspec', '>= 3.10'