Skip to content

Commit 8d7384e

Browse files
committed
CI integration
Quality Assurance (codacy), Continuous Improvements (circle) Coordinates (DockerHUB) integration
1 parent 11446b1 commit 8d7384e

File tree

264 files changed

+216
-148772
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+216
-148772
lines changed

.circleci/config.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
version: 2
2+
3+
jobs:
4+
test:
5+
docker:
6+
- image: circleci/golang:1.9
7+
8+
working_directory: /go/src/jancajthaml
9+
steps:
10+
- checkout
11+
12+
- run:
13+
name: Sync dependencies
14+
command: |
15+
go get -u github.com/kardianos/govendor
16+
govendor sync -v
17+
18+
- run:
19+
name: Run tests
20+
command: |
21+
cd /go/src/jancajthaml/src/datadog-mock
22+
go test -v ./...
23+
24+
- run:
25+
name: Build server
26+
command: |
27+
cd /go/src/jancajthaml/src/datadog-mock
28+
go clean
29+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/src/github.com/jancajthaml/target/datadog_mock
30+
31+
- persist_to_workspace:
32+
root: /go/src/github.com/jancajthaml
33+
paths:
34+
- target/datadog_mock
35+
36+
deploy:
37+
docker:
38+
- image: docker:17.05.0-ce-git
39+
40+
working_directory: /app
41+
steps:
42+
- attach_workspace:
43+
at: /go/src/github.com/jancajthaml
44+
45+
- checkout
46+
47+
- setup_remote_docker
48+
49+
- run:
50+
name: Build application Docker image
51+
command: |
52+
cp -r /go/src/github.com/jancajthaml/target /app/target
53+
docker build -t bundle .
54+
55+
- run:
56+
name: List images
57+
command: |
58+
docker images
59+
60+
- deploy:
61+
name: Push image to DockerHUB
62+
command: |
63+
docker login -e ${DOCKER_EMAIL} -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
64+
docker tag bundle "jancajthaml/datadog_mock:${CIRCLE_SHA1}"
65+
docker push "jancajthaml/datadog_mock:${CIRCLE_SHA1}"
66+
67+
workflows:
68+
version: 2
69+
test_and_deploy:
70+
jobs:
71+
- test
72+
- deploy:
73+
requires:
74+
- test

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
AUTHORS
1+
Jan Cajthaml <[email protected]>

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
All development activity takes place on github.
2+
3+
If you think you've discovered a bug, or you would like
4+
to make a feature request please do this through github.

ISSUE_TEMPLATE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
### Step 1: Are you in the right place?
2+
3+
* For issues or feature requests related to the code **in this repository** file a Github issue.
4+
* For general technical questions, post a question on [StackOverflow](http://stackoverflow.com/) tagged appropriately.
5+
6+
### Step 2: Describe the problem:
7+
8+
#### Steps to reproduce:
9+
10+
1. _____
11+
2. _____
12+
3. _____
13+
14+
#### Observed Results:
15+
16+
* What happened? This could be a description, log output, etc.
17+
18+
#### Expected Results:
19+
20+
* What did you expect to happen?
21+
22+
#### Relevant Code:
23+
24+
```
25+
// TODO(you): code here to reproduce the problem
26+
```

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ all: install test authors run
66
.PHONY: install
77
install: prepare-dev lint bundle
88

9+
.PHONY: perf
10+
perf:
11+
@./dev/siege.sh
12+
913
.PHONY: fmt
1014
fmt:
1115
docker-compose run --rm fmt

README.md

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
1-
# DataDog Server mock
1+
# datadog-mock #
22

3-
2MB golang server listening on port 8125 writing metrics to stdout.
3+
datadog-mock is a golang statsd mock server listening on port 8125 and relaying events to stdout.
44

5-
### Bootstrap
5+
[![Build Status](https://circleci.com/gh/jancajthaml/datadog-mock.svg?style=svg)](https://circleci.com/gh/jancajthaml/datadog-mock) [![Static Analysis](https://api.codacy.com/project/badge/Grade/c5c255a292f84cf88972f92f74f9174d)](https://www.codacy.com/app/jan-cajthaml/datadog-mock?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=jancajthaml/datadog-mock&amp;utm_campaign=Badge_Grade) [![Test Coverage](https://coveralls.io/repos/github/jancajthaml/datadog-mock/badge.svg?branch=master)](https://coveralls.io/github/jancajthaml/datadog-mock?branch=master)
66

7-
```
8-
make install
9-
make test
10-
```
7+
## Getting started ##
118

12-
### Running
9+
Bootstrap environment with `make install test` then grab `./target/datadog_mock`
10+
or docker image `datadog/mock`.
1311

14-
```
15-
make run
16-
```
12+
## Usage ##
1713

18-
or
14+
Run in docker with `make run` or `./target/datadog_mock` locally.
1915

20-
```
21-
docker run -it --log-driver none --rm -p 0.0.0.0:8125:8125/UDP datadog/mock
22-
```
16+
## Testing ##
2317

24-
or
18+
When datadog/mock is running you can either test simple relay
19+
`./dev/event-producer.sh` or siege with `make perf`.
2520

26-
```
27-
./target/datadog_mock
28-
```
29-
30-
31-
### Verify
32-
33-
When datadog/mock is running
34-
35-
```
36-
echo "deploys.test.myservice:1|c" > /dev/udp/127.0.0.1/8125
37-
```
38-
39-
or
40-
41-
```
42-
EACH=.001 ./dev/event-producer.sh
43-
```
21+
## License ##
4422

23+
This service is distributed under the Apache License, Version 2.0 license found
24+
in the [LICENSE](./LICENSE) file.

dev/event-producer.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#!/bin/bash
22

33
set -eo pipefail
4-
54
trap exit INT TERM
65

76
####
8-
sample="deploys.test.myservice:1|c"
97

10-
[ -z $EACH ] && EACH=2 || :
8+
if [ -z $EACH ]; then EACH=2; fi
9+
if [ -z $MESSAGE ]; then MESSAGE="deploys.test.myservice:1|c"; fi
1110

12-
printf "[info] sending \"%s\" every %ssec\n" $sample $EACH
11+
printf "[info] sending \"%s\" every %ssec\n" $MESSAGE $EACH
1312

1413
####
1514

1615
while true; do
17-
echo $sample > /dev/udp/127.0.0.1/8125
16+
echo $MESSAGE > /dev/udp/127.0.0.1/8125
1817
sleep $EACH
1918
done
2019

dev/siege.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
exec 3>&1 4>&2
6+
7+
post_stop() {
8+
exit_code=$?
9+
printf "\n"
10+
if [ -n "$error" ]; then
11+
printf "Error: %s\n" $error
12+
fi
13+
exec 3>&- 4>&-
14+
exit $exit_code
15+
}
16+
17+
trap post_stop INT TERM
18+
trap "kill 0" EXIT
19+
20+
MESSAGE="deploys.test.myservice:1|c" EACH=.0001 ./dev/event-producer.sh &> /dev/null &
21+
MESSAGE="deploys.test.myservice:2|c" EACH=.0001 ./dev/event-producer.sh &> /dev/null &
22+
MESSAGE="deploys.test.myservice:3|c" EACH=.0001 ./dev/event-producer.sh &> /dev/null &
23+
24+
docker rm -f $(docker ps -aq --filter="name=datadog" --filter="status=running") &> /dev/null || :
25+
26+
printf "processing [0 / sec]"
27+
28+
error=$( { (docker-compose run --rm --no-deps --service-ports artefact 2>&4 || :) | perl -e 'open(TTY, ">:unix", "/dev/tty");while (<>) {$l++;if (time > $e) {$e=time;print TTY "\rprocessing [$l / sec]";$l=0}}' 1>&3; } 2>&1 )

src/datadog-mock/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func main() {
2626
stream, err := net.ResolveUDPAddr("udp", ":8125")
2727

2828
if err != nil {
29-
fmt.Println("Fatal: %v", err)
29+
fmt.Println(err)
3030
os.Exit(1)
3131
}
3232

0 commit comments

Comments
 (0)