Test failure due to Ecto and async task
up vote
5
down vote
favorite
Interesting issue I'm getting. I have a test that deals with file uploading using arc-ecto. In the uploader module I override storage_dir
function. There I do a database call to fetch id of the parent record of the thing I'm uploading. Works great in practice.
Tests freak out though. I'm guessing it has something to do with the fact that file saving is an async task. So test finishes before file is saved. Database connection is closed and uploader errors out. Here's the error:
15:33:10.457 [error] Postgrex.Protocol (#PID<0.325.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.535.0> exited while client #PID<0.538.0> is still running with: shutdown
15:33:10.645 [error] Postgrex.Protocol (#PID<0.331.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.596.0> exited while client #PID<0.599.0> is still running with: shutdown
15:33:10.674 [error] Task #PID<0.599.0> started from #PID<0.598.0> terminating
** (DBConnection.ConnectionError) tcp recv: closed
(ecto) lib/ecto/adapters/postgres/connection.ex:115: Ecto.Adapters.Postgres.Connection.execute/4
(ecto) lib/ecto/adapters/sql.ex:243: Ecto.Adapters.SQL.sql_call/6
(ecto) lib/ecto/adapters/sql.ex:441: Ecto.Adapters.SQL.execute_or_reset/7
(ecto) lib/ecto/repo/queryable.ex:130: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:35: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:68: Ecto.Repo.Queryable.one/4
(pedal_app) lib/pedal_app/web/uploaders/photo_uploader.ex:31: PedalApp.Web.PhotoUploader.storage_dir/2
lib/arc/storage/local.ex:33: Arc.Storage.Local.build_local_path/3
lib/arc/storage/local.ex:27: Arc.Storage.Local.delete/3
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<0.51838860/0 in Arc.Actions.Delete.async_delete_version/3>
Args:
Is this a common thing? How can I tell my test not to bail until everything is done?
Edit: My work-around is to do a preload for everything so I don't do db calls in the uploader. But question still stands.
elixir phoenix-framework ecto arc-ecto
add a comment |
up vote
5
down vote
favorite
Interesting issue I'm getting. I have a test that deals with file uploading using arc-ecto. In the uploader module I override storage_dir
function. There I do a database call to fetch id of the parent record of the thing I'm uploading. Works great in practice.
Tests freak out though. I'm guessing it has something to do with the fact that file saving is an async task. So test finishes before file is saved. Database connection is closed and uploader errors out. Here's the error:
15:33:10.457 [error] Postgrex.Protocol (#PID<0.325.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.535.0> exited while client #PID<0.538.0> is still running with: shutdown
15:33:10.645 [error] Postgrex.Protocol (#PID<0.331.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.596.0> exited while client #PID<0.599.0> is still running with: shutdown
15:33:10.674 [error] Task #PID<0.599.0> started from #PID<0.598.0> terminating
** (DBConnection.ConnectionError) tcp recv: closed
(ecto) lib/ecto/adapters/postgres/connection.ex:115: Ecto.Adapters.Postgres.Connection.execute/4
(ecto) lib/ecto/adapters/sql.ex:243: Ecto.Adapters.SQL.sql_call/6
(ecto) lib/ecto/adapters/sql.ex:441: Ecto.Adapters.SQL.execute_or_reset/7
(ecto) lib/ecto/repo/queryable.ex:130: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:35: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:68: Ecto.Repo.Queryable.one/4
(pedal_app) lib/pedal_app/web/uploaders/photo_uploader.ex:31: PedalApp.Web.PhotoUploader.storage_dir/2
lib/arc/storage/local.ex:33: Arc.Storage.Local.build_local_path/3
lib/arc/storage/local.ex:27: Arc.Storage.Local.delete/3
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<0.51838860/0 in Arc.Actions.Delete.async_delete_version/3>
Args:
Is this a common thing? How can I tell my test not to bail until everything is done?
Edit: My work-around is to do a preload for everything so I don't do db calls in the uploader. But question still stands.
elixir phoenix-framework ecto arc-ecto
add a comment |
up vote
5
down vote
favorite
up vote
5
down vote
favorite
Interesting issue I'm getting. I have a test that deals with file uploading using arc-ecto. In the uploader module I override storage_dir
function. There I do a database call to fetch id of the parent record of the thing I'm uploading. Works great in practice.
Tests freak out though. I'm guessing it has something to do with the fact that file saving is an async task. So test finishes before file is saved. Database connection is closed and uploader errors out. Here's the error:
15:33:10.457 [error] Postgrex.Protocol (#PID<0.325.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.535.0> exited while client #PID<0.538.0> is still running with: shutdown
15:33:10.645 [error] Postgrex.Protocol (#PID<0.331.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.596.0> exited while client #PID<0.599.0> is still running with: shutdown
15:33:10.674 [error] Task #PID<0.599.0> started from #PID<0.598.0> terminating
** (DBConnection.ConnectionError) tcp recv: closed
(ecto) lib/ecto/adapters/postgres/connection.ex:115: Ecto.Adapters.Postgres.Connection.execute/4
(ecto) lib/ecto/adapters/sql.ex:243: Ecto.Adapters.SQL.sql_call/6
(ecto) lib/ecto/adapters/sql.ex:441: Ecto.Adapters.SQL.execute_or_reset/7
(ecto) lib/ecto/repo/queryable.ex:130: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:35: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:68: Ecto.Repo.Queryable.one/4
(pedal_app) lib/pedal_app/web/uploaders/photo_uploader.ex:31: PedalApp.Web.PhotoUploader.storage_dir/2
lib/arc/storage/local.ex:33: Arc.Storage.Local.build_local_path/3
lib/arc/storage/local.ex:27: Arc.Storage.Local.delete/3
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<0.51838860/0 in Arc.Actions.Delete.async_delete_version/3>
Args:
Is this a common thing? How can I tell my test not to bail until everything is done?
Edit: My work-around is to do a preload for everything so I don't do db calls in the uploader. But question still stands.
elixir phoenix-framework ecto arc-ecto
Interesting issue I'm getting. I have a test that deals with file uploading using arc-ecto. In the uploader module I override storage_dir
function. There I do a database call to fetch id of the parent record of the thing I'm uploading. Works great in practice.
Tests freak out though. I'm guessing it has something to do with the fact that file saving is an async task. So test finishes before file is saved. Database connection is closed and uploader errors out. Here's the error:
15:33:10.457 [error] Postgrex.Protocol (#PID<0.325.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.535.0> exited while client #PID<0.538.0> is still running with: shutdown
15:33:10.645 [error] Postgrex.Protocol (#PID<0.331.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.596.0> exited while client #PID<0.599.0> is still running with: shutdown
15:33:10.674 [error] Task #PID<0.599.0> started from #PID<0.598.0> terminating
** (DBConnection.ConnectionError) tcp recv: closed
(ecto) lib/ecto/adapters/postgres/connection.ex:115: Ecto.Adapters.Postgres.Connection.execute/4
(ecto) lib/ecto/adapters/sql.ex:243: Ecto.Adapters.SQL.sql_call/6
(ecto) lib/ecto/adapters/sql.ex:441: Ecto.Adapters.SQL.execute_or_reset/7
(ecto) lib/ecto/repo/queryable.ex:130: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:35: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:68: Ecto.Repo.Queryable.one/4
(pedal_app) lib/pedal_app/web/uploaders/photo_uploader.ex:31: PedalApp.Web.PhotoUploader.storage_dir/2
lib/arc/storage/local.ex:33: Arc.Storage.Local.build_local_path/3
lib/arc/storage/local.ex:27: Arc.Storage.Local.delete/3
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<0.51838860/0 in Arc.Actions.Delete.async_delete_version/3>
Args:
Is this a common thing? How can I tell my test not to bail until everything is done?
Edit: My work-around is to do a preload for everything so I don't do db calls in the uploader. But question still stands.
elixir phoenix-framework ecto arc-ecto
elixir phoenix-framework ecto arc-ecto
edited Mar 29 '17 at 23:05
asked Mar 29 '17 at 22:43
Grocery
1,6861224
1,6861224
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can disable asynchronous processing adding @async false
to your upload definition.
I'm sure that you don't want to disable it in dev/production, only on tests.
I would try this:
On config/test.exs
you can add:
config :project_name, arc_async: false
On your uploader definition you can add:
@async Application.get_env(:project_name, :arc_async, true)
I didn't test it, so, not sure if it will work but at least is something to try.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43105490%2ftest-failure-due-to-ecto-and-async-task%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can disable asynchronous processing adding @async false
to your upload definition.
I'm sure that you don't want to disable it in dev/production, only on tests.
I would try this:
On config/test.exs
you can add:
config :project_name, arc_async: false
On your uploader definition you can add:
@async Application.get_env(:project_name, :arc_async, true)
I didn't test it, so, not sure if it will work but at least is something to try.
add a comment |
up vote
0
down vote
You can disable asynchronous processing adding @async false
to your upload definition.
I'm sure that you don't want to disable it in dev/production, only on tests.
I would try this:
On config/test.exs
you can add:
config :project_name, arc_async: false
On your uploader definition you can add:
@async Application.get_env(:project_name, :arc_async, true)
I didn't test it, so, not sure if it will work but at least is something to try.
add a comment |
up vote
0
down vote
up vote
0
down vote
You can disable asynchronous processing adding @async false
to your upload definition.
I'm sure that you don't want to disable it in dev/production, only on tests.
I would try this:
On config/test.exs
you can add:
config :project_name, arc_async: false
On your uploader definition you can add:
@async Application.get_env(:project_name, :arc_async, true)
I didn't test it, so, not sure if it will work but at least is something to try.
You can disable asynchronous processing adding @async false
to your upload definition.
I'm sure that you don't want to disable it in dev/production, only on tests.
I would try this:
On config/test.exs
you can add:
config :project_name, arc_async: false
On your uploader definition you can add:
@async Application.get_env(:project_name, :arc_async, true)
I didn't test it, so, not sure if it will work but at least is something to try.
answered Nov 20 at 1:32
Marcos Tapajós
1615
1615
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43105490%2ftest-failure-due-to-ecto-and-async-task%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown