Skip to content

Commit

Permalink
update e2e to work with dev cli image
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMahe committed May 5, 2020
1 parent 6025ee5 commit 9760e71
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- run: docker swarm init
- <<: *restore_go_cache
- <<: *restore_go_path
- run: make e2e
- run: make e2e version=`echo $CIRCLE_SHA1 | cut -c1-7`
- <<: *save_go_path
- <<: *save_go_cache

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ build-docker-cli: check-version
build-docker-cli-dev: build-docker-cli
docker build -t mesg/engine:cli-dev -f ./Dockerfile.cli.dev --build-arg from=mesg/engine:cli .

e2e: docker-dev
e2e: build-docker-cli-dev
./scripts/run-e2e.sh

test: dep
Expand Down
9 changes: 3 additions & 6 deletions e2e/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/mesg-foundation/engine/app"
"github.com/mesg-foundation/engine/config"
"github.com/mesg-foundation/engine/container"
Expand Down Expand Up @@ -41,14 +40,14 @@ var (
lcd *cosmos.LCD
lcdEngine *cosmos.LCD
cliAddress sdk.AccAddress
cliInitialBalance, _ = sdk.ParseCoins("100000000000000000000000000atto")
)

const (
lcdEndpoint = "http://127.0.0.1:1317/"
pollingInterval = 500 * time.Millisecond // half a block
pollingTimeout = 10 * time.Second // 10 blocks
cliAccountMnemonic = "large fork soccer lab answer enlist robust vacant narrow please inmate primary father must add hub shy couch rail video tool marine pill give"
engineMnemonic = "neutral false together tattoo matrix stamp poem mouse chair chair grain pledge mandate layer shiver embark struggle vicious antenna total faith genre valley mandate"
cliAccountMnemonic = "spike raccoon obscure program raw large unaware dragon hamster round artist case fall wage sample velvet robust legend identify innocent film coral picture organ"
cliAccountName = "cli"
cliAccountPassword = "pass"
)
Expand Down Expand Up @@ -77,7 +76,7 @@ func TestAPI(t *testing.T) {
kb, err = cosmos.NewKeybase(filepath.Join(cfg.Path, cfg.Cosmos.RelativePath))
require.NoError(t, err)
// init engine account
engineAcc, err := kb.CreateAccount(cfg.Account.Name, cfg.Account.Mnemonic, "", cfg.Account.Password, keys.CreateHDPath(cfg.Account.Number, cfg.Account.Index).String(), cosmos.DefaultAlgo)
engineAcc, err := kb.CreateAccount(cfg.Account.Name, engineMnemonic, "", cfg.Account.Password, keys.CreateHDPath(cfg.Account.Number, cfg.Account.Index).String(), cosmos.DefaultAlgo)
require.NoError(t, err)
engineAddress = engineAcc.GetAddress()

Expand All @@ -89,8 +88,6 @@ func TestAPI(t *testing.T) {
// init LCD with engine account and make a transfer to cli account
lcdEngine, err = cosmos.NewLCD(lcdEndpoint, cdc, kb, cfg.DevGenesis.ChainID, cfg.Account.Name, cfg.Account.Password, cfg.Cosmos.MinGasPrices)
require.NoError(t, err)
_, err = lcdEngine.BroadcastMsg(bank.NewMsgSend(engineAddress, cliAddress, cliInitialBalance))
require.NoError(t, err)

// init container
cont, err = container.New(cfg.Name, cfg.Server.Address, cfg.Name)
Expand Down
8 changes: 0 additions & 8 deletions e2e/testdata/e2e.config.yml

This file was deleted.

34 changes: 22 additions & 12 deletions scripts/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@

set -e

export MESG_PATH="$(pwd)"/e2e.test/mesg

# first run non existing test to detect compilation error quickly
echo "run non existing test to detect compilation error quickly"
go test -mod=readonly -v -count=1 ./e2e/... -run=__NONE__

function onexit {
set +e
./scripts/dev.sh stop
rm -rf "${MESG_PATH}"
docker service rm engine
docker wait $(docker ps -f label=com.docker.swarm.service.name=engine -q) 2> /dev/null

docker network remove engine
}

trap onexit EXIT

rm -rf "${MESG_PATH}"
mkdir -p "${MESG_PATH}"
cp "$(pwd)"/e2e/testdata/e2e.config.yml "${MESG_PATH}"/config.yml

./scripts/dev.sh -q

if [[ -z $(docker network list -f name="engine" -q) ]]; then
docker network create --driver overlay engine
fi
docker service create \
--name engine \
-p 1317:1317 \
-p 50052:50052 \
-p 26657:26657 \
--network engine \
--label com.docker.stack.namespace=engine \
mesg/engine:cli-dev

echo "waiting to give some time to the container to start and run"
sleep 10 &
wait $!

echo "starting tests"
go test -failfast -mod=readonly -v -count=1 ./e2e/...

0 comments on commit 9760e71

Please sign in to comment.