-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
106 lines (91 loc) · 2.9 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
GOCMD = go
GOTESTCMD = $(if $(shell command -v gotestsum),gotestsum --junitfile ./test_results/$(1).xml --format testname --,go test)
.PHONY: test
#: run all tests
test: test_with_race test_all
.PHONY: test_with_race
#: run only tests tagged with potential race conditions
test_with_race: test_results
@echo
@echo "+++ testing - race conditions?"
@echo
$(call GOTESTCMD,$@) -tags race --race --timeout 60s -v ./...
.PHONY: test_all
#: run all tests, but with no race condition detection
test_all: test_results
@echo
@echo "+++ testing - all the tests"
@echo
$(call GOTESTCMD,$@) -tags all --timeout 60s -v ./...
test_results:
@mkdir -p test_results
tidy:
$(GOCMD) mod tidy
TEMPLATE ?= pkg/config/templates/emathroughput
.PHONY: test_template
#: generate config from template (usage: make test_template TEMPLATE=pkg/config/templates/proxy)
test_template:
@echo
@echo "+++ generating config from template $(TEMPLATE)"
@echo
./testTemplate.sh $(TEMPLATE)
CONFIG ?= examples/hpsf.yaml
.PHONY: validate
#: validate provided config (usage: make validate CONFIG=examples/hpsf2.yaml)
validate:
@echo
@echo "+++ validating config $(CONFIG)"
@echo
go run ./cmd/hpsf -i $(CONFIG) validate
for format in rConfig rRules cConfig ; do \
echo; \
echo "+++ validating config generation for $${format} with config $(CONFIG)"; \
echo; \
go run ./cmd/hpsf -i $(CONFIG) $${format} || exit 1; \
done
.PHONY: validate_all
validate_all: examples/hpsf* pkg/data/templates/*
for file in $^ ; do \
$(MAKE) validate CONFIG=$${file} || exit 1; \
done
.PHONY: .smoke_refinery
#: run smoke test for refinery component
#: Do not use directly, use the smoke target instead
.smoke_refinery:
if [ -z "$(FILE)" ]; then \
echo "+++ no component file provided, use smoke instead -- exiting"; \
exit 1; \
fi
@echo generating refinery configs for component $(FILE)
mkdir -p tmp
# generate the configs from the provided file
go run ./cmd/hpsf -i ${FILE} -o tmp/refinery-rules.yaml rRules
go run ./cmd/hpsf -i ${FILE} -o tmp/refinery-config.yaml rConfig
# run refinery with the generated configs
docker run -d --rm --name smoke-refinery \
-v ./tmp/refinery-config.yaml:/etc/refinery/refinery.yaml \
-v ./tmp/refinery-rules.yaml:/etc/refinery/rules.yaml \
honeycombio/refinery:latest
sleep 1
# check if the container is running
if [ "$$(docker inspect -f '{{.State.Running}}' 'smoke-refinery')" != "true" ]; then \
echo "+++ container not running"; \
exit 1; \
else \
echo "+++ container is running"; \
docker kill 'smoke-refinery' > /dev/null; \
fi
.PHONY: smoke
#: run smoke tests for HPSF components
smoke: pkg/data/components/*.yaml
for file in $^ ; do \
if [ "$$(yq '.templates[] | select(.kind | contains("refinery_config","refinery_rules"))' $${file})" != "" ]; then \
$(MAKE) .smoke_refinery FILE=$${file}; \
fi; \
done
.PHONY: unsmoke
unsmoke:
@echo
@echo "+++ stopping smoke test"
@echo
docker stop smoke-proxy