Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
3a5f3a45
Commit
3a5f3a45
authored
Dec 28, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
cc8de1a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
37 deletions
+57
-37
go/neo/client_test.go
go/neo/client_test.go
+57
-36
go/zodb/storage/zeo/zeo_test.go
go/zodb/storage/zeo/zeo_test.go
+0
-1
No files found.
go/neo/client_test.go
View file @
3a5f3a45
...
@@ -47,7 +47,7 @@ type NEOSrv interface {
...
@@ -47,7 +47,7 @@ type NEOSrv interface {
// XXX kill or restore?
// XXX kill or restore?
//ClusterName() string // name of the cluster
//ClusterName() string // name of the cluster
//MasterAddr() string // address of the master
//MasterAddr() string // address of the master
ZUrl
()
string
// zurl to access this NEO server
URL
()
string
// zurl to access this NEO server
Bugs
()
[]
string
// list of known server bugs
Bugs
()
[]
string
// list of known server bugs
}
}
...
@@ -60,7 +60,6 @@ type NEOSrvOptions struct {
...
@@ -60,7 +60,6 @@ type NEOSrvOptions struct {
// npartition
// npartition
// nreplica
// nreplica
SSL
bool
// whether to use SSL for node-node exchange
SSL
bool
// whether to use SSL for node-node exchange
}
}
...
@@ -89,7 +88,6 @@ func (_ *NEOPySrv) Bugs() []string {
...
@@ -89,7 +88,6 @@ func (_ *NEOPySrv) Bugs() []string {
}
}
// StartNEOPySrv starts NEO/py server specified by options.
// StartNEOPySrv starts NEO/py server specified by options.
// XXX dup wrt zeo?
func
StartNEOPySrv
(
opt
NEOSrvOptions
)
(
_
*
NEOPySrv
,
err
error
)
{
func
StartNEOPySrv
(
opt
NEOSrvOptions
)
(
_
*
NEOPySrv
,
err
error
)
{
workdir
:=
opt
.
workdir
workdir
:=
opt
.
workdir
defer
xerr
.
Contextf
(
&
err
,
"start neo/py %s/%s"
,
workdir
,
opt
.
name
)
defer
xerr
.
Contextf
(
&
err
,
"start neo/py %s/%s"
,
workdir
,
opt
.
name
)
...
@@ -106,19 +104,13 @@ func StartNEOPySrv(opt NEOSrvOptions) (_ *NEOPySrv, err error) {
...
@@ -106,19 +104,13 @@ func StartNEOPySrv(opt NEOSrvOptions) (_ *NEOPySrv, err error) {
}
}
n
:=
&
NEOPySrv
{
opt
:
opt
,
cancel
:
cancel
,
done
:
make
(
chan
struct
{})}
n
:=
&
NEOPySrv
{
opt
:
opt
,
cancel
:
cancel
,
done
:
make
(
chan
struct
{})}
if
opt
.
SSL
{
npytests
:=
"../../neo/tests/"
n
.
CA
=
npytests
+
"ca.crt"
n
.
Cert
=
npytests
+
"node.crt"
n
.
Key
=
npytests
+
"node.key"
}
// XXX $PYTHONPATH to top, so that `import neo` works?
// XXX $PYTHONPATH to top, so that `import neo` works?
n
.
pysrv
=
xexec
.
Command
(
"./py/runneo.py"
,
workdir
,
opt
.
name
)
n
.
pysrv
=
xexec
.
Command
(
"./py/runneo.py"
,
workdir
,
opt
.
name
)
if
opt
.
SSL
{
if
opt
.
SSL
{
n
.
pysrv
.
Args
=
append
(
n
.
pysrv
.
Args
,
"ca="
+
n
.
CA
)
n
.
pysrv
.
Args
=
append
(
n
.
pysrv
.
Args
,
"ca="
+
opt
.
CA
()
)
n
.
pysrv
.
Args
=
append
(
n
.
pysrv
.
Args
,
"cert="
+
n
.
Cert
)
n
.
pysrv
.
Args
=
append
(
n
.
pysrv
.
Args
,
"cert="
+
opt
.
Cert
()
)
n
.
pysrv
.
Args
=
append
(
n
.
pysrv
.
Args
,
"key="
+
n
.
Key
)
n
.
pysrv
.
Args
=
append
(
n
.
pysrv
.
Args
,
"key="
+
opt
.
Key
()
)
}
}
// $TEMP -> workdir (else NEO/py creates another one for e.g. coverage)
// $TEMP -> workdir (else NEO/py creates another one for e.g. coverage)
n
.
pysrv
.
Env
=
append
(
os
.
Environ
(),
"TEMP="
+
workdir
)
n
.
pysrv
.
Env
=
append
(
os
.
Environ
(),
"TEMP="
+
workdir
)
...
@@ -179,20 +171,8 @@ func (n *NEOPySrv) MasterAddr() string {
...
@@ -179,20 +171,8 @@ func (n *NEOPySrv) MasterAddr() string {
return
n
.
masterAddr
return
n
.
masterAddr
}
}
func
(
n
*
NEOPySrv
)
ZUrl
()
string
{
func
(
n
*
NEOPySrv
)
URL
()
string
{
zurl
:=
""
return
fmt
.
Sprintf
(
"%s%s/%s"
,
n
.
opt
.
URLPrefix
(),
n
.
MasterAddr
(),
n
.
ClusterName
())
if
!
n
.
opt
.
SSL
{
zurl
=
"neo://"
}
else
{
zurl
=
"neos://"
zurl
+=
"ca="
+
url
.
QueryEscape
(
n
.
CA
)
+
";"
zurl
+=
"cert="
+
url
.
QueryEscape
(
n
.
Cert
)
+
";"
zurl
+=
"key="
+
url
.
QueryEscape
(
n
.
Key
)
zurl
+=
"@"
}
zurl
+=
fmt
.
Sprintf
(
"%s/%s"
,
n
.
MasterAddr
(),
n
.
ClusterName
())
return
zurl
}
}
func
(
n
*
NEOPySrv
)
Close
()
(
err
error
)
{
func
(
n
*
NEOPySrv
)
Close
()
(
err
error
)
{
...
@@ -246,7 +226,7 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
...
@@ -246,7 +226,7 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
// FIXME tune glog to write logs into workdir
// FIXME tune glog to write logs into workdir
net
:=
xnet
.
NetPlain
(
"tcp"
)
// FIXME
net
:=
xnet
.
NetPlain
(
"tcp"
)
// FIXME
TLS on SSL
n
.
Ml
,
err
=
net
.
Listen
(
ctx
,
""
);
if
err
!=
nil
{
return
nil
,
err
}
n
.
Ml
,
err
=
net
.
Listen
(
ctx
,
""
);
if
err
!=
nil
{
return
nil
,
err
}
n
.
Sl
,
err
=
net
.
Listen
(
ctx
,
""
);
if
err
!=
nil
{
return
nil
,
err
}
n
.
Sl
,
err
=
net
.
Listen
(
ctx
,
""
);
if
err
!=
nil
{
return
nil
,
err
}
...
@@ -261,7 +241,7 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
...
@@ -261,7 +241,7 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
n
.
S
=
NewStorage
(
opt
.
name
,
n
.
M
l
.
Addr
()
.
String
(),
net
,
n
.
Sback
)
n
.
S
=
NewStorage
(
opt
.
name
,
n
.
M
asterAddr
(),
net
,
n
.
Sback
)
serveWG
.
Go
(
func
(
ctx
context
.
Context
)
error
{
serveWG
.
Go
(
func
(
ctx
context
.
Context
)
error
{
return
n
.
S
.
Run
(
ctx
,
n
.
Sl
)
return
n
.
S
.
Run
(
ctx
,
n
.
Sl
)
})
})
...
@@ -274,10 +254,11 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
...
@@ -274,10 +254,11 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
}
}
err
=
n
.
M
.
Start
()
err
=
n
.
M
.
Start
()
if
err
!=
nil
{
if
err
==
nil
{
if
!
strings
.
HasSuffix
(
err
.
Error
(),
"start: cluster is non-operational"
)
{
// XXX
break
return
nil
,
err
}
}
if
!
strings
.
HasSuffix
(
err
.
Error
(),
"start: cluster is non-operational"
)
{
// XXX
return
nil
,
err
}
}
time
.
Sleep
(
10
*
time
.
Millisecond
)
time
.
Sleep
(
10
*
time
.
Millisecond
)
...
@@ -315,8 +296,48 @@ func (n *NEOGoSrv) Close() (err error) {
...
@@ -315,8 +296,48 @@ func (n *NEOGoSrv) Close() (err error) {
return
err
return
err
}
}
func
(
n
*
NEOGoSrv
)
ZUrl
()
string
{
func
(
n
*
NEOGoSrv
)
MasterAddr
()
string
{
panic
(
"TODO"
)
return
n
.
Ml
.
Addr
()
.
String
()
}
func
(
n
*
NEOGoSrv
)
URL
()
string
{
return
fmt
.
Sprintf
(
"%s%s/%s"
,
n
.
opt
.
URLPrefix
(),
n
.
MasterAddr
(),
n
.
opt
.
name
)
}
// ----------------
const
npytests
=
"../../neo/tests/"
// CA/Cert/Key files to use if opt.SSL=y
func
(
opt
NEOSrvOptions
)
CA
()
string
{
if
!
opt
.
SSL
{
return
""
}
return
npytests
+
"ca.crt"
}
func
(
opt
NEOSrvOptions
)
Cert
()
string
{
if
!
opt
.
SSL
{
return
""
}
return
npytests
+
"node.crt"
}
func
(
opt
NEOSrvOptions
)
Key
()
string
{
if
!
opt
.
SSL
{
return
""
}
return
npytests
+
"node.key"
}
// URLPrefix returns start of URL for a NEO server started with opt.
// e.g. neo:// or neos://ca=1;cert=2;key=3@
// To be come complete returned URL has to be appended with host and path parts.
func
(
opt
NEOSrvOptions
)
URLPrefix
()
string
{
zurl
:=
""
if
!
opt
.
SSL
{
zurl
=
"neo://"
}
else
{
zurl
=
"neos://"
zurl
+=
"ca="
+
url
.
QueryEscape
(
opt
.
CA
())
+
";"
zurl
+=
"cert="
+
url
.
QueryEscape
(
opt
.
Cert
())
+
";"
zurl
+=
"key="
+
url
.
QueryEscape
(
opt
.
Key
())
zurl
+=
"@"
}
return
zurl
}
}
...
@@ -443,7 +464,7 @@ func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv
...
@@ -443,7 +464,7 @@ func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv
withNEOSrv
(
t
,
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
)
{
withNEOSrv
(
t
,
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
)
{
t
.
Helper
()
t
.
Helper
()
X
:=
xtesting
.
FatalIf
(
t
)
X
:=
xtesting
.
FatalIf
(
t
)
ndrv
,
_
,
err
:=
neoOpen
(
nsrv
.
ZUrl
(),
ndrv
,
_
,
err
:=
neoOpen
(
nsrv
.
URL
(),
&
zodb
.
DriverOptions
{
ReadOnly
:
true
});
X
(
err
)
&
zodb
.
DriverOptions
{
ReadOnly
:
true
});
X
(
err
)
defer
func
()
{
defer
func
()
{
err
:=
ndrv
.
Close
();
X
(
err
)
err
:=
ndrv
.
Close
();
X
(
err
)
...
@@ -479,7 +500,7 @@ func TestLoad(t *testing.T) {
...
@@ -479,7 +500,7 @@ func TestLoad(t *testing.T) {
func
TestWatch
(
t
*
testing
.
T
)
{
func
TestWatch
(
t
*
testing
.
T
)
{
withNEOSrv
(
t
,
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
)
{
withNEOSrv
(
t
,
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
)
{
xtesting
.
DrvTestWatch
(
t
,
nsrv
.
ZUrl
(),
openClientByURL
)
xtesting
.
DrvTestWatch
(
t
,
nsrv
.
URL
(),
openClientByURL
)
})
})
}
}
...
...
go/zodb/storage/zeo/zeo_test.go
View file @
3a5f3a45
...
@@ -72,7 +72,6 @@ type ZEOPyOptions struct {
...
@@ -72,7 +72,6 @@ type ZEOPyOptions struct {
}
}
// StartZEOPySrv starts ZEO/py server for FileStorage database located at fs1path.
// StartZEOPySrv starts ZEO/py server for FileStorage database located at fs1path.
// XXX dup wrt neo?
func
StartZEOPySrv
(
fs1path
string
,
opt
ZEOPyOptions
)
(
_
*
ZEOPySrv
,
err
error
)
{
func
StartZEOPySrv
(
fs1path
string
,
opt
ZEOPyOptions
)
(
_
*
ZEOPySrv
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"startzeo %s"
,
fs1path
)
defer
xerr
.
Contextf
(
&
err
,
"startzeo %s"
,
fs1path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment