@@ -389,7 +389,7 @@ void testLogFewSaltAgesOnRotation() throws Exception {
389389 var minAges = new Duration []{Duration .ofDays (30 ), Duration .ofDays (60 )};
390390 saltRotation .rotateSalts (lastSnapshot , minAges , 0.4 , targetDate ());
391391
392- var actual = appender .list .stream ().map (Object ::toString ).collect (Collectors .toSet ());
392+ var actual = appender .list .stream ().map (Object ::toString ).filter ( s -> s . contains ( "salt_count_type" ) || s . contains ( "Salt rotation complete" )). collect (Collectors .toSet ());
393393 assertThat (actual ).isEqualTo (expected );
394394 }
395395
@@ -429,7 +429,7 @@ void testLogManySaltAgesOnRotation() throws Exception {
429429 var minAges = new Duration []{Duration .ofDays (30 ), Duration .ofDays (60 )};
430430 saltRotation .rotateSalts (lastSnapshot , minAges , 0.2 , targetDate ());
431431
432- var actual = appender .list .stream ().map (Object ::toString ).collect (Collectors .toSet ());
432+ var actual = appender .list .stream ().map (Object ::toString ).filter ( s -> s . contains ( "salt_count_type" ) || s . contains ( "Salt rotation complete" )). collect (Collectors .toSet ());
433433 assertThat (actual ).isEqualTo (expected );
434434 }
435435
@@ -726,4 +726,35 @@ void testKeyRotationSaltToKeyRotation() throws Exception {
726726 assertThat (salts [0 ].currentSalt ()).isNotNull ();
727727 assertThat (salts [0 ].previousSalt ()).isNull ();
728728 }
729+
730+ @ ParameterizedTest
731+ @ CsvSource ({
732+ "true, 1, 3" ,
733+ "false, 0, 1"
734+ })
735+ void testKeyRotationLogKeyBuckets (boolean v4Enabled , int expectedNewKeyBuckets , int expectedTotalKeyBuckets ) throws Exception {
736+ saltRotation = new SaltRotation (keyGenerator , JsonObject .of (AdminConst .ENABLE_V4_RAW_UID , v4Enabled ));
737+
738+ final Duration [] minAges = {
739+ Duration .ofDays (30 )
740+ };
741+
742+ var willRefresh = targetDate ();
743+ var willNotRefresh = targetDate ().plusDays (30 );
744+ var lastSnapshot = SaltSnapshotBuilder .start ()
745+ .entries (SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willRefresh ).currentSalt (),
746+ SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willNotRefresh ).currentSalt (),
747+ SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willRefresh ).currentKey (1 ),
748+ SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willNotRefresh ).currentKey (2 ))
749+ .build ();
750+
751+ saltRotation .rotateSalts (lastSnapshot , minAges , 1 , targetDate ());
752+
753+ var expected = Set .of (
754+ "[INFO] salt_bucket_count_type=new-key-buckets target_date=2025-01-01 bucket_count=" + expectedNewKeyBuckets ,
755+ "[INFO] salt_bucket_count_type=total-key-buckets target_date=2025-01-01 bucket_count=" + expectedTotalKeyBuckets
756+ );
757+ var actual = appender .list .stream ().map (Object ::toString ).filter (s -> s .contains ("salt_bucket_count_type" )).collect (Collectors .toSet ());
758+ assertThat (actual ).isEqualTo (expected );
759+ }
729760}
0 commit comments