Skip to content

Commit

Permalink
ci: add ubuntu-24.04 to CI
Browse files Browse the repository at this point in the history
* Replace `ubuntu-latest` with `ubuntu-22.04` - we expect that soon that
  tag will point at 24.04 and we want to keep testing w/ 22.04
  explicitly
* Add `ubuntu-24.04` - in the future, once the switch mentioned above
  has happened, we can replace this with `ubuntu-latest` once more.
* Add `apt-get autopurge -y needrestart` to work around an upstream
  issue with GitHub runners/Ubuntu 24.04 that provokes unexpected run
  cancellation without this fix.
* Add a helper to `tests/runner.rs` for checking the Nginx version. We
  use this to conditionally skip the TLS session resumption nginx tests
  when running on 24.04 with Nginx 1.24+ - there's an outstanding issue
  where resumption doesn't work with this nginx version.
  • Loading branch information
cpu committed Jun 21, 2024
1 parent 8cf645c commit dddf950
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 33 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/libssl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ jobs:
- stable
- beta
- nightly
os: [ubuntu-latest]
# TODO(XXX): consider replacing ubuntu-24.04 w/ ubuntu-latest when appropriate
os: [ubuntu-24.04, ubuntu-22.04]
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y openssl libssl3 libssl-dev lld
run: sudo apt-get update && sudo apt-get autopurge -y needrestart && sudo apt-get install -y openssl libssl3 libssl-dev lld

- name: Install ${{ matrix.rust }} toolchain
uses: dtolnay/rust-toolchain@master
Expand Down
85 changes: 54 additions & 31 deletions rustls-libssl/tests/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,37 +502,42 @@ fn nginx() {
b"hello world\n"
);

for (port, reused) in [(8443, '.'), (8444, 'r'), (8445, 'r'), (8446, 'r')] {
// multiple requests without http connection reuse
// (second should be a TLS resumption if possible)
assert_eq!(
Command::new("curl")
.env("LD_LIBRARY_PATH", "")
.args([
"--verbose",
"--cacert",
"test-ca/rsa/ca.cert",
"-H",
"connection: close",
&format!("https://localhost:{port}/"),
&format!("https://localhost:{port}/ssl-agreed"),
&format!("https://localhost:{port}/ssl-server-name"),
&format!("https://localhost:{port}/ssl-was-reused")
])
.stdout(Stdio::piped())
.output()
.map(print_output)
.unwrap()
.stdout,
format!(
"hello world\n\
protocol:TLSv1.3,cipher:TLS_AES_256_GCM_SHA384\n\
server-name:localhost\n\
reused:{reused}\n"
)
.as_bytes(),
);
println!("PASS: resumption test for port={port} reused={reused}");
// TODO(XXX): Session resumption is not working w/ nginx 1.24.0+
// Until this is fixed skip the resumption specific tests with
// newer Nginx versions.
if matches!(nginx_version(), (1, minor) if minor < 24) {
for (port, reused) in [(8443, '.'), (8444, 'r'), (8445, 'r'), (8446, 'r')] {
// multiple requests without http connection reuse
// (second should be a TLS resumption if possible)
assert_eq!(
Command::new("curl")
.env("LD_LIBRARY_PATH", "")
.args([
"--verbose",
"--cacert",
"test-ca/rsa/ca.cert",
"-H",
"connection: close",
&format!("https://localhost:{port}/"),
&format!("https://localhost:{port}/ssl-agreed"),
&format!("https://localhost:{port}/ssl-server-name"),
&format!("https://localhost:{port}/ssl-was-reused")
])
.stdout(Stdio::piped())
.output()
.map(print_output)
.unwrap()
.stdout,
format!(
"hello world\n\
protocol:TLSv1.3,cipher:TLS_AES_256_GCM_SHA384\n\
server-name:localhost\n\
reused:{reused}\n"
)
.as_bytes(),
);
println!("PASS: resumption test for port={port} reused={reused}");
}
}

// big download (throttled by curl to ensure non-blocking writes work)
Expand All @@ -556,6 +561,24 @@ fn nginx() {
drop(nginx_server);
}

// Return the major and minor version components of the Nginx binary in `$PATH`.
fn nginx_version() -> (u32, u32) {
let nginx_version_output = Command::new("nginx").args(["-v"]).output().unwrap();
let nginx_version_output = String::from_utf8_lossy(&nginx_version_output.stderr);
let raw_version = nginx_version_output
.lines()
.next()
.unwrap()
.strip_prefix("nginx version: nginx/")
.unwrap();
let mut version_components = raw_version.split('.');
let must_parse_numeric = |c: &str| c.parse::<u32>().unwrap();
(
version_components.next().map(must_parse_numeric).unwrap(),
version_components.next().map(must_parse_numeric).unwrap(),
)
}

struct KillOnDrop(Option<Child>);

impl KillOnDrop {
Expand Down

0 comments on commit dddf950

Please sign in to comment.