Skip to content

Commit 938000e

Browse files
committed
wip
1 parent 81ed16b commit 938000e

File tree

7 files changed

+233
-52
lines changed

7 files changed

+233
-52
lines changed

.github/workflows/framework-golden-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
count: 1
3232
timeout: 10m
3333
- name: TestReload
34-
config: reload.toml
34+
config: upgrade_all.toml
3535
count: 1
3636
timeout: 10m
3737
steps:
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
package simple_node_set
22

3-
// UpdateNodeConfigs updates nodes configuration TOML files
3+
import (
4+
"github.com/smartcontractkit/chainlink-testing-framework/framework/chaos"
5+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
6+
"time"
7+
)
8+
9+
// UpgradeNodeSet updates nodes configuration TOML files
410
// this API is discouraged, however, you can use it if nodes require restart or configuration updates, temporarily!
5-
func UpdateNodeConfigs(in *Input, cfg string) {
6-
in.NodeSpecs[0].Node.UserConfigOverrides = in.NodeSpecs[0].Node.UserConfigOverrides + cfg
11+
func UpgradeNodeSet(in *Input, bc *blockchain.Output, url string, wait time.Duration) (*Output, error) {
12+
_, err := chaos.ExecPumba("rm --volumes=false re2:node.*|postgresql.*", wait)
13+
if err != nil {
14+
return nil, err
15+
}
716
in.Out = nil
17+
out, err := NewSharedDBNodeSet(in, bc, url)
18+
in.Out = out
19+
return out, err
820
}

framework/examples/myproject/reload.toml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package examples
2+
3+
import (
4+
"fmt"
5+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
6+
"github.com/smartcontractkit/chainlink-testing-framework/framework/clclient"
7+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
8+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake"
9+
ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set"
10+
"github.com/stretchr/testify/require"
11+
"testing"
12+
"time"
13+
)
14+
15+
type CfgUpgradeAll struct {
16+
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
17+
MockerDataProvider *fake.Input `toml:"data_provider" validate:"required"`
18+
NodeSet *ns.Input `toml:"nodeset" validate:"required"`
19+
}
20+
21+
func TestUpgradeAll(t *testing.T) {
22+
in, err := framework.Load[CfgReload](t)
23+
require.NoError(t, err)
24+
25+
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
26+
require.NoError(t, err)
27+
dp, err := fake.NewFakeDataProvider(in.MockerDataProvider)
28+
require.NoError(t, err)
29+
30+
// deploy first time
31+
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc, dp.BaseURLDocker)
32+
require.NoError(t, err)
33+
34+
c, err := clclient.NewCLDefaultClients(out.CLNodes, framework.L)
35+
require.NoError(t, err)
36+
_, _, err = c[0].CreateJobRaw(testJob)
37+
require.NoError(t, err)
38+
39+
in.NodeSet.NodeSpecs[0].Node.Image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
40+
in.NodeSet.NodeSpecs[0].Node.UserConfigOverrides = `
41+
[Log]
42+
level = 'info'
43+
`
44+
45+
out, err = ns.UpgradeNodeSet(in.NodeSet, bc, dp.BaseURLDocker, 10*time.Second)
46+
require.NoError(t, err)
47+
48+
jobs, _, err := c[0].ReadJobs()
49+
require.NoError(t, err)
50+
fmt.Println(jobs)
51+
52+
t.Run("test something", func(t *testing.T) {
53+
for _, n := range out.CLNodes {
54+
require.NotEmpty(t, n.Node.HostURL)
55+
require.NotEmpty(t, n.Node.HostP2PURL)
56+
}
57+
})
58+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
[blockchain_a]
3+
chain_id = "31337"
4+
image = "f4hrenh9it/foundry:latest"
5+
port = "8545"
6+
type = "anvil"
7+
8+
[data_provider]
9+
port = 9111
10+
11+
[nodeset]
12+
nodes = 5
13+
override_mode = "all"
14+
15+
[[nodeset.node_specs]]
16+
17+
[nodeset.node_specs.db]
18+
image = "postgres:15.6"
19+
pull_image = true
20+
21+
[nodeset.node_specs.node]
22+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
23+
pull_image = false
24+
25+
[[nodeset.node_specs]]
26+
27+
[nodeset.node_specs.db]
28+
image = "postgres:15.6"
29+
pull_image = true
30+
31+
[nodeset.node_specs.node]
32+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
33+
pull_image = false
34+
35+
[[nodeset.node_specs]]
36+
37+
[nodeset.node_specs.db]
38+
image = "postgres:15.6"
39+
pull_image = true
40+
41+
[nodeset.node_specs.node]
42+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
43+
pull_image = false
44+
45+
[[nodeset.node_specs]]
46+
47+
[nodeset.node_specs.db]
48+
image = "postgres:15.6"
49+
pull_image = true
50+
51+
[nodeset.node_specs.node]
52+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
53+
pull_image = false
54+
55+
[[nodeset.node_specs]]
56+
57+
[nodeset.node_specs.db]
58+
image = "postgres:15.6"
59+
pull_image = true
60+
61+
[nodeset.node_specs.node]
62+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
63+
pull_image = false

framework/examples/myproject/reload_test.go renamed to framework/examples/myproject/upgrade_some.go

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package examples
33
import (
44
"fmt"
55
"github.com/smartcontractkit/chainlink-testing-framework/framework"
6-
"github.com/smartcontractkit/chainlink-testing-framework/framework/chaos"
76
"github.com/smartcontractkit/chainlink-testing-framework/framework/clclient"
87
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
98
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake"
@@ -13,6 +12,25 @@ import (
1312
"time"
1413
)
1514

15+
const (
16+
testJob = `
17+
type = "cron"
18+
schemaVersion = 1
19+
schedule = "CRON_TZ=UTC */10 * * * * *" # every 10 secs
20+
observationSource = """
21+
// data source 2
22+
fetch [type=http method=GET url="https://min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=USD"];
23+
parse [type=jsonparse path="RAW,ETH,USD,PRICE"];
24+
multiply [type="multiply" input="$(parse)" times=100]
25+
encode_tx [type="ethabiencode"
26+
abi="submit(uint256 value)"
27+
data="{ \\"value\\": $(multiply) }"]
28+
submit_tx [type="ethtx" to="0x859AAa51961284C94d970B47E82b8771942F1980" data="$(encode_tx)"]
29+
30+
fetch -> parse -> multiply -> encode_tx -> submit_tx
31+
"""`
32+
)
33+
1634
type CfgReload struct {
1735
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
1836
MockerDataProvider *fake.Input `toml:"data_provider" validate:"required"`
@@ -34,33 +52,23 @@ func TestReload(t *testing.T) {
3452

3553
c, err := clclient.NewCLDefaultClients(out.CLNodes, framework.L)
3654
require.NoError(t, err)
37-
_, _, err = c[0].CreateJobRaw(`
38-
type = "cron"
39-
schemaVersion = 1
40-
schedule = "CRON_TZ=UTC */10 * * * * *" # every 10 secs
41-
observationSource = """
42-
// data source 2
43-
fetch [type=http method=GET url="https://min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=USD"];
44-
parse [type=jsonparse path="RAW,ETH,USD,PRICE"];
45-
multiply [type="multiply" input="$(parse)" times=100]
46-
encode_tx [type="ethabiencode"
47-
abi="submit(uint256 value)"
48-
data="{ \\"value\\": $(multiply) }"]
49-
submit_tx [type="ethtx" to="0x859AAa51961284C94d970B47E82b8771942F1980" data="$(encode_tx)"]
50-
51-
fetch -> parse -> multiply -> encode_tx -> submit_tx
52-
"""`)
55+
_, _, err = c[0].CreateJobRaw(testJob)
5356
require.NoError(t, err)
5457

55-
// deploy second time
56-
_, err = chaos.ExecPumba("rm --volumes=false re2:node.*|postgresql.*", 5*time.Second)
57-
require.NoError(t, err)
58-
ns.UpdateNodeConfigs(in.NodeSet, `
59-
[Log]
60-
level = 'info'
61-
`)
62-
out, err = ns.NewSharedDBNodeSet(in.NodeSet, bc, dp.BaseURLDocker)
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, 10*time.Second)
6370
require.NoError(t, err)
71+
6472
jobs, _, err := c[0].ReadJobs()
6573
require.NoError(t, err)
6674
fmt.Println(jobs)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
[blockchain_a]
3+
chain_id = "31337"
4+
image = "f4hrenh9it/foundry:latest"
5+
port = "8545"
6+
type = "anvil"
7+
8+
[data_provider]
9+
port = 9111
10+
11+
[nodeset]
12+
nodes = 5
13+
override_mode = "each"
14+
15+
[[nodeset.node_specs]]
16+
17+
[nodeset.node_specs.db]
18+
image = "postgres:15.6"
19+
pull_image = true
20+
21+
[nodeset.node_specs.node]
22+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
23+
pull_image = false
24+
25+
[[nodeset.node_specs]]
26+
27+
[nodeset.node_specs.db]
28+
image = "postgres:15.6"
29+
pull_image = true
30+
31+
[nodeset.node_specs.node]
32+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
33+
pull_image = false
34+
35+
[[nodeset.node_specs]]
36+
37+
[nodeset.node_specs.db]
38+
image = "postgres:15.6"
39+
pull_image = true
40+
41+
[nodeset.node_specs.node]
42+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
43+
pull_image = false
44+
45+
[[nodeset.node_specs]]
46+
47+
[nodeset.node_specs.db]
48+
image = "postgres:15.6"
49+
pull_image = true
50+
51+
[nodeset.node_specs.node]
52+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
53+
pull_image = false
54+
55+
[[nodeset.node_specs]]
56+
57+
[nodeset.node_specs.db]
58+
image = "postgres:15.6"
59+
pull_image = true
60+
61+
[nodeset.node_specs.node]
62+
image = "public.ecr.aws/chainlink/chainlink:v2.16.0"
63+
pull_image = false

0 commit comments

Comments
 (0)