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

Add CMake targets for integration tests and switch CI to use them #3776

Merged
merged 35 commits into from
Feb 15, 2023

Conversation

harrisonkaiser
Copy link
Contributor

@harrisonkaiser harrisonkaiser commented Jan 25, 2023

Resolved issues:

Description of changes:

Move to using CMake to run integration tests in s2n_small batch. Currently this PR does a straight move from one to the other.

One option, not implemented here, is to run the two methods in parallel.

Call-outs:

CMake has a feature find_package which we use here to find the Python3 executable. This is helpful if you are running the executable in a development environment. However our VM's don't appear to be setup (i.e. CMAKE_PREFIX_PATH is not set) to make it easy for CMake to find the Python, we override this with s2n_codebuild.sh. Would love to hear Ideas about a better solution to this.

Testing:

How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?

Is this a refactor change? If so, how have you proved that the intended behavior hasn't changed?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Jan 25, 2023
@harrisonkaiser harrisonkaiser marked this pull request as ready for review January 25, 2023 18:23
@harrisonkaiser harrisonkaiser requested review from goatgoose, maddeleine, dougch and jmayclin and removed request for dougch January 25, 2023 18:33
@jmayclin
Copy link
Contributor

Perhaps this is a bit out of left field, but what are the advantages of cmake vs just directly invoking the python stuff and driving it from a shell script / python script? Just wondering whether cmake is the neatest/simplest solution for us.

@harrisonkaiser
Copy link
Contributor Author

harrisonkaiser commented Jan 25, 2023

Perhaps this is a bit out of left field, but what are the advantages of cmake vs just directly invoking the python stuff and driving it from a shell script / python script? Just wondering whether cmake is the neatest/simplest solution for us.

The goal is to provide a way for developers to run the integ tests (as a group and individually) independent of codebuild.

Right now we have a bunch of stuff implicitly already setup by docker and explicitly setup by a script. As a result, it is very difficult to replicate CI locally or setup a fully working development environment. The thought behind using CMake is that it could do all the setup environment for the developer. I'd be happy with any solution that effectively achieves that goal.

@harrisonkaiser harrisonkaiser changed the title Cmake integv2 Add CMake integv2 Jan 27, 2023
@harrisonkaiser harrisonkaiser changed the title Add CMake integv2 Add CMake targets for integration test Jan 27, 2023
@harrisonkaiser harrisonkaiser changed the title Add CMake targets for integration test Add CMake targets for integration tests and switch CI to use them Jan 27, 2023
LD_LIBRARY_PATH="${PROJECT_SOURCE_DIR}/libcrypto-root/lib":"${PROJECT_SOURCE_DIR}/test-deps/openssl-1.1.1/lib":"${PROJECT_SOURCE_DIR}/test-deps/gnutls37/nettle/lib":$ENV{LD_LIBRARY_PATH}
PATH="${PROJECT_SOURCE_DIR}/bin":"${PROJECT_SOURCE_DIR}/test-deps/openssl-1.1.1/bin":"${PROJECT_SOURCE_DIR}/test-deps/gnutls37/bin":$ENV{PATH}
PYTHONNOUSERSITE=1
S2N_INTEG_TEST=1
Copy link
Contributor

@jmayclin jmayclin Jan 27, 2023

Choose a reason for hiding this comment

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

Out of the scope of this PR, but I'll also throw out my unsolicited opinion that using special code paths for all integration tests scares me.

This is probably a bit paranoid, but it looks like setting this environment variable let's you call s2n_config_set_unsafe_for_testing. If we were to add a regression that resulted in a production code path calling s2n_config_set_unsafe I don't think we wouldn't catch that in unit or integ tests, because it's explicitly allowed for all of them.

As a future solution maybe we could only set S2N_INTEG_TEST=1 on the tests that actually need it? That could probably be driven from the python layer.

If others agree I can create an issue tracking this.

This is a step towards our goal of enabling CMake for all parts
of the code base. The CMake script now adds integ_<name> target
for each `test_<name>.py` in `tests/integrationv2/`.

A developer can now run `cmake --build <path/to/build> --target test_name`
to run an individual integration test.

We don't remove the existing Makefile.
Copy link
Contributor

@dougch dougch left a comment

Choose a reason for hiding this comment

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

Lines 54-56 need to come out as well; it's building with make and might be polluting things.

Copy link
Contributor

@dougch dougch left a comment

Choose a reason for hiding this comment

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

lgtm with one outstanding bit: how to run individual tests (discussed offline).

@harrisonkaiser harrisonkaiser requested review from dougch and camshaft and removed request for camshaft February 10, 2023 01:46
Copy link
Contributor

@maddeleine maddeleine left a comment

Choose a reason for hiding this comment

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

I'm not an expert on cmake/ctest stuff, but this lgtm.

Copy link
Contributor

@dougch dougch left a comment

Choose a reason for hiding this comment

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

A few questions about parallelism; otherwise LGTM

cmake --build ./build --target clean #Saves on copy back rsync time
Copy link
Contributor

Choose a reason for hiding this comment

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

You're going to get a conflict with #3837

@harrisonkaiser harrisonkaiser enabled auto-merge (squash) February 15, 2023 21:41
@harrisonkaiser harrisonkaiser merged commit f41abb6 into aws:main Feb 15, 2023
@dougch
Copy link
Contributor

dougch commented Feb 15, 2023

Changes post approval lgtm.

dougch pushed a commit to dougch/s2n-tls that referenced this pull request Feb 17, 2023
dougch pushed a commit to dougch/s2n-tls that referenced this pull request Feb 17, 2023
dougch pushed a commit to dougch/s2n-tls that referenced this pull request Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants