MCPcopy Create free account
hub / github.com/dolthub/doltgresql / RunReplicationScripts

Function RunReplicationScripts

testing/go/replication_test.go:510–540  ·  view source on GitHub ↗

RunScripts runs the given collection of scripts.

(t *testing.T, scripts []ReplicationTest)

Source from the content-addressed store, hash-verified

508
509// RunScripts runs the given collection of scripts.
510func RunReplicationScripts(t *testing.T, scripts []ReplicationTest) {
511 // First, we'll run through the scripts to check for the Focus variable. If it's true, then append it to the new slice.
512 focusScripts := make([]ReplicationTest, 0, len(scripts))
513 for _, script := range scripts {
514 if script.Focus {
515 // If this is running in GitHub Actions, then we'll panic, because someone forgot to disable it before committing
516 if _, ok := os.LookupEnv("GITHUB_ACTION"); ok {
517 panic(fmt.Sprintf("The script `%s` has Focus set to `true`. GitHub Actions requires that "+
518 "all tests are run, which Focus circumvents, leading to this error. Please disable Focus on "+
519 "all tests.", script.Name))
520 }
521 focusScripts = append(focusScripts, script)
522 }
523 }
524 // If we have scripts with Focus set, then we replace the normal script slice with the new slice.
525 if len(focusScripts) > 0 {
526 scripts = focusScripts
527 }
528
529 primaryDns := fmt.Sprintf("postgres://postgres:password@127.0.0.1:%d/%s?sslmode=disable&replication=database", localPostgresPort, "postgres")
530
531 // We drop and recreate the replication slot once at the beginning of the test suite. Postgres seems to do a little
532 // work in the background with a publication, so we need to wait a little bit before running any test scripts.
533 require.NoError(t, logrepl.DropPublication(primaryDns, slotName))
534 require.NoError(t, logrepl.CreatePublication(primaryDns, slotName))
535 time.Sleep(500 * time.Millisecond)
536
537 for _, script := range scripts {
538 RunReplicationScript(t, script)
539 }
540}
541
542const slotName = "doltgres_slot"
543const localPostgresPort = 5432

Callers 1

TestReplicationFunction · 0.85

Calls 3

DropPublicationFunction · 0.92
CreatePublicationFunction · 0.92
RunReplicationScriptFunction · 0.85

Tested by

no test coverage detected