Skip to content

Commit

Permalink
perf: speed up e2e docker build (#1734)
Browse files Browse the repository at this point in the history
* speed up e2e docker build
* separate params and medians test
  • Loading branch information
zarazan authored Jan 23, 2023
1 parent 50e5263 commit fd3fd01
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
24 changes: 14 additions & 10 deletions contrib/images/umee.e2e.dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# Docker for e2e testing
# Creates dynamic binaries, by building from the latest version of:
# umeed, price-feeder,
# And release version of peggo
# umeed and release version of peggo

FROM golang:1.19-bullseye AS builder

## Build umeed
## Download Peggo
WORKDIR /src
RUN wget https://github.com/umee-network/peggo/releases/download/v1.4.0/peggo-v1.4.0-linux-amd64.tar.gz && \
tar -xvf peggo-v*

## Download go module dependencies for umeed
WORKDIR /src/umee
# optimization: if go.sum didn't change, docker will use cached image
COPY go.mod go.sum ./
RUN go mod download

## Download go module dependnecies for price-feeder
WORKDIR /src/umee/price-feeder
COPY price-feeder/go.mod price-feeder/go.sum ./
RUN go mod download

## Build umeed and price-feeder
WORKDIR /src/umee
COPY . .
RUN make install && \
cd price-feeder && make install

## Download Peggo
WORKDIR /src
RUN wget https://github.com/umee-network/peggo/releases/download/v1.4.0/peggo-v1.4.0-linux-amd64.tar.gz && \
tar -xvf peggo-v*


## Prepare the final clear binary
FROM ubuntu:rolling
EXPOSE 26656 26657 1317 9090 7171
Expand Down
15 changes: 15 additions & 0 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
appparams "github.com/umee-network/umee/v4/app/params"
"github.com/umee-network/umee/v4/tests/grpc/client"
"github.com/umee-network/umee/v4/x/leverage/fixtures"
leveragetypes "github.com/umee-network/umee/v4/x/leverage/types"
oracletypes "github.com/umee-network/umee/v4/x/oracle/types"
Expand Down Expand Up @@ -75,6 +76,7 @@ type IntegrationTestSuite struct {
valResources []*dockertest.Resource
orchResources []*dockertest.Resource
gravityContractAddr string
umeeClient *client.UmeeClient
}

func TestIntegrationTestSuite(t *testing.T) {
Expand Down Expand Up @@ -129,6 +131,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.runIBCRelayer()
// s.runContractDeployment()
// s.runOrchestrators()
s.initUmeeClient()
}

func (s *IntegrationTestSuite) TearDownSuite() {
Expand Down Expand Up @@ -1034,6 +1037,18 @@ func (s *IntegrationTestSuite) runPriceFeeder() {
s.T().Logf("started price-feeder container: %s", s.priceFeederResource.Container.ID)
}

func (s *IntegrationTestSuite) initUmeeClient() {
var err error
s.umeeClient, err = client.NewUmeeClient(
s.chain.id,
"tcp://localhost:26657",
"tcp://localhost:9090",
"val1",
s.chain.validators[2].mnemonic,
)
s.Require().NoError(err)
}

func noRestart(config *docker.HostConfig) {
// in this case we don't want the nodes to restart on failure
config.RestartPolicy = docker.RestartPolicy{
Expand Down
31 changes: 18 additions & 13 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

appparams "github.com/umee-network/umee/v4/app/params"
"github.com/umee-network/umee/v4/tests/grpc"
"github.com/umee-network/umee/v4/tests/grpc/client"
)

func (s *IntegrationTestSuite) TestIBCTokenTransfer() {
Expand Down Expand Up @@ -142,29 +141,35 @@ func (s *IntegrationTestSuite) TestUmeeTokenTransfers() {
})
}

// TestHistorical queries for the oracle params, collects historical
// TestMedians queries for the oracle params, collects historical
// prices based on those params, checks that the stored medians and
// medians deviations are correct, updates the oracle params with
// a gov prop, then checks the medians and median deviations again.
func (s *IntegrationTestSuite) TestHistorical() {
umeeClient, err := client.NewUmeeClient(
s.chain.id,
"tcp://localhost:26657",
"tcp://localhost:9090",
"val1",
s.chain.validators[2].mnemonic,
)
func (s *IntegrationTestSuite) TestMedians() {
err := grpc.MedianCheck(s.umeeClient)
s.Require().NoError(err)
}

err = grpc.MedianCheck(umeeClient)
func (s *IntegrationTestSuite) TestUpdateOracleParams() {
params, err := s.umeeClient.QueryClient.QueryParams()
s.Require().NoError(err)

s.Require().Equal(uint64(5), params.HistoricStampPeriod)
s.Require().Equal(uint64(4), params.MaximumPriceStamps)
s.Require().Equal(uint64(20), params.MedianStampPeriod)

err = grpc.SubmitAndPassProposal(
umeeClient,
s.umeeClient,
grpc.OracleParamChanges(10, 2, 20),
)
s.Require().NoError(err)

err = grpc.MedianCheck(umeeClient)
params, err = s.umeeClient.QueryClient.QueryParams()
s.Require().NoError(err)

s.Require().Equal(uint64(10), params.HistoricStampPeriod)
s.Require().Equal(uint64(2), params.MaximumPriceStamps)
s.Require().Equal(uint64(20), params.MedianStampPeriod)

s.Require().NoError(err)
}

0 comments on commit fd3fd01

Please sign in to comment.