add fixturenet-payments test
This commit is contained in:
parent
ddebb9c690
commit
2b76be0f57
48
.gitea/workflows/fixturenet-payments-test.yml
Normal file
48
.gitea/workflows/fixturenet-payments-test.yml
Normal file
@ -0,0 +1,48 @@
|
||||
name: Fixturenet-Payments-Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: '*'
|
||||
paths:
|
||||
- '!**'
|
||||
- '.gitea/workflows/triggers/fixturenet-payments-test'
|
||||
|
||||
# Needed until we can incorporate docker startup into the executor container
|
||||
env:
|
||||
DOCKER_HOST: unix:///var/run/dind.sock
|
||||
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Run a payments fixturenet test"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Clone project repository"
|
||||
uses: actions/checkout@v3
|
||||
# At present the stock setup-python action fails on Linux/aarch64
|
||||
# Conditional steps below workaroud this by using deadsnakes for that case only
|
||||
- name: "Install Python for ARM on Linux"
|
||||
if: ${{ runner.arch == 'arm64' && runner.os == 'Linux' }}
|
||||
uses: deadsnakes/action@v3.0.1
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: "Install Python cases other than ARM on Linux"
|
||||
if: ${{ ! (runner.arch == 'arm64' && runner.os == 'Linux') }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: "Print Python version"
|
||||
run: python3 --version
|
||||
- name: "Install shiv"
|
||||
run: pip install shiv
|
||||
- name: "Generate build version file"
|
||||
run: ./scripts/create_build_tag_file.sh
|
||||
- name: "Build local shiv package"
|
||||
run: ./scripts/build_shiv_package.sh
|
||||
- name: Start dockerd # Also needed until we can incorporate into the executor
|
||||
run: |
|
||||
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
||||
sleep 5
|
||||
- name: "Run fixturenet-payments tests"
|
||||
run: ./tests/fixturenet-payments/run-test.sh
|
||||
|
2
.gitea/workflows/triggers/fixturenet-payments-test
Normal file
2
.gitea/workflows/triggers/fixturenet-payments-test
Normal file
@ -0,0 +1,2 @@
|
||||
Change this file to trigger running the fixturenet-payments-test CI job
|
||||
|
29
.github/workflows/fixturenet-payments.yml
vendored
Normal file
29
.github/workflows/fixturenet-payments.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: Fixturenet-Payments Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: '*'
|
||||
push:
|
||||
branches: '*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Run basic test suite"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Clone project repository"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Install Python"
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: "Print Python version"
|
||||
run: python3 --version
|
||||
- name: "Install shiv"
|
||||
run: pip install shiv
|
||||
- name: "Generate build version file"
|
||||
run: ./scripts/create_build_tag_file.sh
|
||||
- name: "Build local shiv package"
|
||||
run: ./scripts/build_shiv_package.sh
|
||||
- name: "Run fixturenet-payments tests"
|
||||
run: ./tests/fixturenet-payments/run-test.sh
|
105
tests/fixturenet-payments/run-test.sh
Executable file
105
tests/fixturenet-payments/run-test.sh
Executable file
@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
echo "$(date +"%Y-%m-%d %T"): Running stack-orchestrator Payments stack fixturenet test"
|
||||
# Bit of a hack, test the most recent package
|
||||
TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 )
|
||||
# Set a new unique repo dir
|
||||
export CERC_REPO_BASE_DIR=$(mktemp -d stack-orchestrator-fixturenet-payments-test.XXXXXXXXXX)
|
||||
echo "$(date +"%Y-%m-%d %T"): Testing this package: $TEST_TARGET_SO"
|
||||
echo "$(date +"%Y-%m-%d %T"): Test version command"
|
||||
reported_version_string=$( $TEST_TARGET_SO version )
|
||||
echo "$(date +"%Y-%m-%d %T"): Version reported is: ${reported_version_string}"
|
||||
echo "$(date +"%Y-%m-%d %T"): Cloning repositories into: $CERC_REPO_BASE_DIR"
|
||||
$TEST_TARGET_SO --stack fixturenet-payments setup-repositories --pull
|
||||
echo "$(date +"%Y-%m-%d %T"): Building containers"
|
||||
$TEST_TARGET_SO --stack fixturenet-payments build-containers
|
||||
echo "$(date +"%Y-%m-%d %T"): Starting stack"
|
||||
$TEST_TARGET_SO --stack fixturenet-payments deploy --cluster payments up
|
||||
echo "$(date +"%Y-%m-%d %T"): Stack started"
|
||||
# Verify that the fixturenet is up and running
|
||||
$TEST_TARGET_SO --stack fixturenet-payments deploy --cluster payments ps
|
||||
|
||||
# get watcher payments channel id
|
||||
timeout=600 # 10 minutes
|
||||
echo "$(date +"%Y-%m-%d %T"): Waiting for watcher payment channel id. Timeout set to $timeout seconds"
|
||||
start_time=$(date +%s)
|
||||
elapsed_time=0
|
||||
while [ -z "$WATCHER_UPSTREAM_PAYMENT_CHANNEL" ] && [ $elapsed_time -lt $timeout ]; do
|
||||
sleep 10
|
||||
echo "$(date +"%Y-%m-%d %T"): Waiting for channel..."
|
||||
WATCHER_UPSTREAM_PAYMENT_CHANNEL=$(docker logs $(docker ps -aq --filter name="mobymask-watcher-server") 2>&1 | \
|
||||
grep "payment channel created with id" | \
|
||||
grep -o '0x[0-9a-fA-F]\+') \
|
||||
|| true
|
||||
current_time=$(date +%s)
|
||||
elapsed_time=$((current_time - start_time))
|
||||
done
|
||||
|
||||
echo "Watcher payment channel id: $WATCHER_UPSTREAM_PAYMENT_CHANNEL"
|
||||
|
||||
sleep 120
|
||||
|
||||
# check watcher payment channel status. Expected result: 'Open'
|
||||
timeout=600 # 10 minutes
|
||||
echo "$(date +"%Y-%m-%d %T"): Querying watcher payment channel status. Timeout set to $timeout seconds"
|
||||
start_time=$(date +%s)
|
||||
elapsed_time=0
|
||||
query="Status:"
|
||||
while [ -z "$watcher_query_result" ] && [ $elapsed_time -lt $timeout ]; do
|
||||
sleep 10
|
||||
echo "$(date +"%Y-%m-%d %T"): Waiting for channel..."
|
||||
watcher_query_result=$(docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $WATCHER_UPSTREAM_PAYMENT_CHANNEL -s false -h ipld-eth-server-1 -p 4005" | \
|
||||
grep "$query" | \
|
||||
grep -o "'.*'") \
|
||||
|| true
|
||||
current_time=$(date +%s)
|
||||
elapsed_time=$((current_time - start_time))
|
||||
done
|
||||
|
||||
# run ponder indexer to get ponder payment channel id
|
||||
timeout=600 # 10 minutes
|
||||
echo "$(date +"%Y-%m-%d %T"): Starting Ponder indexer and waiting for payment channel id. Timeout set to $timeout seconds"
|
||||
start_time=$(date +%s)
|
||||
elapsed_time=0
|
||||
docker exec -itd payments-ponder-app-indexer-1-1 bash -c "DEBUG=laconic:payments pnpm start > /output.log 2>&1"
|
||||
while [ -z "$PONDER_UPSTREAM_PAYMENT_CHANNEL" ] && [ $elapsed_time -lt $timeout ]; do
|
||||
sleep 10
|
||||
echo "$(date +"%Y-%m-%d %T"): Waiting for channel id..."
|
||||
PONDER_UPSTREAM_PAYMENT_CHANNEL=$(docker exec payments-ponder-app-indexer-1-1 bash -c "grep 'Using payment channel' /output.log" | grep -o '0x[0-9a-fA-F]\+' || true)
|
||||
current_time=$(date +%s)
|
||||
elapsed_time=$((current_time - start_time))
|
||||
done
|
||||
|
||||
echo "Ponder payment channel id: $PONDER_UPSTREAM_PAYMENT_CHANNEL"
|
||||
|
||||
if [[ -z "$PONDER_UPSTREAM_PAYMENT_CHANNEL" ]]; then
|
||||
echo "Ponder payment channel id not found."
|
||||
ponder_query_result=0
|
||||
else
|
||||
echo "Ponder payment channel id: $PONDER_UPSTREAM_PAYMENT_CHANNEL"
|
||||
# query ponder payment channel, Expected result: PaidSoFar is nonzero
|
||||
query="PaidSoFar"
|
||||
ponder_query_result=$(docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $PONDER_UPSTREAM_PAYMENT_CHANNEL -s false -h go-nitro -p 4006" | \
|
||||
grep "$query" | \
|
||||
grep -o '[0-9]\+') \
|
||||
|| true
|
||||
fi
|
||||
|
||||
if [[ "$watcher_query_result" == "'Open'" && "$ponder_query_result" -gt 0 ]]; then
|
||||
echo "Test passed"
|
||||
test_result=0
|
||||
else
|
||||
echo "Test failed: watcher_query_result was $watcher_query_result and ponder_query_result was $ponder_query_result"
|
||||
echo "Logs from stack:"
|
||||
$TEST_TARGET_SO --stack fixturenet-payments deploy logs
|
||||
test_result=1
|
||||
fi
|
||||
$TEST_TARGET_SO --stack fixturenet-payments deploy --cluster payments down 30 --delete-volumes
|
||||
echo "$(date +"%Y-%m-%d %T"): Removing cloned repositories"
|
||||
rm -rf $CERC_REPO_BASE_DIR
|
||||
echo "$(date +"%Y-%m-%d %T"): Test finished"
|
||||
exit $test_result
|
Loading…
Reference in New Issue
Block a user