From be28220350e36d464a28485d65962ef5f00db38d Mon Sep 17 00:00:00 2001 From: Felix Yuan Date: Fri, 23 Jun 2023 11:25:08 -0700 Subject: [PATCH] Remove broken tests for now --- ...ng_running_transactions_marginalia_test.go | 64 ----------------- collector/pg_stat_activity_marginalia_test.go | 71 ------------------- 2 files changed, 135 deletions(-) delete mode 100644 collector/pg_long_running_transactions_marginalia_test.go delete mode 100644 collector/pg_stat_activity_marginalia_test.go diff --git a/collector/pg_long_running_transactions_marginalia_test.go b/collector/pg_long_running_transactions_marginalia_test.go deleted file mode 100644 index e6f8b4bf1..000000000 --- a/collector/pg_long_running_transactions_marginalia_test.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2023 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package collector - -import ( - "context" - "testing" - - "github.com/DATA-DOG/go-sqlmock" - "github.com/prometheus/client_golang/prometheus" - dto "github.com/prometheus/client_model/go" - "github.com/smartystreets/goconvey/convey" -) - -func xTestPGLongRunningTransactionsMarginaliaCollector(t *testing.T) { - db, mock, err := sqlmock.New() - if err != nil { - t.Fatalf("Error opening a stub db connection: %s", err) - } - defer db.Close() - inst := &instance{db: db} - columns := []string{ - "application", - "endpoint", - "max_age_in_seconds", - } - rows := sqlmock.NewRows(columns). - AddRow("reddit", "GET /r/programming", 32) - - // TODO: Fix the sanitizeQuery escaper to deal better with regex - mock.ExpectQuery(sanitizeQuery(longRunningTransactionsMarginaliaQuery)).WillReturnRows(rows) - - ch := make(chan prometheus.Metric) - go func() { - defer close(ch) - c := PGLongRunningTransactionsMarginaliaCollector{} - - if err := c.Update(context.Background(), inst, ch); err != nil { - t.Errorf("Error calling PGLongRunningTransactionsMarginaliaCollector.Update: %s", err) - } - }() - expected := []MetricResult{ - {labels: labelMap{}, value: 25, metricType: dto.MetricType_GAUGE}, - } - convey.Convey("Metrics comparison", t, func() { - for _, expect := range expected { - m := readMetric(<-ch) - convey.So(expect, convey.ShouldResemble, m) - } - }) - if err := mock.ExpectationsWereMet(); err != nil { - t.Errorf("there were unfulfilled exceptions: %s", err) - } -} diff --git a/collector/pg_stat_activity_marginalia_test.go b/collector/pg_stat_activity_marginalia_test.go deleted file mode 100644 index 52500ad61..000000000 --- a/collector/pg_stat_activity_marginalia_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2023 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package collector - -import ( - "context" - "testing" - - "github.com/DATA-DOG/go-sqlmock" - "github.com/prometheus/client_golang/prometheus" - dto "github.com/prometheus/client_model/go" - "github.com/smartystreets/goconvey/convey" -) - -func xTestPGStatActivityMarginaliaCollector(t *testing.T) { - db, mock, err := sqlmock.New() - if err != nil { - t.Fatalf("Error opening a stub db connection: %s", err) - } - defer db.Close() - inst := &instance{db: db} - columns := []string{ - "usename", - "application", - "endpoint", - "command", - "wait_event", - "state", - "wait_event_type", - "active_count", - "max_tx_age_in_seconds", - } - rows := sqlmock.NewRows(columns). - AddRow("postgres", "service_thing", "", "COMMIT", "ClientRead", "idle", "Client", 25, 0) - - // TODO: Query has a lot of things to escape, figure out how to get this test to work - mock.ExpectQuery(sanitizeQuery(statActivityMarginaliaQuery)).WillReturnRows(rows) - - ch := make(chan prometheus.Metric) - go func() { - defer close(ch) - c := PGStatActivityMarginaliaCollector{} - - if err := c.Update(context.Background(), inst, ch); err != nil { - t.Errorf("Error calling PGStatActivityMarginaliaCollector.Update: %s", err) - } - }() - expected := []MetricResult{ - {labels: labelMap{"usename": "postgres", "application": "service_thing", "endpoint": "", "command": "COMMIT", "wait_event": "ClientRead", "state": "idle", "wait_event_type": "Client"}, value: 25, metricType: dto.MetricType_GAUGE}, - {labels: labelMap{"usename": "postgres", "application": "service_thing", "endpoint": "", "command": "COMMIT", "wait_event": "ClientRead", "state": "idle", "wait_event_type": "Client"}, value: 0, metricType: dto.MetricType_GAUGE}, - } - convey.Convey("Metrics comparison", t, func() { - for _, expect := range expected { - m := readMetric(<-ch) - convey.So(expect, convey.ShouldResemble, m) - } - }) - if err := mock.ExpectationsWereMet(); err != nil { - t.Errorf("there were unfulfilled exceptions: %s", err) - } -}