-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worker: Add some basic end-to-end tests
Part of #1
- Loading branch information
Showing
10 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.gem | ||
dump.rdb | ||
Gemfile.lock | ||
spec/examples.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RSpec.describe do | ||
it { expect(false).to be false } | ||
it { expect(1).to be 2 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.describe do | ||
it { expect(true).to be true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
RSpec.describe do | ||
it do | ||
$tries ||= 0 | ||
$tries += 1 | ||
|
||
expect($tries).to eq 3 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.describe do | ||
it { expect(true).to be true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# TODO check process exit code | ||
# TODO test empty no spec files scenario | ||
# TODO test providing a specific file | ||
# TODO test providing a specific example (foo[2:1]) notation | ||
# TODO test providing a different spec folder | ||
# TODO test worker liveness | ||
# TODO reporter | ||
# TODO concurrent workers | ||
|
||
RSpec.describe RSpecQ do | ||
context "suite with legit failures" do | ||
it "retries failed examples and build fails" do | ||
queue = exec_build("failing_suite") | ||
|
||
expect(queue).to be_well_formed | ||
expect(queue.build_successful?).to be false | ||
expect(queue.example_count).to eq 6 | ||
expect(queue.requeued_jobs).to eq({ "./spec/bar_spec.rb[1:2]" => "3" }) | ||
expect(queue.processed_jobs).to match_array([ | ||
"./spec/foo_spec.rb", | ||
"./spec/bar_spec.rb", | ||
"./spec/bar_spec.rb[1:2]", | ||
]) | ||
end | ||
end | ||
|
||
context "passing suite" do | ||
it do | ||
queue = exec_build("passing_suite") | ||
|
||
expect(queue).to be_well_formed | ||
expect(queue.build_successful?).to be true | ||
expect(queue.example_count).to eq 1 | ||
expect(queue.requeued_jobs).to be_empty | ||
expect(queue.processed_jobs).to match_array(["./spec/foo_spec.rb"]) | ||
end | ||
end | ||
|
||
context "suite with flakey failures" do | ||
it "passes" do | ||
queue = exec_build("flakey_suite") | ||
|
||
expect(queue).to be_well_formed | ||
expect(queue.build_successful?).to be true | ||
expect(queue.processed_jobs).to match_array([ | ||
"./spec/foo_spec.rb", | ||
"./spec/foo_spec.rb[1:1]", | ||
]) | ||
expect(queue.requeued_jobs).to eq({ "./spec/foo_spec.rb[1:1]" => "2" }) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "securerandom" | ||
|
||
module Helpers | ||
REDIS_HOST = "127.0.0.1".freeze | ||
|
||
def rand_id | ||
SecureRandom.hex(4) | ||
end | ||
|
||
def exec_build(path) | ||
worker_id = rand_id | ||
build_id = rand_id | ||
|
||
Dir.chdir(File.join("sample_suites", path)) do | ||
`bundle exec rspecq --worker #{worker_id} --build #{build_id}` | ||
end | ||
|
||
return RSpecQ::Queue.new(build_id, worker_id, REDIS_HOST) | ||
end | ||
end |