Skip to content

Runtime selection of field vs simulated gameplay tests#3744

Open
nycrat wants to merge 50 commits into
masterfrom
avah/combine_simulated_and_field_tests
Open

Runtime selection of field vs simulated gameplay tests#3744
nycrat wants to merge 50 commits into
masterfrom
avah/combine_simulated_and_field_tests

Conversation

@nycrat

@nycrat nycrat commented May 27, 2026

Copy link
Copy Markdown
Member

Description

This is a stacked PR: #3744 #3806 #3807

This PR combines simulated and field gameplay test runners under the common TbotsTestRunner interface. This allows all tests to be run as either field tests or simulated tests with just a different flag passed into the bazel test command.

This PR contains many refactoring changes to our existing python testing framework. These changes were important to improving code quality while implementing the changes, and they will make it easier to implement #3369 in the future.

  • ./tbots.py test move_tactic_test
  • ./tbots.py test move_tactic_field_test
  • ./tbots.py test move_tactic_test --run_field_test
  • ./tbots.py test move_tactic_field_test --run_field_test

Testing Done

  • All existing sim and field tests can now be ran as simulated tests
  • All tests can be ran as field tests, however, the robot ids have to match

Resolved Issues

resolves #2908
resolves #2856 cause this PR just gets rid of simulated aggregate tests
resolves #3784

Length Justification and Key Files to Review

A lot of just renaming and combining the simulated_tests and field_tests under the gameplay_tests package. None of the logic is changed for validations and existing tests.

Important not just refactoring changes to review:

(in src/software/gameplay_tests)

  • fixture.py
  • util.py
  • tbots_test_runner.py
  • field_test_runner.py
  • simulated_test_runner.py

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

@nycrat nycrat force-pushed the avah/combine_simulated_and_field_tests branch 5 times, most recently from f7b544d to db5f8e2 Compare June 1, 2026 18:24
@williamckha williamckha mentioned this pull request Jun 8, 2026
4 tasks
@nycrat nycrat force-pushed the avah/combine_simulated_and_field_tests branch from db5f8e2 to fd08dcd Compare June 14, 2026 03:02
@nycrat nycrat force-pushed the avah/combine_simulated_and_field_tests branch from d5f2675 to a49d254 Compare June 16, 2026 22:08
@nycrat nycrat requested a review from annieisawesome2 June 21, 2026 03:54
while True:
try:
world = self.world_buffer.get(
block=True, timeout=WORLD_BUFFER_TIMEOUT

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.

Hi! From my understanding whne the test is waiting for a world message and none arrive in 5 seconds it logs ending test early but it doesn't actually end early (just logs message and tries waiting again... could just wait forever if no world shows up?) I don't think the timeout gets checked when it's stuck in this loop. I think this is cause the code was copied from simulated test runner where retrying made sense... on each retry we re send the missing data so it can probably eventually fix the problem but in field runner that resend logic is missing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah I think your logic makes sense. This exact code was from like 3 years ago when field test runner was initially created so idk how this bug was not spotted yet. I'll write a fix so that the test actually stops

Comment thread src/software/gameplay_tests/passing_field_test.py Outdated
import pytest


def get_runtime_dir():

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.

doesn't this break the CI uploads? The old code put test files in /tmp/tbots locally but this generates a random folder. But CI looks for log files in /tmp/tbots/blue/... and /tmp/tbots/yellow/... which show up in randomly named folders... I don't think CI can find them?

Could we bring back TEST_TMPDIR symlink behavior, default to /tmp/tbots locally like before. Then add something random to the path if you actually need to run tests at the same time?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh nice catch I actually didn't know about this. I think this should be separated into another ticket cause this behaviour of get_runtime_dir was already implemented before this PR. I'm thinking of putting the randomly generated folders in /tmp/tbots/ cause its still necessary in ci_mode to have different folders

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

New issue here: #3793

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.

thanks!

@nycrat nycrat requested a review from annieisawesome2 June 21, 2026 21:27
@nycrat

nycrat commented Jun 21, 2026

Copy link
Copy Markdown
Member Author

@annieisawesome2 I addressed comments, ready for re-review if you have time

@nycrat nycrat force-pushed the avah/combine_simulated_and_field_tests branch from fa2aba5 to e42ab95 Compare June 21, 2026 22:00
@annieisawesome2

Copy link
Copy Markdown
Contributor

@annieisawesome2 I addressed comments, ready for re-review if you have time

Sounds good I will finish up tonight

@nycrat nycrat force-pushed the avah/combine_simulated_and_field_tests branch from 8fd923b to 42e8972 Compare June 22, 2026 17:53
time_elapsed_s += time.time() - processing_start_time

# Check that all eventually validations are eventually valid
validation.check_validation(eventually_validation_proto_set)

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.

All the new changes look great! One small thing with the world timeout fix. If no world is received, here it references eventually_validation_proto_set before it is assigned i think. we can probs just fix with pytest.fail.. in the except queue.Empty block?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right I didn't notice that. I rewrote it to raise an exception since that is the same mechanism the test validations use to signal a test failure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants