-
Notifications
You must be signed in to change notification settings - Fork 209
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
chore: use shared containers for integration tests #924
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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::collections::HashMap; | ||
|
||
use iceberg::spec::{NestedField, PrimitiveType, Schema, Type}; | ||
use iceberg::{Catalog, Namespace, NamespaceIdent}; | ||
use iceberg_catalog_rest::RestCatalog; | ||
|
||
use crate::get_shared_containers; | ||
|
||
mod append_data_file_test; | ||
mod append_partition_data_file_test; | ||
mod conflict_commit_test; | ||
mod datafusion; | ||
mod read_evolved_schema; | ||
mod read_positional_deletes; | ||
mod scan_all_type; | ||
|
||
pub async fn random_ns() -> Namespace { | ||
let fixture = get_shared_containers(); | ||
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone()); | ||
|
||
let ns = Namespace::with_properties( | ||
NamespaceIdent::from_strs([uuid::Uuid::new_v4().to_string()]).unwrap(), | ||
HashMap::from([ | ||
("owner".to_string(), "ray".to_string()), | ||
("community".to_string(), "apache".to_string()), | ||
]), | ||
); | ||
|
||
rest_catalog | ||
.create_namespace(ns.name(), ns.properties().clone()) | ||
.await | ||
.unwrap(); | ||
|
||
ns | ||
} | ||
|
||
fn test_schema() -> Schema { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each test is an independent test and I think it's common for them to have different schemas, e.g. scal_all_type. Do we really need to extract this as a public function? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, thanks for the review! So initially I found that I don't have any strong opinions on it though—would you prefer for the schemas to be constructed directly in each of those tests as before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Both way looks good to me. I'm fine to keep it now for reuse by 3 case and we can remove them when need to evolve schema indenpently. |
||
Schema::builder() | ||
.with_schema_id(1) | ||
.with_identifier_field_ids(vec![2]) | ||
.with_fields(vec![ | ||
NestedField::optional(1, "foo", Type::Primitive(PrimitiveType::String)).into(), | ||
NestedField::required(2, "bar", Type::Primitive(PrimitiveType::Int)).into(), | ||
NestedField::optional(3, "baz", Type::Primitive(PrimitiveType::Boolean)).into(), | ||
]) | ||
.build() | ||
.unwrap() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the tests now share this fixture but they're all executed in different runtimes, they can't share the same client, as those can get dropped prematurely when a test ends, resulting in
dispatch task is gone: runtime dropped the dispatch task