forked from newrelic/node-newrelic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
206 lines (176 loc) · 6.13 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
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
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
SMOKE = test/smoke/*.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
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
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)
smoke: clean node_modules
npm install --production
@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)
$(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 library/mongo:2; \
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 postgres:9.2; \
fi
if docker ps -a | grep -q "[^a-zA-Z_]nr_node_oracle[^a-zA-Z_]"; 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 [email protected]: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 [email protected]; \
fi
if node -v | grep -q "^v0"; then \
npm install -g npm@latest; \
fi
echo "\nUpgrading npm is expected to have many warnings due to tolerance changes over the years.\n"