forked from prymitive/karma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
32 lines (28 loc) · 1.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
DOCKER_NAME := alertmanager-karma-mock
DOCKER_IMAGE := prom/alertmanager
DOCKER_ARGS := --name $(DOCKER_NAME) --rm -d -p 9093:9093 \
-v $(CURDIR)/alertmanager.yml:/etc/alertmanager/config.yml \
-v $(CURDIR)/alertmanager.yml:/etc/alertmanager/alertmanager.yml
# list of Alertmanager versions to generate mock files for
VERSIONS := 0.4.0 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.6.2 0.7.0 0.7.1 0.8.0 0.9.0 0.9.1 0.10.0 0.11.0 0.12.0 0.13.0 0.14.0 0.15.0 0.15.1 0.15.2 0.15.3
%/.ok: livemock.py
$(eval VERSION := $(word 1, $(subst /, ,$@)))
@echo "Generating mock files for Alertmanager $(VERSION)"
docker pull $(DOCKER_IMAGE):v$(VERSION)
@docker rm -f $(DOCKER_NAME) > /dev/null 2>&1 || true
@echo "Starting Alertmanager"
docker run $(DOCKER_ARGS) $(DOCKER_IMAGE):v$(VERSION)
@sleep 15
@echo "Sending mock alerts and silences"
@python livemock.py
@mkdir -p $(CURDIR)/$(VERSION)/api/v1 $(CURDIR)/$(VERSION)/api/v1/alerts
@echo "Collecting API responses"
@curl --fail -s localhost:9093/metrics > $(CURDIR)/$(VERSION)/metrics
@curl --fail -s localhost:9093/api/v1/status | python -m json.tool > $(CURDIR)/$(VERSION)/api/v1/status
@curl --fail -s localhost:9093/api/v1/silences | python -m json.tool > $(CURDIR)/$(VERSION)/api/v1/silences
@curl --fail -s localhost:9093/api/v1/alerts/groups | python -m json.tool > $(CURDIR)/$(VERSION)/api/v1/alerts/groups
@touch $(VERSION)/.ok
@echo "Done"
.PHONY: all
all: $(foreach version, $(VERSIONS), $(version)/.ok)
.DEFAULT_GOAL := all