You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

393 lines
11 KiB

6 years ago
p2p: file descriptor leaks (#3150) * close peer's connection to avoid fd leak Fixes #2967 * rename peer#Addr to RemoteAddr * fix test * fixes after Ethan's review * bring back the check * changelog entry * write a test for switch#acceptRoutine * increase timeouts? :( * remove extra assertNPeersWithTimeout * simplify test * assert number of peers (just to be safe) * Cleanup in OnStop * run tests with verbose flag on CircleCI * spawn a reading routine to prevent connection from closing * get port from the listener random port is faster, but often results in ``` panic: listen tcp 127.0.0.1:44068: bind: address already in use [recovered] panic: listen tcp 127.0.0.1:44068: bind: address already in use goroutine 79 [running]: testing.tRunner.func1(0xc0001bd600) /usr/local/go/src/testing/testing.go:792 +0x387 panic(0x974d20, 0xc0001b0500) /usr/local/go/src/runtime/panic.go:513 +0x1b9 github.com/tendermint/tendermint/p2p.MakeSwitch(0xc0000f42a0, 0x0, 0x9fb9cc, 0x9, 0x9fc346, 0xb, 0xb42128, 0x0, 0x0, 0x0, ...) /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/test_util.go:182 +0xa28 github.com/tendermint/tendermint/p2p.MakeConnectedSwitches(0xc0000f42a0, 0x2, 0xb42128, 0xb41eb8, 0x4f1205, 0xc0001bed80, 0x4f16ed) /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/test_util.go:75 +0xf9 github.com/tendermint/tendermint/p2p.MakeSwitchPair(0xbb8d20, 0xc0001bd600, 0xb42128, 0x2f7, 0x4f16c0) /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch_test.go:94 +0x4c github.com/tendermint/tendermint/p2p.TestSwitches(0xc0001bd600) /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch_test.go:117 +0x58 testing.tRunner(0xc0001bd600, 0xb42038) /usr/local/go/src/testing/testing.go:827 +0xbf created by testing.(*T).Run /usr/local/go/src/testing/testing.go:878 +0x353 exit status 2 FAIL github.com/tendermint/tendermint/p2p 0.350s ```
6 years ago
  1. version: 2
  2. defaults: &defaults
  3. working_directory: /go/src/github.com/tendermint/tendermint
  4. docker:
  5. - image: circleci/golang:1.11.4
  6. environment:
  7. GOBIN: /tmp/workspace/bin
  8. docs_update_config: &docs_update_config
  9. working_directory: ~/repo
  10. docker:
  11. - image: tendermint/docs_deployment
  12. environment:
  13. AWS_REGION: us-east-1
  14. jobs:
  15. setup_dependencies:
  16. <<: *defaults
  17. steps:
  18. - run: mkdir -p /tmp/workspace/bin
  19. - run: mkdir -p /tmp/workspace/profiles
  20. - checkout
  21. - restore_cache:
  22. keys:
  23. - v3-pkg-cache
  24. - run:
  25. name: tools
  26. command: |
  27. export PATH="$GOBIN:$PATH"
  28. make get_tools
  29. - run:
  30. name: dependencies
  31. command: |
  32. export PATH="$GOBIN:$PATH"
  33. make get_vendor_deps
  34. - run:
  35. name: binaries
  36. command: |
  37. export PATH="$GOBIN:$PATH"
  38. make install install_abci
  39. - persist_to_workspace:
  40. root: /tmp/workspace
  41. paths:
  42. - bin
  43. - profiles
  44. - save_cache:
  45. key: v3-pkg-cache
  46. paths:
  47. - /go/pkg
  48. # - save_cache:
  49. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  50. # paths:
  51. # - /go/src/github.com/tendermint/tendermint
  52. build_slate:
  53. <<: *defaults
  54. steps:
  55. - attach_workspace:
  56. at: /tmp/workspace
  57. - restore_cache:
  58. key: v3-pkg-cache
  59. # https://discuss.circleci.com/t/saving-cache-stopped-working-warning-skipping-this-step-disabled-in-configuration/24423/2
  60. # - restore_cache:
  61. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  62. - checkout
  63. - run:
  64. name: tools
  65. command: |
  66. export PATH="$GOBIN:$PATH"
  67. make get_tools
  68. - run:
  69. name: dependencies
  70. command: |
  71. export PATH="$GOBIN:$PATH"
  72. make get_vendor_deps
  73. - run: mkdir -p $GOPATH/src/github.com/tendermint
  74. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  75. - run:
  76. name: slate docs
  77. command: |
  78. set -ex
  79. export PATH="$GOBIN:$PATH"
  80. make build-slate
  81. lint:
  82. <<: *defaults
  83. steps:
  84. - attach_workspace:
  85. at: /tmp/workspace
  86. - restore_cache:
  87. key: v3-pkg-cache
  88. # - restore_cache:
  89. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  90. - checkout
  91. - run:
  92. name: tools
  93. command: |
  94. export PATH="$GOBIN:$PATH"
  95. make get_tools
  96. make get_dev_tools
  97. - run:
  98. name: dependencies
  99. command: |
  100. export PATH="$GOBIN:$PATH"
  101. make get_vendor_deps
  102. - run: mkdir -p $GOPATH/src/github.com/tendermint
  103. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  104. - run:
  105. name: metalinter
  106. command: |
  107. set -ex
  108. export PATH="$GOBIN:$PATH"
  109. make metalinter
  110. - run:
  111. name: check_dep
  112. command: |
  113. set -ex
  114. export PATH="$GOBIN:$PATH"
  115. make check_dep
  116. test_abci_apps:
  117. <<: *defaults
  118. steps:
  119. - attach_workspace:
  120. at: /tmp/workspace
  121. - restore_cache:
  122. key: v3-pkg-cache
  123. # - restore_cache:
  124. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  125. - checkout
  126. - run:
  127. name: tools
  128. command: |
  129. export PATH="$GOBIN:$PATH"
  130. make get_tools
  131. - run:
  132. name: dependencies
  133. command: |
  134. export PATH="$GOBIN:$PATH"
  135. make get_vendor_deps
  136. - run: mkdir -p $GOPATH/src/github.com/tendermint
  137. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  138. - run:
  139. name: Run abci apps tests
  140. command: |
  141. export PATH="$GOBIN:$PATH"
  142. bash abci/tests/test_app/test.sh
  143. # if this test fails, fix it and update the docs at:
  144. # https://github.com/tendermint/tendermint/blob/develop/docs/abci-cli.md
  145. test_abci_cli:
  146. <<: *defaults
  147. steps:
  148. - attach_workspace:
  149. at: /tmp/workspace
  150. - restore_cache:
  151. key: v3-pkg-cache
  152. # - restore_cache:
  153. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  154. - checkout
  155. - run:
  156. name: tools
  157. command: |
  158. export PATH="$GOBIN:$PATH"
  159. make get_tools
  160. - run:
  161. name: dependencies
  162. command: |
  163. export PATH="$GOBIN:$PATH"
  164. make get_vendor_deps
  165. - run: mkdir -p $GOPATH/src/github.com/tendermint
  166. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  167. - run:
  168. name: Run abci-cli tests
  169. command: |
  170. export PATH="$GOBIN:$PATH"
  171. bash abci/tests/test_cli/test.sh
  172. test_apps:
  173. <<: *defaults
  174. steps:
  175. - attach_workspace:
  176. at: /tmp/workspace
  177. - restore_cache:
  178. key: v3-pkg-cache
  179. # - restore_cache:
  180. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  181. - checkout
  182. - run:
  183. name: tools
  184. command: |
  185. export PATH="$GOBIN:$PATH"
  186. make get_tools
  187. - run:
  188. name: dependencies
  189. command: |
  190. export PATH="$GOBIN:$PATH"
  191. make get_vendor_deps
  192. - run: mkdir -p $GOPATH/src/github.com/tendermint
  193. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  194. - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends bsdmainutils
  195. - run:
  196. name: Run tests
  197. command: bash test/app/test.sh
  198. test_cover:
  199. <<: *defaults
  200. parallelism: 4
  201. steps:
  202. - attach_workspace:
  203. at: /tmp/workspace
  204. - restore_cache:
  205. key: v3-pkg-cache
  206. # - restore_cache:
  207. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  208. - checkout
  209. - run:
  210. name: tools
  211. command: |
  212. export PATH="$GOBIN:$PATH"
  213. make get_tools
  214. - run:
  215. name: dependencies
  216. command: |
  217. export PATH="$GOBIN:$PATH"
  218. make get_vendor_deps
  219. - run: mkdir -p $GOPATH/src/github.com/tendermint
  220. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  221. - run: mkdir -p /tmp/logs
  222. - run:
  223. name: Run tests
  224. command: |
  225. for pkg in $(go list github.com/tendermint/tendermint/... | circleci tests split --split-by=timings); do
  226. id=$(basename "$pkg")
  227. GOCACHE=off go test -v -timeout 5m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
  228. done
  229. - persist_to_workspace:
  230. root: /tmp/workspace
  231. paths:
  232. - "profiles/*"
  233. - store_artifacts:
  234. path: /tmp/logs
  235. test_persistence:
  236. <<: *defaults
  237. steps:
  238. - attach_workspace:
  239. at: /tmp/workspace
  240. - restore_cache:
  241. key: v3-pkg-cache
  242. # - restore_cache:
  243. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  244. - checkout
  245. - run:
  246. name: tools
  247. command: |
  248. export PATH="$GOBIN:$PATH"
  249. make get_tools
  250. - run:
  251. name: dependencies
  252. command: |
  253. export PATH="$GOBIN:$PATH"
  254. make get_vendor_deps
  255. - run: mkdir -p $GOPATH/src/github.com/tendermint
  256. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  257. - run:
  258. name: Run tests
  259. command: bash test/persist/test_failure_indices.sh
  260. localnet:
  261. working_directory: /home/circleci/.go_workspace/src/github.com/tendermint/tendermint
  262. machine:
  263. image: circleci/classic:latest
  264. environment:
  265. GOBIN: /home/circleci/.go_workspace/bin
  266. GOPATH: /home/circleci/.go_workspace/
  267. GOOS: linux
  268. GOARCH: amd64
  269. parallelism: 1
  270. steps:
  271. - checkout
  272. - run:
  273. name: run localnet and exit on failure
  274. command: |
  275. set -x
  276. make get_tools
  277. make get_vendor_deps
  278. make build-linux
  279. make localnet-start &
  280. ./scripts/localnet-blocks-test.sh 40 5 10 localhost
  281. test_p2p:
  282. environment:
  283. GOBIN: /home/circleci/.go_workspace/bin
  284. GOPATH: /home/circleci/.go_workspace
  285. machine:
  286. image: circleci/classic:latest
  287. steps:
  288. - checkout
  289. - run: mkdir -p $GOPATH/src/github.com/tendermint
  290. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  291. - run: bash test/p2p/circleci.sh
  292. - store_artifacts:
  293. path: /home/circleci/project/test/p2p/logs
  294. upload_coverage:
  295. <<: *defaults
  296. steps:
  297. - attach_workspace:
  298. at: /tmp/workspace
  299. # - restore_cache:
  300. # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  301. - checkout
  302. - run:
  303. name: tools
  304. command: |
  305. export PATH="$GOBIN:$PATH"
  306. make get_tools
  307. - run:
  308. name: dependencies
  309. command: |
  310. export PATH="$GOBIN:$PATH"
  311. make get_vendor_deps
  312. - run: mkdir -p $GOPATH/src/github.com/tendermint
  313. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  314. - run:
  315. name: gather
  316. command: |
  317. set -ex
  318. echo "mode: atomic" > coverage.txt
  319. for prof in $(ls /tmp/workspace/profiles/); do
  320. tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt
  321. done
  322. - run:
  323. name: upload
  324. command: bash .circleci/codecov.sh -f coverage.txt
  325. deploy_docs:
  326. <<: *docs_update_config
  327. steps:
  328. - checkout
  329. - run:
  330. name: Trigger website build
  331. command: |
  332. chamber exec tendermint -- start_website_build
  333. workflows:
  334. version: 2
  335. test-suite:
  336. jobs:
  337. - deploy_docs:
  338. filters:
  339. branches:
  340. only:
  341. - master
  342. - develop
  343. - setup_dependencies
  344. - lint:
  345. requires:
  346. - setup_dependencies
  347. - test_abci_apps:
  348. requires:
  349. - setup_dependencies
  350. - test_abci_cli:
  351. requires:
  352. - setup_dependencies
  353. - test_apps:
  354. requires:
  355. - setup_dependencies
  356. - test_cover:
  357. requires:
  358. - setup_dependencies
  359. - test_persistence:
  360. requires:
  361. - setup_dependencies
  362. - localnet:
  363. requires:
  364. - setup_dependencies
  365. - test_p2p
  366. - upload_coverage:
  367. requires:
  368. - test_cover