2.9 KiB
2.9 KiB
Distributed System Tests for Nim-Codex
Contributing tests
Do you want to write some tests for Codex using this distributed test setup? Great! Here's what you do.
- Create a branch. Name it something descriptive, but start it with
tests/
please. [Example:tests/data-redundancy
.] - Checkout your branch, and decide if your tests will be 'short' tests (minutes to hours), or 'long' tests (hours to days), or both! Create a folder for your tests in the matching folders (
/Tests
,/LongTests
) and don't worry: You can always move your tests later if you like. [Example, short:/Tests/DataRedundancy/
, long:/LongTests/DataRedundancy/
] - Create one or more code files in your new folder, and write some tests! Here are some tips to help you get started. You can always take a look at the example tests found in
/Tests/BasicTests/ExampleTests.cs
- Set up a standard NUnit test fixture.
- Inherrit from
DistTest
orAutoBootstrapDistTest
. - When using
DistTest
:- You must start your own Codex bootstrap node. You can use
SetupCodexBootstrapNode(...)
for this. - When you start other Codex nodes with
SetupCodexNodes(...)
you can pass the bootstrap node by adding the.WithBootstrapNode(...)
option.
- You must start your own Codex bootstrap node. You can use
- When using
AutoBootstrapDistTest
:- The test-infra creates the bootstrap node for you, and automatically passes it to each Codex node you create in your tests. Handy for keeping your tests clean and to-the-point.
- When using the auto-bootstrap, you have no control over the bootstrap node from your tests. You can't (for example) shut it down during the course of the test. If you need this level of control for your scenario, use the
DistTest
instead.
- You can generate files of random test data by calling
GenerateTestFile(...)
. - If your test needs a long time to run, add the
[UseLongTimeouts]
function attribute. This will greatly increase maximum time-out values for operations like for example uploading and downloading files. - You can enable access to the Codex node metrics by adding the option
.EnableMetrics()
. Enabling metrics will make the test-infra download and save all Codex metrics in case of a test failure. (The metrics are stored as CSV, in the same location as the test log file.) - You can enable access to the blockchain marketplace by adding the option
.EnableMarketplace(...)
. - Enabling metrics and/or enabling the marketplace takes extra resources from the test-infra and increases the time needed during Codex node setup. Please don't enable these features unless your tests need them.
- Tip: Codex nodes can be named. Use the option
WithName(...)
and make reading your test logs a little nicer! - Tip: Commit often.
- Once you're happy with your tests, please create a pull-request and ask (another) Codex core contributor to review your changes.