Skip to content

Commit fa6d6d8

Browse files
authored
Merge pull request #11 from jancajthaml/feature/ci-perf-tests
perf workflow on host machine
2 parents 0783693 + d02707e commit fa6d6d8

File tree

2 files changed

+66
-6
lines changed

2 files changed

+66
-6
lines changed

.circleci/config.yml

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,54 @@ jobs:
3939
paths:
4040
- target/datadog_mock
4141

42+
performance:
43+
docker:
44+
- image: samueldebruyn/debian-git
45+
environment:
46+
- LANG: C.UTF-8
47+
- MESSAGE: "deploys.test.myservice:1|c"
48+
- EACH: ".0001"
49+
50+
working_directory: /app
51+
steps:
52+
- attach_workspace:
53+
at: /go/src/github.com/jancajthaml
54+
55+
- checkout
56+
57+
- run:
58+
name: Start perf tests
59+
command: |
60+
cp -r /go/src/github.com/jancajthaml/target/datadog_mock /app/server
61+
62+
duration=10
63+
64+
echo "will stream UDP event to server for $duration seconds"
65+
66+
spawn_producer() {
67+
(./dev/event-producer.sh &> /dev/null) & sleep $duration
68+
kill $! &> /dev/null || :
69+
}
70+
71+
spawn_server() {
72+
(/app/server &> log.txt) & sleep $(( $duration + 2 ))
73+
kill $! &> /dev/null || :
74+
}
75+
76+
calculate_results() {
77+
lines=$(wc -l log.txt | awk '{print $1}')
78+
average=$(($lines / $duration))
79+
echo "throughput $average / sec"
80+
}
81+
82+
trap 'exit 0' INT TERM
83+
84+
for i in $(seq 1 8); do
85+
spawn_producer &
86+
done
87+
spawn_server &&
88+
calculate_results
89+
4290
deploy:
4391
docker:
4492
- image: docker:17.09.0-ce-git
@@ -53,6 +101,11 @@ jobs:
53101
- checkout
54102
- setup_remote_docker
55103

104+
- run:
105+
name: Install Dependencies
106+
command: |
107+
apk --no-cache add curl
108+
56109
- run:
57110
name: Build application Docker image
58111
command: |
@@ -65,12 +118,18 @@ jobs:
65118
- deploy:
66119
name: Push image to DockerHUB
67120
command: |
68-
docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
69-
121+
echo ${DOCKER_PASSWORD}| docker login -u ${DOCKER_USER} --password-stdin
70122
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
71123
VERSION=$(git tag | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$" | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1)
72124
else
73-
VERSION="snapshot.${CIRCLE_SHA1}"
125+
parse_git_branch() {
126+
branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
127+
if [ -z "$branch" ]; then
128+
branch="snapshot.${CIRCLE_SHA1}"
129+
fi
130+
echo ${branch##*/}
131+
}
132+
VERSION="$(parse_git_branch)"
74133
fi
75134
76135
docker tag bundle "jancajthaml/datadog_mock:${VERSION}"
@@ -79,14 +138,16 @@ jobs:
79138
- deploy:
80139
name: Notifying microbadger to update badges
81140
command: |
82-
apk --no-cache add curl
83141
curl -X POST https://hooks.microbadger.com/images/jancajthaml/datadog_mock/${MICROBADGER_TOKEN}
84142
85143
workflows:
86144
version: 2
87-
test_and_deploy:
145+
validate_and_publish:
88146
jobs:
89147
- test
90148
- deploy:
91149
requires:
92150
- test
151+
- performance:
152+
requires:
153+
- test

dev/siege.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ trap "kill 0" EXIT
2020
MESSAGE="deploys.test.myservice:1|c" EACH=.0001 ./dev/event-producer.sh &> /dev/null &
2121
MESSAGE="deploys.test.myservice:2|c" EACH=.0001 ./dev/event-producer.sh &> /dev/null &
2222
MESSAGE="deploys.test.myservice:3|c" EACH=.0001 ./dev/event-producer.sh &> /dev/null &
23-
2423
docker rm -f $(docker ps -aq --filter="name=datadog" --filter="status=running") &> /dev/null || :
2524

2625
printf "processing [0 / sec]"

0 commit comments

Comments
 (0)