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

Run Smoke Tests in CI #1144

Merged
merged 54 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
655d289
adds dummy package
Feb 14, 2024
4a8cf37
print vars
Feb 14, 2024
3e50a1b
print vars
Feb 14, 2024
31da7f8
cd instead of pushdir
Feb 14, 2024
99765a1
cleanup script
Feb 14, 2024
a350a23
create dir
Feb 14, 2024
93109e6
try something else
Feb 14, 2024
634834e
relative path output bin dir
Feb 14, 2024
425e38a
fix config paths
Feb 14, 2024
0972a75
comment out things
Feb 14, 2024
c13244c
start lodestar
Feb 14, 2024
b445cd6
print out log
Feb 14, 2024
f00dd5b
print out log
Feb 14, 2024
b766c70
print out lodestar
Feb 14, 2024
d6cbb85
check geth version
Feb 14, 2024
c83538f
update geth version
Feb 14, 2024
89a88f4
remove commented out code
Feb 14, 2024
8135b0c
update go files
Feb 14, 2024
09948b0
adds smoketests
Feb 14, 2024
f4593bd
create dir
Feb 14, 2024
6aca13d
adjust scripts
Feb 14, 2024
ead4b35
permissions
Feb 14, 2024
d8d94bf
check script
Feb 14, 2024
ac8e78d
allow service to be down
Feb 14, 2024
0247b19
cleanup script
Feb 14, 2024
4f78144
last run, hopefully
Feb 15, 2024
08cfde7
fix tests
Feb 15, 2024
8ad77df
fixes
Feb 15, 2024
e7acfa5
fixes
Feb 15, 2024
fa5e58d
check lodestar
Feb 15, 2024
242620c
check lodestar
Feb 15, 2024
4594a8c
update geth
Feb 15, 2024
b1059ac
bump
Feb 15, 2024
d53e2fb
try again
Feb 15, 2024
7a1d64c
try again
Feb 15, 2024
25fec14
update go
Feb 16, 2024
4895da0
update go
Feb 16, 2024
4ac5c42
cleanup
Feb 16, 2024
83b8215
lodestar should run the background
Feb 16, 2024
3270b2d
tmp fixes
Feb 19, 2024
b37c74c
run init.sh
Feb 20, 2024
42cf054
check what happens with the download
Feb 20, 2024
075d610
change OS check
Feb 20, 2024
2a6775a
remove other steps to see what is happening
Feb 20, 2024
e3fa4a4
revert go modules version
Feb 20, 2024
1fbe37d
revert unnecessary changes
Feb 25, 2024
f46039a
remove http endpoint from relayer
Mar 4, 2024
4f162e8
update nightly, revert unrelated changes
Mar 4, 2024
a6affed
check rust version
Mar 4, 2024
93d7b3b
increase slot time
Mar 4, 2024
cc44889
increase block time check
Mar 4, 2024
17a1400
lower block check count
Mar 5, 2024
e4aac75
revert seconds per slot
Mar 5, 2024
6bd2886
revert printout
Mar 5, 2024
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
30 changes: 30 additions & 0 deletions relayer/cmd/run/beacon/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package beacon

import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -71,6 +73,10 @@ func run(_ *cobra.Command, _ []string) error {

eg, ctx := errgroup.WithContext(ctx)

eg.Go(func() error {
return startHttpServer(ctx)
})

// Ensure clean termination upon SIGINT, SIGTERM
eg.Go(func() error {
notify := make(chan os.Signal, 1)
Expand Down Expand Up @@ -102,3 +108,27 @@ func run(_ *cobra.Command, _ []string) error {

return nil
}

func startHttpServer(ctx context.Context) error {
srv := &http.Server{Addr: ":8080", Handler: nil}
claravanstaden marked this conversation as resolved.
Show resolved Hide resolved

http.HandleFunc("/beacon/health", healthCheckHandler)

go func() {
<-ctx.Done()
if err := srv.Shutdown(context.Background()); err != nil {
logrus.WithError(err).Error("beacon health check endpoint shutting down")
}
}()

logrus.Info("starting health check HTTP server on port 8080")
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
return fmt.Errorf("http server could not be started: %v", err)
}

return nil
}

func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
12 changes: 10 additions & 2 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -eux

echo "Checkout polkadot-sdk Snowfork fork"
pushd ..
Expand All @@ -21,8 +21,11 @@ echo "Setting up git hooks"
git config --local core.hooksPath hooks/

echo "Installing Rust nightly toolchain"
rustup default stable
rustup target add wasm32-unknown-unknown
rustup install --profile minimal $RUST_NIGHTLY_VERSION
rustup component add --toolchain $RUST_NIGHTLY_VERSION rustfmt
rustup show

echo "Installing sszgen"
go install github.com/ferranbt/fastssz/[email protected]
Expand All @@ -36,8 +39,13 @@ echo "Installing web packages"
echo "Download geth to replace the nix version"
OS=$(uname -s | tr A-Z a-z)
MACHINE_TYPE=$(uname -m | tr A-Z a-z)
if [ "$OS" == "linux" ]; then
MACHINE_TYPE="amd64"
fi
claravanstaden marked this conversation as resolved.
Show resolved Hide resolved

geth_package=geth-$OS-$MACHINE_TYPE-1.13.11-8f7eb9cc
curl https://gethstore.blob.core.windows.net/builds/$geth_package.tar.gz -o /tmp/geth.tar.gz
curl https://gethstore.blob.core.windows.net/builds/$geth_package.tar.gz -o /tmp/geth.tar.gz || { echo 'Download failed'; exit 1; }
mkdir -p $GOPATH/bin
tar -xvf /tmp/geth.tar.gz -C $GOPATH
cp $GOPATH/$geth_package/geth $GOPATH/bin
geth version
2 changes: 2 additions & 0 deletions web/packages/test/scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ build_binaries() {
echo "No changes detected in polkadot or substrate and binaries are available, not rebuilding relaychain binaries."
fi

mkdir -p "$output_bin_dir"

cp target/release/polkadot $output_bin_dir/polkadot
cp target/release/polkadot-execute-worker $output_bin_dir/polkadot-execute-worker
cp target/release/polkadot-prepare-worker $output_bin_dir/polkadot-prepare-worker
Expand Down
41 changes: 41 additions & 0 deletions web/packages/test/scripts/check-relayer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -eu

# Set a timeout of 40 minutes (2400 seconds)
timeout=2400
start_time=$(date +%s)

url="http://localhost:8080/beacon/health"
echo "checking start-services and relayer state"

while true; do
# Check if the timeout has been reached
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))

if [ $elapsed_time -ge $timeout ]; then
echo "Timeout reached. Exiting with error."
exit 1 # Exit with an error condition
fi

# Check if start-services.sh is still running
pgrep -f start-services.sh > /dev/null
if [ $? -ne 0 ]; then
echo "start-services.sh is not running. Exiting with error."
exit 1 # Exit with an error condition
fi

# Use curl to get the HTTP status code, trimming any trailing newlines
status_code=$(curl -o /dev/null -s -w "%{http_code}" "$url" || echo -n 000)
# Remove any trailing newlines or whitespace
status_code=$(echo -n "$status_code" | tr -d '\n')

# Check if the status code is 200
if [ "$status_code" -eq 200 ]; then
echo "Beacon relayer has started.."
exit 0
else
echo "Beacon relayer has not started yet. Waiting for 10 seconds."
sleep 10
fi
done
16 changes: 16 additions & 0 deletions web/packages/test/scripts/run-smoketests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eu

source scripts/set-env.sh

pushd $root_dir/smoketest

./make-bindings.sh
echo "run register token test"
cargo test --test register_token --release -- --nocapture
claravanstaden marked this conversation as resolved.
Show resolved Hide resolved
echo "run send token test"
cargo test --test send_token --release -- --nocapture
echo "run transfer token test"
cargo test --test transfer_token --release -- --nocapture

popd