-
Notifications
You must be signed in to change notification settings - Fork 19
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
add fixturenet-payments test #601
Open
iskay
wants to merge
2
commits into
main
Choose a base branch
from
iskay/fixturenet-payments-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Change this file to trigger running the fixturenet-payments-test CI job | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a trailing newline please.