2025-02-24 17:29:44 +11:00
|
|
|
import std/httpclient
|
2023-06-22 20:32:18 +10:00
|
|
|
import std/os
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
import std/sequtils
|
|
|
|
|
import std/strutils
|
|
|
|
|
import std/sugar
|
|
|
|
|
import std/times
|
2024-03-12 10:57:13 +01:00
|
|
|
import pkg/codex/conf
|
feat: create logging proxy (#663)
* implement a logging proxy
The logging proxy:
- prevents the need to import chronicles (as well as export except toJson),
- prevents the need to override `writeValue` or use or import nim-json-seralization elsewhere in the codebase, allowing for sole use of utils/json for de/serialization,
- and handles json formatting correctly in chronicles json sinks
* Rename logging -> logutils to avoid ambiguity with common names
* clean up
* add setProperty for JsonRecord, remove nim-json-serialization conflict
* Allow specifying textlines and json format separately
Not specifying a LogFormat will apply the formatting to both textlines and json sinks.
Specifying a LogFormat will apply the formatting to only that sink.
* remove unneeded usages of std/json
We only need to import utils/json instead of std/json
* move serialization from rest/json to utils/json so it can be shared
* fix NoColors ambiguity
Was causing unit tests to fail on Windows.
* Remove nre usage to fix Windows error
Windows was erroring with `could not load: pcre64.dll`. Instead of fixing that error, remove the pcre usage :)
* Add logutils module doc
* Shorten logutils.formatIt for `NBytes`
Both json and textlines formatIt were not needed, and could be combined into one formatIt
* remove debug integration test config
debug output and logformat of json for integration test logs
* Use ## module doc to support docgen
* bump nim-poseidon2 to export fromBytes
Before the changes in this branch, fromBytes was likely being resolved by nim-stew, or other dependency. With the changes in this branch, that dependency was removed and fromBytes could no longer be resolved. By exporting fromBytes from nim-poseidon, the correct resolution is now happening.
* fixes to get compiling after rebasing master
* Add support for Result types being logged using formatIt
2024-01-23 18:35:03 +11:00
|
|
|
import pkg/codex/logutils
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
import pkg/chronos/transports/stream
|
|
|
|
|
import pkg/ethers
|
2024-03-12 10:57:13 +01:00
|
|
|
import pkg/questionable
|
|
|
|
|
import ./codexconfig
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
import ./codexprocess
|
|
|
|
|
import ./hardhatconfig
|
2024-03-12 10:57:13 +01:00
|
|
|
import ./hardhatprocess
|
|
|
|
|
import ./nodeconfigs
|
2024-12-20 16:23:40 +11:00
|
|
|
import ./utils
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
import ../asynctest
|
|
|
|
|
import ../checktest
|
2023-06-22 20:32:18 +10:00
|
|
|
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
export asynctest
|
|
|
|
|
export ethers except `%`
|
|
|
|
|
export hardhatprocess
|
|
|
|
|
export codexprocess
|
|
|
|
|
export hardhatconfig
|
|
|
|
|
export codexconfig
|
2025-02-20 16:52:51 +11:00
|
|
|
export nodeconfigs
|
2023-06-22 20:32:18 +10:00
|
|
|
|
2025-02-24 17:29:44 +11:00
|
|
|
{.push raises: [].}
|
|
|
|
|
|
2023-09-13 16:17:56 +02:00
|
|
|
type
|
|
|
|
|
RunningNode* = ref object
|
|
|
|
|
role*: Role
|
|
|
|
|
node*: NodeProcess
|
2025-01-21 21:54:46 +01:00
|
|
|
|
2023-09-13 16:17:56 +02:00
|
|
|
Role* {.pure.} = enum
|
|
|
|
|
Client
|
|
|
|
|
Provider
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
Validator
|
|
|
|
|
Hardhat
|
2025-01-21 21:54:46 +01:00
|
|
|
|
2024-03-12 10:57:13 +01:00
|
|
|
MultiNodeSuiteError = object of CatchableError
|
2025-02-24 17:29:44 +11:00
|
|
|
SuiteTimeoutError = object of MultiNodeSuiteError
|
2024-03-12 10:57:13 +01:00
|
|
|
|
2024-12-20 16:23:40 +11:00
|
|
|
const HardhatPort {.intdefine.}: int = 8545
|
|
|
|
|
const CodexApiPort {.intdefine.}: int = 8080
|
|
|
|
|
const CodexDiscPort {.intdefine.}: int = 8090
|
|
|
|
|
const TestId {.strdefine.}: string = "TestId"
|
2025-02-05 18:31:40 +11:00
|
|
|
const DebugCodexNodes {.booldefine.}: bool = false
|
|
|
|
|
const LogsDir {.strdefine.}: string = ""
|
2025-03-24 16:47:05 +01:00
|
|
|
|
2025-02-24 17:29:44 +11:00
|
|
|
proc raiseMultiNodeSuiteError(
|
|
|
|
|
msg: string, parent: ref CatchableError = nil
|
|
|
|
|
) {.raises: [MultiNodeSuiteError].} =
|
2025-02-06 16:53:25 +11:00
|
|
|
raise newException(MultiNodeSuiteError, msg, parent)
|
|
|
|
|
|
|
|
|
|
template withLock(lock: AsyncLock, body: untyped) =
|
|
|
|
|
if lock.isNil:
|
|
|
|
|
lock = newAsyncLock()
|
|
|
|
|
|
|
|
|
|
await lock.acquire()
|
|
|
|
|
try:
|
|
|
|
|
body
|
|
|
|
|
finally:
|
|
|
|
|
try:
|
|
|
|
|
lock.release()
|
|
|
|
|
except AsyncLockError as parent:
|
|
|
|
|
raiseMultiNodeSuiteError "lock error", parent
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2024-12-20 16:23:40 +11:00
|
|
|
|
2025-03-24 16:47:05 +01:00
|
|
|
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
template multinodesuite*(name: string, body: untyped) =
|
|
|
|
|
asyncchecksuite name:
|
2024-12-14 06:07:55 +01:00
|
|
|
# Following the problem described here:
|
|
|
|
|
# https://github.com/NomicFoundation/hardhat/issues/2053
|
|
|
|
|
# It may be desirable to use http RPC provider.
|
|
|
|
|
# This turns out to be equally important in tests where
|
|
|
|
|
# subscriptions get wiped out after 5mins even when
|
|
|
|
|
# a new block is mined.
|
|
|
|
|
# For this reason, we are using http provider here as the default.
|
|
|
|
|
# To use a different provider in your test, you may use
|
|
|
|
|
# multinodesuiteWithProviderUrl template in your tests.
|
|
|
|
|
# If you want to use a different provider url in the nodes, you can
|
|
|
|
|
# use withEthProvider config modifier in the node config
|
|
|
|
|
# to set the desired provider url. E.g.:
|
2024-12-20 16:23:40 +11:00
|
|
|
# NodeConfigs(
|
2024-12-14 06:07:55 +01:00
|
|
|
# hardhat:
|
|
|
|
|
# HardhatConfig.none,
|
|
|
|
|
# clients:
|
|
|
|
|
# CodexConfigs.init(nodes=1)
|
|
|
|
|
# .withEthProvider("ws://localhost:8545")
|
|
|
|
|
# .some,
|
|
|
|
|
# ...
|
2024-12-20 16:23:40 +11:00
|
|
|
var jsonRpcProviderUrl = "http://127.0.0.1:" & $HardhatPort
|
2024-12-14 06:07:55 +01:00
|
|
|
var running {.inject, used.}: seq[RunningNode]
|
2024-12-18 15:10:36 +07:00
|
|
|
var bootstrapNodes: seq[string]
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
let starttime = now().format("yyyy-MM-dd'_'HH:mm:ss")
|
|
|
|
|
var currentTestName = ""
|
|
|
|
|
var nodeConfigs: NodeConfigs
|
|
|
|
|
var ethProvider {.inject, used.}: JsonRpcProvider
|
|
|
|
|
var accounts {.inject, used.}: seq[Address]
|
|
|
|
|
var snapshot: JsonNode
|
2025-02-03 15:33:41 +11:00
|
|
|
var lastUsedHardhatPort = HardhatPort
|
|
|
|
|
var lastUsedCodexApiPort = CodexApiPort
|
|
|
|
|
var lastUsedCodexDiscPort = CodexDiscPort
|
2025-02-06 16:53:25 +11:00
|
|
|
var codexPortLock: AsyncLock
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
|
|
|
|
template test(tname, startNodeConfigs, tbody) =
|
|
|
|
|
currentTestName = tname
|
|
|
|
|
nodeConfigs = startNodeConfigs
|
|
|
|
|
test tname:
|
|
|
|
|
tbody
|
|
|
|
|
|
2024-12-20 16:23:40 +11:00
|
|
|
proc updatePort(url: var string, port: int) =
|
|
|
|
|
let parts = url.split(':')
|
|
|
|
|
url = @[parts[0], parts[1], $port].join(":")
|
|
|
|
|
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
proc newHardhatProcess(
|
|
|
|
|
config: HardhatConfig, role: Role
|
2025-02-24 17:29:44 +11:00
|
|
|
): Future[NodeProcess] {.async: (raises: [MultiNodeSuiteError, CancelledError]).} =
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
var args: seq[string] = @[]
|
|
|
|
|
if config.logFile:
|
2025-02-24 17:29:44 +11:00
|
|
|
try:
|
|
|
|
|
let updatedLogFile =
|
|
|
|
|
getLogFile(LogsDir, starttime, name, currentTestName, $role, none int)
|
|
|
|
|
args.add "--log-file=" & updatedLogFile
|
|
|
|
|
except IOError as e:
|
|
|
|
|
raiseMultiNodeSuiteError(
|
|
|
|
|
"failed to start hardhat because logfile path could not be obtained: " &
|
|
|
|
|
e.msg,
|
|
|
|
|
e,
|
|
|
|
|
)
|
|
|
|
|
except OSError as e:
|
|
|
|
|
raiseMultiNodeSuiteError(
|
|
|
|
|
"failed to start hardhat because logfile path could not be obtained: " &
|
|
|
|
|
e.msg,
|
|
|
|
|
e,
|
|
|
|
|
)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2025-02-03 15:33:41 +11:00
|
|
|
let port = await nextFreePort(lastUsedHardhatPort)
|
2024-12-20 16:23:40 +11:00
|
|
|
jsonRpcProviderUrl.updatePort(port)
|
|
|
|
|
args.add("--port")
|
|
|
|
|
args.add($port)
|
2025-02-03 15:33:41 +11:00
|
|
|
lastUsedHardhatPort = port
|
2024-12-20 16:23:40 +11:00
|
|
|
|
2024-03-12 10:57:13 +01:00
|
|
|
try:
|
2025-06-20 17:55:00 +02:00
|
|
|
let node = await HardhatProcess.startNode(args, config.debugEnabled, "hardhat")
|
2025-01-29 18:50:17 +11:00
|
|
|
await node.waitUntilStarted()
|
2025-06-20 17:55:00 +02:00
|
|
|
trace "hardhat node started"
|
|
|
|
|
return node
|
2024-03-12 10:57:13 +01:00
|
|
|
except NodeProcessError as e:
|
2025-01-29 18:50:17 +11:00
|
|
|
raiseMultiNodeSuiteError "hardhat node not started: " & e.msg
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
|
|
|
|
proc newCodexProcess(
|
2024-03-12 10:57:13 +01:00
|
|
|
roleIdx: int, conf: CodexConfig, role: Role
|
2025-02-24 17:29:44 +11:00
|
|
|
): Future[NodeProcess] {.async: (raises: [MultiNodeSuiteError, CancelledError]).} =
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
let nodeIdx = running.len
|
2024-03-12 10:57:13 +01:00
|
|
|
var config = conf
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
|
|
|
|
if nodeIdx > accounts.len - 1:
|
2024-03-12 10:57:13 +01:00
|
|
|
raiseMultiNodeSuiteError "Cannot start node at nodeIdx " & $nodeIdx &
|
|
|
|
|
", not enough eth accounts."
|
2023-06-22 20:32:18 +10:00
|
|
|
|
2025-02-06 16:34:42 +11:00
|
|
|
let datadir =
|
|
|
|
|
getTempDir() / "Codex" / sanitize(TestId) / sanitize(currentTestName) /
|
|
|
|
|
sanitize($starttime) / sanitize($role & "_" & $roleIdx)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2024-03-12 10:57:13 +01:00
|
|
|
try:
|
2025-02-05 18:31:40 +11:00
|
|
|
if config.logFile.isSome or DebugCodexNodes:
|
2025-02-24 17:29:44 +11:00
|
|
|
try:
|
|
|
|
|
let updatedLogFile =
|
|
|
|
|
getLogFile(LogsDir, starttime, name, currentTestName, $role, some roleIdx)
|
|
|
|
|
config.withLogFile(updatedLogFile)
|
|
|
|
|
except IOError as e:
|
|
|
|
|
raiseMultiNodeSuiteError(
|
|
|
|
|
"failed to start " & $role &
|
|
|
|
|
" because logfile path could not be obtained: " & e.msg,
|
|
|
|
|
e,
|
|
|
|
|
)
|
|
|
|
|
except OSError as e:
|
|
|
|
|
raiseMultiNodeSuiteError(
|
|
|
|
|
"failed to start " & $role &
|
|
|
|
|
" because logfile path could not be obtained: " & e.msg,
|
|
|
|
|
e,
|
|
|
|
|
)
|
2024-03-12 10:57:13 +01:00
|
|
|
|
2025-02-05 18:31:40 +11:00
|
|
|
if DebugCodexNodes:
|
2025-03-04 13:05:03 +11:00
|
|
|
config.addCliOption("--log-level", $LogLevel.TRACE)
|
|
|
|
|
|
2025-02-06 16:53:25 +11:00
|
|
|
var apiPort, discPort: int
|
|
|
|
|
withLock(codexPortLock):
|
|
|
|
|
apiPort = await nextFreePort(lastUsedCodexApiPort + nodeIdx)
|
|
|
|
|
discPort = await nextFreePort(lastUsedCodexDiscPort + nodeIdx)
|
|
|
|
|
config.addCliOption("--api-port", $apiPort)
|
|
|
|
|
config.addCliOption("--disc-port", $discPort)
|
|
|
|
|
lastUsedCodexApiPort = apiPort
|
|
|
|
|
lastUsedCodexDiscPort = discPort
|
2025-02-03 15:33:41 +11:00
|
|
|
|
2024-12-18 15:10:36 +07:00
|
|
|
for bootstrapNode in bootstrapNodes:
|
|
|
|
|
config.addCliOption("--bootstrap-node", bootstrapNode)
|
2025-02-03 15:33:41 +11:00
|
|
|
|
2024-03-12 10:57:13 +01:00
|
|
|
config.addCliOption("--data-dir", datadir)
|
2025-01-09 23:41:22 +05:30
|
|
|
config.addCliOption("--nat", "none")
|
2024-03-12 10:57:13 +01:00
|
|
|
config.addCliOption("--listen-addrs", "/ip4/127.0.0.1/tcp/0")
|
|
|
|
|
except CodexConfigError as e:
|
|
|
|
|
raiseMultiNodeSuiteError "invalid cli option, error: " & e.msg
|
|
|
|
|
|
|
|
|
|
try:
|
2025-02-24 17:29:44 +11:00
|
|
|
let node = await CodexProcess.startNode(
|
|
|
|
|
config.cliArgs, config.debugEnabled, $role & $roleIdx
|
|
|
|
|
)
|
2024-03-12 10:57:13 +01:00
|
|
|
await node.waitUntilStarted()
|
|
|
|
|
trace "node started", nodeName = $role & $roleIdx
|
2025-02-24 17:29:44 +11:00
|
|
|
return node
|
|
|
|
|
except CodexConfigError as e:
|
|
|
|
|
raiseMultiNodeSuiteError "failed to get cli args from config: " & e.msg, e
|
2024-03-12 10:57:13 +01:00
|
|
|
except NodeProcessError as e:
|
2025-02-24 17:29:44 +11:00
|
|
|
raiseMultiNodeSuiteError "node not started, error: " & e.msg, e
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
|
|
|
|
proc hardhat(): HardhatProcess =
|
|
|
|
|
for r in running:
|
|
|
|
|
if r.role == Role.Hardhat:
|
|
|
|
|
return HardhatProcess(r.node)
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
|
|
proc clients(): seq[CodexProcess] {.used.} =
|
|
|
|
|
return collect:
|
|
|
|
|
for r in running:
|
|
|
|
|
if r.role == Role.Client:
|
|
|
|
|
CodexProcess(r.node)
|
|
|
|
|
|
|
|
|
|
proc providers(): seq[CodexProcess] {.used.} =
|
|
|
|
|
return collect:
|
|
|
|
|
for r in running:
|
|
|
|
|
if r.role == Role.Provider:
|
|
|
|
|
CodexProcess(r.node)
|
|
|
|
|
|
|
|
|
|
proc validators(): seq[CodexProcess] {.used.} =
|
|
|
|
|
return collect:
|
|
|
|
|
for r in running:
|
|
|
|
|
if r.role == Role.Validator:
|
|
|
|
|
CodexProcess(r.node)
|
|
|
|
|
|
2025-02-24 17:29:44 +11:00
|
|
|
proc startHardhatNode(
|
|
|
|
|
config: HardhatConfig
|
|
|
|
|
): Future[NodeProcess] {.async: (raises: [MultiNodeSuiteError, CancelledError]).} =
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
return await newHardhatProcess(config, Role.Hardhat)
|
|
|
|
|
|
2024-03-12 10:57:13 +01:00
|
|
|
proc startClientNode(conf: CodexConfig): Future[NodeProcess] {.async.} =
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
let clientIdx = clients().len
|
2024-03-12 10:57:13 +01:00
|
|
|
var config = conf
|
2024-12-14 06:07:55 +01:00
|
|
|
config.addCliOption(StartUpCmd.persistence, "--eth-provider", jsonRpcProviderUrl)
|
2024-03-12 10:57:13 +01:00
|
|
|
config.addCliOption(
|
|
|
|
|
StartUpCmd.persistence, "--eth-account", $accounts[running.len]
|
|
|
|
|
)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
return await newCodexProcess(clientIdx, config, Role.Client)
|
|
|
|
|
|
2025-02-24 17:29:44 +11:00
|
|
|
proc startProviderNode(
|
|
|
|
|
conf: CodexConfig
|
|
|
|
|
): Future[NodeProcess] {.async: (raises: [MultiNodeSuiteError, CancelledError]).} =
|
|
|
|
|
try:
|
|
|
|
|
let providerIdx = providers().len
|
|
|
|
|
var config = conf
|
|
|
|
|
config.addCliOption(
|
|
|
|
|
StartUpCmd.persistence, "--eth-provider", jsonRpcProviderUrl
|
|
|
|
|
)
|
|
|
|
|
config.addCliOption(
|
|
|
|
|
StartUpCmd.persistence, "--eth-account", $accounts[running.len]
|
|
|
|
|
)
|
|
|
|
|
config.addCliOption(
|
|
|
|
|
PersistenceCmd.prover, "--circom-r1cs",
|
|
|
|
|
"vendor/codex-contracts-eth/verifier/networks/hardhat/proof_main.r1cs",
|
|
|
|
|
)
|
|
|
|
|
config.addCliOption(
|
|
|
|
|
PersistenceCmd.prover, "--circom-wasm",
|
|
|
|
|
"vendor/codex-contracts-eth/verifier/networks/hardhat/proof_main.wasm",
|
|
|
|
|
)
|
|
|
|
|
config.addCliOption(
|
|
|
|
|
PersistenceCmd.prover, "--circom-zkey",
|
|
|
|
|
"vendor/codex-contracts-eth/verifier/networks/hardhat/proof_main.zkey",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return await newCodexProcess(providerIdx, config, Role.Provider)
|
|
|
|
|
except CodexConfigError as e:
|
|
|
|
|
raiseMultiNodeSuiteError "Failed to start codex node, error adding cli options: " &
|
|
|
|
|
e.msg, e
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
2025-02-24 17:29:44 +11:00
|
|
|
proc startValidatorNode(
|
|
|
|
|
conf: CodexConfig
|
|
|
|
|
): Future[NodeProcess] {.async: (raises: [MultiNodeSuiteError, CancelledError]).} =
|
|
|
|
|
try:
|
|
|
|
|
let validatorIdx = validators().len
|
|
|
|
|
var config = conf
|
|
|
|
|
config.addCliOption(
|
|
|
|
|
StartUpCmd.persistence, "--eth-provider", jsonRpcProviderUrl
|
|
|
|
|
)
|
|
|
|
|
config.addCliOption(
|
|
|
|
|
StartUpCmd.persistence, "--eth-account", $accounts[running.len]
|
|
|
|
|
)
|
|
|
|
|
config.addCliOption(StartUpCmd.persistence, "--validator")
|
|
|
|
|
|
|
|
|
|
return await newCodexProcess(validatorIdx, config, Role.Validator)
|
|
|
|
|
except CodexConfigError as e:
|
|
|
|
|
raiseMultiNodeSuiteError "Failed to start validator node, error adding cli options: " &
|
|
|
|
|
e.msg, e
|
2023-06-22 20:32:18 +10:00
|
|
|
|
2025-02-24 17:29:44 +11:00
|
|
|
proc teardownImpl() {.async: (raises: []).} =
|
2024-03-12 10:57:13 +01:00
|
|
|
for nodes in @[validators(), clients(), providers()]:
|
|
|
|
|
for node in nodes:
|
|
|
|
|
await node.stop() # also stops rest client
|
2025-02-24 17:29:44 +11:00
|
|
|
try:
|
|
|
|
|
node.removeDataDir()
|
|
|
|
|
except CodexProcessError as e:
|
|
|
|
|
error "Failed to remove data dir during teardown", error = e.msg
|
2024-03-12 10:57:13 +01:00
|
|
|
|
|
|
|
|
# if hardhat was started in the test, kill the node
|
|
|
|
|
# otherwise revert the snapshot taken in the test setup
|
|
|
|
|
let hardhat = hardhat()
|
|
|
|
|
if not hardhat.isNil:
|
|
|
|
|
await hardhat.stop()
|
|
|
|
|
else:
|
2025-02-24 17:29:44 +11:00
|
|
|
try:
|
|
|
|
|
discard await noCancel send(ethProvider, "evm_revert", @[snapshot])
|
|
|
|
|
except ProviderError as e:
|
|
|
|
|
error "Failed to revert hardhat state during teardown", error = e.msg
|
2024-03-12 10:57:13 +01:00
|
|
|
|
2025-05-23 16:13:19 +02:00
|
|
|
await ethProvider.close()
|
|
|
|
|
|
2024-03-12 10:57:13 +01:00
|
|
|
running = @[]
|
|
|
|
|
|
|
|
|
|
template failAndTeardownOnError(message: string, tryBody: untyped) =
|
|
|
|
|
try:
|
|
|
|
|
tryBody
|
2025-02-24 17:29:44 +11:00
|
|
|
except CancelledError as e:
|
2025-03-04 13:11:38 +11:00
|
|
|
await teardownImpl()
|
|
|
|
|
when declared(teardownAllIMPL):
|
|
|
|
|
teardownAllIMPL()
|
|
|
|
|
fail()
|
|
|
|
|
quit(1)
|
2024-03-12 10:57:13 +01:00
|
|
|
except CatchableError as er:
|
|
|
|
|
fatal message, error = er.msg
|
|
|
|
|
echo "[FATAL] ", message, ": ", er.msg
|
|
|
|
|
await teardownImpl()
|
|
|
|
|
when declared(teardownAllIMPL):
|
|
|
|
|
teardownAllIMPL()
|
|
|
|
|
fail()
|
|
|
|
|
quit(1)
|
|
|
|
|
|
2025-03-17 17:08:24 -03:00
|
|
|
proc updateBootstrapNodes(
|
|
|
|
|
node: CodexProcess
|
2025-02-24 17:29:44 +11:00
|
|
|
): Future[void] {.async: (raises: [MultiNodeSuiteError]).} =
|
|
|
|
|
try:
|
|
|
|
|
without ninfo =? await node.client.info():
|
|
|
|
|
# raise CatchableError instead of Defect (with .get or !) so we
|
|
|
|
|
# can gracefully shutdown and prevent zombies
|
|
|
|
|
raiseMultiNodeSuiteError "Failed to get node info"
|
|
|
|
|
bootstrapNodes.add ninfo["spr"].getStr()
|
|
|
|
|
except CatchableError as e:
|
|
|
|
|
raiseMultiNodeSuiteError "Failed to get node info: " & e.msg, e
|
|
|
|
|
|
|
|
|
|
setupAll:
|
refactor: debug and logging
- Move test manager values to config object
- Increase codex port separation (between api and disc ports) in an attempt to prevent overlap across tests (ie Test1: api=8000(tcp), disc=9000(udp), and Test2: api=9000(tcp), disc=10000(udp))
- print stderr when exitcode == 1 if there's < 3 lines of stdout
- Logging:
- Always write test manager harness chronicles logs to file, ie testmanager.chronicles.log in the root of the `integration/logs/<run name>` dir
- Always write individual test stdout to file, ie `<test file name>.stdout.log` in the root of the `integration/logs/<run name>/<test file name>` dir
- On error, print stderr to screen and write stderr to file. Or on failure, if stdout is sufficiently short, write stderr to screen and file in `integration/logs/<run name>/<test file name>/<test file name>.stderr.log`
- When debugging, ie DebugCodexNodes == true
- Removes DebugTestHarness from controlling anything other than printing chronicles output from the testmanager to the terminal
- Now, if DebugCodexNodes is set to true:
- Codex node (chronicles) output for multinodesuite tests is logged to file, eg `integration/logs/<run name>/<test file name>/<test name>/<role>_<idx>.log`
- Codex chronicles output is logged to stdout, which also written to file (see above)
2025-03-06 15:49:08 +11:00
|
|
|
# When this file is run with `-d:chronicles_sinks=textlines[file]`, we
|
|
|
|
|
# need to set the log file path at runtime, otherwise chronicles didn't seem to
|
|
|
|
|
# create a log file even when using an absolute path
|
|
|
|
|
when defaultChroniclesStream.outputs is (FileOutput,) and LogsDir.len > 0:
|
|
|
|
|
let logFile =
|
|
|
|
|
LogsDir / sanitize(getAppFilename().extractFilename & ".chronicles.log")
|
|
|
|
|
let success = defaultChroniclesStream.outputs[0].open(logFile, fmAppend)
|
|
|
|
|
doAssert success, "Failed to open log file: " & logFile
|
2024-12-18 15:10:36 +07:00
|
|
|
|
2023-06-22 20:32:18 +10:00
|
|
|
setup:
|
2024-03-12 10:57:13 +01:00
|
|
|
if var conf =? nodeConfigs.hardhat:
|
|
|
|
|
try:
|
2025-02-24 17:29:44 +11:00
|
|
|
let node = await noCancel startHardhatNode(conf)
|
2024-03-12 10:57:13 +01:00
|
|
|
running.add RunningNode(role: Role.Hardhat, node: node)
|
2025-03-04 13:11:38 +11:00
|
|
|
except CatchableError as e: # CancelledError not raised due to noCancel
|
2024-03-12 10:57:13 +01:00
|
|
|
echo "failed to start hardhat node"
|
|
|
|
|
fail()
|
|
|
|
|
quit(1)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
|
|
|
|
|
try:
|
2024-03-12 09:18:25 +01:00
|
|
|
# Workaround for https://github.com/NomicFoundation/hardhat/issues/2053
|
|
|
|
|
# Do not use websockets, but use http and polling to stop subscriptions
|
|
|
|
|
# from being removed after 5 minutes
|
2025-05-23 16:13:19 +02:00
|
|
|
ethProvider = JsonRpcProvider.new(jsonRpcProviderUrl)
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
# if hardhat was NOT started by the test, take a snapshot so it can be
|
|
|
|
|
# reverted in the test teardown
|
2024-03-12 10:57:13 +01:00
|
|
|
if nodeConfigs.hardhat.isNone:
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
snapshot = await send(ethProvider, "evm_snapshot")
|
|
|
|
|
accounts = await ethProvider.listAccounts()
|
2025-02-24 17:29:44 +11:00
|
|
|
except CancelledError as e:
|
|
|
|
|
raise e
|
refactor: multinode integration test refactor (#662)
* refactor multi node test suite
Refactor the multinode test suite into the marketplace test suite.
- Arbitrary number of nodes can be started with each test: clients, providers, validators
- Hardhat can also be started locally with each test, usually for the purpose of saving and inspecting its log file.
- Log files for all nodes can be persisted on disk, with configuration at the test-level
- Log files, if persisted (as specified in the test), will be persisted to a CI artifact
- Node config is specified at the test-level instead of the suite-level
- Node/Hardhat process starting/stopping is now async, and runs much faster
- Per-node config includes:
- simulating proof failures
- logging to file
- log level
- log topics
- storage quota
- debug (print logs to stdout)
- Tests find next available ports when starting nodes, as closing ports on Windows can lag
- Hardhat is no longer required to be running prior to starting the integration tests (as long as Hardhat is configured to run in the tests).
- If Hardhat is already running, a snapshot will be taken and reverted before and after each test, respectively.
- If Hardhat is not already running and configured to run at the test-level, a Hardhat process will be spawned and torn down before and after each test, respectively.
* additional logging for debug purposes
* address PR feedback
- fix spelling
- revert change from catching ProviderError to SignerError -- this should be handled more consistently in the Market abstraction, and will be handled in another PR.
- remove method label from raiseAssert
- remove unused import
* Use API instead of command exec to test for free port
Use chronos `createStreamServer` API to test for free port by binding localhost address and port. Use `ServerFlags.ReuseAddr` to enable reuse of same IP/Port on multiple test runs.
* clean up
* remove upraises annotations from tests
* Update tests to work with updated erasure coding slot sizes
* update dataset size, nodes, tolerance to match valid ec params
Integration tests now have valid dataset sizes (blocks), tolerances, and number of nodes, to work with valid ec params. These values are validated when requested storage.
Print the rest api failure message (via doAssert) when a rest api call fails (eg the rest api may validate some ec params).
All integration tests pass when the async `clock.now` changes are reverted.
* dont use async clock for now
* fix workflow
* move integration logs uplod to reusable
---------
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
2024-02-19 15:55:39 +11:00
|
|
|
except CatchableError as e:
|
2024-03-12 10:57:13 +01:00
|
|
|
echo "Hardhat not running. Run hardhat manually " &
|
|
|
|
|
"before executing tests, or include a " & "HardhatConfig in the test setup."
|
|
|
|
|
fail()
|
|
|
|
|
quit(1)
|
|
|
|
|
|
|
|
|
|
if var clients =? nodeConfigs.clients:
|
|
|
|
|
failAndTeardownOnError "failed to start client nodes":
|
|
|
|
|
for config in clients.configs:
|
2025-02-24 17:29:44 +11:00
|
|
|
let node = await noCancel startClientNode(config)
|
2024-03-12 10:57:13 +01:00
|
|
|
running.add RunningNode(role: Role.Client, node: node)
|
2025-03-17 17:08:24 -03:00
|
|
|
await CodexProcess(node).updateBootstrapNodes()
|
2024-03-12 10:57:13 +01:00
|
|
|
|
|
|
|
|
if var providers =? nodeConfigs.providers:
|
|
|
|
|
failAndTeardownOnError "failed to start provider nodes":
|
|
|
|
|
for config in providers.configs.mitems:
|
2025-02-24 17:29:44 +11:00
|
|
|
let node = await noCancel startProviderNode(config)
|
2024-03-12 10:57:13 +01:00
|
|
|
running.add RunningNode(role: Role.Provider, node: node)
|
2025-03-17 17:08:24 -03:00
|
|
|
await CodexProcess(node).updateBootstrapNodes()
|
2024-03-12 10:57:13 +01:00
|
|
|
|
|
|
|
|
if var validators =? nodeConfigs.validators:
|
|
|
|
|
failAndTeardownOnError "failed to start validator nodes":
|
|
|
|
|
for config in validators.configs.mitems:
|
2025-02-24 17:29:44 +11:00
|
|
|
let node = await noCancel startValidatorNode(config)
|
2024-03-12 10:57:13 +01:00
|
|
|
running.add RunningNode(role: Role.Validator, node: node)
|
2023-06-22 20:32:18 +10:00
|
|
|
|
2024-05-23 17:29:30 +02:00
|
|
|
# ensure that we have a recent block with a fresh timestamp
|
|
|
|
|
discard await send(ethProvider, "evm_mine")
|
|
|
|
|
|
2023-06-22 20:32:18 +10:00
|
|
|
teardown:
|
2024-03-12 10:57:13 +01:00
|
|
|
await teardownImpl()
|
2023-06-22 20:32:18 +10:00
|
|
|
|
|
|
|
|
body
|