Skip to content

Commit

Permalink
add script to run sandbox conductor and chc service concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
c12i committed Sep 12, 2024
1 parent a704319 commit 32f4077
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Smoke test - zome_call_single_value
run: |
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc-chc-service --port 8181 && sleep 1 | hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &"
nix develop .#ci -c bash -c "./scripts/run.sh"
# TODO using `localhost` is resolving to an IPv6 address, but why is that giving a connection refused?
# Run the scenario for 5 seconds
Expand All @@ -81,7 +81,7 @@ jobs:
- name: Smoke test - single_write_many_read
run: |
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc-chc-service --port 8181 && sleep 1 | hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &"
nix develop .#ci -c bash -c "./scripts/run.sh"
# Run the scenario for 5 seconds
RUST_LOG=info nix run .#single_write_many_read -- --connection-string ws://localhost:8888 --duration 5 --no-progress
Expand All @@ -91,7 +91,7 @@ jobs:
- name: Smoke test - dht_sync_lag
run: |
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc-chc-service --port 8181 && sleep 1 | hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &"
nix develop .#ci -c bash -c "./scripts/run.sh"
# Run the scenario for 5 seconds
RUST_LOG=info nix run .#dht_sync_lag -- --connection-string ws://localhost:8888 --agents 2 --behaviour write:1 --behaviour record_lag:1 --duration 5 --no-progress
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
- name: Smoke test - write_read
run: |
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc-chc-service --port 8181 && sleep 1 | hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &"
nix develop .#ci -c bash -c "./scripts/run.sh"
# Run the scenario for 5 seconds
RUST_LOG=info nix run .#write_read -- --connection-string ws://localhost:8888 --duration 5 --no-progress
Expand All @@ -131,7 +131,7 @@ jobs:
- name: Smoke test - write_query
run: |
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc-chc-service --port 8181 && sleep 1 | hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &"
nix develop .#ci -c bash -c "./scripts/run.sh"
# Run the scenario for 5 seconds
RUST_LOG=info nix run .#write_query -- --connection-string ws://localhost:8888 --duration 5 --no-progress
Expand All @@ -141,7 +141,7 @@ jobs:
- name: Smoke test - local_signals
run: |
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc-chc-service --port 8181 && sleep 1 | hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &"
nix develop .#ci -c bash -c "./scripts/run.sh"
# Run the scenario for 5 seconds
RUST_LOG=info nix run .#local_signals -- --connection-string ws://localhost:8888 --duration 5 --no-progress
Expand All @@ -151,7 +151,7 @@ jobs:
- name: Smoke test - write_validated
run: |
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc-chc-service --port 8181 && sleep 1 | hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &"
nix develop .#ci -c bash -c "./scripts/run.sh"
# Run the scenario for 5 seconds
RUST_LOG=info nix run .#write_validated -- --connection-string ws://localhost:8888 --duration 5 --no-progress
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# array to store background process PIDs
pids=()

# cleanup function
clean_up() {
echo "Cleaning up..."
for pid in "${pids[@]}"; do
kill "$pid" 2>/dev/null
done
exit
}

# set up trap for multiple signals
trap clean_up INT TERM

# start hc-chc-service
hc-chc-service --port 8181 &
pids+=($!)
sleep 1

# start hc-sandbox
hc s clean && echo "1234" | hc s --piped create --chc-url http://localhost:8181 && echo "1234" | hc s --piped -f 8888 run &
pids+=($!)

wait

0 comments on commit 32f4077

Please sign in to comment.