-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathdatabox-test
executable file
·66 lines (53 loc) · 5.93 KB
/
databox-test
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
#!/bin/bash
#include helper functions
source ./scripts/utils.sh
function fail {
echo -e "[$( red FAILED )] ${1} \nERROR: ${2}"
#output debug information
echo "docker version:"
docker version
echo "docker ps \n"
docker ps
echo "docker image ls \n"
docker image ls
echo "docker service ls \n"
docker service ls
echo "service logs databox_container-manager \n"
docker service logs databox_container-manager
echo "\n"
exit 1
}
function success {
echo -e "[$( green OK )] $1"
}
#Start databox
export DATABOX_TESTING=1
source ./databox-start dev
echo "Sleeping...."
sleep 60
docker ps
#can we see the CM UI
STATUS=$(curl -sL -w "%{http_code}\\n" "http://127.0.0.1:8989/" -o /dev/null)
test_assert $STATUS 200 "Is core-container-manager available?"
#is the arbiter up
RES=$(curl -sL "http://127.0.0.1:8989/arbiter/status")
test_assert "$RES" "active" "Is the arbiter available?"
#is the arbiter /cat endpoint ok
EXPECTED='{"catalogue-metadata":[{"rel":"urn:X-hypercat:rels:isContentType","val":"application/vnd.hypercat.catalogue+json"},{"rel":"urn:X-hypercat:rels:hasDescription:en","val":"Databox Root Catalogue"},{"rel":"urn:X-hypercat:rels:hasHomepage","val":"http://www.databoxproject.uk/"},{"rel":"urn:X-hypercat:rels:containsContentType","val":"application/vnd.hypercat.catalogue+json"},{"rel":"urn:Xhypercat:rels:supportsSearch","val":"urn:X-hypercat:search:simple"}],"items":[]}'
RES=$(curl -sL "http://127.0.0.1:8989/arbiter/cat")
test_assert "$RES" "$EXPECTED" "Is the arbiter cat endpoint is ok?"
#can we install the OS monitor driver
PAYLOAD='{"manifest-version":1,"name":"driver-os-monitor","version":"0.1.0","description":"A Databox driver to monitor the local os","author":"Anthony Brown <Anthony.Brown@nottingham.ac.uk> ()","license":"MIT","databox-type":"driver","tags":["monitor","os"],"homepage":"https://github.com/me-box/driver-os-monitor","repository":{"type":"git","url":"git+https://github.com/me-box/driver-os-monitor.git"},"resource-requirements":{"store":"store-json"}}'
RES=$(curl -s -H 'Content-Type: application/json' -X POST -d "${PAYLOAD}" -L 'http://127.0.0.1:8989/api/install')
EXPECTED='{"status":200,"msg":"Success"}'
test_assert "$RES" "$EXPECTED" "Can we install the driver-os-monitor?"
#can we install the OS monitor app
PAYLOAD='{"manifest-version":1,"name":"app-os-monitor","databox-type":"app","version":"0.1.0","description":"An app in golang to plot the output of the os monitor driver.","author":"Tosh Brown <Anthony.Brown@nottingham.ac.uk>","license":"MIT","tags":["template","app","nodejs"],"homepage":"https://github.com/me-box/app-os-monitor","repository":{"type":"git","url":"git+https://github.com/me-box/app-os-monitor"},"packages":[{"name":"OS monitor Plotter","purpose":"To visualize your databox load and free memory","install":"required","risks":"None.","benefits":"You can see the data!","datastores":["loadavg1","loadavg5","loadavg15","freemem"],"enabled":true}],"allowed-combinations":[],"datasources":[{"type":"loadavg1","required":true,"name":"loadavg1","clientid":"loadavg1","granularities":[],"hypercat":{"item-metadata":[{"rel":"urn:X-hypercat:rels:hasDescription:en","val":"Databox load average 1 minuet"},{"rel":"urn:X-hypercat:rels:isContentType","val":"text/json"},{"rel":"urn:X-databox:rels:hasVendor","val":"Databox Inc."},{"rel":"urn:X-databox:rels:hasType","val":"loadavg1"},{"rel":"urn:X-databox:rels:hasDatasourceid","val":"loadavg1"},{"rel":"urn:X-databox:rels:hasStoreType","val":"store-json"},{"rel":"urn:X-databox:rels:hasUnit","val":"%"}],"href":"https://driver-os-monitor-store-json:8080/loadavg1"}},{"type":"loadavg5","required":true,"name":"loadavg5","clientid":"loadavg5","granularities":[],"hypercat":{"item-metadata":[{"rel":"urn:X-hypercat:rels:hasDescription:en","val":"Databox load average 5 minuets"},{"rel":"urn:X-hypercat:rels:isContentType","val":"text/json"},{"rel":"urn:X-databox:rels:hasVendor","val":"Databox Inc."},{"rel":"urn:X-databox:rels:hasType","val":"loadavg5"},{"rel":"urn:X-databox:rels:hasDatasourceid","val":"loadavg5"},{"rel":"urn:X-databox:rels:hasStoreType","val":"store-json"},{"rel":"urn:X-databox:rels:hasUnit","val":"%"}],"href":"https://driver-os-monitor-store-json:8080/loadavg5"}},{"type":"loadavg15","required":true,"name":"loadavg15","clientid":"loadavg15","granularities":[],"hypercat":{"item-metadata":[{"rel":"urn:X-hypercat:rels:hasDescription:en","val":"Databox load average 15 minuets"},{"rel":"urn:X-hypercat:rels:isContentType","val":"text/json"},{"rel":"urn:X-databox:rels:hasVendor","val":"Databox Inc."},{"rel":"urn:X-databox:rels:hasType","val":"loadavg15"},{"rel":"urn:X-databox:rels:hasDatasourceid","val":"loadavg15"},{"rel":"urn:X-databox:rels:hasStoreType","val":"store-json"},{"rel":"urn:X-databox:rels:hasUnit","val":"%"}],"href":"https://driver-os-monitor-store-json:8080/loadavg15"}},{"type":"freemem","required":true,"name":"freemem","clientid":"freemem","granularities":[],"hypercat":{"item-metadata":[{"rel":"urn:X-hypercat:rels:hasDescription:en","val":"Free memory in bytes"},{"rel":"urn:X-hypercat:rels:isContentType","val":"text/json"},{"rel":"urn:X-databox:rels:hasVendor","val":"Databox Inc."},{"rel":"urn:X-databox:rels:hasType","val":"freemem"},{"rel":"urn:X-databox:rels:hasDatasourceid","val":"freemem"},{"rel":"urn:X-databox:rels:hasStoreType","val":"store-json"},{"rel":"urn:X-databox:rels:hasUnit","val":"bytes"}],"href":"https://driver-os-monitor-store-json:8080/freemem"}}],"export-whitelist":[{"url":"https://export.amar.io/","description":"Exports the calculated sentiment to amar.io"}],"resource-requirements":{}}'
RES=$(curl -s -H 'Content-Type: application/json' -X POST -d "${PAYLOAD}" -L 'http://127.0.0.1:8989/api/install')
EXPECTED='{"status":200,"msg":"Success"}'
test_assert "$RES" "$EXPECTED" "Can we install the app-os-monitor?"
#is the OS monitor app up
sleep 30
STATUS=$(curl -sL -w "%{http_code}\\n" "http://127.0.0.1:8989/app-os-monitor/ui" -o /dev/null)
test_assert "$STATUS" 200 "Is the app-os-monitor/ui available?"
exit 0