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 |
|
- version: 2
-
- defaults: &defaults
- working_directory: /go/src/github.com/tendermint/tendermint
- docker:
- - image: circleci/golang:1.11.4
- environment:
- GOBIN: /tmp/workspace/bin
-
- docs_update_config: &docs_update_config
- working_directory: ~/repo
- docker:
- - image: tendermint/docs_deployment
- environment:
- AWS_REGION: us-east-1
-
- jobs:
- setup_dependencies:
- <<: *defaults
- steps:
- - run: mkdir -p /tmp/workspace/bin
- - run: mkdir -p /tmp/workspace/profiles
- - checkout
- - restore_cache:
- keys:
- - v3-pkg-cache
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run:
- name: binaries
- command: |
- export PATH="$GOBIN:$PATH"
- make install install_abci
- - persist_to_workspace:
- root: /tmp/workspace
- paths:
- - bin
- - profiles
- - save_cache:
- key: v3-pkg-cache
- paths:
- - /go/pkg
- # - save_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- # paths:
- # - /go/src/github.com/tendermint/tendermint
-
- build_slate:
- <<: *defaults
- steps:
- - attach_workspace:
- at: /tmp/workspace
- - restore_cache:
- key: v3-pkg-cache
- # https://discuss.circleci.com/t/saving-cache-stopped-working-warning-skipping-this-step-disabled-in-configuration/24423/2
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run:
- name: slate docs
- command: |
- set -ex
- export PATH="$GOBIN:$PATH"
- make build-slate
-
- lint:
- <<: *defaults
- steps:
- - attach_workspace:
- at: /tmp/workspace
- - restore_cache:
- key: v3-pkg-cache
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- make get_dev_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run:
- name: metalinter
- command: |
- set -ex
- export PATH="$GOBIN:$PATH"
- make metalinter
- - run:
- name: check_dep
- command: |
- set -ex
- export PATH="$GOBIN:$PATH"
- make check_dep
-
- test_abci_apps:
- <<: *defaults
- steps:
- - attach_workspace:
- at: /tmp/workspace
- - restore_cache:
- key: v3-pkg-cache
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run:
- name: Run abci apps tests
- command: |
- export PATH="$GOBIN:$PATH"
- bash abci/tests/test_app/test.sh
-
- # if this test fails, fix it and update the docs at:
- # https://github.com/tendermint/tendermint/blob/develop/docs/abci-cli.md
- test_abci_cli:
- <<: *defaults
- steps:
- - attach_workspace:
- at: /tmp/workspace
- - restore_cache:
- key: v3-pkg-cache
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run:
- name: Run abci-cli tests
- command: |
- export PATH="$GOBIN:$PATH"
- bash abci/tests/test_cli/test.sh
-
- test_apps:
- <<: *defaults
- steps:
- - attach_workspace:
- at: /tmp/workspace
- - restore_cache:
- key: v3-pkg-cache
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends bsdmainutils
- - run:
- name: Run tests
- command: bash test/app/test.sh
-
- test_cover:
- <<: *defaults
- parallelism: 4
- steps:
- - attach_workspace:
- at: /tmp/workspace
- - restore_cache:
- key: v3-pkg-cache
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run: mkdir -p /tmp/logs
- - run:
- name: Run tests
- command: |
- for pkg in $(go list github.com/tendermint/tendermint/... | circleci tests split --split-by=timings); do
- id=$(basename "$pkg")
-
- GOCACHE=off go test -v -timeout 5m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
- done
- - persist_to_workspace:
- root: /tmp/workspace
- paths:
- - "profiles/*"
- - store_artifacts:
- path: /tmp/logs
-
- test_persistence:
- <<: *defaults
- steps:
- - attach_workspace:
- at: /tmp/workspace
- - restore_cache:
- key: v3-pkg-cache
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run:
- name: Run tests
- command: bash test/persist/test_failure_indices.sh
-
- localnet:
- working_directory: /home/circleci/.go_workspace/src/github.com/tendermint/tendermint
- machine:
- image: circleci/classic:latest
- environment:
- GOBIN: /home/circleci/.go_workspace/bin
- GOPATH: /home/circleci/.go_workspace/
- GOOS: linux
- GOARCH: amd64
- parallelism: 1
- steps:
- - checkout
- - run:
- name: run localnet and exit on failure
- command: |
- set -x
- make get_tools
- make get_vendor_deps
- make build-linux
- make localnet-start &
- ./scripts/localnet-blocks-test.sh 40 5 10 localhost
-
- test_p2p:
- environment:
- GOBIN: /home/circleci/.go_workspace/bin
- GOPATH: /home/circleci/.go_workspace
- machine:
- image: circleci/classic:latest
- steps:
- - checkout
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
- - run: bash test/p2p/circleci.sh
- - store_artifacts:
- path: /home/circleci/project/test/p2p/logs
-
- upload_coverage:
- <<: *defaults
- steps:
- - attach_workspace:
- at: /tmp/workspace
- # - restore_cache:
- # key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
- - checkout
- - run:
- name: tools
- command: |
- export PATH="$GOBIN:$PATH"
- make get_tools
- - run:
- name: dependencies
- command: |
- export PATH="$GOBIN:$PATH"
- make get_vendor_deps
- - run: mkdir -p $GOPATH/src/github.com/tendermint
- - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
-
- - run:
- name: gather
- command: |
- set -ex
-
- echo "mode: atomic" > coverage.txt
- for prof in $(ls /tmp/workspace/profiles/); do
- tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt
- done
- - run:
- name: upload
- command: bash .circleci/codecov.sh -f coverage.txt
-
- deploy_docs:
- <<: *docs_update_config
- steps:
- - checkout
- - run:
- name: Trigger website build
- command: |
- chamber exec tendermint -- start_website_build
-
- workflows:
- version: 2
- test-suite:
- jobs:
- - deploy_docs:
- filters:
- branches:
- only:
- - master
- - develop
- - setup_dependencies
- - lint:
- requires:
- - setup_dependencies
- - test_abci_apps:
- requires:
- - setup_dependencies
- - test_abci_cli:
- requires:
- - setup_dependencies
- - test_apps:
- requires:
- - setup_dependencies
- - test_cover:
- requires:
- - setup_dependencies
- - test_persistence:
- requires:
- - setup_dependencies
- - localnet:
- requires:
- - setup_dependencies
- - test_p2p
- - upload_coverage:
- requires:
- - test_cover
|