From 73ce61b3db01aab9ebb4690f1b68e5fa41e6c6b4 Mon Sep 17 00:00:00 2001 From: Alex Yu Date: Thu, 6 Jun 2019 10:30:25 +0300 Subject: [PATCH] Integration scripts for skywire with public services Ported generic environment from skywire-services --- Makefile | 2 +- integration/generic/env-vars.sh | 22 +++++++++++ integration/generic/nodeA.json | 59 +++++++++++++++++++++++++++++ integration/generic/nodeC.json | 59 +++++++++++++++++++++++++++++ integration/intermediary-nodeB.json | 37 ++++++++++++++++++ integration/run-generic-env.sh | 23 +++++++++++ integration/startup.sh | 15 ++++++++ integration/tear-down.sh | 9 +++++ integration/test-messaging-loop.sh | 8 ++++ integration/test-messaging.sh | 4 ++ 10 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 integration/generic/env-vars.sh create mode 100644 integration/generic/nodeA.json create mode 100644 integration/generic/nodeC.json create mode 100644 integration/intermediary-nodeB.json create mode 100755 integration/run-generic-env.sh create mode 100755 integration/startup.sh create mode 100755 integration/tear-down.sh create mode 100755 integration/test-messaging-loop.sh create mode 100755 integration/test-messaging.sh diff --git a/Makefile b/Makefile index e4ccd2c55..7a551e942 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/integration/generic/env-vars.sh b/integration/generic/env-vars.sh new file mode 100644 index 000000000..756a09e74 --- /dev/null +++ b/integration/generic/env-vars.sh @@ -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 diff --git a/integration/generic/nodeA.json b/integration/generic/nodeA.json new file mode 100644 index 000000000..e984c6f48 --- /dev/null +++ b/integration/generic/nodeA.json @@ -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" + } +} diff --git a/integration/generic/nodeC.json b/integration/generic/nodeC.json new file mode 100644 index 000000000..0b9aa6136 --- /dev/null +++ b/integration/generic/nodeC.json @@ -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" + } +} diff --git a/integration/intermediary-nodeB.json b/integration/intermediary-nodeB.json new file mode 100644 index 000000000..8c8188ef0 --- /dev/null +++ b/integration/intermediary-nodeB.json @@ -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" + } +} diff --git a/integration/run-generic-env.sh b/integration/run-generic-env.sh new file mode 100755 index 000000000..97139c529 --- /dev/null +++ b/integration/run-generic-env.sh @@ -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 diff --git a/integration/startup.sh b/integration/startup.sh new file mode 100755 index 000000000..1ca41aa4c --- /dev/null +++ b/integration/startup.sh @@ -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 diff --git a/integration/tear-down.sh b/integration/tear-down.sh new file mode 100755 index 000000000..37c685dee --- /dev/null +++ b/integration/tear-down.sh @@ -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 diff --git a/integration/test-messaging-loop.sh b/integration/test-messaging-loop.sh new file mode 100755 index 000000000..97223bde1 --- /dev/null +++ b/integration/test-messaging-loop.sh @@ -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 diff --git a/integration/test-messaging.sh b/integration/test-messaging.sh new file mode 100755 index 000000000..524e15fd8 --- /dev/null +++ b/integration/test-messaging.sh @@ -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