-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use shared containers for integration tests (#924)
Closes #923 This PR makes integration tests re-use the same set of docker containers, hence allowing them to be run concurrently 1. all existing tests are moved to a `shared_tests` module, with a single top-level `shared.rs` file, thus requiring only [one compilation](https://corrode.dev/blog/tips-for-faster-rust-compile-times/#combine-all-integration-tests-into-a-single-binary) step (as opposed to compiling every test file individually) 2. `set_test_fixture` is made sync, since there's no async code in it 3. given 1 and 2, the test fixture is wrapped in a `OnceLock`, so that it is invoked only once for the resulting (shared) test binary; it also has a corresponding destructor to spin down the containers after the tests run 4. if there's a need for integration tests which don't use the shared docker containers, their test files should be placed alongside `shared.rs` (top-level); otherwise they should be created in the `shared_tests` module 5. one (shared) file can now contain an arbitrary number of tests that utilize the shared set of containers (without having to resort to decorating them with `#[serial]`) Finally, with this change my integration test runs go from taking ~3.5 minutes down to 30 seconds. EDIT: The CI `unit` workflow run duration also seems [~10min shorter now](#924 (comment)).
- Loading branch information
Showing
18 changed files
with
205 additions
and
172 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use std::sync::{Arc, OnceLock}; | ||
|
||
use ctor::dtor; | ||
use iceberg_integration_tests::{set_test_fixture, TestFixture}; | ||
|
||
pub mod shared_tests; | ||
|
||
static DOCKER_CONTAINERS: OnceLock<Arc<TestFixture>> = OnceLock::new(); | ||
|
||
pub fn get_shared_containers() -> &'static Arc<TestFixture> { | ||
DOCKER_CONTAINERS.get_or_init(|| Arc::new(set_test_fixture("shared_tests"))) | ||
} | ||
|
||
#[dtor] | ||
fn shutdown() { | ||
if let Some(fixture) = DOCKER_CONTAINERS.get() { | ||
fixture._docker_compose.down() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.