mirror of https://github.com/jackc/pgx.git
Add tests for replication slot drop, and go fmt
parent
b2f416c07d
commit
41d9c0f338
|
@ -208,6 +208,13 @@ func (rc *ReplicationConn) Close() error {
|
|||
return rc.c.Close()
|
||||
}
|
||||
|
||||
func (rc *ReplicationConn) IsAlive() bool {
|
||||
return rc.c.IsAlive()
|
||||
}
|
||||
|
||||
func (rc *ReplicationConn) CauseOfDeath() error {
|
||||
return rc.c.CauseOfDeath()
|
||||
}
|
||||
|
||||
func (rc *ReplicationConn) readReplicationMessage() (r *ReplicationMessage, err error) {
|
||||
var t byte
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package pgx_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/jackc/pgx"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"reflect"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// This function uses a postgresql 9.6 specific column
|
||||
|
@ -152,6 +152,15 @@ func TestSimpleReplicationConnection(t *testing.T) {
|
|||
replicationConn.SendStandbyStatus(status)
|
||||
replicationConn.StopReplication()
|
||||
|
||||
if replicationConn.IsAlive() == false {
|
||||
t.Errorf("Connection died: %v", replicationConn.CauseOfDeath())
|
||||
}
|
||||
|
||||
err = replicationConn.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("Replication connection close failed: %v", err)
|
||||
}
|
||||
|
||||
// Let's push the boundary conditions of the standby status and ensure it errors correctly
|
||||
status, err = pgx.NewStandbyStatus(0, 1, 2, 3, 4)
|
||||
if err == nil {
|
||||
|
@ -173,20 +182,23 @@ func TestSimpleReplicationConnection(t *testing.T) {
|
|||
t.Errorf("Unexpected write position %d", status.WalWritePosition)
|
||||
}
|
||||
|
||||
err = replicationConn.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("Replication connection close failed: %v", err)
|
||||
}
|
||||
|
||||
restartLsn := getConfirmedFlushLsnFor(t, conn, "pgx_test")
|
||||
integerRestartLsn, _ := pgx.ParseLSN(restartLsn)
|
||||
if integerRestartLsn != maxWal {
|
||||
t.Fatalf("Wal offset update failed, expected %s found %s", pgx.FormatLSN(maxWal), restartLsn)
|
||||
}
|
||||
|
||||
_, err = conn.Exec("select pg_drop_replication_slot($1)", "pgx_test")
|
||||
replicationConn2 := mustReplicationConnect(t, *replicationConnConfig)
|
||||
defer closeReplicationConn(t, replicationConn2)
|
||||
|
||||
err = replicationConn2.DropReplicationSlot("pgx_test")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to drop replication slot: %v", err)
|
||||
}
|
||||
|
||||
droppedLsn := getConfirmedFlushLsnFor(t, conn, "pgx_test")
|
||||
if droppedLsn != "" {
|
||||
t.Errorf("Got odd flush lsn %s for supposedly dropped slot", droppedLsn)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue