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

fix: admin_getFileLocation; test: sync test #141

Merged
merged 5 commits into from
Jul 23, 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
6 changes: 5 additions & 1 deletion node/rpc/src/admin/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ impl RpcServer for RpcServerImpl {
tx_seq: u64,
all_shards: bool,
) -> RpcResult<Option<Vec<LocationInfo>>> {
info!("admin_getFileLocation()");

let tx = match self.ctx.log_store.get_tx_by_seq_number(tx_seq).await? {
Some(tx) => tx,
None => {
Expand Down Expand Up @@ -225,7 +227,9 @@ impl RpcServer for RpcServerImpl {
shard_config: shard_config.unwrap(),
})
.collect();
if all_shards && all_shards_available(info.iter().map(|info| info.shard_config).collect()) {

if !all_shards || all_shards_available(info.iter().map(|info| info.shard_config).collect())
{
Ok(Some(info))
} else {
Ok(None)
Expand Down
13 changes: 11 additions & 2 deletions tests/sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __test_sync_file_by_rpc(self):
client1 = self.nodes[0]
client2 = self.nodes[1]

# stop client2, preventing it from receiving AnnounceFile
client2.shutdown()

# Create submission
chunk_data = random.randbytes(256 * 1024)
data_root = self.__create_submission(chunk_data)
Expand All @@ -41,16 +44,22 @@ def __test_sync_file_by_rpc(self):
segments = submit_data(client1, chunk_data)
self.log.info("segments: %s", [(s["root"], s["index"], s["proof"]) for s in segments])
wait_until(lambda: client1.zgs_get_file_info(data_root)["finalized"])

# File should not be auto sync on node 2

# restart client2
client2.start()
client2.wait_for_rpc_connection()

# File should not be auto sync on node 2 and there is no cached file locations
wait_until(lambda: client2.zgs_get_file_info(data_root) is not None)
time.sleep(3)
assert_equal(client2.zgs_get_file_info(data_root)["finalized"], False)
assert(client2.admin_get_file_location(0) is None)

# Trigger file sync by rpc
assert(client2.admin_start_sync_file(0) is None)
wait_until(lambda: client2.sync_status_is_completed_or_unknown(0))
wait_until(lambda: client2.zgs_get_file_info(data_root)["finalized"])
assert(client2.admin_get_file_location(0) is not None)

# Validate data
assert_equal(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_framework/zgs_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def admin_get_sync_status(self, tx_seq):
def sync_status_is_completed_or_unknown(self, tx_seq):
status = self.rpc.admin_getSyncStatus([tx_seq])
return status == "Completed" or status == "unknown"

def admin_get_file_location(self, tx_seq, all_shards = True):
return self.rpc.admin_getFileLocation([tx_seq, all_shards])

def clean_data(self):
shutil.rmtree(os.path.join(self.data_dir, "db"))
Loading