forked from newrelic/node-newrelic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
248 lines (212 loc) · 7.15 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
MOCHA = node_modules/.bin/mocha
MOCHA_NOBIN = node_modules/.bin/_mocha
COVER = node_modules/.bin/cover
TAP = node_modules/.bin/tap
ESLINT = node_modules/.bin/eslint
JSDOC = node_modules/.bin/jsdoc
NODE_VERSION = $(shell node --version)
PACKAGE_VERSION = $(shell node -e 'console.log(require("./package").version)')
INTEGRATION = test/integration/*.tap.js
INTEGRATION += test/integration/*/*.tap.js
INTEGRATION += test/integration/*/*/*.tap.js
INTEGRATION += test/versioned/*/*.tap.js
SMOKE = test/smoke/*.tap.js
PRERELEASE = test/prerelease/*/*.tap.js
# subcomponents manage their own modules
PACKAGES = $(shell find . -name package.json -and -not -path '*/node_modules/*' -and -not -path '*/example*')
# strip the package.json from the results
NPMDIRS = $(PACKAGES:/package.json=)
# 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
.PHONY: unit integration ssl ca-gen smoke lint
.PHONY: sub_node_modules $(SUBNPM)
all: build test
clean:
find . -depth -type d -name node_modules -print0 | xargs -0 rm -rf
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
rm -rf docs/
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
lint: node_modules
$(ESLINT) ./*.js lib
test-force-all:
export NR_NODE_TEST_FORCE_ALL=true
npm install
npm install oracle
make test
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
@cd test && npm install;
@$(MOCHA) -c test/unit --recursive
sub_node_modules:
@cd test && npm install glob@~3.2.9
@node test/bin/install_sub_deps
ca-gen:
@./bin/update-ca-bundle.sh
docker:
@HOST=`docker-machine ip default 2>/dev/null`; \
if test "$${HOST}"; then \
echo "Using docker-machine 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}; \
export NR_NODE_TEST_RABBIT_HOST=$${HOST}; \
fi; \
integration: node_modules ca-gen $(CERTIFICATE) docker
@cd test && npm install glob@~3.2.9
@node test/bin/install_sub_deps integration
@node test/bin/install_sub_deps versioned
time $(TAP) $(INTEGRATION)
prerelease: node_modules ca-gen $(CERTIFICATE) docker
@cd test && npm install glob@~3.2.9
@node test/bin/install_sub_deps prerelease
time $(TAP) $(PRERELEASE)
smoke: clean
npm install --production --loglevel warn
npm install tap
@cd test/smoke && npm install
time $(TAP) $(SMOKE)
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)
docs: node_modules
$(JSDOC) -c ./jsdoc-conf.json --private -r .
public-docs: node_modules
$(JSDOC) -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/
cp examples/shim/*.png out/
publish-docs:
git checkout gh-pages
git pull origin gh-pages
git merge -
make public-docs
git rm -r docs
mv out docs
git add docs
git commit -m "docs: update for ${PACKAGE_VERSION}"
git push origin gh-pages && git push public gh-pages:gh-pages
$(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
security:
./node_modules/.bin/nsp check
services:
if docker ps -a | grep -q "nr_node_memcached"; then \
docker start nr_node_memcached; \
else \
docker run -d --name nr_node_memcached -p 11211:11211 memcached; \
fi
if docker ps -a | grep -q "nr_node_mongodb"; then \
docker start nr_node_mongodb; \
else \
docker run -d --name nr_node_mongodb -p 27017:27017 library/mongo:2; \
fi
if docker ps -a | grep -q "nr_node_mysql"; 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 "nr_node_redis"; 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 "nr_node_cassandra"; 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 "nr_node_postgres"; then \
docker start nr_node_postgres; \
else \
docker run -d --name nr_node_postgres -p 5432:5432 postgres:9.2; \
fi
if docker ps -a | grep -q "nr_node_rabbit"; then \
docker start nr_node_rabbit; \
else \
docker run -d --name nr_node_rabbit -p 5672:5672 rabbitmq:3; \
fi
if docker ps -a | grep -q "nr_node_oracle"; then \
docker start nr_node_oracle; \
else \
docker run -d --name nr_node_oracle -p 1521:1521 alexeiled/docker-oracle-xe-11g; \
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 git@source.datanerd.us:newrelic/cross_agent_tests.git test/lib/cross_agent_tests
rm -rf test/lib/cross_agent_tests/.git
# versions prior to 1.4(ish) can't upgrade themselves directly to latest so hop to 1.4.28 first.
# Only upgrade to latest if we are on node 0.x
update_npm_global:
if npm -v | grep -q "^1"; then \
npm install -g npm@1.4.28; \
fi
if node -v | grep -q "^v0"; then \
npm install -g npm@3; \
fi
echo "\nUpgrading npm is expected to have many warnings due to tolerance changes over the years.\n"