Commit b3868525 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'osw-adjust-constants-for-single-running-seeds' into 'master'

Adjust constant evaluation for single running seeds

Closes #36649

See merge request gitlab-org/gitlab!20382
parents a8a13d7c 87a4fd8e
...@@ -5,7 +5,6 @@ class Gitlab::Seeder::Users ...@@ -5,7 +5,6 @@ class Gitlab::Seeder::Users
RANDOM_USERS_COUNT = 20 RANDOM_USERS_COUNT = 20
MASS_USERS_COUNT = ENV['CI'] ? 10 : 1_000_000 MASS_USERS_COUNT = ENV['CI'] ? 10 : 1_000_000
MASS_INSERT_USERNAME_START = 'mass_insert_user_'
attr_reader :opts attr_reader :opts
...@@ -29,7 +28,7 @@ class Gitlab::Seeder::Users ...@@ -29,7 +28,7 @@ class Gitlab::Seeder::Users
ActiveRecord::Base.connection.execute <<~SQL ActiveRecord::Base.connection.execute <<~SQL
INSERT INTO users (username, name, email, confirmed_at, projects_limit, encrypted_password) INSERT INTO users (username, name, email, confirmed_at, projects_limit, encrypted_password)
SELECT SELECT
'#{MASS_INSERT_USERNAME_START}' || seq, '#{Gitlab::Seeder::MASS_INSERT_USER_START}' || seq,
'Seed user ' || seq, 'Seed user ' || seq,
'seed_user' || seq || '@example.com', 'seed_user' || seq || '@example.com',
to_timestamp(seq), to_timestamp(seq),
......
...@@ -52,7 +52,6 @@ class Gitlab::Seeder::Projects ...@@ -52,7 +52,6 @@ class Gitlab::Seeder::Projects
internal: 1, # 1m projects + internal: 1, # 1m projects +
public: 1 # 1m projects = 5m total public: 1 # 1m projects = 5m total
} }
MASS_INSERT_NAME_START = 'mass_insert_project_'
def seed! def seed!
Sidekiq::Testing.inline! do Sidekiq::Testing.inline! do
...@@ -167,7 +166,7 @@ class Gitlab::Seeder::Projects ...@@ -167,7 +166,7 @@ class Gitlab::Seeder::Projects
INSERT INTO projects (name, path, creator_id, namespace_id, visibility_level, created_at, updated_at) INSERT INTO projects (name, path, creator_id, namespace_id, visibility_level, created_at, updated_at)
SELECT SELECT
'Seed project ' || seq || ' ' || ('{#{visibility_per_user}}'::text[])[seq] AS project_name, 'Seed project ' || seq || ' ' || ('{#{visibility_per_user}}'::text[])[seq] AS project_name,
'mass_insert_project_' || ('{#{visibility_per_user}}'::text[])[seq] || '_' || seq AS project_path, '#{Gitlab::Seeder::MASS_INSERT_PROJECT_START}' || ('{#{visibility_per_user}}'::text[])[seq] || '_' || seq AS project_path,
u.id AS user_id, u.id AS user_id,
n.id AS namespace_id, n.id AS namespace_id,
('{#{visibility_level_per_user}}'::int[])[seq] AS visibility_level, ('{#{visibility_level_per_user}}'::int[])[seq] AS visibility_level,
......
...@@ -16,6 +16,8 @@ module Gitlab ...@@ -16,6 +16,8 @@ module Gitlab
class Seeder class Seeder
extend ActionView::Helpers::NumberHelper extend ActionView::Helpers::NumberHelper
MASS_INSERT_PROJECT_START = 'mass_insert_project_'
MASS_INSERT_USER_START = 'mass_insert_user_'
ESTIMATED_INSERT_PER_MINUTE = 2_000_000 ESTIMATED_INSERT_PER_MINUTE = 2_000_000
MASS_INSERT_ENV = 'MASS_INSERT' MASS_INSERT_ENV = 'MASS_INSERT'
...@@ -24,7 +26,7 @@ module Gitlab ...@@ -24,7 +26,7 @@ module Gitlab
included do included do
scope :not_mass_generated, -> do scope :not_mass_generated, -> do
where.not("path LIKE '#{Gitlab::Seeder::Projects::MASS_INSERT_NAME_START}%'") where.not("path LIKE '#{MASS_INSERT_PROJECT_START}%'")
end end
end end
end end
...@@ -34,7 +36,7 @@ module Gitlab ...@@ -34,7 +36,7 @@ module Gitlab
included do included do
scope :not_mass_generated, -> do scope :not_mass_generated, -> do
where.not("username LIKE '#{Gitlab::Seeder::Users::MASS_INSERT_USERNAME_START}%'") where.not("username LIKE '#{MASS_INSERT_USER_START}%'")
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment