mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-02-08 14:27:00 +00:00
fixed version parsing for Windows and EnterpriseDB (#151)
* fixed version parsing for Windows and EnterpriseDB * fixed formatting
This commit is contained in:
parent
5b9fea01ee
commit
b0d5700ec0
@ -80,7 +80,7 @@ func (cu *ColumnUsage) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
}
|
||||
|
||||
// Regex used to get the "short-version" from the postgres version field.
|
||||
var versionRegex = regexp.MustCompile(`^\w+ ((\d+)(\.\d+)?(\.\d+)?)\s`)
|
||||
var versionRegex = regexp.MustCompile(`^\w+ ((\d+)(\.\d+)?(\.\d+)?)`)
|
||||
var lowestSupportedVersion = semver.MustParse("9.1.0")
|
||||
|
||||
// Parses the version of postgres into the short version string we can use to
|
||||
|
@ -145,6 +145,34 @@ func (s *FunctionalSuite) TestEnvironmentSettingWithDnsAndSecrets(c *C) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *FunctionalSuite) TestPostgresVersionParsing(c *C) {
|
||||
type TestCase struct {
|
||||
input string
|
||||
expected string
|
||||
}
|
||||
|
||||
cases := []TestCase{
|
||||
{
|
||||
input: "PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18) 6.3.0 20170516, 64-bit",
|
||||
expected: "10.1.0",
|
||||
},
|
||||
{
|
||||
input: "PostgreSQL 9.5.4, compiled by Visual C++ build 1800, 64-bit",
|
||||
expected: "9.5.4",
|
||||
},
|
||||
{
|
||||
input: "EnterpriseDB 9.6.5.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16), 64-bit",
|
||||
expected: "9.6.5",
|
||||
},
|
||||
}
|
||||
|
||||
for _, cs := range cases {
|
||||
ver, err := parseVersion(cs.input)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(ver.String(), Equals, cs.expected)
|
||||
}
|
||||
}
|
||||
|
||||
func UnsetEnvironment(c *C, d string) {
|
||||
err := os.Unsetenv(d)
|
||||
c.Assert(err, IsNil)
|
||||
|
Loading…
Reference in New Issue
Block a user