Skip to content

Commit 2bdf2c0

Browse files
committed
spec: rspec2 --tags for parallel_excluded specs
Change-Id: I20bf507acb2d0c26d34220d8e52fdf02cbde3e12 Reviewed-on: https://gerrit.instructure.com/32627 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Shawn Meredith <shawn@instructure.com> Product-Review: Shawn Meredith <shawn@instructure.com> QA-Review: Shawn Meredith <shawn@instructure.com>
1 parent 1c2696a commit 2bdf2c0

5 files changed

Lines changed: 66 additions & 55 deletions

File tree

lib/tasks/parallelized.rake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ unless ARGV.any? { |a| a =~ /\Agems/ }
1616
task :nonselenium, :count do |t, args|
1717
Rake::Task['spec:single'].execute #first rake task to run the files that fail in parallel in a single thread
1818

19+
#bug funky exit_codes resolved in ruby193p288 fix when resolved
1920
if File.zero?('tmp/parallel_log/rspec.failures')
2021
Rake::Task['parallel:nonseleniumparallel'].invoke(args[:count])
2122
else
@@ -32,11 +33,22 @@ unless ARGV.any? { |a| a =~ /\Agems/ }
3233
Rake::Task['parallel:spec'].invoke(count, '', '', test_files.join(' '))
3334
end
3435

36+
task :selenium_tags, :test_files, :tag do |t, args|
37+
require "parallelized_specs"
38+
puts 'starting single threaded selenium specs'
39+
#fix better logging as tags matures
40+
output = `bundle exec rspec --format doc #{args[:test_files]} --tag #{args[:tag]}`
41+
puts output
42+
#bug funky exit_codes resolved in ruby193p288 fix when resolved
43+
output.match(/(\d) failure/).to_a.last.to_i != 0 ? exit(1) : puts('all non_parallel selenium specs passed')
44+
end
45+
3546
task :selenium, :count, :build_section do |t, args|
3647
require "parallelized_specs"
3748
#used to split selenium builds when :build_section is set split it in two.
3849
test_files = FileList['spec/selenium/**/*_spec.rb'] + FileList['vendor/plugins/*/spec_canvas/selenium/*_spec.rb']
3950
test_files = test_files.to_a.sort_by! { |file| File.size(file) }
51+
4052
args[:build_section].to_i == 0 ? section = nil : section = args[:build_section].to_i
4153

4254
unless section.nil?
@@ -69,6 +81,12 @@ unless ARGV.any? { |a| a =~ /\Agems/ }
6981
end
7082
test_files.map! { |f| "#{Rails.root}/#{f}" }
7183
test_files.each { |f| puts f }
84+
85+
unless CANVAS_RAILS2
86+
Rake::Task['parallel:selenium_tags'].invoke(test_files.join(' '), 'non_parallel')
87+
end
88+
89+
puts 'starting paralellized selenium spec runtime'
7290
Rake::Task['parallel:spec'].invoke(args[:count], '', '', test_files.join(' '))
7391
end
7492

@@ -84,4 +102,4 @@ unless ARGV.any? { |a| a =~ /\Agems/ }
84102
Rake::Task['parallel:spec'].invoke(count, '', '', test_files.join(' '))
85103
end
86104
end
87-
end
105+
end

spec/selenium/content_migrations_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_selective_content(source_course=nil)
7777
@course.assignments.count.should == 1
7878
end
7979

80-
describe "content migrations" do
80+
describe "content migrations", :non_parallel do
8181
include_examples "in-process server selenium tests"
8282

8383
context "common cartridge importing" do

spec/selenium/course_settings_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_select_standard_for(context)
165165
end
166166

167167
context "right sidebar" do
168-
it "should allow entering student view from the right sidebar" do
168+
it "should allow entering student view from the right sidebar", :non_parallel do
169169
@fake_student = @course.student_view_student
170170
get "/courses/#{@course.id}/settings"
171171
f(".student_view_button").click

spec/selenium/dashboard_spec.rb

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def disable_recent_activity_header_course_link
112112
a2 = @course.account.announcements.create!(:message => "another announcement")
113113

114114
get "/"
115-
messages = ffj("#dashboard .global-message .message.user_content")
115+
messages = ffj("#dashboard .global-message .message.user_content")
116116
messages.size.should == 2
117117
messages[0].text.should == a2.message
118118
messages[1].text.should == a1.message
@@ -122,7 +122,7 @@ def disable_recent_activity_header_course_link
122122
announcement = @course.account.announcements.create!(:message => "blah blah http://random-survey-startup.ly/?some_GET_parameter_by_which_to_differentiate_results={{ACCOUNT_DOMAIN}}")
123123

124124
get "/"
125-
fj("#dashboard .global-message .message.user_content").text.should == announcement.message.gsub("{{ACCOUNT_DOMAIN}}",@course.account.domain)
125+
fj("#dashboard .global-message .message.user_content").text.should == announcement.message.gsub("{{ACCOUNT_DOMAIN}}", @course.account.domain)
126126
end
127127

128128
it "should show appointment stream items on the dashboard" do
@@ -215,25 +215,21 @@ def check_list_text(list_element, text, should_have_text = true)
215215
f('.to-do-list > li').should include_text(assignment.submission_action_string)
216216

217217
#verify assignment is in drop down
218-
assignment_menu = f('#assignments_menu_item')
219-
driver.action.move_to(assignment_menu).perform
220-
keep_trying_until { assignment_menu.should include_text("To Turn In") }
221-
assignment_menu.should include_text(assignment.title)
218+
driver.execute_script %{$('#assignments_menu_item').addClass('hover');}
219+
wait_for_ajaximations
220+
f('#assignments_menu_item').should include_text("To Turn In")
221+
f('#assignments_menu_item').should include_text(assignment.title)
222222
end
223223

224224
it "should display course name in course menu" do
225225
@course.update_attributes(:start_at => 2.days.from_now, :conclude_at => 4.days.from_now, :restrict_enrollments_to_course_dates => false)
226226
Enrollment.update_all(:created_at => 1.minute.ago)
227227

228228
get "/"
229-
230-
course_menu = f('#courses_menu_item')
231-
232-
driver.action.move_to(course_menu).perform
233-
keep_trying_until {
234-
course_menu.should include_text('My Courses')
235-
course_menu.should include_text(@course.name)
236-
}
229+
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
230+
wait_for_ajaximations
231+
f('#courses_menu_item').should include_text('My Courses')
232+
f('#courses_menu_item').should include_text(@course.name)
237233
end
238234

239235
it "should display should display student groups in course menu" do
@@ -244,14 +240,10 @@ def check_list_text(list_element, text, should_have_text = true)
244240
Enrollment.update_all(:created_at => 1.minute.ago)
245241

246242
get "/"
247-
248-
course_menu = f('#courses_menu_item')
249-
250-
driver.action.move_to(course_menu).perform
251-
keep_trying_until {
252-
course_menu.should include_text(group.name)
253-
course_menu.should include_text('Current Groups')
254-
}
243+
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
244+
wait_for_ajaximations
245+
f('#courses_menu_item').should include_text(group.name)
246+
f('#courses_menu_item').should include_text('Current Groups')
255247
end
256248

257249
it "should go to /courses when the courses nav item is clicked" do
@@ -349,10 +341,10 @@ def check_list_text(list_element, text, should_have_text = true)
349341
c1.save!
350342
get "/"
351343

352-
driver.action.move_to(f('#courses_menu_item')).perform
353-
course_menu = f('#menu_enrollments')
354-
keep_trying_until { course_menu.should be_displayed }
355-
course_menu.should_not include_text(c1.name)
344+
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
345+
item = fj('#menu_enrollments')
346+
item.should be_displayed
347+
item.should_not include_text(c1.name)
356348
end
357349

358350
it "should show recent feedback and it should work" do
@@ -403,10 +395,12 @@ def check_list_text(list_element, text, should_have_text = true)
403395
f('.to-do-list > li').should include_text('Grade ' + assignment.title)
404396

405397
#verify assignment is in drop down
406-
assignment_menu = f('#assignments_menu_item')
407-
driver.action.move_to(assignment_menu).perform
408-
keep_trying_until { assignment_menu.should include_text("To Grade") }
409-
assignment_menu.should include_text(assignment.title)
398+
driver.execute_script %{$('#assignments_menu_item').addClass('hover');}
399+
400+
wait_for_ajaximations
401+
402+
f('#assignments_menu_item').should include_text("To Grade")
403+
f('#assignments_menu_item').should include_text(assignment.title)
410404
end
411405

412406
it "should show submitted essay quizzes in the todo list" do
@@ -436,27 +430,25 @@ def check_list_text(list_element, text, should_have_text = true)
436430

437431
get "/"
438432

439-
course_menu = f('#courses_menu_item')
440-
driver.action.move_to(course_menu).perform
441-
keep_trying_until do
442-
course_menu.should include_text('My Courses')
443-
course_menu.should include_text('Customize')
444-
course_menu.should include_text('View all courses')
445-
end
433+
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
434+
wait_for_ajaximations
435+
436+
fj('#courses_menu_item').should include_text('My Courses')
437+
fj('#courses_menu_item').should include_text('Customize')
438+
fj('#courses_menu_item').should include_text('View all courses')
446439
end
447440

441+
448442
it "should allow customization if there are sufficient course invitations" do
449443
20.times { course_with_teacher({:user => user_with_communication_channel(:user_state => :creation_pending), :active_course => true}) }
450-
451444
get "/"
452445

453-
course_menu = f('#courses_menu_item')
454-
driver.action.move_to(course_menu).perform
455-
keep_trying_until do
456-
course_menu.should include_text('My Courses')
457-
course_menu.should include_text('Customize')
458-
course_menu.should include_text('View all courses')
459-
end
446+
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
447+
wait_for_ajaximations
448+
449+
fj('#courses_menu_item').should include_text('My Courses')
450+
fj('#courses_menu_item').should include_text('Customize')
451+
fj('#courses_menu_item').should include_text('View all courses')
460452
end
461453

462454
it "should allow customization if all courses are already favorited" do
@@ -467,13 +459,11 @@ def check_list_text(list_element, text, should_have_text = true)
467459
}
468460

469461
get "/"
462+
driver.execute_script %{$('#courses_menu_item').addClass('hover');}
463+
wait_for_ajaximations
470464

471-
course_menu = f('#courses_menu_item')
472-
driver.action.move_to(course_menu).perform
473-
keep_trying_until do
474-
course_menu.should include_text('My Courses')
475-
course_menu.should include_text('Customize')
476-
end
465+
fj('#courses_menu_item').should include_text('My Courses')
466+
fj('#courses_menu_item').should include_text('Customize')
477467
end
478468

479469
it "should allow customization even before the course ajax request comes back" do

spec/spec_helper.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ def include_examples(*args)
2626
end
2727

2828
unless CANVAS_RAILS2 || ENV['NO_RERUN']
29-
require 'timeout'
29+
Spec.configure do |c|
30+
c.treat_symbols_as_metadata_keys_with_true_values = true
31+
end
32+
3033
RSpec.configure do |c|
3134
c.around(:each) do |example|
3235
attempts = 0

0 commit comments

Comments
 (0)