Skip to content

Commit

Permalink
Release v2.0.0 alpha.10 (#391)
Browse files Browse the repository at this point in the history
* disable mock bob client

* update CHANGELOG.md
  • Loading branch information
piakushin authored Dec 3, 2021
1 parent 9d393fb commit 3a6b0ec
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 33 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ Bob versions changelog
- Add traits to support pearl #123


#### Fixed
- Cluster tests now use mock of BobClient, some cluster and cluster config tests were updated, all tests now pass (#280)

#### Updated
- Upgrade pearl to v0.8.1

Expand Down
20 changes: 12 additions & 8 deletions bob-common/src/bob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ pub mod b_client {
let mut client = self.client.clone();
self.metrics.exist_count();
let timer = BobClientMetrics::start_timer();
let keys = keys.into_iter().map(|key| BlobKey { key: key.into() }).collect();
let keys = keys
.into_iter()
.map(|key| BlobKey { key: key.into() })
.collect();
let message = ExistRequest {
keys,
options: Some(options),
Expand Down Expand Up @@ -207,13 +210,14 @@ use std::{
time::Duration,
};

cfg_if::cfg_if! {
if #[cfg(any(feature = "testing", test))] {
pub use self::b_client::MockBobClient as BobClient;
} else {
pub use self::b_client::BobClient;
}
}
// cfg_if::cfg_if! {
// if #[cfg(any(feature = "testing", test))] {
// pub use self::b_client::MockBobClient as BobClient;
// } else {
// pub use self::b_client::BobClient;
// }
// }
pub use self::b_client::BobClient;

pub type PutResult = Result<NodeOutput<()>, NodeOutput<Error>>;

Expand Down
10 changes: 1 addition & 9 deletions bob-common/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
bob_client::{Factory},
bob_client::{BobClient, Factory},
data::BobData,
};
use http::Uri;
Expand All @@ -10,14 +10,6 @@ use std::{
};
use tokio::sync::RwLock;

cfg_if::cfg_if! {
if #[cfg(any(feature = "testing", test))] {
use crate::bob_client::b_client::MockBobClient as BobClient;
} else {
use crate::bob_client::b_client::BobClient;
}
}

pub type Id = u16;

pub type Name = String;
Expand Down
42 changes: 29 additions & 13 deletions bob/src/cluster/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::atomic::{AtomicU64, Ordering};

use crate::{
prelude::*,
{cluster::Cluster, test_utils}
{cluster::Cluster, test_utils},
};

use bob_common::{
Expand All @@ -11,7 +11,7 @@ use bob_common::{
cluster::{tests::cluster_config, Cluster as ClusterConfig},
node::tests::node_config,
},
data::BobMeta
data::BobMeta,
};
use tokio::time::sleep;

Expand All @@ -21,8 +21,8 @@ fn ping_ok(client: &mut BobClient, node: Node) {
let cl = node;

client
.expect_ping()
.returning(move || test_utils::ping_ok(cl.name().to_owned()));
.expect_ping()
.returning(move || test_utils::ping_ok(cl.name().to_owned()));
}

fn put_ok(client: &mut BobClient, node: Node, call: Arc<CountCall>) {
Expand Down Expand Up @@ -114,11 +114,12 @@ async fn create_cluster(
let mut mock_client = BobClient::new();

let (_, func, call) = map
.iter()
.find(|(name, _, _)| *name == node.name())
.expect("find node with name");
.iter()
.find(|(name, _, _)| *name == node.name())
.expect("find node with name");
func(&mut mock_client, node.clone(), call.clone());
node.set_connection(mock_client).await;
// node.set_connection(mock_client).await;
todo!()
}

let backend = Arc::new(Backend::new(mapper.clone(), node).await);
Expand Down Expand Up @@ -159,7 +160,14 @@ fn create_node(
get_err(client, n, c);
}
};
f(client, n.clone(), call.clone(), set_put_ok, set_get_ok, returned_timestamp);
f(
client,
n.clone(),
call.clone(),
set_put_ok,
set_get_ok,
returned_timestamp,
);
client.expect_clone().returning(move || {
let mut cl = BobClient::default();
f(
Expand Down Expand Up @@ -311,15 +319,19 @@ async fn two_node_one_vdisk_cluster_one_node_failed_put_err() {
.collect();
let (quorum, backend) = create_cluster(&node, &cluster, &actions).await;

let result = quorum.put(BobKey::from(5), BobData::new(vec![], BobMeta::new(11))).await;
let result = quorum
.put(BobKey::from(5), BobData::new(vec![], BobMeta::new(11)))
.await;
sleep(Duration::from_millis(1)).await;

assert!(result.is_ok());
// assert_eq!(1, calls[0].1.put_count());
warn!("can't track put result, because it doesn't pass through mock client");
assert_eq!(1, calls[1].1.put_count());

let get = backend.get_local(BobKey::from(5), Operation::new_alien(0)).await;
let get = backend
.get_local(BobKey::from(5), Operation::new_alien(0))
.await;
assert!(get.is_ok());
}

Expand Down Expand Up @@ -403,7 +415,9 @@ async fn three_node_two_vdisk_cluster_one_node_failed_put_err() {
let (quorum, backend) = create_cluster(&node, &cluster, &actions).await;

info!("quorum put: 0");
let result = quorum.put(BobKey::from(0), BobData::new(vec![], BobMeta::new(11))).await;
let result = quorum
.put(BobKey::from(0), BobData::new(vec![], BobMeta::new(11)))
.await;
sleep(Duration::from_millis(1000)).await;

assert!(result.is_ok());
Expand All @@ -412,7 +426,9 @@ async fn three_node_two_vdisk_cluster_one_node_failed_put_err() {
assert_eq!(1, calls[1].1.put_count());
assert_eq!(1, calls[2].1.put_count());

let get = backend.get_local(BobKey::from(0), Operation::new_alien(0)).await;
let get = backend
.get_local(BobKey::from(0), Operation::new_alien(0))
.await;
assert!(get.is_ok());
}

Expand Down

0 comments on commit 3a6b0ec

Please sign in to comment.