diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d5b76472d..c21113599 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -54,7 +54,9 @@ jobs: if: steps.cache-packages.outputs.cache-hit != 'true' run: go mod download - name: Install Ginkgo CLI - run: go install github.com/onsi/ginkgo/ginkgo + run: | + go get github.com/onsi/ginkgo/ginkgo@v1.16.5 + go install github.com/onsi/ginkgo/ginkgo - name: Run Tests run: | export PATH=$PATH:$(go env GOPATH)/bin @@ -68,6 +70,7 @@ jobs: uses: mikepenz/action-junit-report@v2 if: always() with: + name: Unit Test Report report_paths: '**/logs/tests-*.xml' github_token: ${{ secrets.GITHUB_TOKEN }} - name: Publish Artifacts @@ -116,15 +119,18 @@ jobs: if: steps.cache-packages.outputs.cache-hit != 'true' run: go mod download - name: Install Ginkgo CLI - run: go install github.com/onsi/ginkgo/ginkgo + run: | + go get github.com/onsi/ginkgo/ginkgo@v1.16.5 + go install github.com/onsi/ginkgo/ginkgo - name: Run Tests run: | export PATH=$PATH:$(go env GOPATH)/bin - make test_smoke args="--nodes=15" + make test_smoke args="-nodes=15" - name: Publish Test Results uses: mikepenz/action-junit-report@v2 if: always() with: + name: Smoke Test Report report_paths: '**/logs/tests-*.xml' github_token: ${{ secrets.GITHUB_TOKEN }} - name: Publish Artifacts @@ -176,15 +182,18 @@ jobs: if: steps.cache-packages.outputs.cache-hit != 'true' run: go mod download - name: Install Ginkgo CLI - run: go install github.com/onsi/ginkgo/ginkgo + run: | + go get github.com/onsi/ginkgo/ginkgo@v1.16.5 + go install github.com/onsi/ginkgo/ginkgo - name: Run Tests run: | export PATH=$PATH:$(go env GOPATH)/bin - make test_performance args="--nodes=15" + make test_performance args="-nodes=15" - name: Publish Test Results uses: mikepenz/action-junit-report@v2 if: always() with: + name: Performance Test Report report_paths: '**/logs/tests-*.xml' github_token: ${{ secrets.GITHUB_TOKEN }} - name: Publish Artifacts @@ -192,4 +201,65 @@ jobs: uses: actions/upload-artifact@v1 with: name: test-logs - path: ./logs \ No newline at end of file + path: ./logs + + # Chaos tests not stable enough for CI yet + # chaos: + # # Only run performance tests on significant PRs / merges to main + # if: startsWith(github.ref, 'v') || contains(github.ref, 'main') || contains(github.ref, 'develop') + # needs: unit + # runs-on: ubuntu-latest + # env: + # CGO_ENABLED: 1 + # NETWORK: ethereum_geth_performance + # steps: + # - name: Checkout the repo + # uses: actions/checkout@v2 + # - name: Setup Go + # uses: actions/setup-go@v1 + # with: + # go-version: 1.17 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # aws-region: ${{ secrets.AWS_REGION }} + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # role-duration-seconds: 3600 + # - name: Set Kubernetes Context + # uses: azure/k8s-set-context@v1 + # with: + # method: kubeconfig + # kubeconfig: ${{ secrets.KUBECONFIG }} + # - name: Cache Vendor Packages + # uses: actions/cache@v2 + # id: cache-packages + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # restore-keys: | + # ${{ runner.os }}-go- + # - name: Download Go Vendor Packages + # if: steps.cache-packages.outputs.cache-hit != 'true' + # run: go mod download + # - name: Install Ginkgo CLI + # run: go install github.com/onsi/ginkgo/ginkgo + # - name: Run Tests + # run: | + # export PATH=$PATH:$(go env GOPATH)/bin + # make test_chaos args="-nodes=15" + # - name: Publish Test Results + # uses: mikepenz/action-junit-report@v2 + # if: always() + # with: + # report_paths: '**/logs/tests-*.xml' + # github_token: ${{ secrets.GITHUB_TOKEN }} + # - name: Publish Artifacts + # if: failure() + # uses: actions/upload-artifact@v1 + # with: + # name: test-logs + # path: ./logs \ No newline at end of file diff --git a/Makefile b/Makefile index e878562db..211d9b15f 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,10 @@ go_mod: install: go_mod golangci test_smoke: - ginkgo -r -p -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress -skipPackage=./suite/performance,./suite/chaos ./suite/... $(args) + ginkgo -r -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress $(args) ./suite/smoke test_performance: - ginkgo -r -p -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress ./suite/performance ./suite/chaos $(args) + ginkgo -r -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress $(args) ./suite/performance + +test_chaos: + ginkgo -r -keepGoing --trace --randomizeAllSpecs --randomizeSuites --progress $(args) ./suite/chaos diff --git a/actions/actions.go b/actions/actions.go index bbcf72d21..09e19d525 100644 --- a/actions/actions.go +++ b/actions/actions.go @@ -4,10 +4,11 @@ package actions import ( "encoding/json" "fmt" - "github.com/smartcontractkit/integrations-framework/contracts" "math/big" "strings" + "github.com/smartcontractkit/integrations-framework/contracts" + "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" uuid "github.com/satori/go.uuid" @@ -80,7 +81,7 @@ func ExtractRequestIDFromJobRun(jobDecodeData client.RunsResponseData) ([]byte, // EncodeOnChainVRFProvingKey encodes uncompressed public VRF key to on-chain representation func EncodeOnChainVRFProvingKey(vrfKey client.VRFKey) ([2]*big.Int, error) { - uncompressed := vrfKey.Attributes.Uncompressed + uncompressed := vrfKey.Data.Attributes.Uncompressed provingKey := [2]*big.Int{} var set1 bool var set2 bool diff --git a/client/chainlink.go b/client/chainlink.go index b73dfc45f..3010a11bd 100644 --- a/client/chainlink.go +++ b/client/chainlink.go @@ -43,9 +43,11 @@ type Chainlink interface { DeleteP2PKey(id int) error ReadETHKeys() (*ETHKeys, error) - ReadVRFKeys() (*VRFKeys, error) PrimaryEthAddress() (string, error) + CreateVRFKey() (*VRFKey, error) + ReadVRFKeys() (*VRFKeys, error) + CreateEI(eia *EIAttributes) (*EIKeyCreate, error) ReadEIs() (*EIKeys, error) DeleteEI(name string) error @@ -225,6 +227,11 @@ func (c *chainlink) ReadP2PKeys() (*P2PKeys, error) { p2pKeys := &P2PKeys{} log.Info().Str("Node URL", c.Config.URL).Msg("Reading P2P Keys") _, err := c.do(http.MethodGet, "/v2/keys/p2p", nil, p2pKeys, http.StatusOK) + if len(p2pKeys.Data) == 0 { + err = fmt.Errorf("Found no P2P Keys on the chainlink node. Node URL: %s", c.Config.URL) + log.Err(err).Msg("Error getting P2P keys") + return nil, err + } for index := range p2pKeys.Data { p2pKeys.Data[index].Attributes.PeerID = strings.TrimPrefix(p2pKeys.Data[index].Attributes.PeerID, "p2p_") } @@ -243,15 +250,29 @@ func (c *chainlink) ReadETHKeys() (*ETHKeys, error) { ethKeys := ÐKeys{} log.Info().Str("Node URL", c.Config.URL).Msg("Reading ETH Keys") _, err := c.do(http.MethodGet, "/v2/keys/eth", nil, ethKeys, http.StatusOK) + if len(ethKeys.Data) == 0 { + log.Warn().Str("Node URL", c.Config.URL).Msg("Found no ETH Keys on the node") + } return ethKeys, err } // ReadVRFKeys reads all VRF keys from the Chainlink node func (c *chainlink) ReadVRFKeys() (*VRFKeys, error) { - ethKeys := &VRFKeys{} + vrfKeys := &VRFKeys{} log.Info().Str("Node URL", c.Config.URL).Msg("Reading VRF Keys") - _, err := c.do(http.MethodGet, "/v2/keys/vrf", nil, ethKeys, http.StatusOK) - return ethKeys, err + _, err := c.do(http.MethodGet, "/v2/keys/vrf", nil, vrfKeys, http.StatusOK) + if len(vrfKeys.Data) == 0 { + log.Warn().Str("Node URL", c.Config.URL).Msg("Found no VRF Keys on the node") + } + return vrfKeys, err +} + +// CreateVRFKey creates a VRF key on the Chainlink node +func (c *chainlink) CreateVRFKey() (*VRFKey, error) { + vrfKey := &VRFKey{} + log.Info().Str("Node URL", c.Config.URL).Msg("Creating VRF Key") + _, err := c.do(http.MethodPost, "/v2/keys/vrf", nil, vrfKey, http.StatusOK) + return vrfKey, err } // PrimaryEthAddress returns the primary ETH address for the chainlink node diff --git a/client/chainlink_models.go b/client/chainlink_models.go index 326192ebf..101b7fda7 100644 --- a/client/chainlink_models.go +++ b/client/chainlink_models.go @@ -116,13 +116,18 @@ type VRFKeyAttributes struct { DeletedAt interface{} `json:"deletedAt"` } -// VRFKey is the model that represents the created VRF key when read -type VRFKey struct { +// VRFKeyData is the model that represents the created VRF key's data when read +type VRFKeyData struct { Type string `json:"type"` ID string `json:"id"` Attributes VRFKeyAttributes `json:"attributes"` } +// VRFKey is the model that represents the created VRF key when read +type VRFKey struct { + Data VRFKeyData `json:"data"` +} + // VRFKeys is the model that represents the created VRF keys when read type VRFKeys struct { Data []VRFKey `json:"data"` diff --git a/go.mod b/go.mod index 3a861cbfa..b8b927f70 100644 --- a/go.mod +++ b/go.mod @@ -27,10 +27,8 @@ require ( ) require ( - github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/spf13/cobra v1.2.1 // indirect - golang.org/x/tools v0.1.7 // indirect google.golang.org/protobuf v1.27.1 // indirect ) diff --git a/go.sum b/go.sum index 47908df9d..2bf9eac4b 100644 --- a/go.sum +++ b/go.sum @@ -662,7 +662,6 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= @@ -2458,7 +2457,6 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/suite/performance/vrf.go b/suite/performance/vrf.go index 3e5735cd5..8e291d461 100644 --- a/suite/performance/vrf.go +++ b/suite/performance/vrf.go @@ -2,6 +2,9 @@ package performance import ( "context" + "math/big" + "time" + "github.com/ethereum/go-ethereum/common" "github.com/onsi/ginkgo" "github.com/rs/zerolog/log" @@ -11,8 +14,6 @@ import ( "github.com/smartcontractkit/integrations-framework/contracts" "github.com/smartcontractkit/integrations-framework/environment" "golang.org/x/sync/errgroup" - "math/big" - "time" ) // VRFProvingData proving key and job ID pair @@ -280,7 +281,7 @@ func (f *VRFTest) createChainlinkJobs() error { if err != nil { return err } - pubKeyCompressed := nodeKeys.Data[0].ID + pubKeyCompressed := nodeKeys.Data[0].Data.ID jobUUID := uuid.NewV4() os := &client.VRFTxPipelineSpec{ Address: p.coordinator.Address(), diff --git a/suite/smoke/contracts_flux_validate_flag_test.go b/suite/smoke/contracts_flux_validate_flag_test.go index 1b93091d6..db87e677b 100644 --- a/suite/smoke/contracts_flux_validate_flag_test.go +++ b/suite/smoke/contracts_flux_validate_flag_test.go @@ -3,12 +3,13 @@ package smoke import ( "context" "fmt" - "github.com/smartcontractkit/integrations-framework/hooks" - "github.com/smartcontractkit/integrations-framework/utils" "math/big" "strings" "time" + "github.com/smartcontractkit/integrations-framework/hooks" + "github.com/smartcontractkit/integrations-framework/utils" + "github.com/rs/zerolog/log" "github.com/ethereum/go-ethereum/common" diff --git a/suite/smoke/contracts_ocr_test.go b/suite/smoke/contracts_ocr_test.go index 5cb3a5e27..de5e77029 100644 --- a/suite/smoke/contracts_ocr_test.go +++ b/suite/smoke/contracts_ocr_test.go @@ -8,22 +8,26 @@ import ( ) var _ = Describe("OCR Feed @ocr", func() { + var i *actions.OCRSetupInputs DescribeTable("Deploys and watches an OCR feed @ocr", func( envInit environment.K8sEnvSpecInit, ) { - i := &actions.OCRSetupInputs{} + i = &actions.OCRSetupInputs{} By("Deploying environment", actions.DeployOCRForEnv(i, envInit)) By("Funding nodes", actions.FundNodes(i)) By("Deploying OCR contracts", actions.DeployOCRContracts(i, 1)) By("Creating OCR jobs", actions.CreateOCRJobs(i)) By("Checking OCR rounds", actions.CheckRound(i)) - By("Printing gas stats", func() { - i.SuiteSetup.DefaultNetwork().Client.GasStats().PrintStats() - }) - By("Tearing down the environment", i.SuiteSetup.TearDown()) }, Entry("all the same version", environment.NewChainlinkCluster(6)), Entry("different versions", environment.NewMixedVersionChainlinkCluster(6, 2)), ) + + AfterEach(func() { + By("Calculating gas costs", func() { + i.NetworkInfo.Client.GasStats().PrintStats() + }) + By("Tearing down the environment", i.SuiteSetup.TearDown()) + }) }) diff --git a/suite/smoke/contracts_vrf_test.go b/suite/smoke/contracts_vrf_test.go index 7777ae59d..8f36ef085 100644 --- a/suite/smoke/contracts_vrf_test.go +++ b/suite/smoke/contracts_vrf_test.go @@ -2,9 +2,10 @@ package smoke import ( "context" + "math/big" + "github.com/smartcontractkit/integrations-framework/hooks" "github.com/smartcontractkit/integrations-framework/utils" - "math/big" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -69,10 +70,10 @@ var _ = Describe("VRF suite @vrf", func() { By("Creating jobs and registering proving keys", func() { for _, n := range nodes { - nodeKeys, err := n.ReadVRFKeys() + nodeKey, err := n.CreateVRFKey() Expect(err).ShouldNot(HaveOccurred()) - log.Debug().Interface("Key JSON", nodeKeys).Msg("Created proving key") - pubKeyCompressed := nodeKeys.Data[0].ID + log.Debug().Interface("Key JSON", nodeKey).Msg("Created proving key") + pubKeyCompressed := nodeKey.Data.ID jobUUID := uuid.NewV4() os := &client.VRFTxPipelineSpec{ Address: coordinator.Address(), @@ -91,7 +92,7 @@ var _ = Describe("VRF suite @vrf", func() { oracleAddr, err := n.PrimaryEthAddress() Expect(err).ShouldNot(HaveOccurred()) - provingKey, err := actions.EncodeOnChainVRFProvingKey(nodeKeys.Data[0]) + provingKey, err := actions.EncodeOnChainVRFProvingKey(*nodeKey) Expect(err).ShouldNot(HaveOccurred()) err = coordinator.RegisterProvingKey( networkInfo.Wallets.Default(),