From b0dbc47e2c29419133c1a24ed6922a68584a3e28 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 8 Aug 2018 15:33:24 +0900 Subject: [PATCH] Simplify fixtures --- db/fixtures/development/14_pipelines.rb | 107 ++++-------------- spec/fixtures/junit/junit_feature.xml.gz | Bin 541 -> 0 bytes spec/fixtures/junit/junit_feature_ant.xml.gz | Bin 1837 -> 0 bytes .../junit/junit_feature_rspec_0_3.xml.gz | Bin 541 -> 0 bytes .../junit/junit_feature_rspec_1_3.xml.gz | Bin 522 -> 0 bytes .../junit/junit_feature_rspec_2_3.xml.gz | Bin 359 -> 0 bytes spec/fixtures/junit/junit_master.xml.gz | Bin 568 -> 0 bytes spec/fixtures/junit/junit_master_ant.xml.gz | Bin 1659 -> 0 bytes .../junit/junit_master_rspec_0_3.xml.gz | Bin 592 -> 0 bytes .../junit/junit_master_rspec_1_3.xml.gz | Bin 367 -> 0 bytes .../junit/junit_master_rspec_2_3.xml.gz | Bin 360 -> 0 bytes 11 files changed, 20 insertions(+), 87 deletions(-) delete mode 100644 spec/fixtures/junit/junit_feature.xml.gz delete mode 100644 spec/fixtures/junit/junit_feature_ant.xml.gz delete mode 100644 spec/fixtures/junit/junit_feature_rspec_0_3.xml.gz delete mode 100644 spec/fixtures/junit/junit_feature_rspec_1_3.xml.gz delete mode 100644 spec/fixtures/junit/junit_feature_rspec_2_3.xml.gz delete mode 100644 spec/fixtures/junit/junit_master.xml.gz delete mode 100644 spec/fixtures/junit/junit_master_ant.xml.gz delete mode 100644 spec/fixtures/junit/junit_master_rspec_0_3.xml.gz delete mode 100644 spec/fixtures/junit/junit_master_rspec_1_3.xml.gz delete mode 100644 spec/fixtures/junit/junit_master_rspec_2_3.xml.gz diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb index c8ec7224751..04002637610 100644 --- a/db/fixtures/development/14_pipelines.rb +++ b/db/fixtures/development/14_pipelines.rb @@ -30,8 +30,6 @@ class Gitlab::Seeder::Pipelines queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, { name: 'spinach:osx', stage: 'test', status: :failed, allow_failure: true, queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, - { name: 'java ant', stage: 'test', status: :failed, allow_failure: true, - queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago }, # deploy stage { name: 'staging', stage: 'deploy', environment: 'staging', status_event: :success, @@ -63,51 +61,6 @@ class Gitlab::Seeder::Pipelines end end - def create_running_pipeline_with_test_reports(ref, rspec_pattern:, ant_pattern:) - raise 'Unknown result_pattern' unless %w[pass failed-1 failed-2 failed-3 corrupted].include?(rspec_pattern) - raise 'Unknown result_pattern' unless %w[pass failed-1 failed-2 failed-3].include?(ant_pattern) - - last_commit = @project.repository.commit(ref) - pipeline = create_pipeline!(@project, ref, last_commit) - - @project.merge_requests.find_by_source_branch(ref).update!(head_pipeline_id: pipeline.id) if ref != 'master' - - (0...3).each do |index| - Ci::Build.create!(name: "rspec:pg #{index} 3", stage: 'test', status: :running, project: @project, pipeline: pipeline, ref: ref).tap do |build| - path = if rspec_pattern == 'corrupted' - Rails.root + "spec/fixtures/junit/junit_with_corrupted_data.xml.gz" - else - Rails.root + "spec/fixtures/junit/#{rspec_pattern}-rspec-#{index}-3.xml.gz" - end - - artifacts_cache_file(path) do |file| - build.job_artifacts.create!(project: build.project, file_type: :junit, file_format: :gzip, file: file) - end - end - end - - Ci::Build.create!(name: "java ant", stage: 'test', status: :running, project: @project, pipeline: pipeline, ref: ref).tap do |build| - path = Rails.root + "spec/fixtures/junit/#{ant_pattern}-ant-test.xml.gz" - - artifacts_cache_file(path) do |file| - build.job_artifacts.create!(project: build.project, file_type: :junit, file_format: :gzip, file: file) - end - end - - pipeline.update_duration - pipeline.update_status - end - - def finish_last_pipeline(ref) - last_pipeline = @project.pipelines.where(ref: ref).last - last_pipeline.builds.update_all(status: :success) - last_pipeline.update_status - end - - def destroy_pipeline(ref) - @project.pipelines.where(ref: ref).destroy_all - end - private def pipelines @@ -153,8 +106,8 @@ class Gitlab::Seeder::Pipelines # (id required), that is why we need `#tap` method instead of passing # block directly to `Ci::Build#create!`. - setup_artifacts(build) if %w[build test].include?(build.stage) - setup_test_reports(build) if %w[test].include?(build.stage) + setup_artifacts(build) + setup_test_reports(build) setup_build_log(build) build.project.environments. @@ -165,6 +118,8 @@ class Gitlab::Seeder::Pipelines end def setup_artifacts(build) + return unless build.stage == "build" + artifacts_cache_file(artifacts_archive_path) do |file| build.job_artifacts.build(project: build.project, file_type: :archive, file_format: :zip, file: file) end @@ -175,27 +130,15 @@ class Gitlab::Seeder::Pipelines end def setup_test_reports(build) + return unless build.stage == "test" && build.name == "rspec:osx" + if build.ref == build.project.default_branch - if build.name.include?('rspec:linux') - artifacts_cache_file(artifacts_rspec_junit_master_path(build.name)) do |file| - build.job_artifacts.build(project: build.project, file_type: :junit, file_format: :gzip, file: file) - end - elsif build.name.include?('java ant') - artifacts_cache_file(artifacts_ant_junit_master_path) do |file| - build.job_artifacts.build(project: build.project, file_type: :junit, file_format: :gzip, file: file) - end + artifacts_cache_file(test_reports_pass_path) do |file| + build.job_artifacts.build(project: build.project, file_type: :junit, file_format: :gzip, file: file) end else - if build.name.include?('rspec:linux') - artifacts_rspec_junit_feature_path(build.name).try do |path| - artifacts_cache_file(path) do |file| - build.job_artifacts.build(project: build.project, file_type: :junit, file_format: :gzip, file: file) - end - end - elsif build.name.include?('java ant') - artifacts_cache_file(artifacts_ant_junit_feature_path) do |file| - build.job_artifacts.build(project: build.project, file_type: :junit, file_format: :gzip, file: file) - end + artifacts_cache_file(test_reports_failed_path) do |file| + build.job_artifacts.build(project: build.project, file_type: :junit, file_format: :gzip, file: file) end end end @@ -239,22 +182,12 @@ class Gitlab::Seeder::Pipelines Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz' end - def artifacts_rspec_junit_master_path(build_name) - index, total = build_name.scan(/ (\d) (\d)/).first - Rails.root + "spec/fixtures/junit/junit_master_rspec_#{index}_#{total}.xml.gz" - end - - def artifacts_rspec_junit_feature_path(build_name) - index, total = build_name.scan(/ (\d) (\d)/).first - Rails.root + "spec/fixtures/junit/junit_feature_rspec_#{index}_#{total}.xml.gz" + def test_reports_pass_path + Rails.root + 'spec/fixtures/junit/pass-rspec-0-3.xml.gz' end - def artifacts_ant_junit_master_path - Rails.root + "spec/fixtures/junit/junit_master_ant.xml.gz" - end - - def artifacts_ant_junit_feature_path - Rails.root + "spec/fixtures/junit/junit_feature_ant.xml.gz" + def test_reports_failed_path + Rails.root + 'spec/fixtures/junit/failed-1-rspec-0-3.xml.gz' end def artifacts_cache_file(file_path) @@ -267,9 +200,9 @@ class Gitlab::Seeder::Pipelines end end -# Gitlab::Seeder.quiet do -# Project.all.sample(5).each do |project| -# project_builds = Gitlab::Seeder::Pipelines.new(project) -# project_builds.seed! -# end -# end +Gitlab::Seeder.quiet do + Project.all.sample(5).each do |project| + project_builds = Gitlab::Seeder::Pipelines.new(project) + project_builds.seed! + end +end diff --git a/spec/fixtures/junit/junit_feature.xml.gz b/spec/fixtures/junit/junit_feature.xml.gz deleted file mode 100644 index 802c35f6fccabdc25e3ed58001a0c54e71be3c64..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 541 zcmV+&0^$x=YAsCsEmetsJJ^UF+r`p~s-Pl1iI z1*S`dK(=zVu}y(rFVEv0o|aKA#KOH10;@YJFtDczVcafog}}GQd#Vdm2-n)QeIPC{ zMW7H|;BjBfP^y+HRXdeVnnicMz?DjOvD(Jz_A*u3W|ytg_ey0-A>25Y!==5o6yl9i zw7x!G#Xh+2R7sp3#g(&F9|Bp46_!!%gYy)`5I>8@13MGd2=}_}slau*IX=dujPm4F z&G52HGeOmA=0l;UYRM9eZLV&p^%SnA7$*B-bUu#8y8%cGSuF%VZpeZL!_XK3ZEM&M zqSbo{Bz>?9+;^Q0j|kVMr2?19aB%YbUCXe4k)!&sS|4GV9|DJtm~}%1M)csR5~?$p z-StjR8Y8XVPwNPVuW|Ci1bDWidF48<1J%&8u?-Z(B0`WyPX&It@Kj~l*?7Jd<1D{Y zpPhUnIU9aDmgf^!GRh1LUp;Xx#R1*TXWBb{f*aS1C<6F9{hRy%e|o`NnP%xKGZwz> zTUXt}d;=}rQ_Bl57G|xSi1RQHbl00e^^ZdFq(|(>yDsAZWwHpzSnd f|JpoiyWZk!@Z{H=m(kAv00960DaxND8w3CV$Nmec diff --git a/spec/fixtures/junit/junit_feature_ant.xml.gz b/spec/fixtures/junit/junit_feature_ant.xml.gz deleted file mode 100644 index 401025ec1e0b9fa2ed2e938b84bbdef32aefea2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1837 zcmV+|2h#W-iwGD~v|d{P|5Qa&R4qecY-4q7VRUbDRAqB?E_iKh0BUt^X>=`RcwudD zY-KN0MN?EQLt$)Vb!=gDZ*o*+b963vZEOInS?_M!I1>MSc?zBmC|cZ#mTbpO-8c(h z)81{aX^Yxj6t`F`XliUTrbvMtInF)(f|M-VSxZ)eeo92n42SdQH#79*&zn?|H5eb1AAWLmgu@pvu z$&~^Vz8(zX*WCdRGo$Z-V;J{Ct`*OX0fk`{kb?XjlRTFUwV8s&fY_DDGD!Rh{@78_ z3kV8F8`0?Ey!f!l(rgrTqxd3>UWdJC8V!d1!LZ*8uFeR#%#6;!paAPWcMA{Yu}mSA zVrH0mpouU6Su>f#DCp$YbnKED=rDyHDP{rb)QGr8idxH+z>3}Gin{ghaZJBYx0`hW z6wE=+T?({_oN4Ljam zRC@zZuG3DfoZNz;4kQ1s6`W2|Z4a^Fqfq(gq+_0qK^_yFkZqh+Op|Y){+LY1pRUJW zuN&ECTJOO7FwI@8`ZQjr-e6%IhdKjwm#jjTCWC$>qF1_cou*7Bm0WEWlx2)B!6Uw< z&e_Q9DuKDBI&(%~vT!=R`KAQAV)oTnLULH)e1ZF<)zsIvIg=L1Tu20ihH)67$$>1H z#Lw!ztF~ZNQx5e*KlcoB_b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{!W`A$Yg`JsPQ{y4u5YC*3t3*t|Ai=pKsY##bJNjU3Te0A zt(I-ENqumisf(#xrJb|g7y{Xt3T%?f2j?k7P5cu)&)%7+M|e_Zq#9SnW+O3gk}5yr z9Byn@KxA!4edt&?d>*Ph|q| zHyx8KH@ZE)Wft1&!NW#I|Of0^c5`34fLw5;s4O-ptR>)7^iYCwL*2kfKFXX#|Qs z4Iw^T{Pgf%o$$UtbcLkI5(+_dGg)NGX_TV+lU#+=*cY?`-PpS4C9lazhv5+kwlr^~TZd zSEG~hQM`+fTLfF_gOl;2ck#_yfv+P)aQwW?6bl4_)dWms;V4i>+NL91!bBFUdTmu- zcdq#9&%|`AHTGTolk2}D##DAp7lZ^{9JasvC(4_<_Ako%*Xs0#9{~UW|Nm!hIPPu& F0060fxAOo1 diff --git a/spec/fixtures/junit/junit_master.xml.gz b/spec/fixtures/junit/junit_master.xml.gz deleted file mode 100644 index 88b7de6fa61e74a61375f2deb63a8f6efb5dc064..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 568 zcmV-80>}LyiwGEP$xT}T|8jG1Wn(UQZEOH?b8uy2E_iKh0K}AEPunmMz~A#JPM(BX zO=-?)1|=ln3EsAcjXg8hIf_SO8=u4A+fQlBpE9PQZQA4rdD zi(CMO-~zAn(Tt@yLn-sc;U?y&dS8ni`c=Wh{9L;;tMy`vfof4;A+jc^vYm=? zF0GhAcZzvi=1I@S2j`pFH`z1d_=blbzFm?91%^R_vMnsfzc~boL$C}y^t}pq0xnEP zwU}k&A=$%mv#@-!A3V$tbJ0}WMM6)^YDKk3=+={t)Rr($VEnCIEFqOiGSRO0Do_gp z8@qzKo+bj~ou^uS{NzcO<;l8OMdK{*L?2vyPw`|lC7RPs(`+4+>&bkY zBmh5?xA zRoQkmO_kld`eSW~PsAbqraF`h{FOSy9eIfVR3GAVf%iN+M6Z{a%l|5I8H3XCryrm) zObp6yZlc#(JSZ08Z*%33T=L=V(k=wj5d!hh#n288(^iwGD9v|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y82s+MG`+T&NEES4UE;S7WI6v;n(H_m4EN)Z?c=whhZhzNW3*Tmguu~{ z#}LmJKRvxS4L)|OHnV1(LS~3=V2h%OJ;H6!)DQ%-HvwO7_CyGmQS*K16eElA&1q8~);p7A{LDU^ zYGeEu{UpLM8^UhYCK(e;4y?b#_0F!$M}!yGPi%3!tG8HotG4_jGGEL)W$?XIz2_49 zLbHT;e!g&@Se};_7W?DP`EWDd%sei0beZAng(El!3g?i)#UmVM(Ypf(=SiZ1PQ&2j zif{@&TP(`?;PT&Dg&cmbk=E2;*OotMUkAJ<0&ziE!Nui${~LVUtp5Tpe}1uU^*sOp N|NkK|OC6R1005x$u=M}{ diff --git a/spec/fixtures/junit/junit_master_rspec_2_3.xml.gz b/spec/fixtures/junit/junit_master_rspec_2_3.xml.gz deleted file mode 100644 index aca6bcb8e187ca23833d837dbccef6119efd0ac0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 360 zcmV-u0hj(CiwGE|Bu`ra|8jG1Wn(UQZEOH?b8uy2E_iKh0IZTvkJB&^#qa$Tqv430 z*iGrCRh+#c?kwk(*PU(*iEYg|3w(Q&P54u8NZkB9dNV&iPj~-q8sUXlLW&kmr4cCl zbP4g<;-`oAs>S<$*AHwzx--FCk~TSkwqt7si=MUIj5HUXLX# zR$Xar?wV%RQrwg+?zL%^zEh@sFy_2Joe#}htweeOH=gBX-U)#poyca) z