Commit 55476bd0 authored by Kirill Smelkov's avatar Kirill Smelkov

X Run all client tests with both encodings

parent b9009ed2
...@@ -496,34 +496,24 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv), optv ...tOption ...@@ -496,34 +496,24 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv), optv ...tOption
} }
} }
// withNEO tests f on all kinds of NEO servers connected to by NEO client. // withNEO tests f on all kinds of NEO servers connected to by NEO client with
// all kind of default settings.
func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv ...tOptions) { func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv ...tOptions) {
t.Helper() t.Helper()
withNEOSrv(t, func(t *testing.T, nsrv NEOSrv) { withNEOSrv(t, func(t *testing.T, nsrv NEOSrv) {
t.Helper() t.Helper()
X := xtesting.FatalIf(t)
ndrv, _, err := neoOpen(nsrv.URL(), // test client with N,M and M,N dial encoding try orders. This
&zodb.DriverOptions{ReadOnly: true}); X(err)
defer func() {
err := ndrv.Close(); X(err)
}()
f(t, nsrv, ndrv)
}, optv...)
}
// TestEncAutodetect verifies that client can autodetect server encoding.
func TestEncAutodetect(t *testing.T) {
withNEOSrv(t, func(t *testing.T, nsrv NEOSrv) {
// test client with N,M and M,N encoding try orders. This
// verifies that encoding autodetection actually works when
// NEO/go client connects NEO/py server.
// //
// For example if NEO/py server implments only M encoding, // - makes sure that both encodings are working ok (when
// testing with N,M verifies retry after handshaking with // testing against NEO/go), and
// enc=N. //
// - verifies that encoding autodetection actually works when
// NEO/go client connects NEO/py server.
//
// For example if NEO/py server implments only M encoding,
// testing with N,M verifies retry after handshaking with
// enc=N.
encTryOrder0 := neonet.DialEncTryOrder encTryOrder0 := neonet.DialEncTryOrder
defer func() { defer func() {
neonet.DialEncTryOrder = encTryOrder0 neonet.DialEncTryOrder = encTryOrder0
...@@ -543,9 +533,17 @@ func TestEncAutodetect(t *testing.T) { ...@@ -543,9 +533,17 @@ func TestEncAutodetect(t *testing.T) {
encvs += fmt.Sprintf("%c", enc) encvs += fmt.Sprintf("%c", enc)
} }
noautodetect, srvEnc := nsrv.BugEncFixed()
t.Run(fmt.Sprintf("dialEncTryOrder=%v", encvs), func(t *testing.T) { t.Run(fmt.Sprintf("dialEncTryOrder=%v", encvs), func(t *testing.T) {
X := xtesting.FatalIf(t) X := xtesting.FatalIf(t)
if noautodetect && len(encv) > 1 && encv[0] == srvEnc {
// skip - the other case when encv[0] != srvEnc will
// both test autodetection and exchanve via srvEnc.
t.Skip("skip: does not excercise client redial")
}
neonet.DialEncTryOrder = encv neonet.DialEncTryOrder = encv
ndrv, _, err := neoOpen(nsrv.URL(), ndrv, _, err := neoOpen(nsrv.URL(),
&zodb.DriverOptions{ReadOnly: true}); X(err) &zodb.DriverOptions{ReadOnly: true}); X(err)
...@@ -556,8 +554,7 @@ func TestEncAutodetect(t *testing.T) { ...@@ -556,8 +554,7 @@ func TestEncAutodetect(t *testing.T) {
// verify that link was established with either: // verify that link was established with either:
// - encv[0] encoding (NEO/go = server supports autodetection) // - encv[0] encoding (NEO/go = server supports autodetection)
// - server encoding (NEO/py) // - server encoding (NEO/py)
encOK := encv[0] encOK := neonet.DialEncTryOrder[0]
noautodetect, srvEnc := nsrv.BugEncFixed()
if noautodetect { if noautodetect {
encOK = srvEnc encOK = srvEnc
} }
...@@ -567,11 +564,14 @@ func TestEncAutodetect(t *testing.T) { ...@@ -567,11 +564,14 @@ func TestEncAutodetect(t *testing.T) {
if enc != encOK { if enc != encOK {
t.Fatalf("connected with encoding %c ; want %c", enc, encOK) t.Fatalf("connected with encoding %c ; want %c", enc, encOK)
} }
f(t, nsrv, ndrv)
}) })
} }
}) }, optv...)
} }
// XXX connect with wrong clusterName -> rejected // XXX connect with wrong clusterName -> rejected
func TestEmptyDB(t *testing.T) { func TestEmptyDB(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment