Skip to content

Extend nat-lab.sh for natlab-subset sharding - #1937

Open
stalowyjez wants to merge 4 commits into
mainfrom
nat-lab-subset-sharding
Open

Extend nat-lab.sh for natlab-subset sharding#1937
stalowyjez wants to merge 4 commits into
mainfrom
nat-lab-subset-sharding

Conversation

@stalowyjez

@stalowyjez stalowyjez commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Problem

Every nat-lab shard is quite heavy running the whole nat-lab

Solution

Let's add additional options for running nat-lab, so we can divide tests into shards which run only particular subset of all nat-lab containers, thus reducing the overall load

☑️ Definition of Done checklist

  • Commit history is clean (requirements)
  • README.md is updated
  • Functionality is covered by unit or integration tests

@stalowyjez
stalowyjez requested a review from a team as a code owner August 7, 2026 11:02
@stalowyjez
stalowyjez force-pushed the nat-lab-subset-sharding branch from 489a30d to 86ab3a6 Compare August 25, 2026 13:04
@stalowyjez
stalowyjez force-pushed the nat-lab-subset-sharding branch from b3444ad to 35ec855 Compare August 25, 2026 15:36
@stalowyjez
stalowyjez force-pushed the nat-lab-subset-sharding branch from 35ec855 to 86ab3a6 Compare August 26, 2026 11:00
@stalowyjez
stalowyjez force-pushed the nat-lab-subset-sharding branch from 86ab3a6 to 4baa9da Compare August 26, 2026 12:09
@stalowyjez
stalowyjez force-pushed the nat-lab-subset-sharding branch from 4baa9da to 77a8067 Compare August 26, 2026 14:33
@stalowyjez
stalowyjez force-pushed the nat-lab-subset-sharding branch from 86c8464 to 8c78ece Compare August 28, 2026 14:18
@stalowyjez
stalowyjez force-pushed the nat-lab-subset-sharding branch from 8c78ece to 21b9913 Compare August 28, 2026 21:55

@gytsto gytsto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

Comment thread nat-lab/tests/test_nordvpnlite.py Outdated

# CI load balancing only - see the shard_* markers in pyproject.toml. These tests need
# nothing beyond the plain docker services.
pytestmark = pytest.mark.shard_windows

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this mean that the tests will run only on Windows container? 😕 This doesn't seem right since nordvpnlite was never intended to run on Windows

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nah, it only will run on Windows shards, it will use the pure docker containers only (i.e. even if this test file contains some tests using additional containers, it is always used with DOCKER_ONLY, so only these using the basic containers will run)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we document somehow more explicitly what Windows shards entail and how Windows shards is different from regular shard?

Reading it for the first time gives the impression that only Windows containers / VMs are started, and/or that only Windows tests are run in this shard. Does the Windows shard start all the regular natlab containers + Windows VMs?

I wonder if there is a more "elegant way" to assign the shards, personally find it puzzling at first glance to see mark windows inside of nordvpnlite.py.

Comment thread nat-lab/tests/test_upnp_connection.py Outdated

# CI load balancing only - see the shard_* markers in pyproject.toml. The windows/mac
# params below keep their own marks, so they still run on their own shards.
pytestmark = pytest.mark.shard_openwrt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused, does this includes or excludes the tests from OpenWRT?

If the former, why would we want to test UPNP only on OpenWRT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

windows and mac tests are excluded from this load balancing, because we always use it with DOCKER_ONLY filter in CI config, so only these using basic containers are under this mark and these will be moved to openwrt shard to better balance the tests between them

Comment thread nat-lab/tests/test_ens.py
Comment thread nat-lab/tests/test_dns.py Outdated

# CI load balancing only - see the shard_* markers in pyproject.toml. These tests need
# nothing beyond the plain docker services.
pytestmark = pytest.mark.shard_mac

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These tests need nothing beyond the plain docker services.

Is this true for the macOS VM though?

Also, how does this interact with the mac shard, none of the tests below specify ConnectionTag.VM_MAC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The tests don't need anything more than lite-mode, but because we have a bit too much litemode tests, it makes sense to move them to other shards to balance it a bit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see so this just manually "assigns" the test to the shard that runs the macOS tests?

What happens if I accidentally mark test_openwrt.py with shard_mac?

Using the given JSON description of natlab shards and known test
durations determine the test split and use the proper test set for the
considered shard in conftest.
Currently the test success is dependent on when it is run among the
other tests - it should be able to be run as the first test, though, so
in this commit we add some robustness to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants