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

jsonrpc-feature returned #417

Merged
merged 42 commits into from
Nov 29, 2023
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
27257ce
feat: go from websocket-server to json rpc websocket/http server
zeeshanlakhani Oct 31, 2023
16392e7
refactor: cleanup settings
zeeshanlakhani Oct 31, 2023
234621d
refactor: testing around e2e websocket/jsonrpc, feature-fl
zeeshanlakhani Nov 2, 2023
ed774e4
chore: return of the retry
zeeshanlakhani Nov 3, 2023
708369e
chore: test setup
zeeshanlakhani Nov 3, 2023
6da6e71
fix: subscription map, checks, multiple broadcasts
zeeshanlakhani Nov 6, 2023
3af2ff1
fix: move to sub id as lookup key
zeeshanlakhani Nov 6, 2023
5659f06
chore: cleanup
zeeshanlakhani Nov 6, 2023
049a4ba
chore: fix warning
zeeshanlakhani Nov 6, 2023
44b8485
chore: comment
zeeshanlakhani Nov 6, 2023
64bfe77
chore: websocket->webserver
zeeshanlakhani Nov 7, 2023
058deef
feat: Add event notifications (#410)
bgins Nov 7, 2023
713718e
fix: p2p timeout, ipfs settings, more
zeeshanlakhani Nov 8, 2023
ff4ebc8
chore: updates, new wasms
zeeshanlakhani Nov 8, 2023
aa1d673
chore: add one cleanup
zeeshanlakhani Nov 8, 2023
14d7dc2
chore: wasms update is life
zeeshanlakhani Nov 8, 2023
20694da
chore: test fixins
zeeshanlakhani Nov 8, 2023
f6a3b4f
chore: minor updates
zeeshanlakhani Nov 9, 2023
b7ae3f9
chore: updates
zeeshanlakhani Nov 9, 2023
0aac079
chore: updates
zeeshanlakhani Nov 9, 2023
b88d113
chore: updates
zeeshanlakhani Nov 9, 2023
b233e1c
chore: updates
zeeshanlakhani Nov 9, 2023
522b42a
chore: testing
zeeshanlakhani Nov 9, 2023
476c47f
feat: Add pubsub receipt sharing notifications (#418)
bgins Nov 10, 2023
7ad88b5
refactor: Fix connection notification test (#424)
bgins Nov 11, 2023
b9cfa50
chore: additional test
zeeshanlakhani Nov 11, 2023
82f3348
fix: better usage, bin docs
zeeshanlakhani Nov 11, 2023
0616a33
chore: builds on for pr
zeeshanlakhani Nov 13, 2023
951abe6
refactor: (#429)
bgins Nov 13, 2023
9f817f2
chore: update debs for targets
zeeshanlakhani Nov 13, 2023
da344c1
chore: builds trial1
zeeshanlakhani Nov 13, 2023
11a8f88
fix: make configuration run without -c (all defaults) (#433)
Nov 14, 2023
0cd381d
refactor: static/dynamic nodeinfo and recv deadlines (#435)
Nov 14, 2023
59383e5
refactor: Add Gossipsub Message wrapper (#436)
bgins Nov 15, 2023
ce0c49f
fix: schedule + db conflict (#437)
Nov 15, 2023
0b37875
fix: remove unnecessary decode (#438)
Nov 16, 2023
032427e
chore: Remove databases after test runs (#444)
bgins Nov 17, 2023
c858c68
chore: send_async where possible (#445)
Nov 17, 2023
3168793
refactor: Refactor and split-up settings (#451)
bgins Nov 28, 2023
7c45cf5
Update websocket relay example app (#448)
bgins Nov 28, 2023
0aa6e3a
feat: add npm package to homestar runtime (#434)
hugomrdias Nov 29, 2023
f794950
chore: comments, logs, & cleanup (#456)
Nov 29, 2023
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
Prev Previous commit
Next Next commit
chore: minor updates
zeeshanlakhani committed Nov 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit f6a3b4f30871af0672a50709fb25d179ca418082
8 changes: 1 addition & 7 deletions homestar-functions/test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -255,12 +255,6 @@ mod test_mod {
let rotated = Component::rotate90_base64(img_uri.into());
let gray = Component::grayscale(rotated);
let cropped = Component::crop(gray, 10, 10, 50, 50);
let result = Component::blur(cropped, 0.1);

let png_img = image::io::Reader::new(Cursor::new(&result))
.with_guessed_format()
.unwrap()
.decode()
.unwrap();
Component::blur(cropped, 0.1);
}
}
1 change: 1 addition & 0 deletions homestar-runtime/src/network/webserver/rpc.rs
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ use dashmap::DashMap;
use faststr::FastStr;
#[cfg(feature = "websocket-notify")]
use futures::StreamExt;
#[cfg(feature = "websocket-notify")]
use homestar_core::ipld::DagCbor;
use jsonrpsee::{
server::RpcModule,
2 changes: 1 addition & 1 deletion homestar-runtime/src/settings.rs
Original file line number Diff line number Diff line change
@@ -278,7 +278,7 @@ impl Default for Network {
webserver_port: 1337,
webserver_timeout: Duration::new(120, 0),
websocket_capacity: 1024,
websocket_receiver_timeout: Duration::from_millis(500),
websocket_receiver_timeout: Duration::from_millis(1000),
workflow_quorum: 3,
keypair_config: PubkeyConfig::Random,
node_addresses: Vec::new(),
13 changes: 11 additions & 2 deletions homestar-runtime/src/worker.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ use crate::{
workflow::{self, Resource},
Db, Receipt,
};
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use chrono::NaiveDateTime;
use faststr::FastStr;
use fnv::FnvHashSet;
@@ -351,7 +351,16 @@ where
});

let handle = task_set.spawn(async move {
let resolved = resolved.await?;
let resolved = match resolved.await {
Ok(inst_result) => inst_result,
Err(err) => {
error!(err=?err, "error resolving cid");
return Err(anyhow!("error resolving cid: {err}"))
.with_context(|| {
format!("could not spawn task for cid: {workflow_cid}")
});
}
};
match wasm_ctx.run(wasm, &fun, resolved).await {
Ok(output) => Ok((
output,
112 changes: 86 additions & 26 deletions homestar-runtime/tests/webserver.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
use crate::utils::startup_ipfs;
use crate::utils::{kill_homestar, stop_all_bins, TimeoutFutureExt, BIN_NAME, IPFS};
use anyhow::Result;
use futures::StreamExt;
use jsonrpsee::{
core::client::{Subscription, SubscriptionClientT},
rpc_params,
@@ -83,10 +82,6 @@ fn test_workflow_run_serial() -> Result<()> {
let ws_url = format!("ws://{}:{}", Ipv4Addr::LOCALHOST, ws_port);

tokio_test::block_on(async {
tokio_tungstenite::connect_async(ws_url.clone())
.await
.unwrap();

let workflow_str =
fs::read_to_string("tests/fixtures/test-workflow-image-pipeline.json").unwrap();
let json: serde_json::Value = serde_json::from_str(&workflow_str).unwrap();
@@ -98,7 +93,7 @@ fn test_workflow_run_serial() -> Result<()> {
.build(ws_url.clone())
.await
.unwrap();
let sub1: Subscription<Vec<u8>> = client1
let mut sub1: Subscription<Vec<u8>> = client1
.subscribe(
SUBSCRIBE_RUN_WORKFLOW_ENDPOINT,
rpc_params![run.clone()],
@@ -108,14 +103,35 @@ fn test_workflow_run_serial() -> Result<()> {
.unwrap();

// we have 3 operations
sub1.take(3)
.for_each(|msg| async move {
let json: serde_json::Value = serde_json::from_slice(&msg.unwrap()).unwrap();
let check = json.get("metadata").unwrap();
let expected = serde_json::json!({"name": "test", "replayed": false, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}});
assert_eq!(check, &expected);
})
.await;
let one = sub1
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap();
let json: serde_json::Value = serde_json::from_slice(&one.unwrap().unwrap()).unwrap();
let check = json.get("metadata").unwrap();
let expected = serde_json::json!({"name": "test", "replayed": false, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}});
assert_eq!(check, &expected);

let two = sub1
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap();
let json: serde_json::Value = serde_json::from_slice(&two.unwrap().unwrap()).unwrap();
let check = json.get("metadata").unwrap();
let expected = serde_json::json!({"name": "test", "replayed": false, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}});
assert_eq!(check, &expected);

let three = sub1
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap();
let json: serde_json::Value = serde_json::from_slice(&three.unwrap().unwrap()).unwrap();
let check = json.get("metadata").unwrap();
let expected = serde_json::json!({"name": "test", "replayed": false, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}});
assert_eq!(check, &expected);

// separate subscription, only 3 events too
let mut sub2: Subscription<Vec<u8>> = client1
@@ -127,14 +143,28 @@ fn test_workflow_run_serial() -> Result<()> {
.await
.unwrap();

let msg = sub2.next().await.unwrap();
let json: serde_json::Value = serde_json::from_slice(&msg.unwrap()).unwrap();
let msg = sub2
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap();
let json: serde_json::Value = serde_json::from_slice(&msg.unwrap().unwrap()).unwrap();
let check = json.get("metadata").unwrap();
let expected = serde_json::json!({"name": "test", "replayed": true, "workflow": {"/": "bafyrmihfhdhxmhotbgn5digt6n7vgz2ukisafhjozki2e6nwtvunep3mrm"}});
assert_eq!(check, &expected);

assert!(sub2.next().await.is_some());
assert!(sub2.next().await.is_some());
assert!(sub2
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap()
.is_some());
assert!(sub2
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap()
.is_some());

let client2 = WsClientBuilder::default().build(ws_url).await.unwrap();
let mut sub3: Subscription<Vec<u8>> = client2
@@ -148,13 +178,28 @@ fn test_workflow_run_serial() -> Result<()> {

let _ = sub2
.next()
.with_timeout(std::time::Duration::from_millis(500))
.with_timeout(std::time::Duration::from_millis(2500))
.await
.is_err();

assert!(sub3.next().await.is_some());
assert!(sub2.next().await.is_some());
assert!(sub2.next().await.is_some());
assert!(sub3
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap()
.is_some());
assert!(sub2
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap()
.is_some());
assert!(sub2
.next()
.with_timeout(std::time::Duration::from_millis(2500))
.await
.unwrap()
.is_some());

let another_run_str = format!(r#"{{"name": "another_test","workflow": {}}}"#, json_string);
let another_run: serde_json::Value = serde_json::from_str(&another_run_str).unwrap();
@@ -169,12 +214,27 @@ fn test_workflow_run_serial() -> Result<()> {

let _ = sub3
.next()
.with_timeout(std::time::Duration::from_millis(500))
.with_timeout(std::time::Duration::from_millis(5000))
.await
.is_err();
assert!(sub4.next().await.is_some());
assert!(sub4.next().await.is_some());
assert!(sub4.next().await.is_some());
assert!(sub4
.next()
.with_timeout(std::time::Duration::from_millis(5000))
.await
.unwrap()
.is_some());
assert!(sub4
.next()
.with_timeout(std::time::Duration::from_millis(5000))
.await
.unwrap()
.is_some());
assert!(sub4
.next()
.with_timeout(std::time::Duration::from_millis(5000))
.await
.unwrap()
.is_some());
});

let _ = Command::new(BIN.as_os_str()).arg("stop").output();