#!/bin/bash set -ex go build -o ./chord-node # Test create and join. ./chord-node join -ip 127.0.0.1:3000 & FIRST=$! sleep 3.25 ./chord-node join -ip 127.0.0.1:3001 -c 127.0.0.1:3000 & SECOND=$! sleep 0.25 ./chord-node join -ip 127.0.0.1:3002 -c 127.0.0.1:3000 & THIRD=$! sleep 5 # Each node logs its predecessor and successors. At this point, we see the ring. # Test lookup. # First check that the lookup is independent of the node we ask. ./chord-node lookup -k key1 -n 127.0.0.1:3000 ./chord-node lookup -k key1 -n 127.0.0.1:3001 ./chord-node lookup -k key1 -n 127.0.0.1:3002 # Now check that we get some different nodes for different keys. ./chord-node lookup -k key2 -n 127.0.0.1:3000 ./chord-node lookup -k key3 -n 127.0.0.1:3000 # Test data storage. ./chord-node put -k key1 -v value1 -n 127.0.0.1:3000 ./chord-node get -k key1 -n 127.0.0.1:3000 ./chord-node put -k key1 -v value2 -n 127.0.0.1:3001 ./chord-node get -k key1 -n 127.0.0.1:3002 # Test leaving. ./chord-node leave -n 127.0.0.1:3000 echo "NOTE: An ERROR line about the HTTP API server closing is expected." kill $FIRST $SECOND $THIRD