diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 68cc7e3..e4ce4ea 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -10,7 +10,7 @@ on: jobs: test: runs-on: ubuntu-latest - container: lesovsky/pgcenter-testing:v0.0.5 + container: lesovsky/pgcenter-testing:0.0.6 steps: - name: Checkout code diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b5c8fa2..35d6773 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ on: jobs: test: runs-on: ubuntu-latest - container: lesovsky/pgcenter-testing:v0.0.5 + container: lesovsky/pgcenter-testing:0.0.6 steps: - name: Checkout code diff --git a/internal/query/pgcenter_schema.go b/internal/query/pgcenter_schema.go index 95af610..aeac18a 100644 --- a/internal/query/pgcenter_schema.go +++ b/internal/query/pgcenter_schema.go @@ -47,7 +47,10 @@ while () { # skip header if required. if ($i < $_[3]) { $i++; next; } chomp; - my @items = map {s/^\s+|\s+$//g; $_;} split ($_[1]); + # trim extra white-spaces + $_ =~ s/\s+/ /g; + $_ =~ s/^\s+|\s+$//g; + my @items = map { $_ } split ($_[1]); my %iitems; # use filter if required. if ($items[0] =~ $_[2] && $_[2] ne "") { diff --git a/internal/query/pgcenter_schema_test.go b/internal/query/pgcenter_schema_test.go new file mode 100644 index 0000000..a659aa2 --- /dev/null +++ b/internal/query/pgcenter_schema_test.go @@ -0,0 +1,36 @@ +package query + +import ( + "fmt" + "github.com/lesovsky/pgcenter/internal/postgres" + "github.com/stretchr/testify/assert" + "testing" +) + +func Test_QueryPgcenterSchema(t *testing.T) { + queries := []string{ + "SELECT * FROM pgcenter.sys_proc_diskstats", + "SELECT * FROM pgcenter.sys_proc_loadavg", + "SELECT * FROM pgcenter.sys_proc_meminfo", + "SELECT * FROM pgcenter.sys_proc_netdev", + "SELECT * FROM pgcenter.sys_proc_stat", + "SELECT * FROM pgcenter.sys_proc_uptime", + "SELECT * FROM pgcenter.sys_proc_mounts", + } + + versions := []int{90500, 90600, 100000, 110000, 120000, 130000, 140000} + + for _, version := range versions { + t.Run(fmt.Sprintf("query-pgcenter-schema/%d", version), func(t *testing.T) { + conn, err := postgres.NewTestConnectVersion(version) + assert.NoError(t, err) + + for _, q := range queries { + _, err = conn.Exec(q) + assert.NoError(t, err) + } + + conn.Close() + }) + } +} diff --git a/testing/Dockerfile b/testing/Dockerfile index 6e12fba..f5b61d4 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -11,7 +11,7 @@ # __release_tag__ gosec v2.6.1 was released 2021-01-22 FROM ubuntu:20.04 -LABEL version="v0.0.5" +LABEL version="0.0.6" ENV DEBIAN_FRONTEND=noninteractive @@ -44,4 +44,4 @@ RUN apt-get update && \ COPY prepare-test-environment.sh /usr/local/bin/ COPY fixtures.sql /usr/local/testing/ -CMD ["echo", "I'm pgcenter-testing v0.0.5"] +CMD ["echo", "I'm pgcenter-testing 0.0.6"] diff --git a/testing/fixtures.sql b/testing/fixtures.sql index 93cb356..174efcf 100644 --- a/testing/fixtures.sql +++ b/testing/fixtures.sql @@ -37,7 +37,10 @@ while () { # skip header if required. if ($i < $_[3]) { $i++; next; } chomp; - my @items = map {s/^\s+|\s+$//g; $_;} split ($_[1]); + # trim extra white-spaces + $_ =~ s/\s+/ /g; + $_ =~ s/^\s+|\s+$//g; + my @items = map { $_ } split ($_[1]); my %iitems; # use filter if required. if ($items[0] =~ $_[2] && $_[2] ne "") {