Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new UBOS allow_private_addresses customizationpoint on Mastodon and make test work #344

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/feditest/nodedrivers/mastodon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,9 @@ def make_a_follow_b(self, a_uri_here: str, b_uri_there: str, node_there: Activit
def wait_for_object_in_inbox(self, actor_uri: str, object_uri: str, max_wait: float = 5.) -> None:
trace('wait_for_object_in_inbox:')
mastodon_client = self._get_mastodon_client_by_actor_uri(actor_uri)

response = self._poll_until_result( # may throw
lambda: next(
(
s
for s in mastodon_client.timeline("local")
if s.uri == object_uri
),
None,
),
lambda: any( s.uri == object_uri for s in mastodon_client.timeline_home(local=True, remote=True)),
int(max_wait),
1.0,
f'Expected object { object_uri } has not arrived in inbox of actor { actor_uri }'
Expand Down
5 changes: 4 additions & 1 deletion src/feditest/nodedrivers/mastodon/ubos.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def create_from_node_in_testplan(
else:
start_delay = float(start_delay_1)
else:
start_delay = 0.0
start_delay = 10.0 # 10 sec should be good enough

if test_plan_node.parameter(BACKUPFILE_PAR):
raise TestPlanNodeParameterMalformedError(BACKUP_APPCONFIGID_PAR, ' must not be given for MastodonUbosNodeDriver')
Expand Down Expand Up @@ -277,6 +277,9 @@ def create_configuration_account_manager(self, rolename: str, test_plan_node: Te
"mastodon" : {
"singleusermode" : {
"value" : False
},
"allowed_private_addresses" : {
"value" : "192.168.1.1/16" # Allow testing in a Linux container
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/feditest/protocols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, cast, final

from feditest.testplan import TestPlanConstellationNode, TestPlanNodeParameter, TestPlanNodeAccountField, TestPlanNodeNonExistingAccountField
from feditest.reporting import warning, trace
from feditest.reporting import info, warning
from feditest.utils import hostname_validate, appname_validate, appversion_validate


Expand Down Expand Up @@ -352,6 +352,10 @@ def start_delay(self) -> float:
return self._start_delay


def __str__(self) -> str:
return f'NodeConfiguration ({ type(self).__name__ }): node driver: "{ self.node_driver }", app: "{ self.app }", hostname: "{ self.hostname }"'


class Node(ABC):
"""
A Node is the interface through which FediTest talks to an application instance.
Expand Down Expand Up @@ -513,7 +517,7 @@ def provision_node(self, rolename: str, config: NodeConfiguration, account_manag
rolename: the name of this Node in the constellation
config: the NodeConfiguration created with create_configuration
"""
trace(f'Provisioning node for role { rolename } with NodeDriver { self.__class__.__name__} and configuration { config }')
info(f'Provisioning node for role "{ rolename }" with { config }.')
ret = self._provision_node(rolename, config, account_manager)
return ret

Expand All @@ -526,6 +530,8 @@ def unprovision_node(self, node: Node) -> None:
"""
if node.node_driver != self :
raise Exception(f"Node does not belong to this NodeDriver: { node.node_driver } vs { self }") # pylint: disable=broad-exception-raised

info(f'Unprovisioning node for role "{ node.rolename }" with NodeDriver "{ self.__class__.__name__}".')
self._unprovision_node(node)


Expand Down
6 changes: 3 additions & 3 deletions src/feditest/ubos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
NodeDriver
)
from feditest.registry import registry_singleton
from feditest.reporting import error, info, trace, warning
from feditest.reporting import error, trace, warning
from feditest.testplan import TestPlanConstellationNode, TestPlanNodeParameter, TestPlanNodeParameterMalformedError, TestPlanNodeParameterRequiredError
from feditest.utils import email_validate

Expand Down Expand Up @@ -543,10 +543,10 @@ def _exec_shell(self, cmd: str, rshcmd: str | None = None, stdin_content: str |
fullcmd = cmd

if stdin_content:
info( f"Executing '{fullcmd}' with some stdin content" )
trace( f"Executing '{fullcmd}' with some stdin content" )
ret = subprocess.run(fullcmd, shell=True, check=False, text=True, input=stdin_content, capture_output=capture_output)
else:
info( f"Executing '{fullcmd}'")
trace( f"Executing '{fullcmd}'")
ret = subprocess.run(fullcmd, shell=True, check=False, text=True, capture_output=capture_output)

return ret
Expand Down
3 changes: 1 addition & 2 deletions tests/feditest/mastodon_mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ def start_reset_all(self):
@step
def follow(self):
self.follower_node.make_a_follow_b(self.follower_actor_uri, self.leader_actor_uri, self.leader_node)
assert self.note_uri


@step
def leader_creates_note(self):
self.leader_note_uri = self.leader.make_create_note(self.leader_actor_uri, f"testing leader_creates_note {datetime.now()}")
self.leader_note_uri = self.leader_node.make_create_note(self.leader_actor_uri, f"testing leader_creates_note {datetime.now()}")
assert self.leader_note_uri


Expand Down
Loading