Skip to content

Commit

Permalink
Integration scripts for skywire with public services
Browse files Browse the repository at this point in the history
Ported generic environment from skywire-services
  • Loading branch information
ayuryshev committed Jun 6, 2019
1 parent 0c44e34 commit 73ce61b
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DEFAULT_GOAL := help
.PHONY : check lint install-linters dep test
.PHONY : build clean install format
.PHONY : build clean install format bin
.PHONY : host-apps bin
.PHONY : run stop config
.PHONY : docker-image docker-clean docker-network
Expand Down
22 changes: 22 additions & 0 deletions integration/generic/env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This script needs to be `source`d from bash-compatible shell
# E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/generic/env-vars.sh`
export PK_A=$(jq -r ".node.static_public_key" ./integration/generic/nodeA.json)
export RPC_A=$(jq -r ".interfaces.rpc" ./integration/generic/nodeA.json)
export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json)
export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json)
export PK_C=$(jq -r ".node.static_public_key" ./integration/generic/nodeC.json)
export RPC_C=$(jq -r ".interfaces.rpc" ./integration/generic/nodeC.json)

export CHAT_A=http://localhost:8000/message
export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/generic/nodeC.json)/message

alias CLI_A='./bin/skywire-cli --rpc $RPC_A'
alias CLI_B='./bin/skywire-cli --rpc $RPC_B'
alias CLI_C='./bin/skywire-cli --rpc $RPC_C'

echo PK_A: $PK_A
echo PK_B: $PK_B
echo PK_C: $PK_C

echo CHAT_A: $CHAT_A
echo CHAT_C: $CHAT_C
59 changes: 59 additions & 0 deletions integration/generic/nodeA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": "1.0",
"node": {
"static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845",
"static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c"
},
"messaging": {
"discovery": "https://messaging.discovery.skywire.skycoin.net",
"server_count": 1
},
"transport": {
"discovery": "https://transport.discovery.skywire.skycoin.net",
"log_store": {
"type": "file",
"location": "./local/nodeA/transport_logs"
}
},
"routing": {
"setup_nodes": [
"0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
],
"route_finder": "https://routefinder.skywire.skycoin.net/",
"table": {
"type": "boltdb",
"location": "./local/nodeA/routing.db"
}
},
"apps": [
{
"app": "skychat",
"version": "1.0",
"auto_start": true,
"port": 1,
"args": []
},
{
"app": "SSH",
"version": "1.0",
"auto_start": true,
"port": 2,
"args": []
},
{
"app": "socksproxy",
"version": "1.0",
"auto_start": true,
"port": 3,
"args": []
}
],
"trusted_nodes": [],
"manager_nodes": [],
"apps_path": "./apps",
"local_path": "./local/nodeA",
"log_level": "info",
"interfaces": {
"rpc": "localhost:3436"
}
}
59 changes: 59 additions & 0 deletions integration/generic/nodeC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": "1.0",
"node": {
"static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332",
"static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc"
},
"messaging": {
"discovery": "https://messaging.discovery.skywire.skycoin.net",
"server_count": 1
},
"transport": {
"discovery": "https://transport.discovery.skywire.skycoin.net",
"log_store": {
"type": "file",
"location": "./local/nodeC/transport_logs"
}
},
"routing": {
"setup_nodes": [
"0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
],
"route_finder": "https://routefinder.skywire.skycoin.net/",
"table": {
"type": "boltdb",
"location": "./local/nodeC/routing.db"
}
},
"apps": [
{
"app": "skychat",
"version": "1.0",
"auto_start": true,
"port": 1,
"args": ["-addr", ":8001"]
},
{
"app": "SSH-client",
"version": "1.0",
"auto_start": true,
"port": 12,
"args": []
},
{
"app": "socksproxy-client",
"version": "1.0",
"auto_start": true,
"port": 13,
"args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"]
}
],
"trusted_nodes": [],
"manager_nodes": [],
"apps_path": "./apps",
"local_path": "./local/nodeC",
"log_level": "info",
"interfaces": {
"rpc": "localhost:3438"
}
}
37 changes: 37 additions & 0 deletions integration/intermediary-nodeB.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": "1.0",
"node": {
"static_public_key": "0372ee0a2b99b55906ac33b49704073ab90ab4f395d814d48d597b5b42c39e5c79",
"static_secret_key": "5092f14fe18bd7dcd34479c5d26bb3bf68b708ec74a12c4557091e82dd6e6c36"
},
"messaging": {
"discovery": "https://messaging.discovery.skywire.skycoin.net",
"server_count": 1
},
"transport": {
"discovery": "https://transport.discovery.skywire.skycoin.net",
"log_store": {
"type": "file",
"location": "./local/nodeB/transport_logs"
}
},
"routing": {
"setup_nodes": [
"0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
],
"route_finder": "https://routefinder.skywire.skycoin.net/",
"table": {
"type": "boltdb",
"location": "./local/nodeB/routing.db"
}
},
"apps": [],
"trusted_nodes": [],
"manager_nodes": [],
"apps_path": "./bin/apps",
"local_path": "./local/localB",
"log_level": "info",
"interfaces": {
"rpc": "localhost:3435"
}
}
23 changes: 23 additions & 0 deletions integration/run-generic-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

## SKYWIRE

tmux new -s skywire -d

source ./integration/generic/env-vars.sh

echo "Checking transport-discovery is up"
curl --retry 5 --retry-connrefused 1 --connect-timeout 5 https://transport.discovery.skywire.skycoin.net/security/nonces/$PK_A

tmux rename-window -t skywire NodeA
tmux send-keys -t NodeA './skywire-node ./integration/generic/nodeA.json --tag NodeA' C-m
tmux new-window -t skywire -n NodeB
tmux send-keys -t NodeB './skywire-node ./integration/intermediary-nodeB.json --tag NodeB' C-m
tmux new-window -t skywire -n NodeC
tmux send-keys -t NodeC './skywire-node ./integration/generic/nodeC.json --tag NodeC' C-m

tmux new-window -t skywire -n shell

tmux send-keys -t shell 'source ./integration/generic/env-vars.sh' C-m

tmux attach -t skywire
15 changes: 15 additions & 0 deletions integration/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# Use this script:
# - inside tmux session created by run-*-env.sh scripts
# - or standalone `source ./integration/[name of environment]/env-vars.sh && ./integration/startup.sh`

./skywire-cli --rpc $RPC_A node add-tp $PK_B
./skywire-cli --rpc $RPC_C node add-tp $PK_B
sleep 1

echo "NodeA Transports:"
./skywire-cli --rpc $RPC_A node ls-tp

echo "NodeB Transports:"
./skywire-cli --rpc $RPC_B node ls-tp
9 changes: 9 additions & 0 deletions integration/tear-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# In case skywire-nodes are not stopped properly.
kill $(ps aux |grep "[N]odeA" |awk '{print $2}')
kill $(ps aux |grep "[N]odeB" |awk '{print $2}')
kill $(ps aux |grep "[N]odeC" |awk '{print $2}')

echo Removing ./local
rm -rf ./local
8 changes: 8 additions & 0 deletions integration/test-messaging-loop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
source ./integration/generic/env-vars.sh
echo "Press Ctrl-C to exit"
for ((;;))
do
curl --data {'"recipient":"'$PK_A'", "message":"Hello Joe!"}' -X POST $CHAT_C
curl --data {'"recipient":"'$PK_C'", "message":"Hello Mike!"}' -X POST $CHAT_A
done
4 changes: 4 additions & 0 deletions integration/test-messaging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
source ./integration/generic/env-vars.sh
curl --data {'"recipient":"'$PK_A'", "message":"Hello Joe!"}' -X POST $CHAT_C
curl --data {'"recipient":"'$PK_C'", "message":"Hello Mike!"}' -X POST $CHAT_A

0 comments on commit 73ce61b

Please sign in to comment.