This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
267 additions
and
38 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
43 changes: 43 additions & 0 deletions
43
scripts/node_integration_tests/nodes/provider/configure_or_die.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
|
||
import logging | ||
from unittest.mock import patch | ||
|
||
from twisted.internet.defer import inlineCallbacks | ||
|
||
from golemapp import main | ||
|
||
from golem.client import Client | ||
from golem.task.taskserver import TaskServer | ||
|
||
|
||
def on_exception(): | ||
logging.critical("#### Integration test failed ####") | ||
|
||
|
||
client_change_config_orig = Client.change_config | ||
|
||
|
||
def client_change_config(self: Client, *args, **kwargs): | ||
try: | ||
client_change_config_orig(self, *args, **kwargs) | ||
except: # noqa pylint: disable=broad-except | ||
on_exception() | ||
|
||
|
||
task_server_change_config_orig = TaskServer.change_config | ||
|
||
|
||
@inlineCallbacks | ||
def task_server_change_config(self: TaskServer, *args, **kwargs): | ||
try: | ||
yield task_server_change_config_orig(self, *args, **kwargs) | ||
except: # noqa pylint: disable=broad-except | ||
on_exception() | ||
|
||
|
||
with patch("golem.client.Client.change_config", | ||
client_change_config), \ | ||
patch("golem.task.taskserver.TaskServer.change_config", | ||
task_server_change_config): | ||
main() |
Empty file.
75 changes: 75 additions & 0 deletions
75
...pts/node_integration_tests/playbooks/golem/reconfigure_provider_while_working/playbook.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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import time | ||
from functools import partial | ||
|
||
from scripts.node_integration_tests import helpers | ||
from ...test_config_base import NodeId | ||
from ..task_api.playbook import Playbook as BasePlaybook | ||
|
||
|
||
class Playbook(BasePlaybook): | ||
def wait_for_computing_task(self): | ||
def on_success(result): | ||
state = result['provider_state'] | ||
print(f"provider state: {state}") | ||
if state['status'] == 'Computing': | ||
self.next() | ||
else: | ||
time.sleep(10) | ||
|
||
def on_error(_): | ||
print(f"failed getting provider stats") | ||
self.fail() | ||
return self.call(NodeId.provider, 'comp.tasks.stats', | ||
on_success=on_success, on_error=on_error) | ||
|
||
def ui_stop(self, node_id: NodeId): | ||
def on_success(_): | ||
print(f"stopped {node_id.value}") | ||
self.next() | ||
|
||
def on_error(_): | ||
print(f"stopping {node_id.value} failed") | ||
self.fail() | ||
return self.call(node_id, 'ui.stop', on_success=on_success, | ||
on_error=on_error) | ||
|
||
def change_config(self, node_id: NodeId): | ||
opts = { | ||
"node_name": "a new name", | ||
} | ||
|
||
def on_success(_): | ||
print(f"reconfigured {node_id.value}") | ||
time.sleep(10) # give time for async operations to process | ||
self.next() | ||
|
||
def on_error(_): | ||
print(f"reconfiguring {node_id.value} failed") | ||
self.fail() | ||
|
||
return self.call(node_id, 'env.opts.update', opts, | ||
on_success=on_success, on_error=on_error) | ||
|
||
def check_if_test_failed(self, node_id: NodeId): | ||
test_failed = bool(helpers.search_output( | ||
self.output_queues[node_id], | ||
".*#### Integration test failed ####.*")) | ||
|
||
if test_failed: | ||
self.fail("found failure marker in log") | ||
|
||
print("no failure marker found in log") | ||
self.next() | ||
|
||
steps = BasePlaybook.initial_steps + ( | ||
BasePlaybook.step_enable_app, | ||
BasePlaybook.step_create_task, | ||
BasePlaybook.step_get_task_id, | ||
BasePlaybook.step_get_task_status, | ||
wait_for_computing_task, | ||
partial(ui_stop, node_id=NodeId.provider), | ||
partial(change_config, node_id=NodeId.provider), | ||
partial(check_if_test_failed, node_id=NodeId.provider), | ||
# No need to wait for subtask to finish, because it's a waste of time | ||
# and because it's gets cancelled, because task session is closed. | ||
) |
9 changes: 9 additions & 0 deletions
9
.../node_integration_tests/playbooks/golem/reconfigure_provider_while_working/test_config.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from ...test_config_base import NodeId | ||
|
||
from ..task_api.test_config import TestConfig as TestConfigBase | ||
|
||
|
||
class TestConfig(TestConfigBase): | ||
def __init__(self): | ||
super().__init__() | ||
self.nodes[NodeId.provider].script = 'provider/configure_or_die' |
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
Oops, something went wrong.