Skip to content

Commit 615d49b

Browse files
committed
better Makefile, shielded badges
1 parent 694d856 commit 615d49b

File tree

265 files changed

+211
-148778
lines changed

Some content is hidden

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

265 files changed

+211
-148778
lines changed

.circleci/config.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
go get -u golang.org/x/tools/cmd/cover
17+
go get -u github.com/mattn/goveralls
18+
govendor sync -v
19+
20+
- run:
21+
name: Run tests
22+
command: |
23+
cd /go/src/jancajthaml/src/datadog-mock
24+
: > /go/src/jancajthaml/coverage.txt
25+
go test -v -cover -race -coverprofile=/go/src/jancajthaml/coverage.txt -covermode=atomic ./...
26+
goveralls -coverprofile=/go/src/jancajthaml/coverage.txt -service=circle-ci -repotoken=$COVERALLS_TOKEN
27+
28+
- run:
29+
name: Build server
30+
command: |
31+
cd /go/src/jancajthaml/src/datadog-mock
32+
go clean
33+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/src/github.com/jancajthaml/target/datadog_mock
34+
35+
- persist_to_workspace:
36+
root: /go/src/github.com/jancajthaml
37+
paths:
38+
- target/datadog_mock
39+
40+
deploy:
41+
docker:
42+
- image: docker:17.05.0-ce-git
43+
44+
working_directory: /app
45+
steps:
46+
- attach_workspace:
47+
at: /go/src/github.com/jancajthaml
48+
49+
- checkout
50+
51+
- setup_remote_docker
52+
53+
- run:
54+
name: Build application Docker image
55+
command: |
56+
cp -r /go/src/github.com/jancajthaml/target /app/target
57+
docker build \
58+
--build-arg VERSION=$(cat VERSION) \
59+
--build-arg VCS_REF=${CIRCLE_SHA1} \
60+
--build-arg VCS_URL=$(git config --get remote.origin.url) \
61+
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
62+
-t bundle .
63+
64+
- run:
65+
name: List images
66+
command: |
67+
docker images
68+
69+
- deploy:
70+
name: Push image to DockerHUB
71+
command: |
72+
docker login -e ${DOCKER_EMAIL} -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
73+
docker tag bundle "jancajthaml/datadog_mock:${CIRCLE_SHA1}"
74+
docker push "jancajthaml/datadog_mock:${CIRCLE_SHA1}"
75+
76+
workflows:
77+
version: 2
78+
test_and_deploy:
79+
jobs:
80+
- test
81+
- deploy:
82+
requires:
83+
- 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/

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ FROM scratch
1616

1717
MAINTAINER Jan Cajthaml <[email protected]>
1818

19+
ARG BUILD_DATE
20+
ARG VCS_REF
21+
ARG VERSION
22+
LABEL org.label-schema.build-date=$BUILD_DATE \
23+
org.label-schema.name="datadog-mock" \
24+
org.label-schema.description="DataDog mock service Edit" \
25+
org.label-schema.vcs-ref=$VCS_REF \
26+
org.label-schema.vcs-url="https://github.com/jancajthaml/datadog-mock" \
27+
org.label-schema.vendor="Jan Cajthaml" \
28+
org.label-schema.version=$VERSION \
29+
org.label-schema.schema-version="1.0"
30+
1931
COPY target/datadog_mock /datadog_mock
2032

2133
EXPOSE 8125/UDP

ISSUE_TEMPLATE.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
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-
141
#### Observed Results:
152

163
* What happened? This could be a description, log output, etc.

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@ all: install test authors run
66
.PHONY: install
77
install: prepare-dev lint bundle
88

9+
.PHONY: clean
10+
clean:
11+
@docker images | \
12+
grep -i "^datadog/dev" | \
13+
awk '{ print $$3 }' | \
14+
xargs -P$(CORES) -I{} docker rmi -f {} 2> /dev/null || :
15+
16+
.PHONY: perf
17+
perf:
18+
@./dev/siege.sh
19+
920
.PHONY: fmt
1021
fmt:
1122
docker-compose run --rm fmt
1223

1324
.PHONY: sync
1425
sync:
15-
docker-compose run --rm fetch
1626
docker-compose run --rm sync
1727

1828
.PHONY: lint

README.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
1-
# DataDog Server mock
1+
# datadog-mock #
22

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

5-
### Bootstrap
5+
[![Docker Version](https://images.microbadger.com/badges/version/jancajthaml/datadog_mock.svg)](https://microbadger.com/images/jancajthaml/datadog_mock)
6+
[![Build Status](https://circleci.com/gh/jancajthaml/datadog-mock.svg?style=shield)](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)
67

7-
Require docker to assembly
8+
## Getting started ##
89

9-
`make install test`
10+
Bootstrap environment with `make install test` then grab `./target/datadog_mock`
11+
or docker image `datadog/mock`.
1012

11-
### Running
13+
## Usage ##
1214

13-
automagically
15+
Run in docker with `make run` or `./target/datadog_mock` locally.
1416

15-
`make run`
17+
## Testing ##
1618

17-
run in docker
19+
When datadog/mock is running you can either test simple relay
20+
`./dev/event-producer.sh` or siege with `make perf`.
1821

19-
`docker run -it --log-driver none --rm -p 0.0.0.0:8125:8125/UDP datadog/mock`
20-
21-
run on host
22-
23-
`./target/datadog_mock`
24-
25-
26-
### Verify
27-
28-
When datadog/mock is running run manually
29-
30-
`echo "deploys.test.myservice:1|c" > /dev/udp/127.0.0.1/8125`
31-
32-
or send MESSAGE repeat EACH second
33-
34-
`MESSAGE="deploys.test.myservice:1|c" EACH=.001 ./dev/event-producer.sh`
22+
## License ##
3523

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

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

dev/event-producer.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/bin/bash
22

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

76
####
87

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

1211
printf "[info] sending \"%s\" every %ssec\n" $MESSAGE $EACH
1312

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 )

0 commit comments

Comments
 (0)