Skip to content
Snippets Groups Projects
Commit 9ac4e9de authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

refactor: pico.space.raft_group -> pico.space.instance

parent 1a3fa2bd
No related branches found
No related tags found
No related merge requests found
Pipeline #13990 passed
......@@ -19,7 +19,7 @@ use std::marker::PhantomData;
::tarantool::define_str_enum! {
/// An enumeration of builtin cluster-wide spaces
pub enum ClusterwideSpace {
Group = "_picodata_raft_group",
Instance = "_picodata_instance",
Address = "_picodata_peer_address",
State = "_picodata_cluster_state",
Replicaset = "_picodata_replicaset",
......@@ -352,8 +352,7 @@ impl Iterator for PeerAddressIter {
// Peers
////////////////////////////////////////////////////////////////////////////////
/// A struct for accessing storage of all the cluster peers
/// (currently raft_group).
/// A struct for accessing storage of all the cluster peers.
#[derive(Clone, Debug)]
pub struct Peers {
space: Space,
......@@ -363,7 +362,7 @@ pub struct Peers {
}
impl Peers {
const SPACE_NAME: &'static str = ClusterwideSpace::Group.as_str();
const SPACE_NAME: &'static str = ClusterwideSpace::Instance.as_str();
const INDEX_INSTANCE_ID: &'static str = "instance_id";
const INDEX_RAFT_ID: &'static str = "raft_id";
const INDEX_REPLICASET_ID: &'static str = "replicaset_id";
......@@ -798,7 +797,7 @@ inventory::submit!(crate::InnerTest {
use traft::{CurrentGradeVariant as CurrentGrade, TargetGradeVariant as TargetGrade, InstanceId};
let storage_peers = Peers::new().unwrap();
let raft_group = storage_peers.space.clone();
let space_peers = storage_peers.space.clone();
let storage_peer_addresses = PeerAddresses::new().unwrap();
let space_peer_addresses = storage_peer_addresses.space.clone();
......@@ -814,7 +813,7 @@ inventory::submit!(crate::InnerTest {
// r3
("i5", "i5-uuid", 5u64, "r3", "r3-uuid", (CurrentGrade::Online, 0), (TargetGrade::Online, 0), &faildom,),
] {
raft_group.put(&peer).unwrap();
space_peers.put(&peer).unwrap();
let (_, _, raft_id, ..) = peer;
space_peer_addresses.put(&(raft_id, format!("addr:{raft_id}"))).unwrap();
}
......@@ -836,7 +835,7 @@ inventory::submit!(crate::InnerTest {
"Tarantool error:",
" TupleFound: Duplicate key exists",
" in unique index \"raft_id\"",
" in space \"_picodata_raft_group\"",
" in space \"_picodata_instance\"",
" with old tuple",
r#" - ["i1", "i1-uuid", 1, "r1", "r1-uuid", ["{gon}", 0], ["{tgon}", 0], {{"A": "B"}}]"#,
" and new tuple",
......@@ -892,43 +891,43 @@ inventory::submit!(crate::InnerTest {
assert_eq!(box_replication("r3"), ["addr:5"]);
}
raft_group.index("raft_id").unwrap().drop().unwrap();
space_peers.index("raft_id").unwrap().drop().unwrap();
assert_err!(
storage_peers.get(&1),
concat!(
"Tarantool error: NoSuchIndexID: No index #1 is defined",
" in space '_picodata_raft_group'",
" in space '_picodata_instance'",
)
);
raft_group.index("replicaset_id").unwrap().drop().unwrap();
space_peers.index("replicaset_id").unwrap().drop().unwrap();
assert_err!(
storage_peers.replicaset_peers(""),
concat!(
"Tarantool error: NoSuchIndexID: No index #2 is defined",
" in space '_picodata_raft_group'",
" in space '_picodata_instance'",
)
);
raft_group.primary_key().drop().unwrap();
space_peers.primary_key().drop().unwrap();
assert_err!(
storage_peers.get(&InstanceId::from("i1")),
concat!(
"Tarantool error: NoSuchIndexID: No index #0 is defined",
" in space '_picodata_raft_group'",
" in space '_picodata_instance'",
)
);
raft_group.drop().unwrap();
space_peers.drop().unwrap();
assert_err!(
storage_peers.all_peers(),
format!(
"Tarantool error: NoSuchSpace: Space '{}' does not exist",
raft_group.id(),
space_peers.id(),
)
);
}
......
......@@ -423,8 +423,6 @@ pub struct Peer {
/// Instance failure domains. Instances with overlapping failure domains
/// must not be in the same replicaset.
// TODO: raft_group space is kinda bloated, maybe we should store some data
// in different spaces/not deserialize the whole tuple every time?
pub failure_domain: FailureDomain,
}
impl Encode for Peer {}
......
......@@ -46,7 +46,7 @@ def raft_join(
def replicaset_id(instance: Instance):
return instance.eval(
"return pico.space.raft_group:get(...).replicaset_id", instance.instance_id
"return pico.space.instance:get(...).replicaset_id", instance.instance_id
)
......@@ -129,7 +129,7 @@ def test_replication(cluster: Cluster):
for instance in cluster.instances:
with instance.connect(1) as conn:
raft_peer = conn.eval(
"return pico.space.raft_group:get(...):tomap()",
"return pico.space.instance:get(...):tomap()",
instance.instance_id,
)[0]
space_cluster = conn.select("_cluster")
......@@ -190,7 +190,7 @@ def test_init_replication_factor(cluster: Cluster):
replicaset_ids = i1.eval(
"""
return pico.space.raft_group:pairs()
return pico.space.instance:pairs()
:map(function(peer)
return peer.replicaset_id
end)
......@@ -346,7 +346,7 @@ def test_fail_to_join(cluster: Cluster):
joined_instances = i1.eval(
"""
return pico.space.raft_group:pairs()
return pico.space.instance:pairs()
:map(function(peer)
return { peer.instance_id, peer.raft_id }
end)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment