@@ -7757,13 +7757,13 @@ mod tests {
7757
7757
(
7758
7758
get_key( 3 ) ,
7759
7759
Lsn ( 0x20 ) ,
7760
- Value :: WalRecord ( NeonWalRecord :: wal_clear( ) ) ,
7760
+ Value :: WalRecord ( NeonWalRecord :: wal_clear( "c" ) ) ,
7761
7761
) ,
7762
7762
( get_key( 4 ) , Lsn ( 0x10 ) , Value :: Image ( "0x10" . into( ) ) ) ,
7763
7763
(
7764
7764
get_key( 4 ) ,
7765
7765
Lsn ( 0x20 ) ,
7766
- Value :: WalRecord ( NeonWalRecord :: wal_init( ) ) ,
7766
+ Value :: WalRecord ( NeonWalRecord :: wal_init( "i" ) ) ,
7767
7767
) ,
7768
7768
] ;
7769
7769
let image1 = vec ! [ ( get_key( 1 ) , "0x10" . into( ) ) ] ;
@@ -7912,8 +7912,30 @@ mod tests {
7912
7912
7913
7913
#[ cfg( feature = "testing" ) ]
7914
7914
#[ tokio:: test]
7915
- async fn test_simple_bottom_most_compaction_deltas ( ) -> anyhow:: Result < ( ) > {
7916
- let harness = TenantHarness :: create ( "test_simple_bottom_most_compaction_deltas" ) . await ?;
7915
+ async fn test_simple_bottom_most_compaction_deltas_1 ( ) -> anyhow:: Result < ( ) > {
7916
+ test_simple_bottom_most_compaction_deltas_helper (
7917
+ "test_simple_bottom_most_compaction_deltas_1" ,
7918
+ false ,
7919
+ )
7920
+ . await
7921
+ }
7922
+
7923
+ #[ cfg( feature = "testing" ) ]
7924
+ #[ tokio:: test]
7925
+ async fn test_simple_bottom_most_compaction_deltas_2 ( ) -> anyhow:: Result < ( ) > {
7926
+ test_simple_bottom_most_compaction_deltas_helper (
7927
+ "test_simple_bottom_most_compaction_deltas_2" ,
7928
+ true ,
7929
+ )
7930
+ . await
7931
+ }
7932
+
7933
+ #[ cfg( feature = "testing" ) ]
7934
+ async fn test_simple_bottom_most_compaction_deltas_helper (
7935
+ test_name : & ' static str ,
7936
+ use_delta_bottom_layer : bool ,
7937
+ ) -> anyhow:: Result < ( ) > {
7938
+ let harness = TenantHarness :: create ( test_name) . await ?;
7917
7939
let ( tenant, ctx) = harness. load ( ) . await ;
7918
7940
7919
7941
fn get_key ( id : u32 ) -> Key {
@@ -7944,6 +7966,16 @@ mod tests {
7944
7966
let img_layer = ( 0 ..10 )
7945
7967
. map ( |id| ( get_key ( id) , Bytes :: from ( format ! ( "value {id}@0x10" ) ) ) )
7946
7968
. collect_vec ( ) ;
7969
+ // or, delta layer at 0x10 if `use_delta_bottom_layer` is true
7970
+ let delta4 = ( 0 ..10 )
7971
+ . map ( |id| {
7972
+ (
7973
+ get_key ( id) ,
7974
+ Lsn ( 0x08 ) ,
7975
+ Value :: WalRecord ( NeonWalRecord :: wal_init ( format ! ( "value {id}@0x10" ) ) ) ,
7976
+ )
7977
+ } )
7978
+ . collect_vec ( ) ;
7947
7979
7948
7980
let delta1 = vec ! [
7949
7981
(
@@ -7997,21 +8029,61 @@ mod tests {
7997
8029
) ,
7998
8030
] ;
7999
8031
8000
- let tline = tenant
8001
- . create_test_timeline_with_layers (
8002
- TIMELINE_ID ,
8003
- Lsn ( 0x10 ) ,
8004
- DEFAULT_PG_VERSION ,
8005
- & ctx,
8006
- vec ! [
8007
- DeltaLayerTestDesc :: new_with_inferred_key_range( Lsn ( 0x10 ) ..Lsn ( 0x48 ) , delta1) ,
8008
- DeltaLayerTestDesc :: new_with_inferred_key_range( Lsn ( 0x10 ) ..Lsn ( 0x48 ) , delta2) ,
8009
- DeltaLayerTestDesc :: new_with_inferred_key_range( Lsn ( 0x48 ) ..Lsn ( 0x50 ) , delta3) ,
8010
- ] , // delta layers
8011
- vec ! [ ( Lsn ( 0x10 ) , img_layer) ] , // image layers
8012
- Lsn ( 0x50 ) ,
8013
- )
8014
- . await ?;
8032
+ let tline = if use_delta_bottom_layer {
8033
+ tenant
8034
+ . create_test_timeline_with_layers (
8035
+ TIMELINE_ID ,
8036
+ Lsn ( 0x08 ) ,
8037
+ DEFAULT_PG_VERSION ,
8038
+ & ctx,
8039
+ vec ! [
8040
+ DeltaLayerTestDesc :: new_with_inferred_key_range(
8041
+ Lsn ( 0x08 ) ..Lsn ( 0x10 ) ,
8042
+ delta4,
8043
+ ) ,
8044
+ DeltaLayerTestDesc :: new_with_inferred_key_range(
8045
+ Lsn ( 0x20 ) ..Lsn ( 0x48 ) ,
8046
+ delta1,
8047
+ ) ,
8048
+ DeltaLayerTestDesc :: new_with_inferred_key_range(
8049
+ Lsn ( 0x20 ) ..Lsn ( 0x48 ) ,
8050
+ delta2,
8051
+ ) ,
8052
+ DeltaLayerTestDesc :: new_with_inferred_key_range(
8053
+ Lsn ( 0x48 ) ..Lsn ( 0x50 ) ,
8054
+ delta3,
8055
+ ) ,
8056
+ ] , // delta layers
8057
+ vec ! [ ] , // image layers
8058
+ Lsn ( 0x50 ) ,
8059
+ )
8060
+ . await ?
8061
+ } else {
8062
+ tenant
8063
+ . create_test_timeline_with_layers (
8064
+ TIMELINE_ID ,
8065
+ Lsn ( 0x10 ) ,
8066
+ DEFAULT_PG_VERSION ,
8067
+ & ctx,
8068
+ vec ! [
8069
+ DeltaLayerTestDesc :: new_with_inferred_key_range(
8070
+ Lsn ( 0x10 ) ..Lsn ( 0x48 ) ,
8071
+ delta1,
8072
+ ) ,
8073
+ DeltaLayerTestDesc :: new_with_inferred_key_range(
8074
+ Lsn ( 0x10 ) ..Lsn ( 0x48 ) ,
8075
+ delta2,
8076
+ ) ,
8077
+ DeltaLayerTestDesc :: new_with_inferred_key_range(
8078
+ Lsn ( 0x48 ) ..Lsn ( 0x50 ) ,
8079
+ delta3,
8080
+ ) ,
8081
+ ] , // delta layers
8082
+ vec ! [ ( Lsn ( 0x10 ) , img_layer) ] , // image layers
8083
+ Lsn ( 0x50 ) ,
8084
+ )
8085
+ . await ?
8086
+ } ;
8015
8087
{
8016
8088
// Update GC info
8017
8089
let mut guard = tline. gc_info . write ( ) . unwrap ( ) ;
@@ -8121,7 +8193,7 @@ mod tests {
8121
8193
(
8122
8194
key,
8123
8195
Lsn ( 0x10 ) ,
8124
- Value :: Image ( Bytes :: copy_from_slice ( b "0x10") ) ,
8196
+ Value :: WalRecord ( NeonWalRecord :: wal_init ( "0x10" ) ) ,
8125
8197
) ,
8126
8198
(
8127
8199
key,
@@ -8183,7 +8255,7 @@ mod tests {
8183
8255
Lsn ( 0x20 ) ,
8184
8256
KeyLogAtLsn ( vec![ (
8185
8257
Lsn ( 0x20 ) ,
8186
- Value :: Image ( Bytes :: copy_from_slice ( b"0x10;0x20" ) ) ,
8258
+ Value :: Image ( Bytes :: from_static ( b"0x10;0x20" ) ) ,
8187
8259
) ] ) ,
8188
8260
) ,
8189
8261
(
@@ -9165,7 +9237,7 @@ mod tests {
9165
9237
9166
9238
let will_init = will_init_keys. contains ( & i) ;
9167
9239
if will_init {
9168
- delta_layer_spec. push ( ( key, lsn, Value :: WalRecord ( NeonWalRecord :: wal_init ( ) ) ) ) ;
9240
+ delta_layer_spec. push ( ( key, lsn, Value :: WalRecord ( NeonWalRecord :: wal_init ( "" ) ) ) ) ;
9169
9241
9170
9242
expected_key_values. insert ( key, "" . to_string ( ) ) ;
9171
9243
} else {
0 commit comments