Skip to content

Commit

Permalink
test(smoke): register multiple job distributors (#14327)
Browse files Browse the repository at this point in the history
Now that we are supporting multiple job distributors per node, I want to have a smoke test that verifies this behaviour.

We do need to enable the `MultiFeedsManagers` feature tag.
  • Loading branch information
graham-chainlink authored Sep 10, 2024
1 parent 01b6405 commit 340d0dd
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .github/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,16 @@ runner-test-matrix:
E2E_TEST_CHAINLINK_UPGRADE_IMAGE: '{{ env.QA_CHAINLINK_IMAGE }}'
E2E_TEST_CHAINLINK_UPGRADE_VERSION: '{{ env.DEFAULT_CHAINLINK_VERSION }}'

- id: smoke/job_distributor_test.go:*
path: integration-tests/smoke/job_distributor_test.go
test_env_type: docker
runs_on: ubuntu-latest
workflows:
- PR E2E Core Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ && go test smoke/job_distributor_test.go -timeout 30m -count=1 -json
pyroscope_env: ci-smoke-jd-evm-simulated

# END: Other tests

# START: CCIP tests
Expand Down
27 changes: 22 additions & 5 deletions integration-tests/docker/test_env/cl_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/client"
it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils"
"github.com/smartcontractkit/chainlink/integration-tests/utils/templates"
grapqlClient "github.com/smartcontractkit/chainlink/integration-tests/web/sdk/client"
)

var (
ErrConnectNodeClient = "could not connect Node HTTP Client"
ErrStartCLNodeContainer = "failed to start CL node container"
ErrConnectNodeClient = "could not connect Node HTTP Client"
ErrConnectNodeGraphqlClient = "could not connect Node Graphql Client"
ErrStartCLNodeContainer = "failed to start CL node container"
)

const (
Expand All @@ -54,6 +56,7 @@ type ClNode struct {
UserEmail string `json:"userEmail"`
UserPassword string `json:"userPassword"`
AlwaysPullImage bool `json:"-"`
GraphqlAPI grapqlClient.Client `json:"-"`
t *testing.T
l zerolog.Logger
}
Expand Down Expand Up @@ -339,19 +342,25 @@ func (n *ClNode) containerStartOrRestart(restartDb bool) error {
Str("userEmail", n.UserEmail).
Str("userPassword", n.UserPassword).
Msg("Started Chainlink Node container")
clClient, err := client.NewChainlinkClient(&client.ChainlinkConfig{
config := &client.ChainlinkConfig{
URL: clEndpoint,
Email: n.UserEmail,
Password: n.UserPassword,
InternalIP: ip,
},
n.l)
}
clClient, err := client.NewChainlinkClient(config, n.l)
if err != nil {
return fmt.Errorf("%s err: %w", ErrConnectNodeClient, err)
}

graphqlClient, err := newChainLinkGraphqlClient(config)
if err != nil {
return fmt.Errorf("%s err: %w", ErrConnectNodeGraphqlClient, err)
}

n.Container = container
n.API = clClient
n.GraphqlAPI = graphqlClient

return nil
}
Expand Down Expand Up @@ -491,3 +500,11 @@ func (n *ClNode) getContainerRequest(secrets string) (
},
}, nil
}

func newChainLinkGraphqlClient(c *client.ChainlinkConfig) (grapqlClient.Client, error) {
nodeClient, err := grapqlClient.New(c.URL, grapqlClient.Credentials{Email: c.Email, Password: c.Password})
if err != nil {
return nil, err
}
return nodeClient, nil
}
3 changes: 2 additions & 1 deletion integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ require (
github.com/CosmWasm/wasmvm v1.2.4 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/K-Phoen/sdk v0.12.4 // indirect
github.com/Khan/genqlient v0.7.0 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
Expand Down Expand Up @@ -375,7 +376,6 @@ require (
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
Expand Down Expand Up @@ -426,6 +426,7 @@ require (
github.com/umbracle/ethgo v0.1.3 // indirect
github.com/umbracle/fastrlp v0.0.0-20220527094140-59d5dd30e722 // indirect
github.com/valyala/fastjson v1.4.1 // indirect
github.com/vektah/gqlparser/v2 v2.5.11 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ github.com/K-Phoen/grabana v0.22.1 h1:b/O+C3H2H6VNYSeMCYUO4X4wYuwFXgBcRkvYa+fjpQ
github.com/K-Phoen/grabana v0.22.1/go.mod h1:3LTXrTzQzTKTgvKSXdRjlsJbizSOW/V23Q3iX00R5bU=
github.com/K-Phoen/sdk v0.12.4 h1:j2EYuBJm3zDTD0fGKACVFWxAXtkR0q5QzfVqxmHSeGQ=
github.com/K-Phoen/sdk v0.12.4/go.mod h1:qmM0wO23CtoDux528MXPpYvS4XkRWkWX6rvX9Za8EVU=
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
Expand Down Expand Up @@ -179,6 +181,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc=
github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
Expand Down Expand Up @@ -1547,6 +1551,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/valyala/fastjson v1.4.1 h1:hrltpHpIpkaxll8QltMU8c3QZ5+qIiCL8yKqPFJI/yE=
github.com/valyala/fastjson v1.4.1/go.mod h1:nV6MsjxL2IMJQUoHDIrjEI7oLyeqK6aBD7EFWPsvP8o=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8=
github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc=
github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs=
github.com/vultr/govultr/v2 v2.17.2/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI=
github.com/wiremock/go-wiremock v1.9.0 h1:9xcU4/IoEfgCaH4TGhQTtiQyBh2eMtu9JB6ppWduK+E=
Expand Down
59 changes: 59 additions & 0 deletions integration-tests/smoke/job_distributor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package smoke

import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig"
graphqlClient "github.com/smartcontractkit/chainlink/integration-tests/web/sdk/client"
)

func TestRegisteringMultipleJobDistributor(t *testing.T) {
t.Parallel()

l := logging.GetTestLogger(t)

config, err := tc.GetConfig([]string{"Smoke"}, "job_distributor")
require.NoError(t, err, "Error getting config")

privateNetwork, err := actions.EthereumNetworkConfigFromConfig(l, &config)
require.NoError(t, err, "Error building ethereum network config")

env, err := test_env.NewCLTestEnvBuilder().
WithTestConfig(&config).
WithTestInstance(t).
WithStandardCleanup().
WithPrivateEthereumNetwork(privateNetwork.EthereumNetworkConfig).
WithCLNodes(1).
WithStandardCleanup().
Build()
require.NoError(t, err)

ctx := context.Background()
err = env.ClCluster.Nodes[0].GraphqlAPI.CreateJobDistributor(ctx, graphqlClient.FeedsManagerInput{
Name: "job-distributor-1",
Uri: "http://job-distributor-1:8080",
PublicKey: "54227538d9352e0a24550a80ab6a7af6e4f1ffbb8a604e913cbb81c484a7f97d",
})
require.NoError(t, err, "Creating first job distributor in chainlink node shouldn't fail")

err = env.ClCluster.Nodes[0].GraphqlAPI.CreateJobDistributor(ctx, graphqlClient.FeedsManagerInput{
Name: "job-distributor-2",
Uri: "http://job-distributor-2:8080",
PublicKey: "37346b7ea98af21e1309847e00f772826ac3689fe990b1920d01efc58ad2f250",
})
require.NoError(t, err, "Creating second job distributor in chainlink node shouldn't fail")

distributors, err := env.ClCluster.Nodes[0].GraphqlAPI.ListJobDistributors(ctx)
require.NoError(t, err, "Listing job distributors in chainlink node shouldn't fail")
require.Len(t, distributors.FeedsManagers.Results, 2, "There should be 2 job distributors")

assert.Equal(t, "job-distributor-1", distributors.FeedsManagers.Results[0].Name)
assert.Equal(t, "job-distributor-2", distributors.FeedsManagers.Results[1].Name)
}
46 changes: 46 additions & 0 deletions integration-tests/testconfig/job_distributor/job_distributor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[NodeConfig]
BaseConfigTOML = """
[Feature]
FeedsManager = true
LogPoller = true
UICSAKeys = true
MultiFeedsManagers = true
[Log]
Level = 'debug'
JSONConsole = true
[Log.File]
MaxSize = '0b'
[WebServer]
AllowOrigins = '*'
HTTPPort = 6688
SecureCookies = false
HTTPWriteTimeout = '3m'
SessionTimeout = '999h0m0s'
[WebServer.RateLimit]
Authenticated = 2000
Unauthenticated = 1000
[WebServer.TLS]
HTTPSPort = 0
[Database]
MaxIdleConns = 20
MaxOpenConns = 40
MigrateOnStartup = true
[OCR]
Enabled = true
DefaultTransactionQueueDepth = 0
[P2P]
[P2P.V2]
Enabled = true
ListenAddresses = ['0.0.0.0:6690']
AnnounceAddresses = ['0.0.0.0:6690']
DeltaDial = '500ms'
DeltaReconcile = '5s'
"""

0 comments on commit 340d0dd

Please sign in to comment.