Random failure at CircleCI
I have been facing very frequent but still random errors at CircleCI:
1) Filterable#until returns only subjects until the requested date
Failure/Error: 30.times { |i| subject.create(created_at: Time.current.change(day: i + 1)) }
ActiveRecord::StatementInvalid:
PG::UndefinedTable: ERROR: relation "filterable_models" does not exist
LINE 1: INSERT INTO "filterable_models" ("created_at", "updated_at")...
^
: INSERT INTO "filterable_models" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id"
# ./spec/models/concerns/filterable_spec.rb:85:in `block (4 levels) in <top (required)>'
# ./spec/models/concerns/filterable_spec.rb:85:in `times'
# ./spec/models/concerns/filterable_spec.rb:85:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# PG::UndefinedTable:
# ERROR: relation "filterable_models" does not exist
# LINE 1: INSERT INTO "filterable_models" ("created_at", "updated_at")...
# ^
# ./spec/models/concerns/filterable_spec.rb:85:in `block (4 levels) in <top (required)>'
I was not able to reproduce locally
We ran into the same problem at my organisation.
@prem-prakash: Do you utilize parallelization (we use "parallel_tests") on CI? If not, do you use DatebaseCleaner and change your strategy between tests? we use :truncation for some tests, while using :transaction for most of them.
@pierrebeitz yes we use parallelization, but not with parallel_tests, we use circleci native parallelization. Yes we use DatabaseCleaner but we do not change our strategy between tests. I hope this info can help in something
the problem seems to be unrelated to parallelization.
in our case it had to do with the order of the specs. sometimes before the spec declaring
before(:all) do
Temping.create :some_class do
...
end
end
we have a capybara-spec running, which starts a webserver in a dedicated process. for just this spec we change the DatabaseCleaner-strategy from transaction to truncation which is changed back afterwards before the spec in question. Now somehow (whether it is the dedicated process or as i suspect some internal of DatabaseCleaner) the connection does not hold the table which has been created before anymore.
For now i go with the following workaround, which does not seem to be THAT slow:
around(:each) do |example|
Temping.create :some_class do
...
end
example.run
Temping.teardown
end
I hope this helps anyone to work their way to the real issue.
Hi @prem-prakash, did it work with the suggestions made by @pierrebeitz?
Hi, it worked for me! Thanks @pierrebeitz