Skip to content

Commit

Permalink
deploy wiremock as part of load test
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhwarrier committed Mar 27, 2024
1 parent d44abe3 commit 7763027
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 12 deletions.
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240311111125-22812a072c35
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240324144450-2bc22a6738ac
github.com/smartcontractkit/chainlink-testing-framework v1.27.6
github.com/smartcontractkit/chainlink-testing-framework v1.27.7-0.20240327130928-70c8874795b7
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19e/go.mod h1:JiykN+8W5TA4UD2ClrzQCVvcH3NcyLEVv7RwY0busrw=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 h1:7m9PVtccb8/pvKTXMaGuyceFno1icRyC2SFH7KG7+70=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0/go.mod h1:SZ899lZYQ0maUulWbZg+SWqabHQ1wTbyk3jT8wJfyo8=
github.com/smartcontractkit/chainlink-testing-framework v1.27.6 h1:w+VS+w4N2HVA0TgJx+0KkXlW0p+Y0gOxgykaQwuHyYI=
github.com/smartcontractkit/chainlink-testing-framework v1.27.6/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA=
github.com/smartcontractkit/chainlink-testing-framework v1.27.7-0.20240327130928-70c8874795b7 h1:ib9MdYw5tn0wl1ki0j8gQJWJNJkTx8McXC9xbOZcmVU=
github.com/smartcontractkit/chainlink-testing-framework v1.27.7-0.20240327130928-70c8874795b7/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo=
Expand Down
49 changes: 44 additions & 5 deletions integration-tests/load/automationv2_1/automationv2_1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import (
"context"
"encoding/hex"
"fmt"
"github.com/pkg/errors"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/wiremock"
"math"
"math/big"
"net/http"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -44,6 +47,7 @@ import (
ac "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_compatible_utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_emitter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/simple_log_upkeep_counter_wrapper"
gowiremock "github.com/wiremock/go-wiremock"
)

const (
Expand Down Expand Up @@ -124,6 +128,24 @@ Password = '%s'`
}
)

func setUpDataStreamsWireMock(url string) error {
wm := gowiremock.NewClient(url)
rule200 := gowiremock.Get(gowiremock.URLPathEqualTo("/api/v1/reports/bulk")).
WithQueryParam("feedIDs", gowiremock.EqualTo("0x000200")).
WillReturnResponse(gowiremock.NewResponse().
WithBody(`{"reports":[{"feedID":"0x000200","validFromTimestamp":0,"observationsTimestamp":0,"fullReport":"0x000abc"}]}`).
WithStatus(200))
err := wm.StubFor(rule200)
if err != nil {
return err
}
resp, err := http.Post(fmt.Sprintf("%s/__admin/mappings/save", url), "application/json", nil)
if err != nil || resp.StatusCode != 200 {
return errors.New("error saving wiremock mappings")
}
return nil
}

func TestLogTrigger(t *testing.T) {
ctx := tests.Context(t)
l := logging.GetTestLogger(t)
Expand Down Expand Up @@ -243,11 +265,28 @@ Load Config:
}

if *loadedTestConfig.Automation.DataStreams.Enabled {
secretsTOML = fmt.Sprintf(
secretsTOML, "cred1",
*loadedTestConfig.Automation.DataStreams.URL, *loadedTestConfig.Automation.DataStreams.URL,
*loadedTestConfig.Automation.DataStreams.Username, *loadedTestConfig.Automation.DataStreams.Password,
)
if loadedTestConfig.Automation.DataStreams.URL == nil || *loadedTestConfig.Automation.DataStreams.URL == "" {
testEnvironment.AddHelm(wiremock.New(nil))
err := testEnvironment.Run()
require.NoError(t, err, "Error running wiremock server")
wiremockURL := testEnvironment.URLs[wiremock.InternalURLsKey][0]
secretsTOML = fmt.Sprintf(
secretsTOML, "cred1",
wiremockURL, wiremockURL,
"username", "password",
)
if !testEnvironment.Cfg.InsideK8s {
wiremockURL = testEnvironment.URLs[wiremock.LocalURLsKey][0]
}
err = setUpDataStreamsWireMock(wiremockURL)
require.NoError(t, err, "Error setting up wiremock server")
} else {
secretsTOML = fmt.Sprintf(
secretsTOML, "cred1",
*loadedTestConfig.Automation.DataStreams.URL, *loadedTestConfig.Automation.DataStreams.URL,
*loadedTestConfig.Automation.DataStreams.Username, *loadedTestConfig.Automation.DataStreams.Password,
)
}
} else {
secretsTOML = ""
}
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ require (
github.com/ethereum/go-ethereum v1.13.8
github.com/go-resty/resty/v2 v2.11.0
github.com/pelletier/go-toml/v2 v2.1.1
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.30.0
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240311111125-22812a072c35
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240324144450-2bc22a6738ac
github.com/smartcontractkit/chainlink-testing-framework v1.27.6
github.com/smartcontractkit/chainlink-testing-framework v1.27.7-0.20240327130928-70c8874795b7
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c
github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052
github.com/smartcontractkit/seth v0.1.2
github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1
github.com/smartcontractkit/wasp v0.4.6
github.com/stretchr/testify v1.9.0
github.com/wiremock/go-wiremock v1.9.0
go.uber.org/ratelimit v0.3.0
)

Expand Down Expand Up @@ -338,7 +340,6 @@ require (
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/alertmanager v0.26.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19
github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19e/go.mod h1:JiykN+8W5TA4UD2ClrzQCVvcH3NcyLEVv7RwY0busrw=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0 h1:7m9PVtccb8/pvKTXMaGuyceFno1icRyC2SFH7KG7+70=
github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240213121419-1272736c2ac0/go.mod h1:SZ899lZYQ0maUulWbZg+SWqabHQ1wTbyk3jT8wJfyo8=
github.com/smartcontractkit/chainlink-testing-framework v1.27.6 h1:w+VS+w4N2HVA0TgJx+0KkXlW0p+Y0gOxgykaQwuHyYI=
github.com/smartcontractkit/chainlink-testing-framework v1.27.6/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA=
github.com/smartcontractkit/chainlink-testing-framework v1.27.7-0.20240327130928-70c8874795b7 h1:ib9MdYw5tn0wl1ki0j8gQJWJNJkTx8McXC9xbOZcmVU=
github.com/smartcontractkit/chainlink-testing-framework v1.27.7-0.20240327130928-70c8874795b7/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA=
github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea h1:ZdLmNAfKRjH8AYUvjiiDGUgiWQfq/7iNpxyTkvjx/ko=
github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea/go.mod h1:gCKC9w6XpNk6jm+XIk2psrkkfxhi421N9NSiFceXW88=
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8=
Expand Down Expand Up @@ -1671,6 +1671,8 @@ github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
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=
github.com/wiremock/go-wiremock v1.9.0/go.mod h1:/uvO0XFheyy8XetvQqm4TbNQRsGPlByeNegzLzvXs0c=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
Expand Down

0 comments on commit 7763027

Please sign in to comment.