Skip to content

Commit 9d55a96

Browse files
committed
allow to mount capabilities binaries
1 parent 2b5f94e commit 9d55a96

File tree

4 files changed

+70
-56
lines changed

4 files changed

+70
-56
lines changed

framework/COMPONENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ An example [simple component](components/blockchain/anvil.go)
5151

5252
An example of [complex component](components/clnode/clnode.go)
5353

54-
An example of [composite component](components/don/don.go)
54+
An example of [composite component](components/node_set_extended/don.go)
5555

5656
- Inputs should include at least `image`, `tag` and `pull_image` field
5757
```

framework/components/clnode/clnode.go

Lines changed: 64 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,31 @@ import (
1010
tc "github.com/testcontainers/testcontainers-go"
1111
"github.com/testcontainers/testcontainers-go/wait"
1212
"os"
13+
"path/filepath"
1314
"text/template"
1415
"time"
1516
)
1617

1718
// Input represents Chainlink node input
1819
type Input struct {
19-
DataProviderURL string `toml:"data_provider_url" validate:"required"`
20+
DataProviderURL string `toml:"data_provider_url" validate:"required" default:"http://host.docker.internal:9111"`
2021
DbInput *postgres.Input `toml:"db" validate:"required"`
2122
Node *NodeInput `toml:"node" validate:"required"`
2223
Out *Output `toml:"out"`
2324
}
2425

2526
// NodeInput is CL nod container inputs
2627
type NodeInput struct {
27-
Image string `toml:"image" validate:"required"`
28-
Tag string `toml:"tag" validate:"required"`
29-
PullImage bool `toml:"pull_image" default:"true"`
30-
Port string `toml:"port" validate:"required" default:"6688"`
31-
TestConfigOverrides string `toml:"test_config_overrides"`
32-
UserConfigOverrides string `toml:"user_config_overrides"`
33-
TestSecretsOverrides string `toml:"test_secrets_overrides"`
34-
UserSecretsOverrides string `toml:"user_secrets_overrides"`
28+
Image string `toml:"image" validate:"required"`
29+
Tag string `toml:"tag" validate:"required"`
30+
PullImage bool `toml:"pull_image" default:"true"`
31+
Port string `toml:"port" validate:"required" default:"6688"`
32+
CapabilitiesBinaryPaths []string `toml:"capabilities"`
33+
CapabilityContainerDir string `toml:"capabilities_container_dir" default:"/capabilities"`
34+
TestConfigOverrides string `toml:"test_config_overrides"`
35+
UserConfigOverrides string `toml:"user_config_overrides"`
36+
TestSecretsOverrides string `toml:"test_secrets_overrides"`
37+
UserSecretsOverrides string `toml:"user_secrets_overrides"`
3538
}
3639

3740
// Output represents Chainlink node output, nodes and databases connection URLs
@@ -123,50 +126,60 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
123126
"/bin/sh", "-c",
124127
"chainlink -c /config/config -c /config/overrides -c /config/user-overrides -s /config/secrets -s /config/secrets-overrides -s /config/user-secrets-overrides node start -d -p /config/node_password -a /config/apicredentials",
125128
},
126-
Files: []tc.ContainerFile{
127-
{
128-
HostFilePath: cfgPath.Name(),
129-
ContainerFilePath: "/config/config",
130-
FileMode: 0644,
131-
},
132-
{
133-
HostFilePath: secretsPath.Name(),
134-
ContainerFilePath: "/config/secrets",
135-
FileMode: 0644,
136-
},
137-
{
138-
HostFilePath: overridesFile.Name(),
139-
ContainerFilePath: "/config/overrides",
140-
FileMode: 0644,
141-
},
142-
{
143-
HostFilePath: userOverridesFile.Name(),
144-
ContainerFilePath: "/config/user-overrides",
145-
FileMode: 0644,
146-
},
147-
{
148-
HostFilePath: secretsOverridesFile.Name(),
149-
ContainerFilePath: "/config/secrets-overrides",
150-
FileMode: 0644,
151-
},
152-
{
153-
HostFilePath: userSecretsOverridesFile.Name(),
154-
ContainerFilePath: "/config/user-secrets-overrides",
155-
FileMode: 0644,
156-
},
157-
{
158-
HostFilePath: passwordPath.Name(),
159-
ContainerFilePath: "/config/node_password",
160-
FileMode: 0644,
161-
},
162-
{
163-
HostFilePath: apiCredentialsPath.Name(),
164-
ContainerFilePath: "/config/apicredentials",
165-
FileMode: 0644,
166-
},
167-
},
168129
WaitingFor: wait.ForLog("Listening and serving HTTP").WithStartupTimeout(2 * time.Minute),
169130
}
131+
files := []tc.ContainerFile{
132+
{
133+
HostFilePath: cfgPath.Name(),
134+
ContainerFilePath: "/config/config",
135+
FileMode: 0644,
136+
},
137+
{
138+
HostFilePath: secretsPath.Name(),
139+
ContainerFilePath: "/config/secrets",
140+
FileMode: 0644,
141+
},
142+
{
143+
HostFilePath: overridesFile.Name(),
144+
ContainerFilePath: "/config/overrides",
145+
FileMode: 0644,
146+
},
147+
{
148+
HostFilePath: userOverridesFile.Name(),
149+
ContainerFilePath: "/config/user-overrides",
150+
FileMode: 0644,
151+
},
152+
{
153+
HostFilePath: secretsOverridesFile.Name(),
154+
ContainerFilePath: "/config/secrets-overrides",
155+
FileMode: 0644,
156+
},
157+
{
158+
HostFilePath: userSecretsOverridesFile.Name(),
159+
ContainerFilePath: "/config/user-secrets-overrides",
160+
FileMode: 0644,
161+
},
162+
{
163+
HostFilePath: passwordPath.Name(),
164+
ContainerFilePath: "/config/node_password",
165+
FileMode: 0644,
166+
},
167+
{
168+
HostFilePath: apiCredentialsPath.Name(),
169+
ContainerFilePath: "/config/apicredentials",
170+
FileMode: 0644,
171+
},
172+
}
173+
for _, cp := range in.Node.CapabilitiesBinaryPaths {
174+
cpPath := filepath.Base(cp)
175+
framework.L.Info().Any("Path", cpPath).Str("Binary", cpPath).Msg("Copying capability binary")
176+
files = append(files, tc.ContainerFile{
177+
HostFilePath: cp,
178+
ContainerFilePath: filepath.Join(in.Node.CapabilityContainerDir, cpPath),
179+
FileMode: 0644,
180+
})
181+
}
182+
req.Files = append(req.Files, files...)
170183
c, err := tc.GenericContainer(ctx, tc.GenericContainerRequest{
171184
ContainerRequest: req,
172185
Started: true,

framework/components/don/don.go renamed to framework/components/node_set_extended/node_set_extended.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package don
1+
package node_set_extended
22

33
import (
44
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
@@ -15,7 +15,7 @@ type Output struct {
1515
Nodes []*clnode.Output `toml:"node"`
1616
}
1717

18-
func NewDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
18+
func NewExtendedNodeSet(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
1919
if in.Out.UseCache {
2020
return in.Out, nil
2121
}

framework/components/simple_don/simple_don.go renamed to framework/components/simple_node_set/node_set.go

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

33
import (
44
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
@@ -16,7 +16,8 @@ type Output struct {
1616
CLNodes []*clnode.Output `toml:"cl_nodes"`
1717
}
1818

19-
func NewSimpleDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
19+
// NewNodeSet creates a simple set of CL nodes
20+
func NewNodeSet(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
2021
if in.Out.UseCache {
2122
return in.Out, nil
2223
}

0 commit comments

Comments
 (0)