Skip to content

Commit b1e4a7b

Browse files
committed
move db config to nodeset
1 parent 4c2f647 commit b1e4a7b

File tree

16 files changed

+47
-76
lines changed

16 files changed

+47
-76
lines changed

framework/cmd/interactive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func createComponentsFromForm(form *nodeSetForm) error {
6565
Nodes: 5,
6666
OverrideMode: "all",
6767
NodeSpecs: nspecs,
68-
}, bc, "")
68+
}, bc)
6969
}
7070
err = spinner.New().
7171
Title("Creating node set..").

framework/components/clnode/clnode.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ var (
2929

3030
// Input represents Chainlink node input
3131
type Input struct {
32-
DataProviderURL string `toml:"data_provider_url" validate:"required"`
33-
DbInput *postgres.Input `toml:"db" validate:"required"`
34-
Node *NodeInput `toml:"node" validate:"required"`
35-
Out *Output `toml:"out"`
32+
DbInput *postgres.Input `toml:"db" validate:"required"`
33+
Node *NodeInput `toml:"node" validate:"required"`
34+
Out *Output `toml:"out"`
3635
}
3736

3837
// NodeInput is CL nod container inputs

framework/components/clnode/clnode_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func TestComponentDockerNodeWithSharedDB(t *testing.T) {
3131
{
3232
name: "basic use case",
3333
input: &clnode.Input{
34-
DataProviderURL: "http://example.com",
3534
DbInput: &postgres.Input{
3635
Image: "postgres:15.6",
3736
Port: 16000,
@@ -67,7 +66,6 @@ func TestComponentDockerNodeWithDB(t *testing.T) {
6766
{
6867
name: "basic use case",
6968
input: &clnode.Input{
70-
DataProviderURL: "http://example.com",
7169
DbInput: &postgres.Input{
7270
Image: "postgres:15.6",
7371
Port: 15000,

framework/components/simple_node_set/node_set.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type Input struct {
2323
HTTPPortRangeStart int `toml:"http_port_range_start"`
2424
P2PPortRangeStart int `toml:"p2p_port_range_start"`
2525
OverrideMode string `toml:"override_mode" validate:"required,oneof=all each"`
26+
DbInput *postgres.Input `toml:"db" validate:"required"`
2627
NodeSpecs []*clnode.Input `toml:"node_specs" validate:"required"`
2728
Out *Output `toml:"out"`
2829
}
@@ -35,7 +36,7 @@ type Output struct {
3536

3637
// NewSharedDBNodeSet create a new node set with a shared database instance
3738
// all the nodes have their own isolated database
38-
func NewSharedDBNodeSet(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
39+
func NewSharedDBNodeSet(in *Input, bcOut *blockchain.Output) (*Output, error) {
3940
if in.Out != nil && in.Out.UseCache {
4041
return in.Out, nil
4142
}
@@ -50,7 +51,7 @@ func NewSharedDBNodeSet(in *Input, bcOut *blockchain.Output, fakeUrl string) (*O
5051
if len(in.NodeSpecs) != in.Nodes && in.OverrideMode == "each" {
5152
return nil, fmt.Errorf("amount of 'nodes' must be equal to specs provided in override_mode='each'")
5253
}
53-
out, err = sharedDBSetup(in, bcOut, fakeUrl)
54+
out, err = sharedDBSetup(in, bcOut)
5455
if err != nil {
5556
return nil, err
5657
}
@@ -72,9 +73,9 @@ func printURLs(out *Output) {
7273
framework.L.Debug().Any("DB", pgURLs).Send()
7374
}
7475

75-
func sharedDBSetup(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
76-
in.NodeSpecs[0].DbInput.Databases = in.Nodes
77-
dbOut, err := postgres.NewPostgreSQL(in.NodeSpecs[0].DbInput)
76+
func sharedDBSetup(in *Input, bcOut *blockchain.Output) (*Output, error) {
77+
in.DbInput.Databases = in.Nodes
78+
dbOut, err := postgres.NewPostgreSQL(in.DbInput)
7879
if err != nil {
7980
return nil, err
8081
}
@@ -122,8 +123,7 @@ func sharedDBSetup(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output
122123
}
123124

124125
nodeSpec := &clnode.Input{
125-
DataProviderURL: fakeUrl,
126-
DbInput: in.NodeSpecs[overrideIdx].DbInput,
126+
DbInput: in.DbInput,
127127
Node: &clnode.NodeInput{
128128
HTTPPort: httpPortRangeStart + i,
129129
P2PPort: p2pPortRangeStart + i,

framework/components/simple_node_set/nodeset_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ func TestComponentDockerNodeSetSharedDB(t *testing.T) {
5151
nodeSetInput: &ns.Input{
5252
Nodes: 2,
5353
OverrideMode: "all",
54+
DbInput: &postgres.Input{
55+
Image: "postgres:15.6",
56+
},
5457
NodeSpecs: []*clnode.Input{
5558
{
56-
DataProviderURL: "http://example.com",
5759
DbInput: &postgres.Input{
5860
Image: "postgres:15.6",
5961
},
@@ -82,9 +84,12 @@ func TestComponentDockerNodeSetSharedDB(t *testing.T) {
8284
OverrideMode: "each",
8385
HTTPPortRangeStart: 20000,
8486
P2PPortRangeStart: 22000,
87+
DbInput: &postgres.Input{
88+
Image: "postgres:15.6",
89+
Port: 14000,
90+
},
8591
NodeSpecs: []*clnode.Input{
8692
{
87-
DataProviderURL: "http://example.com",
8893
DbInput: &postgres.Input{
8994
Image: "postgres:15.6",
9095
Port: 14000,
@@ -99,7 +104,6 @@ level = 'info'
99104
},
100105
},
101106
{
102-
DataProviderURL: "http://example.com",
103107
DbInput: &postgres.Input{
104108
Image: "postgres:15.6",
105109
},
@@ -127,7 +131,7 @@ level = 'info'
127131
t.Run(tc.name, func(t *testing.T) {
128132
bc, err := blockchain.NewBlockchainNetwork(tc.bcInput)
129133
require.NoError(t, err)
130-
output, err := ns.NewSharedDBNodeSet(tc.nodeSetInput, bc, tc.fakeURL)
134+
output, err := ns.NewSharedDBNodeSet(tc.nodeSetInput, bc)
131135
require.NoError(t, err)
132136
tc.assertion(t, output)
133137
})

framework/components/simple_node_set/reload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88

99
// UpgradeNodeSet updates nodes configuration TOML files
1010
// this API is discouraged, however, you can use it if nodes require restart or configuration updates, temporarily!
11-
func UpgradeNodeSet(in *Input, bc *blockchain.Output, url string, wait time.Duration) (*Output, error) {
11+
func UpgradeNodeSet(in *Input, bc *blockchain.Output, wait time.Duration) (*Output, error) {
1212
_, err := chaos.ExecPumba("rm --volumes=false re2:node.*|postgresql.*", wait)
1313
if err != nil {
1414
return nil, err
1515
}
1616
in.Out = nil
17-
out, err := NewSharedDBNodeSet(in, bc, url)
17+
out, err := NewSharedDBNodeSet(in, bc)
1818
in.Out = out
1919
return out, err
2020
}

framework/examples/myproject/chaos.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
nodes = 5
1313
override_mode = "all"
1414

15-
[[nodeset.node_specs]]
15+
[nodeset.db]
16+
image = "postgres:15.6"
1617

17-
[nodeset.node_specs.db]
18-
image = "postgres:15.6"
19-
pull_image = true
18+
[[nodeset.node_specs]]
2019

2120
[nodeset.node_specs.node]
2221
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
23-
pull_image = false

framework/examples/myproject/chaos_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ func TestChaos(t *testing.T) {
2929

3030
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
3131
require.NoError(t, err)
32-
dp, err := fake.NewFakeDataProvider(in.MockerDataProvider)
32+
_, err = fake.NewFakeDataProvider(in.MockerDataProvider)
3333
require.NoError(t, err)
34-
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc, dp.BaseURLDocker)
34+
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc)
3535
require.NoError(t, err)
3636

3737
c, err := clclient.New(out.CLNodes)

framework/examples/myproject/performance_baseline.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
nodes = 5
1313
override_mode = "all"
1414

15-
[[nodeset.node_specs]]
15+
[nodeset.db]
16+
image = "postgres:15.6"
1617

17-
[nodeset.node_specs.db]
18-
image = "postgres:15.6"
19-
pull_image = true
18+
[[nodeset.node_specs]]
2019

2120
[nodeset.node_specs.node]
2221
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
23-
pull_image = false

framework/examples/myproject/performance_baseline_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func TestPerformanceBaseline(t *testing.T) {
2626

2727
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
2828
require.NoError(t, err)
29-
dp, err := fake.NewFakeDataProvider(in.MockerDataProvider)
29+
_, err = fake.NewFakeDataProvider(in.MockerDataProvider)
3030
require.NoError(t, err)
31-
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc, dp.BaseURLDocker)
31+
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc)
3232
require.NoError(t, err)
3333

3434
var lokiCfg *wasp.LokiConfig

0 commit comments

Comments
 (0)