Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite partitioning #1110

Merged
merged 36 commits into from
Sep 22, 2023
Merged

Conversation

dataclouder
Copy link
Collaborator

@dataclouder dataclouder commented Aug 22, 2023

Experimental method to partition the tests from the acceptance test suite.
In short, it works this way: you run the test with two parameters:

  • -vcd-partitions=3 // this is the number of partitions
  • -vcd-partition-node=1 // this is the identified of the current node

In the other two VCDs, you run the same command, but with -vcd-partition-node=2 and -vcd-partition-node=3. The tests get split in three parts, and each node gets one piece.
The partitioning works by collecting the test names from the current directory, sorting them, and assigning a node number to each name, before the test starts. The operation should give the same result in every VCD, provided that all nodes work on the same branch and commit.

Prerequisites:

  1. Every test must have a preTestCheck and postTestCheck function calls
  2. All VCDs participating in the test must use the same branch and commit
  3. We must not run two or more partitions in the same VCD: it will probably lead to conflicts

Possible problems:

  • Every node in the partition is independent, and has no connection of other nodes.
  • There is no completion check: we can't be sure that all nodes have run their share.
  • Users who run partitioned tests must make sure that:
    • They use the same number of partitions in every test call
    • They use different node numbers in each VCD participating to the distributed run (it is possible to run the same partition on multiple nodes, which would be a total waste of resources)
    • They start as many nodes as the number of partitions declared (starting fewer nodes will leave tests out of the suite run)

Possible enhancements:

  • Every node could produce a log of the tests it ran and the ones it skipped (DONE);
  • The results could be consolidated after completion;
  • The node logs could be compared to make sure that all tests were considered by any node;
  • A sentinel resource could be created at the start of the test suite to make sure that no calls to the test suite will run on the same VCD.

Preparation for parallel handling
This feature would work better if a centralized process were to start all the nodes, and collect the results.
For this reason, the following features were added:

  • there is an option -vcd-partition-tests-file with the name of the file containing the tests that will run in the current node. If such an option was provided, the node will not attempt to create its own list of tests
  • The names of all the test files produced by the node are standardized. If running under a Jenkins job, the names will contain the build number.
  • A sentinel file is created at the end of the test suite, containing the exit code of the run.

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
* Add ability of using third-party tests file
* Standardize file names, using build number if available
* Remove 'dry-run', as '-vcd-short' will achieve the same result
* Create a sentinel file (containing exit code) at the end of the tests

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
@dataclouder dataclouder marked this pull request as ready for review September 19, 2023 05:33
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

Looks great! Only there's no changelog entry.

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
@dataclouder
Copy link
Collaborator Author

Looks great! Only there's no changelog entry.

Added

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

First few comments on a first look. I think it would be good to have a small paragraph about how to execute core functionality with bare hands (using newly introduced flags) in TESTING.md.

scripts/start-multi-node-test.sh Outdated Show resolved Hide resolved
scripts/start-multi-node-test.sh Outdated Show resolved Hide resolved
vcd/config_test.go Show resolved Hide resolved
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
TESTING.md Outdated Show resolved Hide resolved
TESTING.md Show resolved Hide resolved
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

I have done a few runs on smaller set of tests and it worked - thanks!

TESTING.md Show resolved Hide resolved
vcd/resource_vcd_vapp_raw_multi_test.go Show resolved Hide resolved
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Copy link
Contributor

@adezxc adezxc left a comment

Choose a reason for hiding this comment

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

Ran a small subset of tests on my own machine and worked great! Thanks for this improvement

@dataclouder dataclouder merged commit 9322efa into vmware:main Sep 22, 2023
2 checks passed
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.

None yet

5 participants