Newer
Older
Garet Halliday
committed
"strconv"
"testing"
"gfx.cafe/gfx/pggat/lib/auth"
"gfx.cafe/gfx/pggat/lib/auth/credentials"
"gfx.cafe/gfx/pggat/lib/bouncer/backends/v0"
"gfx.cafe/gfx/pggat/lib/gat"
"gfx.cafe/gfx/pggat/lib/gat/modules/raw_pools"
"gfx.cafe/gfx/pggat/lib/gat/pool"
"gfx.cafe/gfx/pggat/lib/gat/pool/pools/session"
"gfx.cafe/gfx/pggat/lib/gat/pool/pools/transaction"
"gfx.cafe/gfx/pggat/lib/gat/pool/recipe"
"gfx.cafe/gfx/pggat/test"
"gfx.cafe/gfx/pggat/test/tests"
func daisyChain(creds auth.Credentials, control recipe.Dialer, n int) (recipe.Dialer, error) {
}
if i%2 == 0 {
options = transaction.Apply(options)
} else {
options.ServerResetQuery = "DISCARD ALL"
options = session.Apply(options)
}
p := pool.NewPool(options)
p.AddRecipe("runner", recipe.NewRecipe(recipe.Options{
Dialer: control,
}))
l := &net_listener.Module{
Config: net_listener.Config{
Network: "tcp",
Address: ":0",
},
}
if err := l.Start(); err != nil {
if err := server.Start(); err != nil {
panic(err)
}
Network: "tcp",
Address: ":" + strconv.Itoa(port),
AcceptOptions: backends.AcceptOptions{
Garet Halliday
committed
Username: "runner",
Credentials: creds,
Database: "pool",
},
}
}
return control, nil
}
func TestTester(t *testing.T) {
Network: "tcp",
Address: "localhost:5432",
AcceptOptions: backends.AcceptOptions{
Garet Halliday
committed
Username: "postgres",
Credentials: credentials.Cleartext{
Username: "postgres",
Password: "password",
},
Database: "postgres",
},
}
// generate random password for testing
var raw [32]byte
_, err := rand.Read(raw[:])
if err != nil {
t.Error(err)
return
}
password := hex.EncodeToString(raw[:])
creds := credentials.Cleartext{
Username: "runner",
Password: password,
}
parent, err := daisyChain(creds, control, 16)
transactionPool := pool.NewPool(transaction.Apply(pool.Options{
Credentials: creds,
}))
transactionPool.AddRecipe("runner", recipe.NewRecipe(recipe.Options{
sessionPool := pool.NewPool(session.Apply(pool.Options{
Credentials: creds,
ServerResetQuery: "discard all",
}))
sessionPool.AddRecipe("runner", recipe.NewRecipe(recipe.Options{
l := &net_listener.Module{
Config: net_listener.Config{
Network: "tcp",
Address: ":0",
},
}
if err = l.Start(); err != nil {
if err = server.Start(); err != nil {
t.Error(err)
return
}
Network: "tcp",
Address: ":" + strconv.Itoa(port),
AcceptOptions: backends.AcceptOptions{
Garet Halliday
committed
Username: "runner",
Credentials: creds,
Database: "transaction",
},
}
Network: "tcp",
Address: ":" + strconv.Itoa(port),
AcceptOptions: backends.AcceptOptions{
Garet Halliday
committed
Username: "runner",
Credentials: creds,
Database: "session",
},
}
tester := test.NewTester(test.Config{
"control": control,
"transaction": transactionDialer,
"session": sessionDialer,
tests.EQP0,
tests.EQP1,
tests.EQP2,
tests.EQP3,
tests.EQP4,
tests.EQP5,
tests.EQP6,
tests.EQP7,
tests.CopyIn0,
tests.CopyIn1,
Garet Halliday
committed
tests.DiscardAll,