Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 0 additions & 105 deletions .circleci/config.yml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

on:
push:
branches:
- main
- master
tags:
- v*
pull_request:

permissions:
contents: read

jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false

- name: Install Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: "1.24"
cache: false

- name: Run tests
run: make test

integration:
name: Integration Tests (Postgres ${{ matrix.postgres_version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
postgres_version:
- "14"
- "15"
- "16"
- "17"

services:
postgres:
image: postgres:${{ matrix.postgres_version }}
env:
POSTGRES_DB: circle_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false

- name: Install Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: "1.24"
cache: false

- name: Run integration tests
env:
DATA_SOURCE_NAME: "postgresql://postgres:test@localhost:5432/circle_test?sslmode=disable"
run: go test -v -tags integration ./...
1 change: 0 additions & 1 deletion .promu.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
go:
# This must match .circle/config.yml.
version: 1.24
repository:
path: github.com/prometheus-community/postgres_exporter
Expand Down
15 changes: 8 additions & 7 deletions cmd/postgres_exporter/postgres_exporter_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package main

import (
"context"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -67,17 +68,17 @@ func (s *IntegrationSuite) TestAllNamespacesReturnResults(c *C) {
c.Assert(err, IsNil)

// Do a version update
err = s.e.checkMapVersions(ch, server)
err = s.e.checkMapVersions(context.Background(), ch, server)
c.Assert(err, IsNil)

err = querySettings(ch, server)
err = querySettings(context.Background(), ch, server)
if !c.Check(err, Equals, nil) {
fmt.Println("## ERRORS FOUND")
fmt.Println(err)
}

// This should never happen in our test cases.
errMap := queryNamespaceMappings(ch, server)
errMap := queryNamespaceMappings(context.Background(), ch, server)
if !c.Check(len(errMap), Equals, 0) {
fmt.Println("## NAMESPACE ERRORS FOUND")
for namespace, err := range errMap {
Expand All @@ -102,12 +103,12 @@ func (s *IntegrationSuite) TestInvalidDsnDoesntCrash(c *C) {
// Send a bad DSN
exporter := NewExporter([]string{"invalid dsn"})
c.Assert(exporter, NotNil)
exporter.scrape(ch)
exporter.scrape(context.Background(), ch)

// Send a DSN to a non-listening port.
exporter = NewExporter([]string{"postgresql://nothing:nothing@127.0.0.1:1/nothing"})
c.Assert(exporter, NotNil)
exporter.scrape(ch)
exporter.scrape(context.Background(), ch)
}

// TestUnknownMetricParsingDoesntCrash deliberately deletes all the column maps out
Expand Down Expand Up @@ -138,7 +139,7 @@ func (s *IntegrationSuite) TestUnknownMetricParsingDoesntCrash(c *C) {
exporter.builtinMetricMaps = emptyMaps

// scrape the exporter and make sure it works
exporter.scrape(ch)
exporter.scrape(context.Background(), ch)
}

// TestExtendQueriesDoesntCrash tests that specifying extend.query-path doesn't
Expand All @@ -161,7 +162,7 @@ func (s *IntegrationSuite) TestExtendQueriesDoesntCrash(c *C) {
c.Assert(exporter, NotNil)

// scrape the exporter and make sure it works
exporter.scrape(ch)
exporter.scrape(context.Background(), ch)
}

func (s *IntegrationSuite) TestAutoDiscoverDatabases(c *C) {
Expand Down
3 changes: 3 additions & 0 deletions collector/pg_shared_preload_libraries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ func TestPGSharedPreloadLibrariesCollectorEmpty(t *testing.T) {
convey.So(expect, convey.ShouldResemble, m)
}
})
// Drain channel to wait for collector goroutine to finish
for range ch {
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("there were unfulfilled expectations: %s", err)
}
Expand Down
Loading