summaryrefslogtreecommitdiff
path: root/blobs-multiprocess/run-test.sh
blob: dae557984c6864eb8f88a9c3c4675dd8bc28a9a1 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash

# Run Multiprocessing Test
# ========================
#

# This script measures the time of several interactions with the Blobs Server
# and outputs them to a text file.
#
# The different test scenarios are:
#   - 1, 2, 4, and 8 server processes.
#   - several client actions (baseline, list, put, get, flag, delete)
#   - 
#
# Client actions
# --------------

# Baseline: is a GET / to a dummy server that returns an empty reply. Nothing
# can be faster than this.

# List: is a GET /blobs/username, which lists the (empty) set of blobs stored
# in the server.

set -e


kill_multiproc() {
  pids=$(ps aux | grep python | grep "\(multiproc\|blobs-server\)" \
         | grep -v grep | sed -e "s/\s\+/ /g" | cut -d' ' -f 2)
  if [ ! -z "${pids}" ]; then
    for pid in ${pids}; do
      kill -9 ${pid}
    done
  fi
}


start_multiproc() {
  procs=${1}
  kill_multiproc
  make multiproc PROCS=${procs} > /dev/null &
  sleep 3
  make roundrobin PROCS=${procs}
  sleep 1
}


ab-get() {
  action=${1}
  procs=${2}
  amount=${3}
  size=${4}
  statement="make stress-get UUID=blob"
  python -c "import timeit; t = timeit.timeit('import os; os.system(\'${statement} > /dev/null\');', number=5); print t / 5"
  echo "${procs} ${action} ${amount} ${size} ${time}"
}


ab-baseline() {
  make ab-get URI=http://127.0.0.1:8000/
}


ab-put() {
  port=${1}
  if [ -z "${port}" ]; then port=8000; fi
  make ab-put URI=http://127.0.0.1:${port}/blobs/user/blob_id
}


ab-get() {
  make ab-get URI=http://127.0.0.1:8000/blobs/user/blob_id
}


ab-list() {
  make ab-get URI=http://127.0.0.1:8000/blobs/user/
}


ab-flag() {
  make ab-flag URI=http://127.0.0.1:8000/blobs/user/blob_id
}


ab-delete() {
  make ab-delete URI=http://127.0.0.1:8000/blobs/user/blob_id
}


run_test() {
  echo "" > results.txt
  #for procs in 1 2 4 8; do
  for procs in 1 2 3 4; do
    echo ":: Running tests for ${procs} proceesses..."

    # setup
    make clean
    make data SIZE=56
    start_multiproc ${procs}
    sleep 2

    echo ":::: Running baseline test..."
    result="${procs} baseline $(ab-baseline)"
    echo ${result}
    echo ${result} >> results.txt
    sleep 2
    #read temp

    echo ":::: Running put test..."
    result="${procs} put $(ab-put)"
    echo ${result}
    echo ${result} >> results.txt
    sleep 2
    #read temp

    # setup tests that depend on existence of blobs
    kill_multiproc
    make clean
    make kill-haproxy
    for port in 8001 8002 8003 8004; do
      echo ":::::: creating blobs prefixed with ${port}-..."
      make server PORT=${port} > /dev/null &!
      sleep 1
      ab-put ${port}
      #read temp
      make kill-server
    done
    sleep 2

    echo ":::: Running list test..."
    start_multiproc ${procs}
    result="${procs} list $(ab-list)"
    echo ${result}
    echo ${result} >> results.txt
    sleep 2

    echo ":::: Running flag test..."
    make flag
    result="${procs} flag $(ab-flag)"
    echo ${result}
    echo ${result} >> results.txt
    sleep 2

    echo ":::: Running get test..."
    kill_multiproc
    start_multiproc ${procs}
    result="${procs} get $(ab-get)"
    echo ${result}
    echo ${result} >> results.txt
    sleep 2

    echo ":::: Running delete test..."
    kill_multiproc
    start_multiproc ${procs}
    result="${procs} delete $(ab-delete)"
    echo ${result}
    echo ${result} >> results.txt
    kill_multiproc
  done
}


run_test