forked from equinor/ert
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix failed realization not being marked as failed
- Loading branch information
1 parent
884f3da
commit edba8b1
Showing
5 changed files
with
44 additions
and
43 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
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
51 changes: 15 additions & 36 deletions
51
tests/ert/unit_tests/ensemble_evaluator/test_ensemble_client.py
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,65 +1,44 @@ | ||
from functools import partial | ||
|
||
import pytest | ||
|
||
from _ert.forward_model_runner.client import Client, ClientConnectionError | ||
from _ert.threading import ErtThread | ||
|
||
from .ensemble_evaluator_utils import _mock_ws | ||
from tests.ert.utils import _mock_ws_task | ||
|
||
|
||
def test_invalid_server(): | ||
async def test_invalid_server(): | ||
port = 7777 | ||
host = "localhost" | ||
url = f"ws://{host}:{port}" | ||
|
||
with Client(url, max_retries=2, timeout_multiplier=2) as c1, pytest.raises( | ||
ClientConnectionError | ||
): | ||
c1.send("hei") | ||
async with Client(url, max_retries=2, timeout_multiplier=2) as c1: | ||
with pytest.raises(ClientConnectionError): | ||
await c1.send("hei") | ||
|
||
|
||
def test_successful_sending(unused_tcp_port): | ||
async def test_successful_sending(unused_tcp_port): | ||
host = "localhost" | ||
url = f"ws://{host}:{unused_tcp_port}" | ||
messages = [] | ||
mock_ws_thread = ErtThread( | ||
target=partial(_mock_ws, messages=messages), args=(host, unused_tcp_port) | ||
) | ||
|
||
mock_ws_thread.start() | ||
messages_c1 = ["test_1", "test_2", "test_3", "stop"] | ||
|
||
with Client(url) as c1: | ||
messages_c1 = ["test_1", "test_2", "test_3"] | ||
async with _mock_ws_task(host, unused_tcp_port, messages), Client(url) as c1: | ||
for msg in messages_c1: | ||
c1.send(msg) | ||
|
||
mock_ws_thread.join() | ||
await c1.send(msg) | ||
|
||
for msg in messages_c1: | ||
assert msg in messages | ||
|
||
|
||
def test_retry(unused_tcp_port): | ||
async def test_retry(unused_tcp_port): | ||
host = "localhost" | ||
url = f"ws://{host}:{unused_tcp_port}" | ||
messages = [] | ||
mock_ws_thread = ErtThread( | ||
target=partial(_mock_ws, messages=messages, delay_startup=2), | ||
args=( | ||
host, | ||
unused_tcp_port, | ||
), | ||
) | ||
|
||
mock_ws_thread.start() | ||
messages_c1 = ["test_1", "test_2", "test_3", "stop"] | ||
|
||
with Client(url, max_retries=2, timeout_multiplier=2) as c1: | ||
messages_c1 = ["test_1", "test_2", "test_3"] | ||
async with _mock_ws_task(host, unused_tcp_port, messages, delay_startup=2), Client( | ||
url, max_retries=2, timeout_multiplier=2 | ||
) as c1: | ||
for msg in messages_c1: | ||
c1.send(msg) | ||
|
||
mock_ws_thread.join() | ||
await c1.send(msg) | ||
|
||
for msg in messages_c1: | ||
assert msg in messages |
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