Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): E2E tests #145

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/per-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,20 @@ jobs:
- name: Kurtosis Lint
run: kurtosis lint ${{ github.workspace }}

test-e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
uses: jdx/mise-action@v2

- name: Start kurtosis engine
run: kurtosis engine start

- name: Run E2E tests
run: just test-e2e

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "test/e2e/lib/bats-support"]
path = test/lib/bats-support
url = https://github.com/bats-core/bats-support.git
[submodule "test/e2e/lib/bats-assert"]
path = test/lib/bats-assert
url = https://github.com/bats-core/bats-assert.git
2 changes: 2 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test-e2e:
bats test/e2e/**/*.bats
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,32 @@ kurtosis service stop <enclave-name> <service-name>
kurtosis service start <enclave-name> <service-name>
```

## Development

### Development environment

We use [`mise`](https://mise.jdx.dev/) as a dependency manager for these tools.
Once properly installed, `mise` will provide the correct versions for each tool. `mise` does not
replace any other installations of these binaries and will only serve these binaries when you are
working inside of the `optimism-package` directory.

#### Install `mise`

Install `mise` by following the instructions provided on the
[Getting Started page](https://mise.jdx.dev/getting-started.html#_1-install-mise-cli).

#### Install dependencies

```sh
mise install
```

### Testing

We use [`BATS`](https://bats-core.readthedocs.io/en/stable/index.html), _Bash Automated Testing System_ to write tests for this repository.

`BATS` is installed as a git submodule so make sure to clone the repo with submodules if you want to run the test suite.

## Contributing

If you have made changes and would like to submit a PR, test locally and make sure to run `lint` on your changes
Expand Down
7 changes: 7 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tools]

# Core dependencies
bats = "1.11.1"
jq = "1.7.1"
just = "1.37.0"
"ubi:kurtosis-tech/kurtosis-cli-release-artifacts[exe=kurtosis]" = "1.4.3"
18 changes: 18 additions & 0 deletions test/e2e/isthmus/assets/kurtosis_args_isthmus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ethereum_package:
participants:
- el_type: reth
cl_type: lighthouse
optimism_package:
chains:
- network_params:
isthmus_time_offset: 0
participants:
- el_type: op-geth
el_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest
cl_type: op-node
cl_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop
cl_extra_params:
- "--l1.trustrpc=true"
batcher_params:
extra_params:
- "--throttle-interval=0"
31 changes: 31 additions & 0 deletions test/e2e/isthmus/isthmus.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
setup() {
load "../../lib/bats-support/load.bash"
load "../../lib/bats-assert/load.bash"
}

@test "should have isthmus time if isthmus_time_offset is configured" {
local ENCLAVE_ID=op-isthmus--001
local ARGS_FILE=$BATS_TEST_DIRNAME/assets/kurtosis_args_isthmus.yaml
assert [ -f "$ARGS_FILE" ]

# First we start the enclave
run kurtosis run --enclave $ENCLAVE_ID . --args-file $BATS_TEST_DIRNAME/assets/kurtosis_args_isthmus.yaml
assert_success

# We get the UUID of the op-geth service
local OP_GETH_SERVICE_UUID=$(kurtosis enclave inspect $ENCLAVE_ID --full-uuids | grep op-el-1-op-geth-op-node-op-kurtosis | awk '{print $1;}')
assert [ -n "$OP_GETH_SERVICE_UUID" ]

# Now we find its RPC URL
local OP_GETH_RPC_URL=$(kurtosis service inspect $ENCLAVE_ID $OP_GETH_SERVICE_UUID | grep ' rpc:' | awk '{print $4;}')
assert [ -n "$OP_GETH_RPC_URL" ]

# We ask the RPC for the node info
local OP_GETH_NODE_INFO_JSON=$(curl -s -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' $OP_GETH_RPC_URL)

# And finally we find the isthmusTime and make sure it's defined
local OP_GETH_ISTHMUS_TIME=$(jq '.result.protocols.eth.config.isthmusTime' <<< $OP_GETH_NODE_INFO_JSON)
assert_equal "$OP_GETH_ISTHMUS_TIME" "0"

kurtosis enclave rm -f $ENCLAVE_ID
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried we might be leaking enclaves if the tests fail.

Should we have "kurtosis enclave add/rm" in setup/teardown functions around the test itself (or at the suite level to save time/resources)?

}
1 change: 1 addition & 0 deletions test/lib/bats-assert
Submodule bats-assert added at e2d855
1 change: 1 addition & 0 deletions test/lib/bats-support
Submodule bats-support added at 9bf10e
Loading