forked from dockersamples/example-voting-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just run "docker-compose -f docker-compose.seed.yml up" to seed (you need to "docker-compose up -d" first)
- Loading branch information
1 parent
d1920ed
commit a33c638
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
seed: | ||
build: ./seed-data | ||
networks: | ||
- front-tier | ||
restart: "no" | ||
|
||
networks: | ||
front-tier: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:3.9-slim | ||
|
||
# add apache bench (ab) tool | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
apache2-utils \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /seed | ||
|
||
COPY . . | ||
|
||
# create POST data files with ab friendly formats | ||
RUN python make-data.py | ||
|
||
CMD /seed/generate-votes.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
# create 3000 votes (2000 for option a, 1000 for option b) | ||
ab -n 1000 -c 50 -p posta -T "application/x-www-form-urlencoded" http://vote/ | ||
ab -n 1000 -c 50 -p postb -T "application/x-www-form-urlencoded" http://vote/ | ||
ab -n 1000 -c 50 -p posta -T "application/x-www-form-urlencoded" http://vote/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# this creates urlencode-friendly files without EOL | ||
import urllib.parse | ||
|
||
outfile = open('postb', 'w') | ||
params = ({ 'vote': 'b' }) | ||
encoded = urllib.parse.urlencode(params) | ||
outfile.write(encoded) | ||
outfile.close() | ||
outfile = open('posta', 'w') | ||
params = ({ 'vote': 'a' }) | ||
encoded = urllib.parse.urlencode(params) | ||
outfile.write(encoded) | ||
outfile.close() |