From bbc1491913ec0e4792a875b7d0f7f57820da835c Mon Sep 17 00:00:00 2001 From: zwang28 <84491488@qq.com> Date: Thu, 12 Sep 2024 19:57:17 +0800 Subject: [PATCH] fix tests --- .../hummock_test/src/state_store_tests.rs | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/storage/hummock_test/src/state_store_tests.rs b/src/storage/hummock_test/src/state_store_tests.rs index 67da2150735af..6f3adaf37355a 100644 --- a/src/storage/hummock_test/src/state_store_tests.rs +++ b/src/storage/hummock_test/src/state_store_tests.rs @@ -32,6 +32,7 @@ use risingwave_hummock_sdk::{ }; use risingwave_meta::hummock::test_utils::setup_compute_env; use risingwave_rpc_client::HummockMetaClient; +use risingwave_storage::error::ErrorKind; use risingwave_storage::hummock::iterator::change_log::test_utils::{ apply_test_log_data, gen_test_data, }; @@ -1234,7 +1235,58 @@ async fn test_multiple_epoch_sync_v2() { .try_wait_epoch(HummockReadEpoch::Committed(epoch3)) .await .unwrap(); - test_get().await; + // The barrier read always read the latest epoch if any committed version available. + if let ErrorKind::Hummock(err) = hummock_storage + .get( + gen_key_from_str(VirtualNode::ZERO, "bb"), + epoch1, + ReadOptions { + cache_policy: CachePolicy::Fill(CacheContext::Default), + ..Default::default() + }, + ) + .await + .unwrap_err() + .inner() + { + assert!(err.is_expired_epoch()); + } else { + panic!("unexpected error"); + }; + + if let ErrorKind::Hummock(err) = hummock_storage + .get( + gen_key_from_str(VirtualNode::ZERO, "bb"), + epoch2, + ReadOptions { + cache_policy: CachePolicy::Fill(CacheContext::Default), + ..Default::default() + }, + ) + .await + .unwrap_err() + .inner() + { + assert!(err.is_expired_epoch()); + } else { + panic!("unexpected error"); + } + + assert_eq!( + hummock_storage + .get( + gen_key_from_str(VirtualNode::ZERO, "bb"), + epoch3, + ReadOptions { + cache_policy: CachePolicy::Fill(CacheContext::Default), + ..Default::default() + } + ) + .await + .unwrap() + .unwrap(), + "555".as_bytes() + ); } #[tokio::test]