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

introduce shared_values module in test_utils which proves the concept of a primitive for out-of-band messaging in tests #2676

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from

Conversation

steveej
Copy link
Member

@steveej steveej commented Aug 17, 2023

this is a step towards a framework for writing
synchronization logic that is suitable for tests that are distributed across many nodes.

the LocalV1 implementation could be removed at this point. i initially relied on it to verify the behavior of the RemoteV1 implementation. i don't foresee a scenario where we couldn't use the latter.

fixes #3740

TODO:

  • CHANGELOG(s) updated with appropriate info
  • Just before pressing the merge button, ensure new entries to CHANGELOG(s) are still under the UNRELEASED heading

@steveej steveej requested a review from maackle August 28, 2023 15:19
Copy link
Contributor

This item has been open for 30 days with no activity.

@github-actions github-actions bot added the stale This issue may be outdated, but we can revive it if it ever becomes relevant again label Nov 10, 2023
@steveej steveej removed the stale This issue may be outdated, but we can revive it if it ever becomes relevant again label Nov 14, 2023
@steveej steveej changed the title experiment(must_get_agent_activity test): put agent sync logic into separate fns and threads experiment: rewrite a test and put agent sync logic into separate fns and threads Dec 19, 2023
Copy link
Contributor

This item has been open for 30 days with no activity.

@github-actions github-actions bot added the stale This issue may be outdated, but we can revive it if it ever becomes relevant again label Jan 20, 2024
the server side can be run e.g. with:

```
env \
  TEST_SHARED_VALUES_REMOTEV1_ROLE="server" \
  TEST_SHARED_VALUES_REMOTEV1_URL="ws://0.0.0.0:34567" \
  cargo nextest run -p holochain_test_utils --no-capture --features slow_tests --status-level=pass distributed
```

clients can then run like this:

```
env \
  TEST_SHARED_VALUES_REMOTEV1_ROLE="client" \
  TEST_SHARED_VALUES_REMOTEV1_URL="ws://localhost:34567" \
  cargo nextest run -p holochain_test_utils --no-capture --features slow_tests --status-level=pass distributed
```
there's still major opportunity to refactor common boilerplate but it's
not a priority for this PoC.
@steveej steveej changed the title tests: implement async shared_values for remote messaging; spike on test scenario introduce shared_values module in test_utils which provies a primitive for out-of-band messaging in tests Feb 8, 2024
@steveej steveej marked this pull request as ready for review February 8, 2024 14:11
@steveej steveej requested a review from a team February 8, 2024 14:11
@steveej steveej changed the title introduce shared_values module in test_utils which provies a primitive for out-of-band messaging in tests introduce shared_values module in test_utils which proves the concept of a primitive for out-of-band messaging in tests Feb 8, 2024
Copy link
Contributor

@ThetaSinner ThetaSinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding the remote values implementation challenging to follow because it's quite large code blocks that are quite deeply nested which isn't very easy to read in a browser.

@@ -312,6 +312,13 @@ async fn remote_signals() -> anyhow::Result<()> {
Ok(())
}

#[ignore = "TODO: part of the next proof of concept"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context required to know what PoC, maybe include a ref to this PR or an issue number?

version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop generated line, where know where to find this :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer src/shared_values.rs referenced from the lib.rs


use std::{collections::BTreeMap, time::Duration};

use anyhow::Result as Fallible;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this wasn't renamed, I'm used to looking at Result or SomethingSpecificResult, so this requires adding a translation. If you import anyhow::Result then Result will be used from anyhow rather than std::result::Result


#[async_trait]
pub(crate) trait SharedValues: DynClone + Sync + Send {
async fn put_t(&mut self, key: String, value: String) -> Fallible<Option<String>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could use some docs, I can probably guess what the outputs are but those in particular would be useful to have docs for

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the _t have a significance beyond distinguishing impl functions from the trait ones? If not I'd prefer that was dropped and the calls were disambiguated where they're made

tokio::select! {
data = self.get_pattern(pattern.as_str(), |(_previous_data, data)| { data.len() >= min_data }) => Ok(data?),
_ = {
let duration = if let Some(wait_timeout) = maybe_wait_timeout {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like duration.unwrap_or(std::time::Duration::MAX) but I get those functional methods a little wrong without IDE support :D


use holochain_websocket::{WebsocketConfig, WebsocketListener};

// TODO: deglob this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO intended for this PR?

pub(crate) const TEST_AGENT_READINESS_TIMEOUT_SECS_DEFAULT: u64 = 360;

#[derive(Debug, Default, strum_macros::EnumString)]
#[strum(serialize_all = "lowercase")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh this is neat, I could do with adding strum to my toolkit then because I usually do this by hand :D


impl RemoteV1Server {
/// Creates a new server and starts it immediately.
pub(crate) async fn new(bind_socket: Option<String>) -> Fallible<Self> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer bind_address to bind_socket

localv1: LocalV1,
server: &mut WebsocketListener,
) -> Fallible<()> {
while let Some(Ok((/* never sends on its own */ _tx, mut recv))) = server.next().await {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is _tx safe to drop though? Because this loop spawns tokio tasks which means this will go out of scope quite quickly

Copy link
Contributor

github-actions bot commented Apr 8, 2024

This item has been open for 30 days with no activity.

@github-actions github-actions bot added the stale This issue may be outdated, but we can revive it if it ever becomes relevant again label Apr 8, 2024
@steveej steveej removed the stale This issue may be outdated, but we can revive it if it ever becomes relevant again label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

PoC-3: synthetic test with first iteration of remote shared_values on workload orchestrator
3 participants