itest: add db backend flag
This commit is contained in:
parent
387f1ef274
commit
98e75b486d
@ -59,7 +59,7 @@ jobs:
|
|||||||
- name: Bitcoind Integration with etcd (txindex enabled)
|
- name: Bitcoind Integration with etcd (txindex enabled)
|
||||||
script:
|
script:
|
||||||
- bash ./scripts/install_bitcoind.sh
|
- bash ./scripts/install_bitcoind.sh
|
||||||
- make itest-parallel backend=bitcoind etcd=1
|
- make itest-parallel backend=bitcoind dbbackend=etcd
|
||||||
|
|
||||||
- name: Bitcoind Integration (txindex disabled)
|
- name: Bitcoind Integration (txindex disabled)
|
||||||
script:
|
script:
|
||||||
|
@ -67,9 +67,8 @@ type NetworkHarness struct {
|
|||||||
Alice *HarnessNode
|
Alice *HarnessNode
|
||||||
Bob *HarnessNode
|
Bob *HarnessNode
|
||||||
|
|
||||||
// embeddedEtcd is set to true if new nodes are to be created with an
|
// dbBackend sets the database backend to use.
|
||||||
// embedded etcd backend instead of just bbolt.
|
dbBackend DatabaseBackend
|
||||||
embeddedEtcd bool
|
|
||||||
|
|
||||||
// Channel for transmitting stderr output from failed lightning node
|
// Channel for transmitting stderr output from failed lightning node
|
||||||
// to main process.
|
// to main process.
|
||||||
@ -84,12 +83,19 @@ type NetworkHarness struct {
|
|||||||
mtx sync.Mutex
|
mtx sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DatabaseBackend int
|
||||||
|
|
||||||
|
const (
|
||||||
|
BackendBbolt DatabaseBackend = iota
|
||||||
|
BackendEtcd
|
||||||
|
)
|
||||||
|
|
||||||
// NewNetworkHarness creates a new network test harness.
|
// NewNetworkHarness creates a new network test harness.
|
||||||
// TODO(roasbeef): add option to use golang's build library to a binary of the
|
// TODO(roasbeef): add option to use golang's build library to a binary of the
|
||||||
// current repo. This will save developers from having to manually `go install`
|
// current repo. This will save developers from having to manually `go install`
|
||||||
// within the repo each time before changes
|
// within the repo each time before changes
|
||||||
func NewNetworkHarness(r *rpctest.Harness, b BackendConfig, lndBinary string,
|
func NewNetworkHarness(r *rpctest.Harness, b BackendConfig, lndBinary string,
|
||||||
embeddedEtcd bool) (*NetworkHarness, error) {
|
dbBackend DatabaseBackend) (*NetworkHarness, error) {
|
||||||
|
|
||||||
feeService := startFeeService()
|
feeService := startFeeService()
|
||||||
|
|
||||||
@ -103,7 +109,7 @@ func NewNetworkHarness(r *rpctest.Harness, b BackendConfig, lndBinary string,
|
|||||||
feeService: feeService,
|
feeService: feeService,
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
lndBinary: lndBinary,
|
lndBinary: lndBinary,
|
||||||
embeddedEtcd: embeddedEtcd,
|
dbBackend: dbBackend,
|
||||||
}
|
}
|
||||||
return &n, nil
|
return &n, nil
|
||||||
}
|
}
|
||||||
@ -306,11 +312,11 @@ func (n *NetworkHarness) NewNodeWithSeedEtcd(name string, etcdCfg *etcd.Config,
|
|||||||
*HarnessNode, []string, []byte, error) {
|
*HarnessNode, []string, []byte, error) {
|
||||||
|
|
||||||
// We don't want to use the embedded etcd instance.
|
// We don't want to use the embedded etcd instance.
|
||||||
const embeddedEtcd = false
|
const dbBackend = BackendBbolt
|
||||||
|
|
||||||
extraArgs := extraArgsEtcd(etcdCfg, name, cluster)
|
extraArgs := extraArgsEtcd(etcdCfg, name, cluster)
|
||||||
return n.newNodeWithSeed(
|
return n.newNodeWithSeed(
|
||||||
name, extraArgs, password, entropy, statelessInit, embeddedEtcd,
|
name, extraArgs, password, entropy, statelessInit, dbBackend,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,10 +329,10 @@ func (n *NetworkHarness) NewNodeEtcd(name string, etcdCfg *etcd.Config,
|
|||||||
password []byte, cluster, wait bool) (*HarnessNode, error) {
|
password []byte, cluster, wait bool) (*HarnessNode, error) {
|
||||||
|
|
||||||
// We don't want to use the embedded etcd instance.
|
// We don't want to use the embedded etcd instance.
|
||||||
const embeddedEtcd = false
|
const dbBackend = BackendBbolt
|
||||||
|
|
||||||
extraArgs := extraArgsEtcd(etcdCfg, name, cluster)
|
extraArgs := extraArgsEtcd(etcdCfg, name, cluster)
|
||||||
return n.newNode(name, extraArgs, true, password, embeddedEtcd, wait)
|
return n.newNode(name, extraArgs, true, password, dbBackend, wait)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNode fully initializes a returns a new HarnessNode bound to the
|
// NewNode fully initializes a returns a new HarnessNode bound to the
|
||||||
@ -336,7 +342,7 @@ func (n *NetworkHarness) NewNode(t *testing.T,
|
|||||||
name string, extraArgs []string) *HarnessNode {
|
name string, extraArgs []string) *HarnessNode {
|
||||||
|
|
||||||
node, err := n.newNode(
|
node, err := n.newNode(
|
||||||
name, extraArgs, false, nil, n.embeddedEtcd, true,
|
name, extraArgs, false, nil, n.dbBackend, true,
|
||||||
)
|
)
|
||||||
require.NoErrorf(t, err, "unable to create new node for %s", name)
|
require.NoErrorf(t, err, "unable to create new node for %s", name)
|
||||||
|
|
||||||
@ -352,16 +358,16 @@ func (n *NetworkHarness) NewNodeWithSeed(name string, extraArgs []string,
|
|||||||
error) {
|
error) {
|
||||||
|
|
||||||
return n.newNodeWithSeed(
|
return n.newNodeWithSeed(
|
||||||
name, extraArgs, password, nil, statelessInit, n.embeddedEtcd,
|
name, extraArgs, password, nil, statelessInit, n.dbBackend,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NetworkHarness) newNodeWithSeed(name string, extraArgs []string,
|
func (n *NetworkHarness) newNodeWithSeed(name string, extraArgs []string,
|
||||||
password, entropy []byte, statelessInit, embeddedEtcd bool) (
|
password, entropy []byte, statelessInit bool, dbBackend DatabaseBackend) (
|
||||||
*HarnessNode, []string, []byte, error) {
|
*HarnessNode, []string, []byte, error) {
|
||||||
|
|
||||||
node, err := n.newNode(
|
node, err := n.newNode(
|
||||||
name, extraArgs, true, password, embeddedEtcd, true,
|
name, extraArgs, true, password, dbBackend, true,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
@ -425,7 +431,7 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
|
|||||||
opts ...NodeOption) (*HarnessNode, error) {
|
opts ...NodeOption) (*HarnessNode, error) {
|
||||||
|
|
||||||
node, err := n.newNode(
|
node, err := n.newNode(
|
||||||
name, extraArgs, true, password, n.embeddedEtcd, true, opts...,
|
name, extraArgs, true, password, n.dbBackend, true, opts...,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -456,7 +462,7 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
|
|||||||
// can be used immediately. Otherwise, the node will require an additional
|
// can be used immediately. Otherwise, the node will require an additional
|
||||||
// initialization phase where the wallet is either created or restored.
|
// initialization phase where the wallet is either created or restored.
|
||||||
func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool,
|
func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool,
|
||||||
password []byte, embeddedEtcd, wait bool, opts ...NodeOption) (
|
password []byte, dbBackend DatabaseBackend, wait bool, opts ...NodeOption) (
|
||||||
*HarnessNode, error) {
|
*HarnessNode, error) {
|
||||||
|
|
||||||
cfg := &NodeConfig{
|
cfg := &NodeConfig{
|
||||||
@ -468,7 +474,7 @@ func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool,
|
|||||||
NetParams: n.netParams,
|
NetParams: n.netParams,
|
||||||
ExtraArgs: extraArgs,
|
ExtraArgs: extraArgs,
|
||||||
FeeURL: n.feeService.url,
|
FeeURL: n.feeService.url,
|
||||||
Etcd: embeddedEtcd,
|
DbBackend: dbBackend,
|
||||||
}
|
}
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(cfg)
|
opt(cfg)
|
||||||
|
@ -80,8 +80,8 @@ var (
|
|||||||
"split test cases with the given (0-based) index",
|
"split test cases with the given (0-based) index",
|
||||||
)
|
)
|
||||||
|
|
||||||
// useEtcd test LND nodes use (embedded) etcd as remote db.
|
// dbBackendFlag specifies the backend to use
|
||||||
useEtcd = flag.Bool("etcd", false, "Use etcd backend for lnd.")
|
dbBackendFlag = flag.String("dbbackend", "bbolt", "Database backend (bbolt, etcd)")
|
||||||
)
|
)
|
||||||
|
|
||||||
// getTestCaseSplitTranche returns the sub slice of the test cases that should
|
// getTestCaseSplitTranche returns the sub slice of the test cases that should
|
||||||
@ -11573,12 +11573,25 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
|||||||
require.NoError(t, miner.Client.NotifyNewTransactions(false))
|
require.NoError(t, miner.Client.NotifyNewTransactions(false))
|
||||||
require.NoError(t, chainBackend.ConnectMiner(), "connect miner")
|
require.NoError(t, chainBackend.ConnectMiner(), "connect miner")
|
||||||
|
|
||||||
|
// Parse database backend
|
||||||
|
var dbBackend lntest.DatabaseBackend
|
||||||
|
switch *dbBackendFlag {
|
||||||
|
case "bbolt":
|
||||||
|
dbBackend = lntest.BackendBbolt
|
||||||
|
|
||||||
|
case "etcd":
|
||||||
|
dbBackend = lntest.BackendEtcd
|
||||||
|
|
||||||
|
default:
|
||||||
|
require.Fail(t, "unknown db backend")
|
||||||
|
}
|
||||||
|
|
||||||
// Now we can set up our test harness (LND instance), with the chain
|
// Now we can set up our test harness (LND instance), with the chain
|
||||||
// backend we just created.
|
// backend we just created.
|
||||||
ht := newHarnessTest(t, nil)
|
ht := newHarnessTest(t, nil)
|
||||||
binary := ht.getLndBinary()
|
binary := ht.getLndBinary()
|
||||||
lndHarness, err = lntest.NewNetworkHarness(
|
lndHarness, err = lntest.NewNetworkHarness(
|
||||||
miner, chainBackend, binary, *useEtcd,
|
miner, chainBackend, binary, dbBackend,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ht.Fatalf("unable to create lightning network harness: %v", err)
|
ht.Fatalf("unable to create lightning network harness: %v", err)
|
||||||
|
@ -220,7 +220,7 @@ type NodeConfig struct {
|
|||||||
|
|
||||||
FeeURL string
|
FeeURL string
|
||||||
|
|
||||||
Etcd bool
|
DbBackend DatabaseBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg NodeConfig) P2PAddr() string {
|
func (cfg NodeConfig) P2PAddr() string {
|
||||||
@ -308,7 +308,7 @@ func (cfg NodeConfig) genArgs() []string {
|
|||||||
args = append(args, "--accept-amp")
|
args = append(args, "--accept-amp")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.Etcd {
|
if cfg.DbBackend == BackendEtcd {
|
||||||
args = append(args, "--db.backend=etcd")
|
args = append(args, "--db.backend=etcd")
|
||||||
args = append(args, "--db.etcd.embedded")
|
args = append(args, "--db.etcd.embedded")
|
||||||
args = append(
|
args = append(
|
||||||
|
@ -49,9 +49,12 @@ ifneq ($(icase),)
|
|||||||
TEST_FLAGS += -test.run="TestLightningNetworkDaemon/.*-of-.*/.*/$(icase)"
|
TEST_FLAGS += -test.run="TestLightningNetworkDaemon/.*-of-.*/.*/$(icase)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Run itests with etcd backend.
|
# Run itests with specified db backend.
|
||||||
ifeq ($(etcd),1)
|
ifneq ($(dbbackend),)
|
||||||
ITEST_FLAGS += -etcd
|
ITEST_FLAGS += -dbbackend=$(dbbackend)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(dbbackend),etcd)
|
||||||
DEV_TAGS += kvdb_etcd
|
DEV_TAGS += kvdb_etcd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user