-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-auto.sh
More file actions
executable file
·88 lines (72 loc) · 2.26 KB
/
test-auto.sh
File metadata and controls
executable file
·88 lines (72 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
cleanup() {
echo "Cleaning up..."
if [[ -n "$consumer_pid" ]]; then
kill -SIGTERM "$consumer_pid" 2>/dev/null
fi
if [[ -n "$provider_pid" ]]; then
kill -SIGTERM "$provider_pid" 2>/dev/null
fi
}
./cloudpipe consumer &
consumer_pid=$!
echo "Consumer process started with PID $consumer_pid"
./cloudpipe provider &
provider_pid=$!
echo "Provider process started with PID $provider_pid"
trap cleanup EXIT
sleep 1
consumer=http://localhost:8000
provider=http://localhost:8001
# create the frontend pipe
curl -X POST -u foo:bar $consumer/frontend/pipes -H "Content-Type: application/json" -d '
{
"id":"backend",
"this": {
"data": {"frontend-data": "foo"}
},
"other": {
"uri":"http://localhost:8001/backend/pipes/frontend",
"Issuer":"http://localhost:8001"
}
}
'
# create the backend pipe
curl -X POST -u foo:bar $provider/backend/pipes -H "Content-Type: application/json" -d '
{
"id":"frontend",
"this": {
"data": {"URI": "https://backend.herokuapp.com"}
},
"other": {
"uri":"http://localhost:8000/frontend/pipes/backend",
"Issuer":"http://localhost:8000"
}
}
'
sleep 1
# view the pipes
curl -s -u foo:bar $consumer/frontend/pipes/backend | jq '.this.data, .other.data'
curl -s -u foo:bar $provider/backend/pipes/frontend | jq '.this.data, .other.data'
euri=`curl -s -u foo:bar $provider/backend/pipes/frontend | jq -r .this.data.URI`
uri=`curl -s -u foo:bar $consumer/frontend/pipes/backend | jq -r .other.data.URI`
if [ "$euri" != "$uri" ]; then
echo "URIs don't match: '$euri' != '$uri'"
exit 1
fi
# validate that the data is updated when the underlying platform changes
kill -INFO $provider_pid
sleep 1
curl -s -u foo:bar $consumer/frontend/pipes/backend | jq '.this.data, .other.data'
curl -s -u foo:bar $provider/backend/pipes/frontend | jq '.this.data, .other.data'
euri=`curl -s -u foo:bar $provider/backend/pipes/frontend | jq -r .this.data.URI`
uri=`curl -s -u foo:bar $consumer/frontend/pipes/backend | jq -r .other.data.URI`
if [ "$euri" != "$uri" ]; then
echo "URIs don't match: '$euri' != '$uri'"
exit 1
fi
euri=https://updated.herokuapp.com
if [ "$euri" != "$uri" ]; then
echo "URIs don't match: '$euri' != '$uri'"
exit 1
fi