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
a87adb49
Commit
a87adb49
authored
Oct 18, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c744c005
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
4 deletions
+60
-4
go/neo/client_test.go
go/neo/client_test.go
+59
-4
go/zodb/storage/zeo/zeo_test.go
go/zodb/storage/zeo/zeo_test.go
+1
-0
No files found.
go/neo/client_test.go
View file @
a87adb49
...
...
@@ -21,21 +21,24 @@ package neo
import
(
"context"
"fmt"
"io/ioutil"
"net/url"
"os"
"os/exec"
"testing"
"time"
"lab.nexedi.com/kirr/neo/go/internal/xtesting"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/go123/xerr"
)
// NEOSrv represents running NEO server.
type
NEOSrv
interface
{
ClusterName
()
string
// name of the cluster
MasterAddr
()
string
// address of the master
// XXX +ClusterName
}
// NEOPySrv represents running NEO/py server.
...
...
@@ -130,6 +133,10 @@ func StartNEOPySrv(workdir string, opt NEOPyOptions) (_ *NEOPySrv, err error) {
return
n
,
nil
}
func
(
n
*
NEOPySrv
)
ClusterName
()
string
{
return
"xxx"
// FIXME stub
}
func
(
n
*
NEOPySrv
)
MasterAddr
()
string
{
return
n
.
masterAddr
}
...
...
@@ -148,10 +155,24 @@ func (n *NEOPySrv) Close() (err error) {
// ----------------
// tOptions represents options for testing.
// XXX dup in ZEO
type
tOptions
struct
{
Preload
string
// preload database with data from this location
}
// withNEOSrv tests f with all kind of NEO servers.
func
withNEOSrv
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
)
)
{
// XXX +optv ?
func
withNEOSrv
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
)
,
optv
...
tOptions
)
{
t
.
Helper
()
opt
:=
tOptions
{}
if
len
(
optv
)
>
1
{
panic
(
"multiple tOptions not allowed"
)
}
if
len
(
optv
)
==
1
{
opt
=
optv
[
0
]
}
// inWorkDir runs f under dedicated work directory.
inWorkDir
:=
func
(
t
*
testing
.
T
,
f
func
(
workdir
string
))
{
t
.
Helper
()
...
...
@@ -159,6 +180,10 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv)) { // XXX +optv
work
,
err
:=
ioutil
.
TempDir
(
""
,
"neo"
);
X
(
err
)
defer
os
.
RemoveAll
(
work
)
if
opt
.
Preload
!=
""
{
panic
(
"TODO: preload"
)
}
f
(
work
)
}
...
...
@@ -184,10 +209,40 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv)) { // XXX +optv
// TODO NEO/go
}
// XXX withNeo
// withNEO tests f on all kinds of NEO servers connected to by NEO client.
func
withNEO
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
,
ndrv
*
Client
),
optv
...
tOptions
)
{
t
.
Helper
()
withNEOSrv
(
t
,
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
)
{
t
.
Helper
()
X
:=
xtesting
.
FatalIf
(
t
)
ndrv
,
_
,
err
:=
neoOpen
(
fmt
.
Sprintf
(
"%s@%s"
,
nsrv
.
ClusterName
(),
nsrv
.
MasterAddr
()),
&
zodb
.
DriverOptions
{
ReadOnly
:
true
});
X
(
err
)
defer
func
()
{
err
:=
ndrv
.
Close
();
X
(
err
)
}()
f
(
t
,
nsrv
,
ndrv
)
},
optv
...
)
}
func
TestEmptyDB
(
t
*
testing
.
T
)
{
withNEO
(
t
,
func
(
t
*
testing
.
T
,
nsrv
NEOSrv
,
n
*
Client
)
{
xtesting
.
DrvTestEmptyDB
(
t
,
n
)
})
}
func
neoOpen
(
zurl
string
,
opt
*
zodb
.
DriverOptions
)
(
_
*
Client
,
at0
zodb
.
Tid
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"openneo %s"
,
zurl
)
u
,
err
:=
url
.
Parse
(
zurl
)
if
err
!=
nil
{
return
nil
,
0
,
err
}
n
,
at0
,
err
:=
openClientByURL
(
context
.
Background
(),
u
,
opt
)
if
err
!=
nil
{
return
nil
,
0
,
err
}
return
n
.
(
*
Client
),
at0
,
nil
}
go/zodb/storage/zeo/zeo_test.go
View file @
a87adb49
...
...
@@ -154,6 +154,7 @@ func (z *ZEOPySrv) Encoding() encoding {
// ----------------
// tOptions represents options for testing.
// XXX dup in NEO
type
tOptions
struct
{
Preload
string
// preload database with data from this location
}
...
...
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