-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Move Gloas spec tests into their own packages #17309
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
base: methodical-codegen-switch
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### Changed | ||
|
|
||
| - Gloas spec tests moved into their own `mainnet/gloas` and `minimal/gloas` | ||
| packages, and `download_spectests.bzl` can now take spec test data from a | ||
| local directory or tarball instead of downloading a release. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/bash | ||
| . "$(dirname "$0")"/common.sh | ||
|
|
||
| # Script to copy generated spectest packages from the bazel build folder back to | ||
| # the source tree (the "generate-and-commit" workflow, mirroring | ||
| # update-go-ssz.sh). Each ssz_gen_spectest target emits a tree-artifact | ||
| # directory containing a methodical_test.go file and a testdata/ fixture tree; | ||
| # this script builds those targets and copies each generated directory over the | ||
| # matching location in the source tree. | ||
|
|
||
| bazel query 'kind(ssz_gen_spectest, //testing/...)' | xargs bazel build $@ | ||
|
|
||
| bin="$(bazel info bazel-bin)" | ||
| searchstring="/bin/" | ||
|
|
||
| # Locate each generated package by its marker file and mirror the whole | ||
| # directory (methodical_test.go + testdata/) back to source. The destination is | ||
| # cleared first so fixtures no longer produced (e.g. after a config or release | ||
| # change) don't linger -- the tree-artifact has no stable file list. BUILD.bazel | ||
| # is (re)generated by gazelle after this script runs, so removing it here is | ||
| # fine. Uses cp rather than rsync to avoid a new system dependency. | ||
| while IFS= read -d $'\0' -r marker; do | ||
| src_dir="$(dirname "$marker")" | ||
| destination="${src_dir#*$searchstring}" | ||
| color "34" "$destination" | ||
| rm -rf "$destination" | ||
| mkdir -p "$destination" | ||
| cp -R "$src_dir"/. "$destination"/ | ||
| # bazel outputs are read-only; make the copies writable in the source tree. | ||
| chmod -R u+w "$destination" | ||
| done < <($findutil -L "$bin"/ -type f -name "methodical_test.go" -print0) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| load("//tools:methodical.bzl", "ssz_gen_spectest") | ||
|
|
||
| # Generates the methodical-ssz spec test package into testing/spectest/methodical | ||
| # (out_dir lands the tree-artifact directory at this package's path). It is run, | ||
| # and its output copied back into the source tree, by hack/update-go-spectest.sh | ||
| # -- the generate-and-commit workflow that mirrors hack/update-go-ssz.sh. The | ||
| # fixtures come from the un-extracted release tarball exposed by the | ||
| # consensus_spec_tests repo rule (see tools/download_spectests.bzl). | ||
| ssz_gen_spectest( | ||
| name = "methodical_spectest", | ||
| config_file = "methodical-spectest.yaml", | ||
| out_dir = "methodical", | ||
| release_tarball = "@consensus_spec_tests//:mainnet.tar.gz", | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,50 @@ bazel test //... --test_tag_filters=spectest --repo_env=CONSENSUS_SPEC_TESTS_VER | |
| ``` | ||
| bazel test //... --test_tag_filters=spectest --repo_env=CONSENSUS_SPEC_TESTS_VERSION=nightly-21422848633 | ||
| ``` | ||
|
|
||
| ## Using local spectest data | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before this PR, You can run the spectests only by using but it's not possible to specify the equivalent of the After this PR, this thing remains, and additionnaly, it's not possible to specify the equivalent of the These 2 things can be added in this current PR, or I can create a GH issue to track it, to be sure we implement this before totally remove Bazel. |
||
|
|
||
| To run spectests against data you already have on disk (e.g. for offline work, | ||
| or to test an unreleased spec build) instead of downloading it, use either of the | ||
| following `--repo_env` flags. A source can be a tarball **or an already-unpacked | ||
| directory tree**. Both flags take precedence over `CONSENSUS_SPEC_TESTS_VERSION` | ||
| and require no network access. All paths must be **absolute**. | ||
|
|
||
| The "flavors" are the three upstream consensus-specs presets: `mainnet` and `minimal` | ||
| (preset-specific configs) and `general` (preset-independent tests: SSZ generic, BLS, | ||
| KZG). You usually only need one at a time. | ||
|
|
||
| **A directory.** Point `CONSENSUS_SPEC_TESTS_DIR` at a directory and, for each | ||
| flavor, the rule uses the first of these it finds, skipping flavors that are absent: | ||
|
|
||
| - `<dir>/<flavor>.tar.gz` — a release-style tarball | ||
| - `<dir>/tests/<flavor>/` — an unpacked tree keeping the upstream `tests/` prefix | ||
| - `<dir>/<flavor>/` — an unpacked tree with the prefix stripped | ||
|
|
||
| So both a directory of tarballs and a directory of already-extracted tests work: | ||
|
|
||
| ``` | ||
| bazel test //... --test_tag_filters=spectest --repo_env=CONSENSUS_SPEC_TESTS_DIR=/abs/path/to/specs | ||
| ``` | ||
|
|
||
| **A single flavor with any name.** Point a specific flavor at an arbitrarily-named | ||
| tarball or directly at an unpacked flavor tree with `CONSENSUS_SPEC_TESTS_<FLAVOR>` | ||
| (`GENERAL`, `MAINNET`, or `MINIMAL`): | ||
|
|
||
| ``` | ||
| bazel test //testing/spectest/mainnet:go_default_test --test_tag_filters=spectest \ | ||
| --repo_env=CONSENSUS_SPEC_TESTS_MAINNET=/abs/path/to/my-mainnet.tar.gz | ||
| ``` | ||
|
|
||
| The two mechanisms can be combined; a per-flavor override wins over the directory | ||
| entry for that flavor. When you supply only some flavors, scope the test target to | ||
| the matching preset (e.g. `//testing/spectest/mainnet/...`) rather than `//...`, since | ||
| the other flavors' filegroups will be empty. | ||
|
|
||
| Notes: | ||
| - Unpacked directories are symlinked in, so no large copy is made. The raw | ||
| `@consensus_spec_tests//:<flavor>.tar.gz` target (used by methodical-ssz | ||
| `gen-spectest`) only exists when you supply an actual tarball, not an unpacked dir. | ||
| - Bazel keys the repository rule on the value of the env var, not the contents of the | ||
| files. If you change data at the same path, run `bazel sync --configure` (or change | ||
| the path) to force a re-fetch. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| load("@prysm//tools/go:def.bzl", "go_test") | ||
|
|
||
| go_test( | ||
| name = "go_default_test", | ||
| size = "large", | ||
| srcs = [ | ||
| "gloas__epoch_processing__effective_balance_updates_test.go", | ||
| "gloas__epoch_processing__eth1_data_reset_test.go", | ||
| "gloas__epoch_processing__historical_summaries_update_test.go", | ||
| "gloas__epoch_processing__inactivity_updates_test.go", | ||
| "gloas__epoch_processing__justification_and_finalization_test.go", | ||
| "gloas__epoch_processing__participation_flag_updates_test.go", | ||
| "gloas__epoch_processing__pending_consolidations_test.go", | ||
| "gloas__epoch_processing__pending_deposits_churn_test.go", | ||
| "gloas__epoch_processing__pending_deposits_test.go", | ||
| "gloas__epoch_processing__process_builder_pending_payments_test.go", | ||
| "gloas__epoch_processing__proposer_lookahead_test.go", | ||
| "gloas__epoch_processing__randao_mixes_reset_test.go", | ||
| "gloas__epoch_processing__registry_updates_test.go", | ||
| "gloas__epoch_processing__rewards_and_penalties_test.go", | ||
| "gloas__epoch_processing__slashings_reset_test.go", | ||
| "gloas__epoch_processing__slashings_test.go", | ||
| "gloas__finality__finality_test.go", | ||
| "gloas__fork__upgrade_to_gloas_test.go", | ||
| "gloas__fork_transition__transition_test.go", | ||
| "gloas__forkchoice__forkchoice_test.go", | ||
| "gloas__operations__attestation_test.go", | ||
| "gloas__operations__attester_slashing_test.go", | ||
| "gloas__operations__block_header_test.go", | ||
| "gloas__operations__bls_to_execution_change_test.go", | ||
| "gloas__operations__builder_deposit_request_test.go", | ||
| "gloas__operations__builder_exit_request_test.go", | ||
| "gloas__operations__consolidation_test.go", | ||
| "gloas__operations__deposit_requests_test.go", | ||
| "gloas__operations__execution_payload_header_test.go", | ||
| "gloas__operations__parent_execution_payload_test.go", | ||
| "gloas__operations__payload_attestation_test.go", | ||
| "gloas__operations__proposer_slashing_test.go", | ||
| "gloas__operations__sync_committee_test.go", | ||
| "gloas__operations__voluntary_exit_churn_test.go", | ||
| "gloas__operations__voluntary_exit_test.go", | ||
| "gloas__operations__withdrawal_request_test.go", | ||
| "gloas__operations__withdrawals_test.go", | ||
| "gloas__random_test.go", | ||
| "gloas__rewards_test.go", | ||
| "gloas__sanity__blocks_test.go", | ||
| "gloas__sanity__slots_test.go", | ||
| "gloas__ssz_static__ssz_static_test.go", | ||
| ], | ||
| data = ["@consensus_spec_tests//:test_data"], | ||
| tags = ["spectest"], | ||
| deps = [ | ||
| "//runtime/version:go_default_library", | ||
| "//testing/spectest/shared/common/forkchoice:go_default_library", | ||
| "//testing/spectest/shared/gloas/epoch_processing:go_default_library", | ||
| "//testing/spectest/shared/gloas/finality:go_default_library", | ||
| "//testing/spectest/shared/gloas/fork:go_default_library", | ||
| "//testing/spectest/shared/gloas/operations:go_default_library", | ||
| "//testing/spectest/shared/gloas/rewards:go_default_library", | ||
| "//testing/spectest/shared/gloas/sanity:go_default_library", | ||
| "//testing/spectest/shared/gloas/ssz_static:go_default_library", | ||
| ], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package mainnet | ||
| package gloas | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
update-go-ssz.shdoes not exist any more.