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
Fix config cannot be updated #5171
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
73 changes: 73 additions & 0 deletions
73
...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,73 @@ | ||
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), | ||
) |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we somehow detect that the configuration has been completed? (instead of waiting the 10 seconds)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we should, but in the current "fire and forget" implementation model, it's not easy to achieve. I tried.