diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 0000000000..615ae64a7b --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,29 @@ +name: E2E tests +on: + push: + branches: + - main + - develop + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + env: + E2E_TESTS: true + E2E_LOGS: true + CI_VERBOSE: true + steps: + - uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Run tests + run: make test-e2e + # - name: Archive test logs + # if: always() + # uses: actions/upload-artifact@v3 + # with: + # name: e2e-logs + # path: e2e-logs-*/ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b34eb43aad..8fb040c237 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,17 +33,8 @@ jobs: with: submodules: recursive - # We need to build the binary with the race flag enabled - # because it will get picked up and run during e2e tests - # and the e2e tests should error out if any kind of race is found - - name: Go build with race - run: CGO_ENABLED=1 GOOS=linux go build -race -a -o artifacts/polygon-edge . - - - name: Add artifacts directory to the path - run: echo "$(pwd)/artifacts" >> $GITHUB_PATH - - name: Go test - run: go test -coverprofile coverage.out -timeout 28m ./... + run: go test -coverprofile coverage.out -timeout 20m `go list ./... | grep -v e2e` - name: Upload coverage file to Codecov uses: codecov/codecov-action@v3 diff --git a/Makefile b/Makefile index 1e8d6a9c9d..263e0aa0d1 100644 --- a/Makefile +++ b/Makefile @@ -39,9 +39,15 @@ generate-bsd-licenses: .PHONY: test test: - go build -o artifacts/polygon-edge . - $(eval export PATH=$(shell pwd)/artifacts:$(PATH)) - go test -timeout 28m ./... + go test -timeout=20m `go list ./... | grep -v e2e` + +.PHONY: test-e2e +test-e2e: + # We need to build the binary with the race flag enabled + # because it will get picked up and run during e2e tests + # and the e2e tests should error out if any kind of race is found + go build -race -o artifacts/polygon-edge . + env EDGE_BINARY=${PWD}/artifacts/polygon-edge go test -v -timeout=30m ./e2e/... .PHONY: run-local run-local: diff --git a/e2e/README.md b/e2e/README.md index 1aae6a0295..1bb1eb5e9c 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -2,35 +2,16 @@ The implemented E2E tests start a local instance of polygon-edge. -As such, they require the binary 'polygon-edge' to be available in the $PATH variable.
-Typically, the actual directory added to the $PATH variable would be the `go/bin` folder. +## Step 1: Run the tests -## Step 1: Build the polygon-edge - -```bash -go build -o $HOME/go/bin/polygon-edge ./main.go -``` - -## Step 2: Run the tests - -Now that the polygon-edge binary is in the `go/bin` folder, the e2e test server is able to locate it when running tests. +Use the make file to launch the tests `make test-e2e` ## Manual checks if things are acting funny ### Check if the polygon-edge process is running If you've stopped the tests abruptly, chances are the polygon-edge process is still running on your machine.
-In order for the tests to function normally, please kill the process. - -### Check if the polygon-edge-* folders are present in /tmp/ - -While running, the e2e server stores data needed for running in the /tmp/polygon-edge* folders.
-To clean up these folders, simply run: - -````bash -cd /tmp/ -rm -rf polygon-edge-* -```` +In order for the tests to function normally, please kill the possible remaining processes using `killall polygon-edge` ### Clean the golang test cache diff --git a/e2e/framework/testserver.go b/e2e/framework/testserver.go index a290071a09..611e687b7f 100644 --- a/e2e/framework/testserver.go +++ b/e2e/framework/testserver.go @@ -192,7 +192,7 @@ func (t *TestServer) SecretsInit() (*InitIBFTResult, error) { args = append(args, commandSlice...) args = append(args, "--data-dir", filepath.Join(t.Config.IBFTDir, "tmp")) - cmd := exec.Command(binaryName, args...) + cmd := exec.Command(resolveBinary(), args...) //nolint:gosec cmd.Dir = t.Config.RootDir if _, err := cmd.Output(); err != nil { @@ -333,7 +333,7 @@ func (t *TestServer) GenerateGenesis() error { blockGasLimit := strconv.FormatUint(t.Config.BlockGasLimit, 10) args = append(args, "--block-gas-limit", blockGasLimit) - cmd := exec.Command(binaryName, args...) + cmd := exec.Command(resolveBinary(), args...) //nolint:gosec cmd.Dir = t.Config.RootDir if t.Config.ShowsLog { @@ -397,7 +397,7 @@ func (t *TestServer) Start(ctx context.Context) error { t.ReleaseReservedPorts() // Start the server - t.cmd = exec.Command(binaryName, args...) + t.cmd = exec.Command(resolveBinary(), args...) //nolint:gosec t.cmd.Dir = t.Config.RootDir if t.Config.ShowsLog { @@ -452,7 +452,7 @@ func (t *TestServer) SwitchIBFTType(typ fork.IBFTType, from uint64, to, deployme } // Start the server - t.cmd = exec.Command(binaryName, args...) + t.cmd = exec.Command(resolveBinary(), args...) //nolint:gosec t.cmd.Dir = t.Config.RootDir if t.Config.ShowsLog { @@ -712,3 +712,12 @@ func (t *TestServer) CallJSONRPC(req map[string]interface{}) map[string]interfac return result } + +func resolveBinary() string { + bin := os.Getenv("EDGE_BINARY") + if bin != "" { + return bin + } + // fallback + return binaryName +} diff --git a/network/server.go b/network/server.go index 9b53105e94..9d1754261b 100644 --- a/network/server.go +++ b/network/server.go @@ -536,7 +536,7 @@ func (s *Server) DisconnectFromPeer(peer peer.ID, reason string) { var ( // Anything below 35s is prone to false timeouts, as seen from empirical test data - DefaultJoinTimeout = 40 * time.Second + DefaultJoinTimeout = 100 * time.Second DefaultBufferTimeout = DefaultJoinTimeout + time.Second*5 ) diff --git a/validators/store/contract/contract_test.go b/validators/store/contract/contract_test.go index 96e385f12d..b99de8fa14 100644 --- a/validators/store/contract/contract_test.go +++ b/validators/store/contract/contract_test.go @@ -450,8 +450,6 @@ func TestContractValidatorStoreGetValidators(t *testing.T) { } func TestContractValidatorStore_CacheChange(t *testing.T) { - t.Parallel() - var ( cacheSize = 2