File tree Expand file tree Collapse file tree 4 files changed +44
-0
lines changed Expand file tree Collapse file tree 4 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ services :
2
+ seed :
3
+ build : ./seed-data
4
+ networks :
5
+ - front-tier
6
+ restart : " no"
7
+
8
+ networks :
9
+ front-tier:
Original file line number Diff line number Diff line change
1
+ FROM python:3.9-slim
2
+
3
+ # add apache bench (ab) tool
4
+ RUN apt-get update \
5
+ && apt-get install -y --no-install-recommends \
6
+ apache2-utils \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ WORKDIR /seed
10
+
11
+ COPY . .
12
+
13
+ # create POST data files with ab friendly formats
14
+ RUN python make-data.py
15
+
16
+ CMD /seed/generate-votes.sh
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # create 3000 votes (2000 for option a, 1000 for option b)
4
+ ab -n 1000 -c 50 -p posta -T " application/x-www-form-urlencoded" http://vote/
5
+ ab -n 1000 -c 50 -p postb -T " application/x-www-form-urlencoded" http://vote/
6
+ ab -n 1000 -c 50 -p posta -T " application/x-www-form-urlencoded" http://vote/
Original file line number Diff line number Diff line change
1
+ # this creates urlencode-friendly files without EOL
2
+ import urllib .parse
3
+
4
+ outfile = open ('postb' , 'w' )
5
+ params = ({ 'vote' : 'b' })
6
+ encoded = urllib .parse .urlencode (params )
7
+ outfile .write (encoded )
8
+ outfile .close ()
9
+ outfile = open ('posta' , 'w' )
10
+ params = ({ 'vote' : 'a' })
11
+ encoded = urllib .parse .urlencode (params )
12
+ outfile .write (encoded )
13
+ outfile .close ()
You can’t perform that action at this time.
0 commit comments