Skip to content

Commit

Permalink
Merge branch 'main' into flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
dougch authored Nov 12, 2024
2 parents e24616e + bcbf0d9 commit cc8af8d
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 434 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ if(S2N_BLOCK_NONPORTABLE_OPTIMIZATIONS)
target_compile_options(${PROJECT_NAME} PUBLIC -DS2N_BLOCK_NONPORTABLE_OPTIMIZATIONS=1)
endif()

target_compile_options(${PROJECT_NAME} PUBLIC -fPIC -include "${CMAKE_CURRENT_LIST_DIR}/utils/s2n_prelude.h")
target_compile_options(${PROJECT_NAME} PUBLIC -fPIC)

set(S2N_PRELUDE "${CMAKE_CURRENT_LIST_DIR}/utils/s2n_prelude.h")
target_compile_options(${PROJECT_NAME} PRIVATE -include "${S2N_PRELUDE}")

# Match on Release, RelWithDebInfo and MinSizeRel
# See: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html#variable:CMAKE_BUILD_TYPE
Expand Down Expand Up @@ -476,6 +479,8 @@ if (BUILD_TESTING)
add_library(testss2n STATIC ${TESTLIB_SRC} ${EXAMPLES_SRC})
target_include_directories(testss2n PUBLIC tests)
target_compile_options(testss2n PRIVATE -std=gnu99)
# make sure all linked tests include the prelude
target_compile_options(testss2n PUBLIC -include "${S2N_PRELUDE}")
target_link_libraries(testss2n PUBLIC ${PROJECT_NAME})
if (SECCOMP)
message(STATUS "Linking tests with seccomp")
Expand Down Expand Up @@ -634,7 +639,7 @@ if (BUILD_TESTING)
pytest
-x -n=${N} --reruns=2 --durations=10 --cache-clear -rpfsq
-o log_cli=true --log-cli-level=DEBUG --provider-version=$ENV{S2N_LIBCRYPTO}
--provider-criterion=off --fips-mode=0 ${test_file_path}
--fips-mode=0 ${test_file_path}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integrationv2
)
else()
Expand Down
13 changes: 0 additions & 13 deletions bindings/rust/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,4 @@ publish = false
[dependencies]
s2n-tls = { path = "../s2n-tls"}
s2n-tls-sys = { path = "../s2n-tls-sys" }
criterion = { version = "0.3", features = ["html_reports"] }
anyhow = "1"
unicode-width = "=0.1.13" # newer versions require newer rust, see https://github.com/aws/s2n-tls/issues/4786

[[bench]]
name = "s2nc"
harness = false

[[bench]]
name = "s2nd"
harness = false

[dev-dependencies]
regex = "=1.9.6" # newer versions require rust 1.65, see https://github.com/aws/s2n-tls/issues/4242
30 changes: 0 additions & 30 deletions bindings/rust/integration/benches/s2nc.rs

This file was deleted.

30 changes: 0 additions & 30 deletions bindings/rust/integration/benches/s2nd.rs

This file was deleted.

2 changes: 2 additions & 0 deletions codebuild/bin/build_aws_crt_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ source codebuild/bin/s2n_setup_env.sh
BUILD_DIR=$1
INSTALL_DIR=$2

# Make sure there isn't another source tree hanging around.
rm -rf /opt/s2n-tls || true
mkdir -p "$BUILD_DIR/s2n"
# In case $BUILD_DIR is a subdirectory of current directory
for file in *;do test "$file" != "$BUILD_DIR" && cp -r "$file" "$BUILD_DIR/s2n";done
Expand Down
66 changes: 0 additions & 66 deletions codebuild/bin/criterion_baseline.sh

This file was deleted.

53 changes: 0 additions & 53 deletions codebuild/bin/criterion_delta.sh

This file was deleted.

59 changes: 0 additions & 59 deletions codebuild/spec/buildspec_ubuntu_integv2criterion.yml

This file was deleted.

30 changes: 0 additions & 30 deletions codebuild/spec/buildspec_ubuntu_integv2criterion_baseline.yml

This file was deleted.

36 changes: 0 additions & 36 deletions tests/integrationv2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,39 +156,3 @@ An example of how to test that the server and the client can send and receive ap
**INTERNALERROR> OSError: cannot send to <Channel id=1 closed>**
An error similar to this is caused by a runtime error in a test. In `tox.ini` change `-n8` to `-n0` to
see the actual error causing the OSError.


# Criterion

### Why

We wanted to use the rust criterion project to benchmark s2n-tls, without re-writing all the integration tests.
To accomplish this, we created some criterion benchmarks that use s2nc and s2nd, and a new provider, CriterionS2N, in the python testing framework.

### Prerequisites

Normally, you'd run criterion with `cargo bench --bench <name>`, but cargo does some checks to see if it needs to rebuild
the benchmark and other housekeeping that slows things down a bit. Running `cargo bench --no-run` is the benchmark equivalent to `cargo build` and will produce a binary executable.

The CI will run `make install` and `make -C ./bindings/rust` to create and install the s2nc/d binaries in a system-wide location, then build the cargo criterion binary handlers for s2nc and s2nd.


### Running locally

The Criterion CodeBuild scripts can be used to run these locally, by setting LOCAL_TESTING the s3/github interactions are disabled. Tooling needed includes python3.9, rust, and write permissions to `/usr/local/bin|lib` (or use sudo) - in addition to the traditional C build tooling.

```
export LOCAL_TESTING=true
INTEGV2_TEST=test_well_known_endpoints ./codebuild/bin/criterion_baseline.sh
INTEGV2_TEST=test_well_known_endpoints ./codebuild/bin/criterion_delta.sh
```

The resulting reports are viewable via `tests/integrationv2/target/criterion/report/index.html`



## Troubleshooting CriterionS2N

The most direct trouble-shooting is done using the [interactive troubleshooting CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html#ssm-pause-build) `codebuild-break` line in the buildspec. Put the break right before the main build step and run interactively.

As mentioned above, in order to get more output from the tests, set the `-n` or `XDIST_WORKER` environment variable to 0 and add a -v to the pytest command line in tox.ini.
5 changes: 1 addition & 4 deletions tests/integrationv2/conftest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from global_flags import set_flag, S2N_PROVIDER_VERSION, S2N_FIPS_MODE, S2N_USE_CRITERION
from global_flags import set_flag, S2N_PROVIDER_VERSION, S2N_FIPS_MODE


def pytest_addoption(parser):
parser.addoption("--provider-version", action="store", dest="provider-version",
default=None, type=str, help="Set the version of the TLS provider")
parser.addoption("--fips-mode", action="store", dest="fips-mode",
default=False, type=int, help="S2N is running in FIPS mode")
parser.addoption("--provider-criterion", action="store", dest="provider-criterion",
default="off", type=str, choices=['off', 'baseline', 'delta'], help="Use Criterion provider in one of 3 modes: [off,baseline,delta]")


def pytest_configure(config):
Expand All @@ -26,7 +24,6 @@ def pytest_configure(config):
set_flag(S2N_FIPS_MODE, True)

set_flag(S2N_PROVIDER_VERSION, config.getoption('provider-version', None))
set_flag(S2N_USE_CRITERION, config.getoption('provider-criterion', "off"))


def pytest_collection_modifyitems(config, items):
Expand Down
Loading

0 comments on commit cc8af8d

Please sign in to comment.