MCPcopy Create free account
hub / github.com/apecloud/myduckserver / RunReplicationScript

Function RunReplicationScript

pgserver/logrepl/replication_test.go:697–719  ·  view source on GitHub ↗

RunReplicationScript runs the given ReplicationTest.

(t *testing.T, dsn string, script ReplicationTest)

Source from the content-addressed store, hash-verified

695
696// RunReplicationScript runs the given ReplicationTest.
697func RunReplicationScript(t *testing.T, dsn string, script ReplicationTest) {
698 scriptDatabase := script.Database
699 if len(scriptDatabase) == 0 {
700 scriptDatabase = "postgres"
701 }
702
703 // primaryDns is the connection to the actual postgres database.
704 // If you have postgres running on a different port, you'll need to change this.
705 primaryDns := dsn + "?sslmode=disable"
706
707 ctx, pgServer, replicaConn, close, err := pgtest.CreateTestServer(t, findFreePort())
708 require.NoError(t, err)
709 defer func() {
710 replicaConn.Close(ctx)
711 err := close()
712 require.NoError(t, err)
713 }()
714
715 ctx = context.Background()
716 t.Run(script.Name, func(t *testing.T) {
717 runReplicationScript(ctx, t, script, pgServer, replicaConn, primaryDns)
718 })
719}
720
721func newReplicator(sqlCtx *sql.Context, t *testing.T, primaryDns string) *logrepl.LogicalReplicator {
722 err := logrepl.CreateSubscription(sqlCtx, subscriptionName, primaryDns, slotName, pglogrepl.LSN(0).String(), true)

Callers 1

RunReplicationScriptsFunction · 0.85

Calls 5

CreateTestServerFunction · 0.92
findFreePortFunction · 0.85
runReplicationScriptFunction · 0.85
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected