@@ -388,7 +388,7 @@ void testLogFewSaltAgesOnRotation() throws Exception {
388388 var minAges = new Duration []{Duration .ofDays (30 ), Duration .ofDays (60 )};
389389 saltRotation .rotateSalts (lastSnapshot , minAges , 0.4 , targetDate ());
390390
391- var actual = appender .list .stream ().map (Object ::toString ).collect (Collectors .toSet ());
391+ var actual = appender .list .stream ().map (Object ::toString ).filter ( s -> s . contains ( "salt_count_type" ) || s . contains ( "Salt rotation complete" )). collect (Collectors .toSet ());
392392 assertThat (actual ).isEqualTo (expected );
393393 }
394394
@@ -428,7 +428,7 @@ void testLogManySaltAgesOnRotation() throws Exception {
428428 var minAges = new Duration []{Duration .ofDays (30 ), Duration .ofDays (60 )};
429429 saltRotation .rotateSalts (lastSnapshot , minAges , 0.2 , targetDate ());
430430
431- var actual = appender .list .stream ().map (Object ::toString ).collect (Collectors .toSet ());
431+ var actual = appender .list .stream ().map (Object ::toString ).filter ( s -> s . contains ( "salt_count_type" ) || s . contains ( "Salt rotation complete" )). collect (Collectors .toSet ());
432432 assertThat (actual ).isEqualTo (expected );
433433 }
434434
@@ -656,4 +656,38 @@ void testKeyRotationKeyToSaltRotation() throws Exception {
656656 assertThat (buckets [0 ].currentKeySalt ()).isNull ();
657657 assertThat (buckets [0 ].previousKeySalt ()).isEqualTo (new SaltEntry .KeyMaterial (0 , "keyKey1" , "keySalt1" ));
658658 }
659+
660+ @ ParameterizedTest
661+ @ CsvSource ({
662+ "true, 3, 1" ,
663+ "false, 1, 3"
664+ })
665+ void testKeyRotationLogBucketFormat (boolean v4Enabled , int expectedTotalKeyBuckets , int expectedTotalSaltBuckets ) throws Exception {
666+ saltRotation = new SaltRotation (keyGenerator , JsonObject .of (AdminConst .ENABLE_V4_RAW_UID , v4Enabled ));
667+ when (keyGenerator .generateRandomKeyString (anyInt ())).thenReturn ("random-key-string" );
668+
669+ final Duration [] minAges = {
670+ Duration .ofDays (30 )
671+ };
672+
673+ var willRefresh = targetDate ();
674+ var willNotRefresh = targetDate ().plusDays (30 );
675+ var lastSnapshot = SaltSnapshotBuilder .start ()
676+ .entries (SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willRefresh ).currentSalt (),
677+ SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willNotRefresh ).currentSalt (),
678+ SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willRefresh ).currentKeySalt (1 ),
679+ SaltBuilder .start ().lastUpdated (targetDate ().minusDays (60 )).refreshFrom (willNotRefresh ).currentKeySalt (2 ))
680+ .build ();
681+
682+ saltRotation .rotateSalts (lastSnapshot , minAges , 1 , targetDate ());
683+
684+ var expected = Set .of (
685+ String .format ("[INFO] UID bucket format: target_date=2025-01-01 bucket_format=total-current-key-buckets bucket_count=%d" , expectedTotalKeyBuckets ),
686+ String .format ("[INFO] UID bucket format: target_date=2025-01-01 bucket_format=total-current-salt-buckets bucket_count=%d" , expectedTotalSaltBuckets ),
687+ String .format ("[INFO] UID bucket format: target_date=2025-01-01 bucket_format=total-previous-key-buckets bucket_count=%d" , 1 ),
688+ String .format ("[INFO] UID bucket format: target_date=2025-01-01 bucket_format=total-previous-salt-buckets bucket_count=%d" , 1 )
689+ );
690+ var actual = appender .list .stream ().map (Object ::toString ).filter (s -> s .contains ("UID bucket format" )).collect (Collectors .toSet ());
691+ assertThat (actual ).isEqualTo (expected );
692+ }
659693}
0 commit comments