@@ -497,6 +497,7 @@ def test_predict_forward_time(self):
497
497
def test_plan_partition_changes_no_empty_partitions (self ):
498
498
with self .assertRaises (NoEmptyPartitionsAvailableException ):
499
499
_plan_partition_changes (
500
+ Table ("table" ),
500
501
[mkPPart ("p_20201231" , 0 ), mkPPart ("p_20210102" , 200 )],
501
502
mkPos (50 ),
502
503
datetime (2021 , 1 , 1 , tzinfo = timezone .utc ),
@@ -505,8 +506,9 @@ def test_plan_partition_changes_no_empty_partitions(self):
505
506
)
506
507
507
508
def test_plan_partition_changes_imminent (self ):
508
- with self .assertLogs ("plan_partition_changes" , level = "INFO" ) as logctx :
509
+ with self .assertLogs ("plan_partition_changes:table " , level = "INFO" ) as logctx :
509
510
planned = _plan_partition_changes (
511
+ Table ("table" ),
510
512
[
511
513
mkPPart ("p_20201231" , 100 ),
512
514
mkPPart ("p_20210102" , 200 ),
@@ -521,7 +523,7 @@ def test_plan_partition_changes_imminent(self):
521
523
self .assertEqual (
522
524
logctx .output ,
523
525
[
524
- "INFO:plan_partition_changes:Start-of-fill predicted at "
526
+ "INFO:plan_partition_changes:table: Start-of-fill predicted at "
525
527
"2021-01-03 which is not 2021-01-02. This change will be marked "
526
528
"as important to ensure that p_20210102: (200) is moved to "
527
529
"2021-01-03"
@@ -545,8 +547,9 @@ def test_plan_partition_changes_imminent(self):
545
547
)
546
548
547
549
def test_plan_partition_changes_wildly_off_dates (self ):
548
- with self .assertLogs ("plan_partition_changes" , level = "INFO" ) as logctx :
550
+ with self .assertLogs ("plan_partition_changes:table " , level = "INFO" ) as logctx :
549
551
planned = _plan_partition_changes (
552
+ Table ("table" ),
550
553
[
551
554
mkPPart ("p_20201231" , 100 ),
552
555
mkPPart ("p_20210104" , 200 ),
@@ -561,7 +564,7 @@ def test_plan_partition_changes_wildly_off_dates(self):
561
564
self .assertEqual (
562
565
logctx .output ,
563
566
[
564
- "INFO:plan_partition_changes:Start-of-fill predicted at "
567
+ "INFO:plan_partition_changes:table: Start-of-fill predicted at "
565
568
"2021-01-02 which is not 2021-01-04. This change will be marked "
566
569
"as important to ensure that p_20210104: (200) is moved to "
567
570
"2021-01-02"
@@ -583,6 +586,7 @@ def test_plan_partition_changes_wildly_off_dates(self):
583
586
584
587
def test_plan_partition_changes_long_delay (self ):
585
588
planned = _plan_partition_changes (
589
+ Table ("table" ),
586
590
[
587
591
mkPPart ("p_20210101" , 100 ),
588
592
mkPPart ("p_20210415" , 200 ),
@@ -610,6 +614,7 @@ def test_plan_partition_changes_long_delay(self):
610
614
def test_plan_partition_changes_short_names (self ):
611
615
self .maxDiff = None
612
616
planned = _plan_partition_changes (
617
+ Table ("table" ),
613
618
[
614
619
mkPPart ("p_2019" , 1912499867 ),
615
620
mkPPart ("p_2020" , 8890030931 ),
@@ -651,6 +656,7 @@ def test_plan_partition_changes_short_names(self):
651
656
652
657
def test_plan_partition_changes_bespoke_names (self ):
653
658
planned = _plan_partition_changes (
659
+ Table ("table" ),
654
660
[mkPPart ("p_start" , 100 ), mkTailPart ("p_future" )],
655
661
mkPos (50 ),
656
662
datetime (2021 , 1 , 6 , tzinfo = timezone .utc ),
@@ -686,6 +692,7 @@ def test_plan_partition_changes_bespoke_names(self):
686
692
def test_plan_partition_changes (self ):
687
693
self .maxDiff = None
688
694
planned = _plan_partition_changes (
695
+ Table ("table" ),
689
696
[
690
697
mkPPart ("p_20201231" , 100 ),
691
698
mkPPart ("p_20210102" , 200 ),
@@ -710,6 +717,7 @@ def test_plan_partition_changes(self):
710
717
711
718
self .assertEqual (
712
719
_plan_partition_changes (
720
+ Table ("table" ),
713
721
[
714
722
mkPPart ("p_20201231" , 100 ),
715
723
mkPPart ("p_20210102" , 200 ),
@@ -739,6 +747,7 @@ def test_plan_partition_changes_misprediction(self):
739
747
match reality. """
740
748
self .maxDiff = None
741
749
planned = _plan_partition_changes (
750
+ Table ("table" ),
742
751
[
743
752
mkPPart ("p_20210505" , 9505010028 ),
744
753
mkPPart ("p_20210604" , 10152257517 ),
@@ -770,25 +779,32 @@ def test_plan_partition_changes_misprediction(self):
770
779
def test_should_run_changes (self ):
771
780
self .assertFalse (
772
781
_should_run_changes (
773
- [ChangePlannedPartition (mkPPart ("p_20210102" , 200 )).set_position ([300 ])]
782
+ Table ("table" ),
783
+ [
784
+ ChangePlannedPartition (mkPPart ("p_20210102" , 200 )).set_position (
785
+ [300 ]
786
+ )
787
+ ],
774
788
)
775
789
)
776
790
777
791
self .assertFalse (
778
792
_should_run_changes (
793
+ Table ("table" ),
779
794
[
780
795
ChangePlannedPartition (mkPPart ("p_20210102" , 200 )).set_position (
781
796
[300 ]
782
797
),
783
798
ChangePlannedPartition (mkPPart ("p_20210109" , 1000 )).set_position (
784
799
[1300 ]
785
800
),
786
- ]
801
+ ],
787
802
)
788
803
)
789
- with self .assertLogs ("should_run_changes" , level = "DEBUG" ) as logctx :
804
+ with self .assertLogs ("should_run_changes:table " , level = "DEBUG" ) as logctx :
790
805
self .assertTrue (
791
806
_should_run_changes (
807
+ Table ("table" ),
792
808
[
793
809
ChangePlannedPartition (mkPPart ("p_20210102" , 200 )).set_position (
794
810
[302 ]
@@ -802,17 +818,21 @@ def test_should_run_changes(self):
802
818
NewPlannedPartition ()
803
819
.set_position ([662 ])
804
820
.set_timestamp (datetime (2021 , 1 , 23 , tzinfo = timezone .utc )),
805
- ]
821
+ ],
806
822
)
807
823
)
808
824
self .assertEqual (
809
825
logctx .output ,
810
- ["DEBUG:should_run_changes:Add: [542] 2021-01-16 " "00:00:00+00:00 is new" ],
826
+ [
827
+ "DEBUG:should_run_changes:table:Add: [542] 2021-01-16 "
828
+ "00:00:00+00:00 is new"
829
+ ],
811
830
)
812
831
813
- with self .assertLogs ("should_run_changes" , level = "DEBUG" ) as logctx :
832
+ with self .assertLogs ("should_run_changes:table " , level = "DEBUG" ) as logctx :
814
833
self .assertTrue (
815
834
_should_run_changes (
835
+ Table ("table" ),
816
836
[
817
837
ChangePlannedPartition (mkPPart ("p_20210102" , 200 )),
818
838
NewPlannedPartition ()
@@ -821,12 +841,15 @@ def test_should_run_changes(self):
821
841
NewPlannedPartition ()
822
842
.set_position ([662 ])
823
843
.set_timestamp (datetime (2021 , 1 , 23 , tzinfo = timezone .utc )),
824
- ]
844
+ ],
825
845
)
826
846
)
827
847
self .assertEqual (
828
848
logctx .output ,
829
- ["DEBUG:should_run_changes:Add: [542] 2021-01-16 " "00:00:00+00:00 is new" ],
849
+ [
850
+ "DEBUG:should_run_changes:table:Add: [542] 2021-01-16 "
851
+ "00:00:00+00:00 is new"
852
+ ],
830
853
)
831
854
832
855
def testgenerate_sql_reorganize_partition_commands_no_change (self ):
@@ -976,6 +999,7 @@ def test_plan_andgenerate_sql_reorganize_partition_commands_with_future_partitio
976
999
self
977
1000
):
978
1001
planned = _plan_partition_changes (
1002
+ Table ("table" ),
979
1003
[
980
1004
mkPPart ("p_20201231" , 100 ),
981
1005
mkPPart ("p_20210104" , 200 ),
@@ -999,7 +1023,7 @@ def test_plan_andgenerate_sql_reorganize_partition_commands_with_future_partitio
999
1023
1000
1024
def test_get_pending_sql_reorganize_partition_commands_no_changes (self ):
1001
1025
with self .assertLogs (
1002
- "get_pending_sql_reorganize_partition_commands" , level = "INFO"
1026
+ "get_pending_sql_reorganize_partition_commands:plushies " , level = "INFO"
1003
1027
) as logctx :
1004
1028
cmds = get_pending_sql_reorganize_partition_commands (
1005
1029
table = Table ("plushies" ),
@@ -1017,7 +1041,7 @@ def test_get_pending_sql_reorganize_partition_commands_no_changes(self):
1017
1041
self .assertEqual (
1018
1042
logctx .output ,
1019
1043
[
1020
- "INFO:get_pending_sql_reorganize_partition_commands:"
1044
+ "INFO:get_pending_sql_reorganize_partition_commands:plushies: "
1021
1045
"Table plushies does not need to be modified currently."
1022
1046
],
1023
1047
)
@@ -1026,7 +1050,7 @@ def test_get_pending_sql_reorganize_partition_commands_no_changes(self):
1026
1050
1027
1051
def test_get_pending_sql_reorganize_partition_commands_with_changes (self ):
1028
1052
with self .assertLogs (
1029
- "get_pending_sql_reorganize_partition_commands" , level = "DEBUG"
1053
+ "get_pending_sql_reorganize_partition_commands:plushies " , level = "DEBUG"
1030
1054
) as logctx :
1031
1055
cmds = get_pending_sql_reorganize_partition_commands (
1032
1056
table = Table ("plushies" ),
@@ -1044,7 +1068,7 @@ def test_get_pending_sql_reorganize_partition_commands_with_changes(self):
1044
1068
self .assertEqual (
1045
1069
logctx .output ,
1046
1070
[
1047
- "DEBUG:get_pending_sql_reorganize_partition_commands:"
1071
+ "DEBUG:get_pending_sql_reorganize_partition_commands:plushies: "
1048
1072
"Table plushies has changes waiting."
1049
1073
],
1050
1074
)
0 commit comments