Skip to content

Commit 484a132

Browse files
committed
try custom ports exposed
1 parent d8d5cee commit 484a132

File tree

4 files changed

+68
-37
lines changed

4 files changed

+68
-37
lines changed

framework/components/clnode/clnode.go

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type NodeInput struct {
5151
UserSecretsOverrides string `toml:"user_secrets_overrides"`
5252
HTTPPort int `toml:"port"`
5353
P2PPort int `toml:"p2p_port"`
54+
CustomPorts []int `toml:"custom_ports"`
5455
}
5556

5657
// Output represents Chainlink node output, nodes and databases connection URLs
@@ -152,6 +153,35 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
152153
} else {
153154
containerName = framework.DefaultTCName("node")
154155
}
156+
customPorts := make([]string, 0)
157+
for _, p := range in.Node.CustomPorts {
158+
customPorts = append(customPorts, fmt.Sprintf("%d/tcp", p))
159+
}
160+
exposedPorts := []string{httpPort, p2pPort}
161+
exposedPorts = append(exposedPorts, customPorts...)
162+
163+
portBindings := nat.PortMap{
164+
nat.Port(httpPort): []nat.PortBinding{
165+
{
166+
HostIP: "0.0.0.0",
167+
HostPort: fmt.Sprintf("%d/tcp", in.Node.HTTPPort),
168+
},
169+
},
170+
nat.Port(p2pPort): []nat.PortBinding{
171+
{
172+
HostIP: "0.0.0.0",
173+
HostPort: fmt.Sprintf("%d/udp", in.Node.P2PPort),
174+
},
175+
},
176+
}
177+
for _, p := range customPorts {
178+
portBindings[nat.Port(p)] = []nat.PortBinding{
179+
{
180+
HostIP: "0.0.0.0",
181+
HostPort: p,
182+
},
183+
}
184+
}
155185

156186
req := tc.ContainerRequest{
157187
AlwaysPullImage: in.Node.PullImage,
@@ -162,7 +192,7 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
162192
NetworkAliases: map[string][]string{
163193
framework.DefaultNetworkName: {containerName},
164194
},
165-
ExposedPorts: []string{httpPort, p2pPort},
195+
ExposedPorts: exposedPorts,
166196
Entrypoint: []string{
167197
"/bin/sh", "-c",
168198
"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",
@@ -171,20 +201,7 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
171201
}
172202
if in.Node.HTTPPort != 0 && in.Node.P2PPort != 0 {
173203
req.HostConfigModifier = func(h *container.HostConfig) {
174-
h.PortBindings = nat.PortMap{
175-
nat.Port(httpPort): []nat.PortBinding{
176-
{
177-
HostIP: "0.0.0.0",
178-
HostPort: fmt.Sprintf("%d/tcp", in.Node.HTTPPort),
179-
},
180-
},
181-
nat.Port(p2pPort): []nat.PortBinding{
182-
{
183-
HostIP: "0.0.0.0",
184-
HostPort: fmt.Sprintf("%d/udp", in.Node.P2PPort),
185-
},
186-
},
187-
}
204+
h.PortBindings = portBindings
188205
}
189206
}
190207
files := []tc.ContainerFile{

framework/examples/myproject/README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@
66
[![Resiliency](https://img.shields.io/badge/Level_4-Resiliency-blue?branch=maturity-model&job=TestSmoke)](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/framework-golden-tests.yml)
77
[![Scalability](https://img.shields.io/badge/Level_5-Scalability-blue?branch=maturity-model&job=TestSmoke)](https://github.com/smartcontractkit/chainlink-testing-framework/actions/workflows/framework-golden-tests.yml)
88

9+
## Level 0
10+
11+
The team creates and maintains a high-level test plan outlining the components involved and test cases in any format.
12+
13+
If the team decides on minimal or no manual testing and the project is trivial, they can consolidate all test cases into `go test` cases, outline the required implementations and commit templates up front.
14+
15+
The team identifies potential integration points with third-party software, blockchain, and external services and document any testing limitations.
16+
17+
If new components are required, the team implements them following this guide: [Developing Components](https://smartcontractkit.github.io/chainlink-testing-framework/developing/developing_components.html).
18+
19+
920
## Level 1
1021
The team maintains a system-level smoke test where all components are deployed using `docker`.
1122

1223
All on-chain changes are done through [chainlink-deployments](https://github.com/smartcontractkit/chainlink-deployments).
1324

14-
The test is readable, and the README clearly explains its purpose.
25+
The test is readable, and the README clearly explains what is tested.
1526

16-
The test is reliable and stable when run with a `-count 30`.
27+
The test is stable when run with a `-count 10`.
1728

1829
If your project includes multiple use cases and functionality suitable for end-to-end testing, you can add additional tests at this level.
1930

@@ -22,7 +33,7 @@ The team has an "upgrade" test to verify product compatibility with older versio
2233

2334
While the number of compatible versions is team-determined, identifying incompatibilities at the system level early is a valuable, mature practice.
2435

25-
This test deploys specific platform and plugin versions, performs an end-to-end smoke test, and then upgrades (or migrates) the plugin(s) or platform on the same database to ensure that users remain unaffected by the upgrade.
36+
This test deploys specific platform and plugin versions, performs an end-to-end smoke test, and then upgrades (or migrates) the plugin(s) or platform on the same database to ensure that users remain unaffected by the upgrade or, in case of breaking changes, migration process is tested.
2637

2738
## Level 3
2839
The team has a baseline performance testing suite.
@@ -43,6 +54,10 @@ The team has complete ownership of their persistent staging environment.
4354

4455
They can perform upgrades, data migrations, and run advanced load tests to validate the scalability of their applications.
4556

57+
## Explanation
58+
59+
It's essential not to skip levels, as they help us manage complexity gradually and keep the focus on our product.
60+
4661
## Developing
4762
Run the tests locally
4863
```

framework/examples/myproject/upgrade.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
pull_image = true
2020

2121
[nodeset.node_specs.node]
22+
custom_ports = [14000, 14001]
2223
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
2324
pull_image = false
2425

framework/examples/myproject/upgrade_test.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package examples
22

33
import (
4-
"fmt"
54
"github.com/smartcontractkit/chainlink-testing-framework/framework"
65
"github.com/smartcontractkit/chainlink-testing-framework/framework/clclient"
76
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
87
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake"
98
ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set"
109
"github.com/stretchr/testify/require"
1110
"testing"
12-
"time"
1311
)
1412

1513
const (
@@ -55,23 +53,23 @@ func TestUpgrade(t *testing.T) {
5553
_, _, err = c[0].CreateJobRaw(testJob)
5654
require.NoError(t, err)
5755

58-
in.NodeSet.NodeSpecs[0].Node.Image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
59-
in.NodeSet.NodeSpecs[0].Node.UserConfigOverrides = `
60-
[Log]
61-
level = 'info'
62-
`
63-
in.NodeSet.NodeSpecs[4].Node.Image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
64-
in.NodeSet.NodeSpecs[4].Node.UserConfigOverrides = `
65-
[Log]
66-
level = 'info'
67-
`
68-
69-
out, err = ns.UpgradeNodeSet(in.NodeSet, bc, dp.BaseURLDocker, 3*time.Second)
70-
require.NoError(t, err)
71-
72-
jobs, _, err := c[0].ReadJobs()
73-
require.NoError(t, err)
74-
fmt.Println(jobs)
56+
// in.NodeSet.NodeSpecs[0].Node.Image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
57+
// in.NodeSet.NodeSpecs[0].Node.UserConfigOverrides = `
58+
// [Log]
59+
// level = 'info'
60+
//`
61+
// in.NodeSet.NodeSpecs[4].Node.Image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
62+
// in.NodeSet.NodeSpecs[4].Node.UserConfigOverrides = `
63+
// [Log]
64+
// level = 'info'
65+
//`
66+
//
67+
// out, err = ns.UpgradeNodeSet(in.NodeSet, bc, dp.BaseURLDocker, 3*time.Second)
68+
// require.NoError(t, err)
69+
//
70+
// jobs, _, err := c[0].ReadJobs()
71+
// require.NoError(t, err)
72+
// fmt.Println(jobs)
7573

7674
t.Run("test something", func(t *testing.T) {
7775
for _, n := range out.CLNodes {

0 commit comments

Comments
 (0)