Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kurtosis testing for nimbus eth1 and eth2 #2281

Merged
merged 14 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: kurtosis local testing script
  • Loading branch information
advaita-saha committed Jun 2, 2024
commit 42ea85cfaf2c553f2b89ea8cc4f74c8a52579625
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/*
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http:https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http:https://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.

FROM debian:testing-slim AS build

SHELL ["/bin/bash", "-c"]

RUN apt-get clean && apt update \
&& apt -y install build-essential git-lfs librocksdb-dev libpcre3-dev
advaita-saha marked this conversation as resolved.
Show resolved Hide resolved

RUN ldd --version ldd

ADD . /root/nimbus-eth1

RUN cd /root/nimbus-eth1 \
&& make -j$(nproc) update \
&& make -j$(nproc) V=1 LOG_LEVEL=TRACE nimbus

# --------------------------------- #
# Starting new image to reduce size #
# --------------------------------- #
FROM debian:testing-slim as deploy

SHELL ["/bin/bash", "-c"]
RUN apt-get clean && apt update \
&& apt -y install build-essential librocksdb-dev libpcre3-dev
advaita-saha marked this conversation as resolved.
Show resolved Hide resolved
RUN apt update && apt -y upgrade

RUN ldd --version ldd

RUN rm -rf /home/user/nimbus-eth1/build/nimbus
advaita-saha marked this conversation as resolved.
Show resolved Hide resolved

COPY --from=build /root/nimbus-eth1/build/nimbus /home/user/nimbus-eth1/build/nimbus

ENV PATH="/home/user/nimbus-eth1/build:${PATH}"
ENTRYPOINT ["nimbus"]
WORKDIR /home/user/nimbus-eth1/build

STOPSIGNAL SIGINT
32 changes: 32 additions & 0 deletions assertoor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http:https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http:https://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.

participants:
- el_type: nimbus
el_image: localtestnet
el_extra_params: ["--log-level=DEBUG"]
cl_type: nimbus
cl_image: statusim/nimbus-eth2:multiarch-latest
cl_extra_params: ["--log-level=DEBUG;INFO:gossip_eth2,attpool,libp2p,gossipsub,pubsubpeer,pubsub,switch,networking,sync,dialer,identify,syncman,connmanager,beacnde,lightcl,requman,gossip_lc,clearance,lpstream,mplexchannel,nodes-verification,tcptransport,chaindag,noise,eth,p2p,discv5,muxedupgrade,multistream,connection,secure,fee_recipient,mplex,syncpool,multiaddress,peer_proto;WARN:message_router"]
use_separate_vc: false
additional_services:
- tx_spammer
- assertoor
- beacon_metrics_gazer
tx_spammer_params:
tx_spammer_extra_args: ["--accounts=1", "--txcount=1"]
mev_type: null
assertoor_params:
image: "ethpandaops/assertoor:master"
run_stability_check: true
run_block_proposal_check: true
run_transaction_test: true
run_blob_transaction_test: false
run_opcodes_transaction_test: true
32 changes: 32 additions & 0 deletions kurtosis-network-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http:https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http:https://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.

participants:
- el_type: nimbus
el_image: advaitanimbus/nimbus-builder-ci:master
advaita-saha marked this conversation as resolved.
Show resolved Hide resolved
el_extra_params: ["--log-level=DEBUG"]
cl_type: nimbus
cl_image: statusim/nimbus-eth2:multiarch-latest
cl_extra_params: ["--log-level=DEBUG;INFO:gossip_eth2,attpool,libp2p,gossipsub,pubsubpeer,pubsub,switch,networking,sync,dialer,identify,syncman,connmanager,beacnde,lightcl,requman,gossip_lc,clearance,lpstream,mplexchannel,nodes-verification,tcptransport,chaindag,noise,eth,p2p,discv5,muxedupgrade,multistream,connection,secure,fee_recipient,mplex,syncpool,multiaddress,peer_proto;WARN:message_router"]
use_separate_vc: false
additional_services:
- tx_spammer
- assertoor
- beacon_metrics_gazer
tx_spammer_params:
tx_spammer_extra_args: ["--accounts=1", "--txcount=1"]
mev_type: null
assertoor_params:
image: "ethpandaops/assertoor:master"
run_stability_check: true
run_block_proposal_check: true
run_transaction_test: true
run_blob_transaction_test: false
run_opcodes_transaction_test: true
191 changes: 191 additions & 0 deletions run-kurtosis-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#!/bin/bash

# Nimbus
# Copyright (c) 2018-2023 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http:https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http:https://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.

# Checking for docker installation
echo "Checking docker installation"
if command -v docker &> /dev/null; then
echo "Docker installation found"
else
echo "Docker installation not found. Please install docker."
exit 1
fi

# Install jq if not installed already
if [ "$(dpkg -l | awk '/jq/ {print }'|wc -l)" -ge 1 ]; then
advaita-saha marked this conversation as resolved.
Show resolved Hide resolved
echo "jq is already installed"
else
echo "Installing jq"
sudo apt-get install -y jq
fi

echo "Starting the Docker Build!"
# Build the docker Image
sudo docker build . -t localtestnet

# The new el_image value
new_el_image="localtestnet"

# Use sed to replace the el_image value in the file
cat kurtosis-network-params.yml | envsubst > assertoor.yaml
sed -i "s/el_image: .*/el_image: $new_el_image/" assertoor.yaml

sudo kurtosis run \
--enclave nimbus-localtestnet \
advaita-saha marked this conversation as resolved.
Show resolved Hide resolved
github.com/kurtosis-tech/ethereum-package \
--args-file assertoor.yaml

assertoor_url=$(echo "$enclave_dump" | grep assertoor | grep http | sed 's/.*\(http:\/\/[0-9.:]\+\).*/\1/')
advaita-saha marked this conversation as resolved.
Show resolved Hide resolved

enclave_dump=$(kurtosis enclave inspect nimbus-localtestnet)
assertoor_url=$(echo "$enclave_dump" | grep assertoor | grep http | sed 's/.*\(http:\/\/[0-9.:]\+\).*/\1/')
echo "Assertoor Checks Please Visit -> ${assertoor_url}"

YELLOW='\033[1;33m'
GRAY='\033[0;37m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'

# print assertor logs
assertoor_container=$(docker container list | grep assertoor | sed 's/^\([^ ]\+\) .*$/\1/')
docker logs -f $assertoor_container &

# helper to fetch task status for specific test id
get_tasks_status() {
tasks=$(curl -s ${assertoor_url}/api/v1/test_run/$1 | jq -c ".data.tasks[] | {index, parent_index, name, title, status, result}")
declare -A task_graph_map
task_graph_map[0]=""

while read task; do
task_id=$(echo "$task" | jq -r ".index")
task_parent=$(echo "$task" | jq -r ".parent_index")
task_name=$(echo "$task" | jq -r ".name")
task_title=$(echo "$task" | jq -r ".title")
task_status=$(echo "$task" | jq -r ".status")
task_result=$(echo "$task" | jq -r ".result")

task_graph="${task_graph_map[$task_parent]}"
task_graph_map[$task_id]="$task_graph |"
if [ ! -z "$task_graph" ]; then
task_graph="${task_graph}- "
fi

if [ "$task_status" == "pending" ]; then
task_status="${GRAY}pending ${NC}"
elif [ "$task_status" == "running" ]; then
task_status="${YELLOW}running ${NC}"
elif [ "$task_status" == "complete" ]; then
task_status="${GREEN}complete${NC}"
fi

if [ "$task_result" == "none" ]; then
task_result="${GRAY}none ${NC}"
elif [ "$task_result" == "success" ]; then
task_result="${GREEN}success${NC}"
elif [ "$task_result" == "failure" ]; then
task_result="${RED}failure${NC}"
fi

echo -e " $(printf '%-4s' "$task_id")\t$task_status\t$task_result\t$(printf '%-50s' "$task_graph$task_name") \t$task_title"
done <<< $(echo "$tasks")
}

# poll & check test status
final_test_result=""
failed_test_id=""
while true
do
pending_tests=0
failed_tests=0
total_tests=0
running_test=""

status_lines=()
task_lines=""
status_lines+=("$(date +'%Y-%m-%d %H:%M:%S') Test Status:")

tests=$(curl -s ${assertoor_url}/api/v1/test_runs | jq -c ".data[] | {run_id, test_id, name, status}")
while read test; do
if [ -z "$test" ]; then
continue
fi
run_id=$(echo "$test" | jq -r ".run_id")
test_id=$(echo "$test" | jq -r ".test_id")
test_name=$(echo "$test" | jq -r ".name")
test_status=$(echo "$test" | jq -r ".status")

if [ "$test_status" == "pending" ]; then
pending_tests=$(expr $pending_tests + 1)
status_name="${GRAY}pending${NC}"
elif [ "$test_status" == "running" ]; then
pending_tests=$(expr $pending_tests + 1)
running_test="$run_id"
status_name="${YELLOW}running${NC}"

elif [ "$test_status" == "success" ]; then
status_name="${GREEN}success${NC}"
elif [ "$test_status" == "failure" ]; then
failed_tests=$(expr $failed_tests + 1)
failed_test_id="$run_id"
status_name="${RED}failure${NC}"
else
status_name="$test_status"
fi
status_lines+=(" $(printf '%-3s' "$test_id") $status_name \t$test_name")
total_tests=$(expr $total_tests + 1)
done <<< $(echo "$tests")

for status_line in "${status_lines[@]}"
do
echo -e "$status_line"
done

if ! [ -z "$running_test" ]; then
task_lines=$(get_tasks_status "$running_test")
echo "Active Test Task Status:"
echo "$task_lines"
fi

if [ $failed_tests -gt 0 ]; then
final_test_result="failure"
break
fi
if [ $total_tests -gt 0 ] && [ $pending_tests -le 0 ]; then
final_test_result="success"
break
fi

sleep 60
done

# save test results & status to github output
echo "test_result=$(echo "$final_test_result")"
echo "test_status"
for status_line in "${status_lines[@]}"
do
echo -e "$status_line"
done
echo ""

if ! [ -z "$failed_test_id" ]; then
echo "failed_test_status"
get_tasks_status "$failed_test_id"
echo ""
else
echo "failed_test_status="
fi

# ------------------------------------------------
# Cleanup
# ------------------------------------------------
rm assertoor.yaml
sudo kurtosis enclave rm -f nimbus-localtestnet