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.

294 lines
7.9 KiB

7 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.12.0
  6. environment:
  7. GOBIN: /tmp/workspace/bin
  8. docs_update_config: &docs_update_config
  9. working_directory: ~/repo
  10. docker:
  11. - image: tendermintdev/jq_curl
  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. 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. curl --silent \
  227. --show-error \
  228. -X POST \
  229. --header "Content-Type: application/json" \
  230. -d "{\"branch\": \"$CIRCLE_BRANCH\"}" \
  231. "https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$WEBSITE_REPO_NAME/build?circle-token=$TENDERBOT_API_TOKEN" > response.json
  232. RESULT=`jq -r '.status' response.json`
  233. MESSAGE=`jq -r '.message' response.json`
  234. if [[ ${RESULT} == "null" ]] || [[ ${RESULT} -ne "200" ]]; then
  235. echo "CircleCI API call failed: $MESSAGE"
  236. exit 1
  237. else
  238. echo "Website build started"
  239. fi
  240. workflows:
  241. version: 2
  242. test-suite:
  243. jobs:
  244. - deploy_docs:
  245. filters:
  246. branches:
  247. only:
  248. - master
  249. - develop
  250. - setup_dependencies
  251. - lint:
  252. requires:
  253. - setup_dependencies
  254. - test_abci_apps:
  255. requires:
  256. - setup_dependencies
  257. - test_abci_cli:
  258. requires:
  259. - setup_dependencies
  260. - test_apps:
  261. requires:
  262. - setup_dependencies
  263. - test_cover:
  264. requires:
  265. - setup_dependencies
  266. - test_persistence:
  267. requires:
  268. - setup_dependencies
  269. - localnet:
  270. requires:
  271. - setup_dependencies
  272. - test_p2p
  273. - upload_coverage:
  274. requires:
  275. - test_cover