forked from newrelic/node-newrelic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
177 lines (151 loc) · 5.23 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
MOCHA = node_modules/.bin/mocha
MOCHA_NOBIN = node_modules/.bin/_mocha
COVER = node_modules/.bin/cover
TAP = node_modules/.bin/tap
NODE_VERSION = $(shell node --version)
INTEGRATION = test/integration/*.tap.js
INTEGRATION += test/integration/*/*.tap.js
INTEGRATION += test/integration/*/*/*.tap.js
INTEGRATION += test/versioned/*/*.tap.js
# subcomponents manage their own modules
NPMDIRS = $(wildcard test/lib/bootstrap/*)
NPMDIRS += $(wildcard test/versioned/*)
SUBNPM = $(NPMDIRS:%=npm-%)
# SSL
SSLKEY = test/lib/test-key.key
# certificate authority, so curl doesn't complain
CACERT = test/lib/ca-certificate.crt
CASUBJ = "/O=testsuite/OU=New Relic CA/CN=Node.js test CA"
CACONFIG = test/lib/test-ca.conf
CAINDEX = test/lib/ca-index
CASERIAL = test/lib/ca-serial
# actual certificate configuration
CERTIFICATE = test/lib/self-signed-test-certificate.crt
SUBJECT = "/O=testsuite/OU=Node.js agent team/CN=ssl.lvh.me"
.PHONY: all build test-cov test clean notes pending pending-core test-clean
.PHONY: unit integration ssl ca-gen
.PHONY: sub_node_modules $(SUBNPM)
all: build test
clean:
find . -depth -type d -name node_modules -print0 | xargs -0 rm -r
rm -rf npm-debug.log newrelic_agent.log .coverage_data cover_html
rm -rf $(SSLKEY) $(CACERT) $(CAINDEX) $(CASERIAL) $(CERTIFICATE)
rm -rf test/lib/*.old test/lib/*.attr
node_modules: package.json
@rm -rf node_modules
npm --loglevel warn install
build: clean node_modules
@echo "Currently using node $(NODE_VERSION)."
test: unit integration
test-clean:
rm -rf test/integration/test-mongodb
rm -rf test/integration/test-mysql
rm newrelic_agent.log
test-ci: node_modules sub_node_modules $(CERTIFICATE)
@rm -f newrelic_agent.log
@$(MOCHA) test/unit --recursive --reporter min
@$(TAP) $(INTEGRATION)
unit: node_modules
@rm -f newrelic_agent.log
@$(MOCHA) test/unit --recursive
sub_node_modules: $(SUBNPM)
$(SUBNPM):
@$(MAKE) -s -C $(@:npm-%=%) node_modules
ca-gen:
@./bin/update-ca-bundle.sh
integration: node_modules sub_node_modules ca-gen $(CERTIFICATE)
@HOST=`boot2docker ip 2>/dev/null`; \
if test "$${HOST}"; then \
echo "Using boot2docker host through IP $${HOST}"; \
export NR_NODE_TEST_MEMCACHED_HOST=$${HOST}; \
export NR_NODE_TEST_MONGODB_HOST=$${HOST}; \
export NR_NODE_TEST_MYSQL_HOST=$${HOST}; \
export NR_NODE_TEST_REDIS_HOST=$${HOST}; \
export NR_NODE_TEST_CASSANDRA_HOST=$${HOST}; \
export NR_NODE_TEST_POSTGRES_HOST=$${HOST}; \
fi; \
time $(TAP) $(INTEGRATION)
coverage: clean node_modules $(CERTIFICATE)
@$(COVER) run $(MOCHA_NOBIN) -- test/unit --recursive
@for tapfile in $(INTEGRATION) ; do \
$(COVER) run $$tapfile ; \
done
@$(COVER) combine
@$(COVER) report html
@$(COVER) report
notes:
find . -name node_modules -prune -o \
-name cover_html -prune -o \
-name newrelic_agent.log -prune -o \
\( -name ".*" -a \! -name . \) -prune -o \
-type f -exec egrep -n -H --color=always -C 2 'FIXME|TODO|NOTE|TBD|hax|HAX' {} \; | less -r
pending: node_modules
@$(MOCHA) test/unit --recursive --reporter list | egrep '^\s+\-'
pending-core: node_modules
@$(MOCHA) test/unit --recursive --reporter list | egrep '^\s+\-' | grep -v 'agent instrumentation of'
ssl: $(CERTIFICATE)
$(SSLKEY):
@openssl genrsa -out $(SSLKEY) 1024
$(CAINDEX):
@touch $(CAINDEX)
$(CASERIAL):
@echo 000a > $(CASERIAL)
$(CACERT): $(SSLKEY) $(CAINDEX) $(CASERIAL)
@openssl req \
-new \
-subj $(CASUBJ) \
-key $(SSLKEY) \
-days 3650 \
-x509 \
-out $(CACERT)
$(CERTIFICATE): $(CACERT)
@openssl req \
-new \
-subj $(SUBJECT) \
-key $(SSLKEY) \
-out server.csr
@openssl ca \
-batch \
-cert $(CACERT) \
-config $(CACONFIG) \
-keyfile $(SSLKEY) \
-in server.csr \
-out $(CERTIFICATE)
@rm -f server.csr
services:
if docker ps -a | grep -q "[^a-zA-Z_]nr_node_memcached[^a-zA-Z_]"; then \
docker start nr_node_memcached; \
else \
docker run -d --name nr_node_memcached -p 11211:11211 borja/docker-memcached; \
fi
if docker ps -a | grep -q "[^a-zA-Z_]nr_node_mongodb[^a-zA-Z_]"; then \
docker start nr_node_mongodb; \
else \
docker run -d --name nr_node_mongodb -p 27017:27017 dockerfile/mongodb; \
fi
if docker ps -a | grep -q "[^a-zA-Z_]nr_node_mysql[^a-zA-Z_]"; then \
docker start nr_node_mysql; \
else \
docker run -d --name nr_node_mysql -p 3306:3306 orchardup/mysql; \
fi
if docker ps -a | grep -q "[^a-zA-Z_]nr_node_redis[^a-zA-Z_]"; then \
docker start nr_node_redis; \
else \
docker run -d --name nr_node_redis -p 6379:6379 redis; \
fi
if docker ps -a | grep -q "[^a-zA-Z_]nr_node_cassandra[^a-zA-Z_]"; then \
docker start nr_node_cassandra; \
else \
docker run -d --name nr_node_cassandra -p 9042:9042 zmarcantel/cassandra; \
fi
if docker ps -a | grep -q "[^a-zA-Z_]nr_node_postgres[^a-zA-Z_]"; then \
docker start nr_node_postgres; \
else \
docker run -d --name nr_node_postgres -p 5432:5432 zaiste/postgresql; \
fi
@echo "\nTo run individual integration tests, run 'source test/docker_env_vars.sh' to set\
the environment variables for all services.\n"
update_cross_agent_tests:
rm -rf test/lib/cross_agent_tests
git clone [email protected]:newrelic/cross_agent_tests.git test/lib/cross_agent_tests
rm -rf test/lib/cross_agent_tests/.git