Skip to content

Commit 5eae99f

Browse files
committed
reload only chainlink node dbs when performing restart of CL nodes
1 parent 5887e37 commit 5eae99f

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

framework/components/postgres/postgres.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ package postgres
33
import (
44
"context"
55
"fmt"
6+
"os"
7+
"strings"
8+
"time"
9+
610
"github.com/docker/docker/api/types/container"
711
"github.com/docker/go-connections/nat"
8-
"github.com/smartcontractkit/chainlink-testing-framework/framework"
912
"github.com/testcontainers/testcontainers-go"
1013
tcwait "github.com/testcontainers/testcontainers-go/wait"
11-
"os"
12-
"strings"
13-
"time"
14+
15+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
1416
)
1517

1618
const (
@@ -20,10 +22,12 @@ const (
2022
ExposedStaticPort = 13000
2123
Database = "chainlink"
2224
DBVolumeName = "postgresql_data"
25+
DBContainerLabel = "postgresql"
2326
)
2427

2528
type Input struct {
2629
Image string `toml:"image" validate:"required"`
30+
Name string `toml:"name"`
2731
Port int `toml:"port"`
2832
VolumeName string `toml:"volume_name"`
2933
Databases int `toml:"databases"`
@@ -40,7 +44,7 @@ func NewPostgreSQL(in *Input) (*Output, error) {
4044
ctx := context.Background()
4145

4246
bindPort := fmt.Sprintf("%s/tcp", Port)
43-
containerName := framework.DefaultTCName("postgresql")
47+
containerName := framework.DefaultTCName(fmt.Sprintf("%s-%s", DBContainerLabel, in.Name))
4448

4549
var sqlCommands []string
4650
for i := 0; i <= in.Databases; i++ {

framework/components/simple_node_set/node_set.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ package simple_node_set
22

33
import (
44
"fmt"
5+
"slices"
6+
"strings"
7+
"sync"
8+
9+
"golang.org/x/sync/errgroup"
10+
511
"github.com/smartcontractkit/chainlink-testing-framework/framework"
612
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
713
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/clnode"
814
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/postgres"
9-
"golang.org/x/sync/errgroup"
10-
"slices"
11-
"strings"
12-
"sync"
1315
)
1416

1517
const (
1618
DefaultHTTPPortStaticRangeStart = 10000
1719
DefaultP2PStaticRangeStart = 12000
20+
CLNodeDBContainerLabel = "clnode"
1821
)
1922

2023
// Input is a node set configuration input
@@ -75,6 +78,7 @@ func printURLs(out *Output) {
7578

7679
func sharedDBSetup(in *Input, bcOut *blockchain.Output) (*Output, error) {
7780
in.DbInput.Databases = in.Nodes
81+
in.DbInput.Name = CLNodeDBContainerLabel
7882
dbOut, err := postgres.NewPostgreSQL(in.DbInput)
7983
if err != nil {
8084
return nil, err

framework/components/simple_node_set/reload.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
package simple_node_set
22

33
import (
4+
"fmt"
5+
"time"
6+
47
"github.com/smartcontractkit/chainlink-testing-framework/framework/chaos"
58
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
6-
"time"
9+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/postgres"
710
)
811

912
// UpgradeNodeSet updates nodes configuration TOML files
1013
// this API is discouraged, however, you can use it if nodes require restart or configuration updates, temporarily!
1114
func UpgradeNodeSet(in *Input, bc *blockchain.Output, wait time.Duration) (*Output, error) {
12-
_, err := chaos.ExecPumba("rm --volumes=false re2:node.*|postgresql.*", wait)
15+
clNodeDBContainerNameRegex := fmt.Sprintf("%s-%s.*", postgres.DBContainerLabel, CLNodeDBContainerLabel)
16+
_, err := chaos.ExecPumba(fmt.Sprintf("rm --volumes=false re2:node.*|%s", clNodeDBContainerNameRegex), wait)
1317
if err != nil {
1418
return nil, err
1519
}

0 commit comments

Comments
 (0)