Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Automating e2e tests #769

Merged
23 changes: 23 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: E2E tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
env:
E2E_TESTS: true
E2E_LOGS: true
CI_VERBOSE: true
vcastellm marked this conversation as resolved.
Show resolved Hide resolved
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-*/
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ generate-bsd-licenses:
test:
go build -o artifacts/polygon-edge .
$(eval export PATH=$(shell pwd)/artifacts:$(PATH))
go test -timeout 28m ./...
go test -timeout 28m `go list ./... | grep -v e2e`

.PHONY: test-e2e
test-e2e:
go build -o polygon-edge main.go
ZeljkoBenovic marked this conversation as resolved.
Show resolved Hide resolved
env EDGE_BINARY=${PWD}/polygon-edge go test -v -timeout=30m ./e2e/...

.PHONY: run-local
run-local:
Expand Down
25 changes: 3 additions & 22 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br />
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. <br/ >
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. <br />
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

Expand Down
17 changes: 13 additions & 4 deletions e2e/framework/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}