wip - Better AOFMIGRATE tests

This commit is contained in:
tidwall 2022-09-27 09:47:09 -07:00
parent 46927b476f
commit cfc9673957
2 changed files with 27 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import (
func subTestAOF(g *testGroup) {
g.regSubTest("loading", aof_loading_test)
g.regSubTest("migrate", aof_migrate_test)
g.regSubTest("AOF", aof_AOF_test)
g.regSubTest("AOFMD5", aof_AOFMD5_test)
g.regSubTest("AOFSHRINK", aof_AOFSHRINK_test)
@ -286,3 +287,21 @@ func aof_READONLY_test(mc *mockServer) error {
Do("READONLY", "maybe").Err("invalid argument 'maybe'"),
)
}
func aof_migrate_test(mc *mockServer) error {
// var aof string
// aof += "set 1 2 point 10 10\r\n"
// aof += "set 2 3 point 30 30\r\n"
// mc2, err := mockOpenServer(MockServerOptions{
// AOFFileName: "aof",
// AOFData: []byte(aof),
// Silent: true,
// Metrics: true,
// })
// if err != nil {
// return err
// }
// defer mc2.Close()
return nil
}

View File

@ -53,9 +53,10 @@ func (mc *mockServer) metricsPort() int {
}
type MockServerOptions struct {
AOFData []byte
Silent bool
Metrics bool
AOFFileName string
AOFData []byte
Silent bool
Metrics bool
}
var nextPort int32 = 10000
@ -88,10 +89,13 @@ func mockOpenServer(opts MockServerOptions) (*mockServer, error) {
fmt.Printf("Starting test server at port %d\n", port)
}
if len(opts.AOFData) > 0 {
if opts.AOFFileName == "" {
opts.AOFFileName = "appendonly.aof"
}
if err := os.MkdirAll(dir, 0777); err != nil {
return nil, err
}
err := os.WriteFile(filepath.Join(dir, "appendonly.aof"),
err := os.WriteFile(filepath.Join(dir, opts.AOFFileName),
opts.AOFData, 0666)
if err != nil {
return nil, err