@@ -605,49 +605,6 @@ def throw_exception_first_time(*args, **kwargs):
605
605
assert_state_clean (check )
606
606
607
607
608
- @requires_over_14
609
- @pytest .mark .parametrize (
610
- 'is_aurora' ,
611
- [True , False ],
612
- )
613
- @pytest .mark .flaky (max_runs = 5 )
614
- def test_wal_stats (aggregator , integration_check , pg_instance , is_aurora ):
615
- conn = _get_superconn (pg_instance )
616
- with conn .cursor () as cur :
617
- cur .execute ("select wal_records, wal_fpi, wal_bytes from pg_stat_wal;" )
618
- (wal_records , wal_fpi , wal_bytes ) = cur .fetchall ()[0 ]
619
- cur .execute ("insert into persons (lastname) values ('test');" )
620
-
621
- # Wait for pg_stat_wal to be updated
622
- for _ in range (10 ):
623
- with conn .cursor () as cur :
624
- cur .execute ("select wal_records, wal_bytes from pg_stat_wal;" )
625
- new_wal_records = cur .fetchall ()[0 ][0 ]
626
- if new_wal_records > wal_records :
627
- break
628
- time .sleep (0.1 )
629
-
630
- check = integration_check (pg_instance )
631
- check .is_aurora = is_aurora
632
- if is_aurora is True :
633
- return
634
- check .run ()
635
-
636
- expected_tags = _get_expected_tags (check , pg_instance )
637
- aggregator .assert_metric ('postgresql.wal.records' , count = 1 , tags = expected_tags )
638
- aggregator .assert_metric ('postgresql.wal.bytes' , count = 1 , tags = expected_tags )
639
-
640
- # Expect at least one Heap + one Transaction additional records in the WAL
641
- assert_metric_at_least (
642
- aggregator , 'postgresql.wal.records' , tags = expected_tags , count = 1 , lower_bound = wal_records + 2
643
- )
644
- # We should have at least one full page write
645
- assert_metric_at_least (aggregator , 'postgresql.wal.bytes' , tags = expected_tags , count = 1 , lower_bound = wal_bytes + 100 )
646
- assert_metric_at_least (
647
- aggregator , 'postgresql.wal.full_page_images' , tags = expected_tags , count = 1 , lower_bound = wal_fpi
648
- )
649
-
650
-
651
608
def test_query_timeout (integration_check , pg_instance ):
652
609
pg_instance ['query_timeout' ] = 1000
653
610
check = integration_check (pg_instance )
@@ -658,61 +615,6 @@ def test_query_timeout(integration_check, pg_instance):
658
615
cursor .execute ("select pg_sleep(2000)" )
659
616
660
617
661
- @requires_over_10
662
- @pytest .mark .parametrize (
663
- 'is_aurora' ,
664
- [True , False ],
665
- )
666
- def test_wal_metrics (aggregator , integration_check , pg_instance , is_aurora ):
667
- check = integration_check (pg_instance )
668
- check .is_aurora = is_aurora
669
-
670
- if is_aurora is True :
671
- return
672
- # Default PG's wal size is 16MB
673
- wal_size = 16777216
674
-
675
- postgres_conn = _get_superconn (pg_instance )
676
- with postgres_conn .cursor () as cur :
677
- cur .execute ("select count(*) from pg_ls_waldir();" )
678
- expected_num_wals = cur .fetchall ()[0 ][0 ]
679
-
680
- check .run ()
681
-
682
- expected_wal_size = expected_num_wals * wal_size
683
- dd_agent_tags = _get_expected_tags (check , pg_instance )
684
- aggregator .assert_metric ('postgresql.wal_count' , count = 1 , value = expected_num_wals , tags = dd_agent_tags )
685
- aggregator .assert_metric ('postgresql.wal_size' , count = 1 , value = expected_wal_size , tags = dd_agent_tags )
686
-
687
-
688
- def test_pg_control (aggregator , integration_check , pg_instance ):
689
- check = integration_check (pg_instance )
690
- check .run ()
691
-
692
- dd_agent_tags = _get_expected_tags (check , pg_instance )
693
- aggregator .assert_metric ('postgresql.control.timeline_id' , count = 1 , value = 1 , tags = dd_agent_tags )
694
-
695
- postgres_conn = _get_superconn (pg_instance )
696
- with postgres_conn .cursor () as cur :
697
- cur .execute ("CHECKPOINT;" )
698
-
699
- aggregator .reset ()
700
- check .run ()
701
- # checkpoint should be less than 2s old
702
- assert_metric_at_least (
703
- aggregator , 'postgresql.control.checkpoint_delay' , count = 1 , higher_bound = 2.0 , tags = dd_agent_tags
704
- )
705
- # After a checkpoint, we have the CHECKPOINT_ONLINE record (114 bytes) and also
706
- # likely receive RUNNING_XACTS (50 bytes) record
707
- assert_metric_at_least (
708
- aggregator , 'postgresql.control.checkpoint_delay_bytes' , count = 1 , higher_bound = 250 , tags = dd_agent_tags
709
- )
710
- # And restart should be slightly more than checkpoint delay
711
- assert_metric_at_least (
712
- aggregator , 'postgresql.control.redo_delay_bytes' , count = 1 , higher_bound = 300 , tags = dd_agent_tags
713
- )
714
-
715
-
716
618
def test_pg_control_wal_level (aggregator , integration_check , pg_instance ):
717
619
"""
718
620
Makes sure that we only get the control checkpoint metrics in the correct environment
0 commit comments