Add PostgreSQL notifier (#2739) (#2824)

* The user is required to specify a table name and database connection
  information in the configuration file.

* INSERTs and DELETEs are done via prepared statements for speed.

* Assumes a table structure, and requires PostgreSQL 9.5 or above due to
  the use of UPSERT.

* Creates the table if it does not exist with the given table name using
  a query like:

    CREATE TABLE myminio (
        key varchar PRIMARY KEY,
        value JSONB
    );

* Vendors some required libraries.
This commit is contained in:
Aditya Manthramurthy
2016-10-03 17:29:55 -07:00
committed by Harshavardhana
parent 4f902d42b2
commit 315e66858c
28 changed files with 6068 additions and 46 deletions

View File

@@ -23,9 +23,9 @@ import (
"testing"
)
const lastConfigVersion = 8
const lastConfigVersion = 9
// TestServerConfigMigrateV1 - tests if a config v1 is purged
// Test if config v1 is purged
func TestServerConfigMigrateV1(t *testing.T) {
rootPath, err := newTestConfig("us-east-1")
if err != nil {
@@ -58,7 +58,8 @@ func TestServerConfigMigrateV1(t *testing.T) {
}
}
// TestServerConfigMigrateV1 - tests if all migrate code return nil when config file is not existent
// Test if all migrate code returns nil when config file does not
// exist
func TestServerConfigMigrateInexistentConfig(t *testing.T) {
rootPath, err := newTestConfig("us-east-1")
if err != nil {
@@ -93,11 +94,13 @@ func TestServerConfigMigrateInexistentConfig(t *testing.T) {
if err := migrateV7ToV8(); err != nil {
t.Fatal("migrate v7 to v8 should succeed when no config file is found")
}
if err := migrateV8ToV9(); err != nil {
t.Fatal("migrate v8 to v9 should succeed when no config file is found")
}
}
// TestServerConfigMigrateV2toV8 - tests if a config from v2 to v8 is successfully done
func TestServerConfigMigrateV2toV8(t *testing.T) {
// Test if a config migration from v2 to v9 is successfully done
func TestServerConfigMigrateV2toV9(t *testing.T) {
rootPath, err := newTestConfig("us-east-1")
if err != nil {
t.Fatalf("Init Test config failed")
@@ -155,7 +158,7 @@ func TestServerConfigMigrateV2toV8(t *testing.T) {
}
}
// TestServerConfigMigrateFaultyConfig - checks if all migrate code return errors with corrupted config files
// Test if all migrate code returns error with corrupted config files
func TestServerConfigMigrateFaultyConfig(t *testing.T) {
rootPath, err := newTestConfig("us-east-1")
if err != nil {
@@ -191,4 +194,7 @@ func TestServerConfigMigrateFaultyConfig(t *testing.T) {
if err := migrateV7ToV8(); err == nil {
t.Fatal("migrateConfigV7ToV8() should fail with a corrupted json")
}
if err := migrateV8ToV9(); err == nil {
t.Fatal("migrateConfigV8ToV9() should fail with a corrupted json")
}
}