|
| 1 | +# NodeSet |
| 2 | + |
| 3 | +## Configuration |
| 4 | +```toml |
| 5 | +[nodeset] |
| 6 | + # amount of Chainlink nodes to spin up |
| 7 | + nodes = 5 |
| 8 | + # Override mode: can be "all" or "each" |
| 9 | + # defines how we override configs, either we apply first node fields to all of them |
| 10 | + # or we define each node custom configuration (used in compatibility testing) |
| 11 | + override_mode = "all" |
| 12 | + |
| 13 | + [[nodeset.node_specs]] |
| 14 | + # Optional URL for fake data provider URL |
| 15 | + # usually set up in test with local mock server |
| 16 | + data_provider_url = "" |
| 17 | + |
| 18 | + [nodeset.node_specs.db] |
| 19 | + # PostgreSQL image version and tag |
| 20 | + image = "postgres:15.6" |
| 21 | + # Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs |
| 22 | + pull_image = true |
| 23 | + |
| 24 | + [nodeset.node_specs.node] |
| 25 | + # A list of paths to capability binaries |
| 26 | + capabilities = ["./capability_1", "./capability_2"] |
| 27 | + # Default capabilities directory inside container |
| 28 | + capabilities_container_dir = "/home/capabilities" |
| 29 | + # Image to use, you can either provide "image" or "docker_file" + "docker_ctx" fields |
| 30 | + image = "public.ecr.aws/chainlink/chainlink:v2.17.0" |
| 31 | + # Path to your Chainlink Dockerfile |
| 32 | + docker_file = "../../core/chainlink.Dockerfile" |
| 33 | + # Path to docker context that should be used to build from |
| 34 | + docker_ctx = "../.." |
| 35 | + # Optional name for image we build, default is "ctftmp" |
| 36 | + docker_image_name = "ctftmp" |
| 37 | + # Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs |
| 38 | + pull_image = true |
| 39 | + # Overrides Chainlink node TOML configuration |
| 40 | + # can be multiline, see example |
| 41 | + user_config_overrides = """ |
| 42 | + [Log] |
| 43 | + level = 'info' |
| 44 | + """ |
| 45 | + # Overrides Chainlink node secrets TOML configuration |
| 46 | + # you can only add fields, overriding existing fields is prohibited by Chainlink node |
| 47 | + user_secrets_overrides = """ |
| 48 | + [AnotherSecret] |
| 49 | + mySecret = 'a' |
| 50 | + """ |
| 51 | + |
| 52 | + # Outputs are the results of deploying a component that can be used by another component |
| 53 | + [nodeset.out] |
| 54 | + # If 'use_cache' equals 'true' we skip component setup when we run the test and return the outputs |
| 55 | + use_cache = true |
| 56 | + |
| 57 | + # Describes deployed or external Chainlink nodes |
| 58 | + [[nodeset.out.cl_nodes]] |
| 59 | + use_cache = true |
| 60 | + |
| 61 | + # Describes deployed or external Chainlink node |
| 62 | + [nodeset.out.cl_nodes.node] |
| 63 | + # Host Docker URLs the test uses |
| 64 | + # in case of using external component you can replace these URLs with another deployment |
| 65 | + p2p_url = "http://127.0.0.1:32996" |
| 66 | + url = "http://127.0.0.1:33096" |
| 67 | + # Describes PostgreSQL instance |
| 68 | + [nodeset.out.cl_nodes.postgresql] |
| 69 | + # PostgreSQL connection string |
| 70 | + # in case of using external database can be overriden |
| 71 | + url = "postgresql://chainlink:[email protected]:33094/chainlink?sslmode=disable" |
| 72 | + |
| 73 | + # Can have more than one node, fields are the same, see above ^^ |
| 74 | + [[nodeset.out.cl_nodes]] |
| 75 | + [nodeset.out.cl_nodes.node] |
| 76 | + [nodeset.out.cl_nodes.postgresql] |
| 77 | + ... |
| 78 | +``` |
| 79 | + |
| 80 | +## Usage |
| 81 | +```golang |
| 82 | +package yourpackage_test |
| 83 | + |
| 84 | +import ( |
| 85 | + "fmt" |
| 86 | + "github.com/smartcontractkit/chainlink-testing-framework/framework" |
| 87 | + ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set" |
| 88 | + "github.com/stretchr/testify/require" |
| 89 | + "testing" |
| 90 | +) |
| 91 | + |
| 92 | +type Config struct { |
| 93 | + NodeSet *ns.Input `toml:"nodeset" validate:"required"` |
| 94 | +} |
| 95 | + |
| 96 | +func TestNodeSet(t *testing.T) { |
| 97 | + in, err := framework.Load[Config](t) |
| 98 | + require.NoError(t, err) |
| 99 | + |
| 100 | + out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc, dp.BaseURLDocker) |
| 101 | + require.NoError(t, err) |
| 102 | + |
| 103 | + ... |
| 104 | +} |
| 105 | +``` |
0 commit comments