Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Jul 24, 2024
1 parent c0634c2 commit fc95005
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Test e2e
on:
push:
branches:
- main
- master
- develop
- update-external-dependencies
- 'release/**'
pull_request:

jobs:
test-e2e:
strategy:
fail-fast: false
matrix:
go-version: [ 1.21.x ]
goarch: [ "amd64" ]
e2e-group: [ "elderberry-validium", "elderberry-rollup" ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
env:
GOARCH: ${{ matrix.goarch }}

- name: Build Docker
run: make build-docker



- name: Test
run: make test-e2e-${{ matrix.e2e-group }}
working-directory: test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ RUN cd /src && make build
# CONTAINER FOR RUNNING BINARY
FROM alpine:3.18.4
COPY --from=build /src/dist/cdk /app/cdk
RUN apk update && apk add postgresql15-client
RUN mkdir /app/data && apk update && apk add postgresql15-client
EXPOSE 8123
CMD ["/bin/sh", "-c", "/app/cdk run"]
23 changes: 23 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: test-e2e-elderberry-validium
test-e2e-elderberry-validium: stop ## Runs e2e tests checking elderberry/validium
./run-e2e-seq_sender.sh cdk-validium

.PHONY: test-e2e-elderberry-rollup
test-e2e-elderberry-rollup: stop ## Runs e2e tests checking elderberry/rollup
./run-e2e-seq_sender.sh rollup

.PHONY: stop
stop:
kurtosis clean --all


## Help display.
## Pulls comments from beside commands and prints a nicely formatted
## display with the commands and their usage information.
.DEFAULT_GOAL := help

.PHONY: help
help: ## Prints this help
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
1 change: 1 addition & 0 deletions test/config/test.kurtosis_template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Level = "info"
Outputs = ["stderr"]

[SequenceSender]
IsValidiumMode={{.zkevm_is_validium}}
WaitPeriodSendSequence = "15s"
LastBatchVirtualizationTimeMaxWaitPeriod = "10s"
L1BlockTimestampMargin = "30s"
Expand Down
32 changes: 32 additions & 0 deletions test/run-e2e-seq_sender.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
source $(dirname $0)/scripts/env.sh
FORK=elderberry
DATA_AVAILABILITY_MODE=$1
if [ -z $DATA_AVAILABILITY_MODE ]; then
echo "Missing DATA_AVAILABILITY_MODE: ['rollup', 'cdk-validium']"
exit 1
fi
KURTOSIS_VERSION=jesteban/cdk-seq_sender
BASE_FOLDER=$(dirname $0)
KURTOSIS_FOLDER=$($BASE_FOLDER/scripts/get_kurtosis_clone_folder.sh $KURTOSIS_VERSION)
[ $? -ne 0 ] && echo "Error getting kurtosis folder" && exit 1

$BASE_FOLDER/scripts/clone_kurtosis.sh $KURTOSIS_VERSION "$KURTOSIS_FOLDER"
[ $? -ne 0 ] && echo "Error cloning kurtosis " && exit 1

docker images -q cdk:latest > /dev/null
if [ $? -ne 0 ] ; then
echo "Building cdk:latest"
pushd $BASE_FOLDER/..
make build-docker
popd
else
echo "docker cdk:latest already exists"
fi

$BASE_FOLDER/scripts/kurtosis_prepare_params_yml.sh "$KURTOSIS_FOLDER" "elderberry" "cdk-validium"
[ $? -ne 0 ] && echo "Error preparing params.yml" && exit 1

kurtosis clean --all
kurtosis run --enclave cdk-v1 --args-file $DEST_KURTOSIS_PARAMS_YML --image-download always $KURTOSIS_FOLDER
[ $? -ne 0 ] && echo "Error running kurtosis" && exit 1
31 changes: 31 additions & 0 deletions test/scripts/clone_kurtosis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
source $(dirname $0)/env.sh

usage() {
echo "Usage: $0 <kurtosis_version> <dest_folder>"
echo "Clones kurtosis-cdk version <kurtosis_version> to folder <dest_folder>"
}

KURTOSIS_CDK_URL="[email protected]:0xPolygon/kurtosis-cdk.git"
KURTOSIS_VERSION=$1
if [ -z $KURTOSIS_VERSION ]; then
echo "Missing param KURTOSIS_VERSION"
usage
exit 1
fi
DEST_FOLDER="$2"
if [ -z $DEST_FOLDER ]; then
echo "Missing param Destination Folder"
usage
exit 1
fi
if [ -d $DEST_FOLDER ]; then
echo "Folder $DEST_FOLDER already exists. No cloning needed"
pushd $DEST_FOLDER > /dev/null
echo "Pulling latest changes"
git pull
popd > /dev/null
exit 0
fi
echo "Cloning kurtosis-cdk version $KURTOSIS_VERSION to folder $DEST_FOLDER"
git clone --depth=1 $KURTOSIS_CDK_URL -b "$KURTOSIS_VERSION" "$DEST_FOLDER"
5 changes: 5 additions & 0 deletions test/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
### Common variables
ENCLAVE=cdk-v1
TMP_CDK_FOLDER=/tmp/cdk
DEST_KURTOSIS_PARAMS_YML=$TMP_CDK_FOLDER/e2e-params.yml
11 changes: 11 additions & 0 deletions test/scripts/get_kurtosis_clone_folder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
source $(dirname $0)/env.sh

KURTOSIS_VERSION=$1
if [ -z $KURTOSIS_VERSION ]; then
echo "KURTOSIS_VERSION is not set. Must be set on file env.sh"
exit 1
fi
KURTOSIS_VERSION_FOLDER_NAME=$(echo $KURTOSIS_VERSION | tr -c '[:alnum:]._-' '_')
DEST_FOLDER=$TMP_CDK_FOLDER/kurtosis-cdk-$KURTOSIS_VERSION_FOLDER_NAME
echo $DEST_FOLDER
35 changes: 35 additions & 0 deletions test/scripts/kurtosis_prepare_params_yml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
source $(dirname $0)/env.sh

if [ -z $DEST_KURTOSIS_PARAMS_YML ]; then
echo "DEST_KURTOSIS_PARAMS_YML is not set. Must be set on file env.sh"
exit 1
fi

KURTOSIS_FOLDER=$1
if [ -z $KURTOSIS_FOLDER ]; then
echo "Missing param Kurtosis Folder"
exit 1
fi

FORK_NAME=$2
if [ -z $FORK_NAME ]; then
echo "Missing param Fork Name"
exit 1
fi
DATA_AVAILABILITY_MODE=$3
if [ -z $DATA_AVAILABILITY_MODE ]; then
echo "Missing param Data Availability Mode : [rollup, cdk-validium]"
exit 1
fi




cp $KURTOSIS_FOLDER/cdk-erigon-sequencer-params.yml $DEST_KURTOSIS_PARAMS_YML
yq -Y --in-place ".args.data_availability_mode = \"$DATA_AVAILABILITY_MODE\"" $DEST_KURTOSIS_PARAMS_YML
yq -Y --in-place ".args.zkevm_sequence_sender_image = \"cdk:latest\"" $DEST_KURTOSIS_PARAMS_YML
yq -Y --in-place ".args.sequencer_type = \"erigon\"" $DEST_KURTOSIS_PARAMS_YML
yq -Y --in-place ".args.deploy_cdk_erigon_node = true" $DEST_KURTOSIS_PARAMS_YML
yq -Y --in-place ".args.sequencer_type = \"erigon\"" $DEST_KURTOSIS_PARAMS_YML
yq -Y --in-place ".args.sequencer_sender_type = \"cdk\"" $DEST_KURTOSIS_PARAMS_YML

0 comments on commit fc95005

Please sign in to comment.