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.

279 lines
7.3 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
p2p: fix infinite loop in addrbook (#3232) * failing test * fix infinite loop in addrbook There are cases where we only have a small number of addresses marked good ("old"), but the selection mechanism keeps trying to select more of these addresses, and hence ends up in an infinite loop. Here we fix this to only try and select such "old" addresses if we have enough of them. Note this means, if we don't have enough of them, we may return more "new" addresses than otherwise expected by the newSelectionBias. This whole GetSelectionWithBias method probably needs to be rewritten, but this is a quick fix for the issue. * changelog * fix infinite loop if not enough new addrs * fix another potential infinite loop if a.nNew == 0 -> pickFromOldBucket=true, but we don't have enough items (a.nOld > len(oldBucketToAddrsMap) false) * Revert "fix another potential infinite loop" This reverts commit 146540c1125597162bd89820d611f6531f5e5e4b. * check num addresses instead of buckets, new test * fixed the int division * add slack to bias % in test, lint fixes * Added checks for selection content in test * test cleanup * Apply suggestions from code review Co-Authored-By: ebuchman <ethan@coinculture.info> * address review comments * change after Anton's review comments * use the same docker image we use for testing when building a binary for localnet * switch back to circleci classic * more review comments * more review comments * refactor addrbook_test * build linux binary inside docker in attempt to fix ``` --> Running dep + make build-linux GOOS=linux GOARCH=amd64 make build make[1]: Entering directory `/home/circleci/.go_workspace/src/github.com/tendermint/tendermint' CGO_ENABLED=0 go build -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`" -tags 'tendermint' -o build/tendermint ./cmd/tendermint/ p2p/pex/addrbook.go:373:13: undefined: math.Round ``` * change dir from /usr to /go * use concrete Go version for localnet binary * check for nil addresses just to be sure
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. - restore_cache:
  60. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  61. - run:
  62. name: slate docs
  63. command: |
  64. set -ex
  65. export PATH="$GOBIN:$PATH"
  66. make build-slate
  67. lint:
  68. <<: *defaults
  69. steps:
  70. - attach_workspace:
  71. at: /tmp/workspace
  72. - restore_cache:
  73. key: v3-pkg-cache
  74. - restore_cache:
  75. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  76. - run:
  77. name: metalinter
  78. command: |
  79. set -ex
  80. export PATH="$GOBIN:$PATH"
  81. make lint
  82. - run:
  83. name: check_dep
  84. command: |
  85. set -ex
  86. export PATH="$GOBIN:$PATH"
  87. make check_dep
  88. test_abci_apps:
  89. <<: *defaults
  90. steps:
  91. - attach_workspace:
  92. at: /tmp/workspace
  93. - restore_cache:
  94. key: v3-pkg-cache
  95. - restore_cache:
  96. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  97. - run:
  98. name: Run abci apps tests
  99. command: |
  100. export PATH="$GOBIN:$PATH"
  101. bash abci/tests/test_app/test.sh
  102. # if this test fails, fix it and update the docs at:
  103. # https://github.com/tendermint/tendermint/blob/develop/docs/abci-cli.md
  104. test_abci_cli:
  105. <<: *defaults
  106. steps:
  107. - attach_workspace:
  108. at: /tmp/workspace
  109. - restore_cache:
  110. key: v3-pkg-cache
  111. - restore_cache:
  112. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  113. - run:
  114. name: Run abci-cli tests
  115. command: |
  116. export PATH="$GOBIN:$PATH"
  117. bash abci/tests/test_cli/test.sh
  118. test_apps:
  119. <<: *defaults
  120. steps:
  121. - attach_workspace:
  122. at: /tmp/workspace
  123. - restore_cache:
  124. key: v3-pkg-cache
  125. - restore_cache:
  126. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  127. - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends bsdmainutils
  128. - run:
  129. name: Run tests
  130. command: bash test/app/test.sh
  131. test_cover:
  132. <<: *defaults
  133. parallelism: 4
  134. steps:
  135. - attach_workspace:
  136. at: /tmp/workspace
  137. - restore_cache:
  138. key: v3-pkg-cache
  139. - restore_cache:
  140. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  141. - run: mkdir -p /tmp/logs
  142. - run:
  143. name: Run tests
  144. command: |
  145. for pkg in $(go list github.com/tendermint/tendermint/... | circleci tests split --split-by=timings); do
  146. id=$(basename "$pkg")
  147. GOCACHE=off go test -v -timeout 5m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
  148. done
  149. - persist_to_workspace:
  150. root: /tmp/workspace
  151. paths:
  152. - "profiles/*"
  153. - store_artifacts:
  154. path: /tmp/logs
  155. test_persistence:
  156. <<: *defaults
  157. steps:
  158. - attach_workspace:
  159. at: /tmp/workspace
  160. - restore_cache:
  161. key: v3-pkg-cache
  162. - restore_cache:
  163. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  164. - run:
  165. name: Run tests
  166. command: bash test/persist/test_failure_indices.sh
  167. localnet:
  168. working_directory: /home/circleci/.go_workspace/src/github.com/tendermint/tendermint
  169. machine:
  170. image: circleci/classic:latest
  171. environment:
  172. GOBIN: /home/circleci/.go_workspace/bin
  173. GOPATH: /home/circleci/.go_workspace/
  174. GOOS: linux
  175. GOARCH: amd64
  176. parallelism: 1
  177. steps:
  178. - checkout
  179. - run:
  180. name: run localnet and exit on failure
  181. command: |
  182. set -x
  183. docker run --rm -v "$PWD":/go/src/github.com/tendermint/tendermint -w /go/src/github.com/tendermint/tendermint golang:1.11.4 make build-linux
  184. make localnet-start &
  185. ./scripts/localnet-blocks-test.sh 40 5 10 localhost
  186. test_p2p:
  187. environment:
  188. GOBIN: /home/circleci/.go_workspace/bin
  189. GOPATH: /home/circleci/.go_workspace
  190. machine:
  191. image: circleci/classic:latest
  192. steps:
  193. - checkout
  194. - run: mkdir -p $GOPATH/src/github.com/tendermint
  195. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  196. - run: bash test/p2p/circleci.sh
  197. - store_artifacts:
  198. path: /home/circleci/project/test/p2p/logs
  199. upload_coverage:
  200. <<: *defaults
  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. - run:
  209. name: gather
  210. command: |
  211. set -ex
  212. echo "mode: atomic" > coverage.txt
  213. for prof in $(ls /tmp/workspace/profiles/); do
  214. tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt
  215. done
  216. - run:
  217. name: upload
  218. command: bash .circleci/codecov.sh -f coverage.txt
  219. deploy_docs:
  220. <<: *docs_update_config
  221. steps:
  222. - checkout
  223. - run:
  224. name: Trigger website build
  225. command: |
  226. chamber exec tendermint -- start_website_build
  227. workflows:
  228. version: 2
  229. test-suite:
  230. jobs:
  231. - deploy_docs:
  232. filters:
  233. branches:
  234. only:
  235. - master
  236. - develop
  237. - setup_dependencies
  238. - lint:
  239. requires:
  240. - setup_dependencies
  241. - test_abci_apps:
  242. requires:
  243. - setup_dependencies
  244. - test_abci_cli:
  245. requires:
  246. - setup_dependencies
  247. - test_apps:
  248. requires:
  249. - setup_dependencies
  250. - test_cover:
  251. requires:
  252. - setup_dependencies
  253. - test_persistence:
  254. requires:
  255. - setup_dependencies
  256. - localnet:
  257. requires:
  258. - setup_dependencies
  259. - test_p2p
  260. - upload_coverage:
  261. requires:
  262. - test_cover