RunReplicationScript runs the given ReplicationTest.
(t *testing.T, script ReplicationTest)
| 544 | |
| 545 | // RunReplicationScript runs the given ReplicationTest. |
| 546 | func RunReplicationScript(t *testing.T, script ReplicationTest) { |
| 547 | scriptDatabase := script.Database |
| 548 | if len(scriptDatabase) == 0 { |
| 549 | scriptDatabase = "postgres" |
| 550 | } |
| 551 | |
| 552 | database := "postgres" |
| 553 | // primaryDns is the connection to the actual postgres (not doltgres) database, which is why we use port 5342. |
| 554 | // If you have postgres running on a different port, you'll need to change this. |
| 555 | primaryDns := fmt.Sprintf("postgres://postgres:password@127.0.0.1:%d/%s?sslmode=disable", localPostgresPort, database) |
| 556 | |
| 557 | ctx, replicaConn, controller := CreateServer(t, scriptDatabase) |
| 558 | defer func() { |
| 559 | replicaConn.Close(ctx) |
| 560 | controller.Stop() |
| 561 | err := controller.WaitForStop() |
| 562 | require.NoError(t, err) |
| 563 | }() |
| 564 | |
| 565 | ctx = context.Background() |
| 566 | t.Run(script.Name, func(t *testing.T) { |
| 567 | runReplicationScript(ctx, t, script, replicaConn.Default, primaryDns) |
| 568 | }) |
| 569 | } |
| 570 | |
| 571 | func newReplicator(t *testing.T, walFilePath string, replicaConn *pgx.Conn, primaryDns string) *logrepl.LogicalReplicator { |
| 572 | connString := replicaConn.PgConn().Conn().RemoteAddr().String() |
no test coverage detected