diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-11-16 15:26:12 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-11-16 15:26:12 -0600 |
commit | 7897d04fcb966a4aa83e44d3d93348caf5715438 (patch) | |
tree | 4cda0f9456185fd27a7f2cb032a2764cf363d1f5 /db/fixtures | |
parent | d41e66cb632cf4a51428c87a07cbdd182e3e0697 (diff) | |
download | gitlab-ce-7897d04fcb966a4aa83e44d3d93348caf5715438.tar.gz |
Update CycleAnalytics seed to account for multiple issue assigneesrs-cycle-analytics-seed
Diffstat (limited to 'db/fixtures')
-rw-r--r-- | db/fixtures/development/17_cycle_analytics.rb | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 383782112a8..96c6d954ff7 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -4,7 +4,7 @@ require './spec/support/test_env' class Gitlab::Seeder::CycleAnalytics def initialize(project, perf: false) @project = project - @user = User.order(:id).last + @user = User.admins.first @issue_count = perf ? 1000 : 5 stub_git_pre_receive! end @@ -77,39 +77,41 @@ class Gitlab::Seeder::CycleAnalytics end def seed! - Sidekiq::Testing.inline! do - issues = create_issues - puts '.' - - # Stage 1 - Timecop.travel 5.days.from_now - add_milestones_and_list_labels(issues) - print '.' - - # Stage 2 - Timecop.travel 5.days.from_now - branches = mention_in_commits(issues) - print '.' - - # Stage 3 - Timecop.travel 5.days.from_now - merge_requests = create_merge_requests_closing_issues(issues, branches) - print '.' - - # Stage 4 - Timecop.travel 5.days.from_now - run_builds(merge_requests) - print '.' - - # Stage 5 - Timecop.travel 5.days.from_now - merge_merge_requests(merge_requests) - print '.' - - # Stage 6 / 7 - Timecop.travel 5.days.from_now - deploy_to_production(merge_requests) - print '.' + Sidekiq::Worker.skipping_transaction_check do + Sidekiq::Testing.inline! do + issues = create_issues + puts '.' + + # Stage 1 + Timecop.travel 5.days.from_now + add_milestones_and_list_labels(issues) + print '.' + + # Stage 2 + Timecop.travel 5.days.from_now + branches = mention_in_commits(issues) + print '.' + + # Stage 3 + Timecop.travel 5.days.from_now + merge_requests = create_merge_requests_closing_issues(issues, branches) + print '.' + + # Stage 4 + Timecop.travel 5.days.from_now + run_builds(merge_requests) + print '.' + + # Stage 5 + Timecop.travel 5.days.from_now + merge_merge_requests(merge_requests) + print '.' + + # Stage 6 / 7 + Timecop.travel 5.days.from_now + deploy_to_production(merge_requests) + print '.' + end end print '.' @@ -123,7 +125,7 @@ class Gitlab::Seeder::CycleAnalytics title: "Cycle Analytics: #{FFaker::Lorem.sentence(6)}", description: FFaker::Lorem.sentence, state: 'opened', - assignee: @project.team.users.sample + assignees: [@project.team.users.sample] } Issues::CreateService.new(@project, @project.team.users.sample, issue_params).execute @@ -155,7 +157,7 @@ class Gitlab::Seeder::CycleAnalytics issue.project.repository.add_branch(@user, branch_name, 'master') - commit_sha = issue.project.repository.create_file(@user, filename, "content", message: "Commit for ##{issue.iid}", branch_name: branch_name) + commit_sha = issue.project.repository.create_file(@user, filename, "content", message: "Commit for #{issue.to_reference}", branch_name: branch_name) issue.project.repository.commit(commit_sha) GitPushService.new(issue.project, @@ -210,6 +212,8 @@ class Gitlab::Seeder::CycleAnalytics def deploy_to_production(merge_requests) merge_requests.each do |merge_request| + next unless merge_request.head_pipeline + Timecop.travel 12.hours.from_now job = merge_request.head_pipeline.builds.where.not(environment: nil).last @@ -223,7 +227,14 @@ Gitlab::Seeder.quiet do flag = 'SEED_CYCLE_ANALYTICS' if ENV[flag] - Project.all.each do |project| + Project.find_each do |project| + # This seed naively assumes that every project has a repository, and every + # repository has a `master` branch, which may be the case for a pristine + # GDK seed, but is almost never true for a GDK that's actually had + # development performed on it. + next unless project.repository_exists? + next unless project.repository.commit('master') + seeder = Gitlab::Seeder::CycleAnalytics.new(project) seeder.seed! end |