Skip to content

PHPC-2261: Revamp Evergreen config #1473

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

Merged
merged 44 commits into from
Oct 16, 2023

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Sep 22, 2023

This PR takes care of PHPC-2260 and PHPC-2261. The following changes have been made, while others are still pending:

  • Extract build tasks from testing to cache build results
  • Make test tasks depend on build tasks
  • Remove matrix build variants in favour of separate ones
  • Migrate existing special tests (OCSP, etc.) to new format
  • Automate generation of build tasks and potentially variants
  • Document structure of evergreen files and how to add/remove tasks/variants in future

The last task is still left to do. However, since generate.tasks does not show generated tasks when configuring a patch build, it is not suitable for us. However, repetitive files (e.g. the version-dependent tasks) will be generated automatically via a script to avoid repetition and errors.

In addition to the changes above, the following semi-related changes have been made:

  • After compilation, a smoketest is run to ensure the library can be loaded. This prevents running a large number of tasks that won't complete successfully
  • Add a make target that runs tests without compiling everything. This was done to avoid having to recursively replace directory names in all build output files. We may opt to invoke run-tests.php directly.
  • Extracted configuration to multiple files to make files easier to understand and use
  • Removed unused functions/tasks (there may be more left to remove)

For now, tests are only run on Debian systems:

  • With PHP 8.2, we test all topologies on all MongoDB versions. This uses Debian 11 and Debian 9.2 to cover MongoDB 3.6 up to the latest build
  • Older PHP versions only test MongoDB 7.0 in a replica set topology with authentication enabled.
  • Other environments are not tested.

We'll have to discuss what tests we want present, and which ones we want to run for pull requests and commits. We may want to include more tasks but not run them by default to allow for testing special scenarios, although those can be added when necessary.

set -o errexit # Exit the script with error if any of the commands fail

# Find PHP binary path for the requested version
Copy link
Member Author

Choose a reason for hiding this comment

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

This was moved over so we can run compile for multiple PHP versions on the same box if we wanted to.

Comment on lines +22 to +26
- name: "test-ocsp-latest"
execution_tasks:
- ".ocsp .latest"
Copy link
Member Author

Choose a reason for hiding this comment

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

Display tasks group a number of tasks in the "configure patch" view. While this limits us to have to select/unselect all OCSP tests at once without having a choice of enabling only some of them, I believe this is fine. Each OCSP test is an individual task due to the way these are structured.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM. I think there's also room for improvement here. If we look at libmongoc, I believe they extracted most of their OCSP logic into run-ocsp-test.sh, which makes the Evergreen configuration more readable. That might allow us to do reduce the complexity of _template-ocsp.yml and bring it more in line with other templates where we'd only selecting server versions.

@@ -0,0 +1,389 @@
tasks:
- name: "ocsp-test_1-rsa-delegate-7.0"
Copy link
Member Author

Choose a reason for hiding this comment

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

The OCSP tasks may be candidates for using a task group. This would allow us to only fetch the build once, install the correct MongoDB version, then run all tasks sequentially on the same build host. This would further cut down resource usage. However, we'll want to make some improvements to mongodb-orchestration to make sure we can set up and tear down OCSP responders properly. We might also have to split up the mongo-orchestration files to allow for separate functions for downloading MongoDB, starting/stopping orchestration, and starting/stopping a deployment.

Comment on lines +33 to +40
include:
- filename: .evergreen/config/functions.yml
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, include is only allowed in top-level files, so we can't nest our includes (and include the various test files in test-tasks.yml).

@alcaeus alcaeus force-pushed the phpc-2201-2260-revamp-evergreen-config branch 10 times, most recently from c859cd6 to d9bb19b Compare September 27, 2023 07:31
Comment on lines +33 to +36
# Define aliases for patch builds and PR builds. These only apply if no aliases are defined in project settings
github_pr_aliases:
# Run all build tasks, except on Power8 and zSeries due to low number of build hardware
- variant: "^build-[^-]+($|-arm64)"
task: ".*"
# Run tests on debian, only testing local replicasets with authentication enabled
- variant: "test-.*"
task: "test-mongodb-.*-replicaset-auth"
Copy link
Member Author

Choose a reason for hiding this comment

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

This configuration only takes effect once the configuration in the project settings has been removed, which I'll do after this pull request is merged.

In addition to this, using variant and task tags for aliases does not work as expected (see EVG-20579), so I've had to come up with regular expressions until that issue is resolved.

@@ -88,3 +88,27 @@ generate-function-map: all
else \
echo "ERROR: Cannot generate function maps without CLI sapi."; \
fi

test-no-build:
Copy link
Member Author

Choose a reason for hiding this comment

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

This target was necessary to avoid make trying to recompile the extension due to the different paths in the various .dep files. Instead of replacing paths in more files than just Makefile, I decided to copy the original test target and remove the dependency to all.

Alternatively, we can also extract the call to run-tests.php, but at that point we may as well consider using a different test runner entirely, such as PHPUnit (which can run phpt files as well).

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we can also extract the call to run-tests.php

I was originally going to suggest replacing this Makefile target with additional logic in .evergreen/run-tests.sh, but seeing how messy this is (and integrated with the rest of the Makefile) I think this is the right call.

at that point we may as well consider using a different test runner entirely, such as PHPUnit (which can run phpt files as well).

I think this is totally worth exploring. Would you mind creating a ticket so we can revisit the idea?

I would never consider using PHPUnit with PHPC for local development (since it'd likely complicate things like backtraces and leak detection), but it may actually make sense for CI assuming it handles all of the same syntax of run-tests.php and generates comparable test suite output. And we'd also be able to test it alongside run-tests.php (e.g. introduce PHPUnit in just an extra task to start). I assume it will also enable better integration with Evergreen, such that we could start populating the "Tests" tab like we do for PHPLIB.

Copy link
Member

Choose a reason for hiding this comment

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

@alcaeus: ☝️

Copy link
Member Author

Choose a reason for hiding this comment

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

Created PHPC-2306 to evaluate PHPUnit as a test runner for PHPC. I also created PHPC-2307 to track attaching test results separately.

@alcaeus alcaeus force-pushed the phpc-2201-2260-revamp-evergreen-config branch from b5032b4 to 7da992f Compare September 27, 2023 07:52
@alcaeus alcaeus requested a review from jmikola September 27, 2023 07:52
@alcaeus alcaeus marked this pull request as ready for review September 27, 2023 07:52
# Protect ourselves against rogue test case that runs forever
# Good rule of thumb: the average length a task takes, times 5, which roughly accounts for variable system performance
# for various build variants
exec_timeout_secs: 1800
Copy link
Member

Choose a reason for hiding this comment

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

If this is still 6 minutes, does that line up with "the average length a task takes, times 5"? Do our tasks roughly take a bit over a minute to execute?

Copy link
Member Author

Choose a reason for hiding this comment

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

The 1800 seconds are 30 minutes, meaning that we'll assume a roughly 6-minute task runtime. I'll double-check to make sure the value is still accurate.

Copy link
Member

Choose a reason for hiding this comment

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

@alcaeus: ☝️

Copy link
Member Author

Choose a reason for hiding this comment

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

Runtime for build tasks is ~2 minutes, while for test tasks it varies between 2 and 5 minutes. Given that this config setting kills tasks that are running too long I don't see an issue with using 30 minutes, but I'm open to reducing it to something more realistic, e.g. 10 minutes.

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

LGTM but there are one or two outstanding questions to follow up on.

- `local`: All tasks that run a local MongoDB cluster for testing.
- `<version>`: These tags allow selection based on MongoDB version, e.g. `6.4`.
- `standalone`, `replicaset`, `sharded`: These tags allow selection based on the MongoDB topology.
- `loadbalanced`: Allows for selecting tests using a load balancer
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that templates/test/load-balanced.yml mixes this tag with "sharded". Is that necessary since LB should already imply a sharded topology? Would it make sense to consider this a topology and fold it into the previous line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the sharded tag from load balanced tests, effectively treating loadbalanced like its own topology.

# Protect ourselves against rogue test case that runs forever
# Good rule of thumb: the average length a task takes, times 5, which roughly accounts for variable system performance
# for various build variants
exec_timeout_secs: 1800
Copy link
Member

Choose a reason for hiding this comment

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

@alcaeus: ☝️

@alcaeus alcaeus force-pushed the phpc-2201-2260-revamp-evergreen-config branch from 3b9f6b0 to a5efc27 Compare October 11, 2023 07:42
@alcaeus alcaeus merged commit a204130 into mongodb:master Oct 16, 2023
@alcaeus alcaeus deleted the phpc-2201-2260-revamp-evergreen-config branch October 16, 2023 07:30
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.

2 participants