Skip to content

Commit

Permalink
chore: remove unused benchmarks (#4869)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmayclin authored Nov 11, 2024
1 parent b589fa4 commit 84561bb
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 432 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -639,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.

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
9 changes: 2 additions & 7 deletions tests/integrationv2/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import pytest
import subprocess

from global_flags import get_flag, is_criterion_on, S2N_USE_CRITERION
from global_flags import get_flag
from processes import ManagedProcess
from providers import Provider, CriterionS2N, S2N
from providers import Provider, S2N

from common import ProviderOptions

Expand All @@ -25,11 +25,6 @@ def managed_process():

def _fn(provider_class: Provider, options: ProviderOptions, timeout=5, send_marker=None, close_marker=None,
expect_stderr=None, kill_marker=None, send_with_newline=None):
if provider_class == S2N and is_criterion_on():
provider_class = CriterionS2N
# This comes from the number of iterations specific in the rust benchmark handler(s).
# currently set at 10 iterations, so give us 10x more time.
timeout = timeout * 10
provider = provider_class(options)
cmd_line = provider.get_cmd_line()
# The process will default to send markers in the providers.py file
Expand Down
Loading

0 comments on commit 84561bb

Please sign in to comment.