@@ -31,9 +31,9 @@ func TestPgReplicationSlotCollectorActive(t *testing.T) {
3131
3232 inst := & instance {db : db }
3333
34- columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" }
34+ columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" , "safe_wal_size" , "wal_status" }
3535 rows := sqlmock .NewRows (columns ).
36- AddRow ("test_slot" , "physical" , 5 , 3 , true )
36+ AddRow ("test_slot" , "physical" , 5 , 3 , true , 323906992 , "reserved" )
3737 mock .ExpectQuery (sanitizeQuery (pgReplicationSlotQuery )).WillReturnRows (rows )
3838
3939 ch := make (chan prometheus.Metric )
@@ -50,6 +50,8 @@ func TestPgReplicationSlotCollectorActive(t *testing.T) {
5050 {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 5 , metricType : dto .MetricType_GAUGE },
5151 {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 3 , metricType : dto .MetricType_GAUGE },
5252 {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 1 , metricType : dto .MetricType_GAUGE },
53+ {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 323906992 , metricType : dto .MetricType_GAUGE },
54+ {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" , "wal_status" : "reserved" }, value : 1 , metricType : dto .MetricType_GAUGE },
5355 }
5456
5557 convey .Convey ("Metrics comparison" , t , func () {
@@ -72,9 +74,9 @@ func TestPgReplicationSlotCollectorInActive(t *testing.T) {
7274
7375 inst := & instance {db : db }
7476
75- columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" }
77+ columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" , "safe_wal_size" , "wal_status" }
7678 rows := sqlmock .NewRows (columns ).
77- AddRow ("test_slot" , "physical" , 6 , 12 , false )
79+ AddRow ("test_slot" , "physical" , 6 , 12 , false , - 4000 , "extended" )
7880 mock .ExpectQuery (sanitizeQuery (pgReplicationSlotQuery )).WillReturnRows (rows )
7981
8082 ch := make (chan prometheus.Metric )
@@ -90,6 +92,8 @@ func TestPgReplicationSlotCollectorInActive(t *testing.T) {
9092 expected := []MetricResult {
9193 {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 6 , metricType : dto .MetricType_GAUGE },
9294 {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 0 , metricType : dto .MetricType_GAUGE },
95+ {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : - 4000 , metricType : dto .MetricType_GAUGE },
96+ {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" , "wal_status" : "extended" }, value : 1 , metricType : dto .MetricType_GAUGE },
9397 }
9498
9599 convey .Convey ("Metrics comparison" , t , func () {
@@ -113,9 +117,9 @@ func TestPgReplicationSlotCollectorActiveNil(t *testing.T) {
113117
114118 inst := & instance {db : db }
115119
116- columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" }
120+ columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" , "safe_wal_size" , "wal_status" }
117121 rows := sqlmock .NewRows (columns ).
118- AddRow ("test_slot" , "physical" , 6 , 12 , nil )
122+ AddRow ("test_slot" , "physical" , 6 , 12 , nil , nil , "lost" )
119123 mock .ExpectQuery (sanitizeQuery (pgReplicationSlotQuery )).WillReturnRows (rows )
120124
121125 ch := make (chan prometheus.Metric )
@@ -131,6 +135,7 @@ func TestPgReplicationSlotCollectorActiveNil(t *testing.T) {
131135 expected := []MetricResult {
132136 {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 6 , metricType : dto .MetricType_GAUGE },
133137 {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" }, value : 0 , metricType : dto .MetricType_GAUGE },
138+ {labels : labelMap {"slot_name" : "test_slot" , "slot_type" : "physical" , "wal_status" : "lost" }, value : 1 , metricType : dto .MetricType_GAUGE },
134139 }
135140
136141 convey .Convey ("Metrics comparison" , t , func () {
@@ -153,9 +158,9 @@ func TestPgReplicationSlotCollectorTestNilValues(t *testing.T) {
153158
154159 inst := & instance {db : db }
155160
156- columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" }
161+ columns := []string {"slot_name" , "slot_type" , "current_wal_lsn" , "confirmed_flush_lsn" , "active" , "safe_wal_size" , "wal_status" }
157162 rows := sqlmock .NewRows (columns ).
158- AddRow (nil , nil , nil , nil , true )
163+ AddRow (nil , nil , nil , nil , true , nil , nil )
159164 mock .ExpectQuery (sanitizeQuery (pgReplicationSlotQuery )).WillReturnRows (rows )
160165
161166 ch := make (chan prometheus.Metric )
0 commit comments