Skip to content
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

Merged
merged 3 commits into from
Feb 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/catalog/glue/tests/glue_catalog_test.rs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ fn before_all() {
normalize_test_name(module_path!()),
format!("{}/testdata/glue_catalog", env!("CARGO_MANIFEST_DIR")),
);
docker_compose.run();
docker_compose.up();
guard.replace(docker_compose);
}

2 changes: 1 addition & 1 deletion crates/catalog/hms/tests/hms_catalog_test.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ fn before_all() {
normalize_test_name(module_path!()),
format!("{}/testdata/hms_catalog", env!("CARGO_MANIFEST_DIR")),
);
docker_compose.run();
docker_compose.up();
guard.replace(docker_compose);
}

2 changes: 1 addition & 1 deletion crates/catalog/rest/tests/rest_catalog_test.rs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ fn before_all() {
normalize_test_name(module_path!()),
format!("{}/testdata/rest_catalog", env!("CARGO_MANIFEST_DIR")),
);
docker_compose.run();
docker_compose.up();
guard.replace(docker_compose);
}

2 changes: 1 addition & 1 deletion crates/iceberg/tests/file_io_gcs_test.rs
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ mod tests {
normalize_test_name(module_path!()),
format!("{}/testdata/file_io_gcs", env!("CARGO_MANIFEST_DIR")),
);
docker_compose.run();
docker_compose.up();
guard.replace(docker_compose);
}

2 changes: 1 addition & 1 deletion crates/iceberg/tests/file_io_s3_test.rs
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ mod tests {
normalize_test_name(module_path!()),
format!("{}/testdata/file_io_s3", env!("CARGO_MANIFEST_DIR")),
);
docker_compose.run();
docker_compose.up();
guard.replace(docker_compose);
}

1 change: 1 addition & 0 deletions crates/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ rust-version = { workspace = true }
[dependencies]
arrow-array = { workspace = true }
arrow-schema = { workspace = true }
ctor = { workspace = true }
datafusion = { workspace = true }
futures = { workspace = true }
iceberg = { workspace = true }
16 changes: 8 additions & 8 deletions crates/integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -18,31 +18,32 @@
use std::collections::HashMap;

use iceberg::io::{S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY};
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};
use iceberg_catalog_rest::RestCatalogConfig;
use iceberg_test_utils::docker::DockerCompose;
use iceberg_test_utils::{normalize_test_name, set_up};

const REST_CATALOG_PORT: u16 = 8181;

pub struct TestFixture {
pub _docker_compose: DockerCompose,
pub rest_catalog: RestCatalog,
pub catalog_config: RestCatalogConfig,
Copy link
Contributor Author

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

}

pub async fn set_test_fixture(func: &str) -> TestFixture {
pub fn set_test_fixture(func: &str) -> TestFixture {
set_up();
let docker_compose = DockerCompose::new(
normalize_test_name(format!("{}_{func}", module_path!())),
format!("{}/testdata", env!("CARGO_MANIFEST_DIR")),
);

// Start docker compose
docker_compose.run();
// Stop any containers from previous runs and start new ones
docker_compose.down();
docker_compose.up();

let rest_catalog_ip = docker_compose.get_container_ip("rest");
let minio_ip = docker_compose.get_container_ip("minio");

let config = RestCatalogConfig::builder()
let catalog_config = RestCatalogConfig::builder()
.uri(format!("http://{}:{}", rest_catalog_ip, REST_CATALOG_PORT))
.props(HashMap::from([
(
@@ -54,10 +55,9 @@ pub async fn set_test_fixture(func: &str) -> TestFixture {
(S3_REGION.to_string(), "us-east-1".to_string()),
]))
.build();
let rest_catalog = RestCatalog::new(config);

TestFixture {
_docker_compose: docker_compose,
rest_catalog,
catalog_config,
}
}
36 changes: 36 additions & 0 deletions crates/integration_tests/tests/shared.rs
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
@@ -17,60 +17,38 @@

//! Integration tests for rest catalog.
use std::collections::HashMap;
use std::sync::Arc;

use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, StringArray};
use futures::TryStreamExt;
use iceberg::spec::{NestedField, PrimitiveType, Schema, Type};
use iceberg::transaction::Transaction;
use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
use iceberg::writer::file_writer::location_generator::{
DefaultFileNameGenerator, DefaultLocationGenerator,
};
use iceberg::writer::file_writer::ParquetWriterBuilder;
use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
use iceberg::{Catalog, Namespace, NamespaceIdent, TableCreation};
use iceberg_integration_tests::set_test_fixture;
use iceberg::{Catalog, TableCreation};
use iceberg_catalog_rest::RestCatalog;
use parquet::arrow::arrow_reader::ArrowReaderOptions;
use parquet::file::properties::WriterProperties;

use crate::get_shared_containers;
use crate::shared_tests::{random_ns, test_schema};

#[tokio::test]
async fn test_append_data_file() {
let fixture = set_test_fixture("test_create_table").await;

let ns = Namespace::with_properties(
NamespaceIdent::from_strs(["apple", "ios"]).unwrap(),
HashMap::from([
("owner".to_string(), "ray".to_string()),
("community".to_string(), "apache".to_string()),
]),
);

fixture
.rest_catalog
.create_namespace(ns.name(), ns.properties().clone())
.await
.unwrap();

let schema = 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();
let fixture = get_shared_containers();
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());
let ns = random_ns().await;
let schema = test_schema();

let table_creation = TableCreation::builder()
.name("t1".to_string())
.schema(schema.clone())
.build();

let table = fixture
.rest_catalog
let table = rest_catalog
.create_table(ns.name(), table_creation)
.await
.unwrap();
@@ -137,7 +115,7 @@ async fn test_append_data_file() {
let mut append_action = tx.fast_append(None, vec![]).unwrap();
append_action.add_data_files(data_file.clone()).unwrap();
let tx = append_action.apply().await.unwrap();
let table = tx.commit(&fixture.rest_catalog).await.unwrap();
let table = tx.commit(&rest_catalog).await.unwrap();

// check result
let batch_stream = table
@@ -157,7 +135,7 @@ async fn test_append_data_file() {
let mut append_action = tx.fast_append(None, vec![]).unwrap();
append_action.add_data_files(data_file.clone()).unwrap();
let tx = append_action.apply().await.unwrap();
let table = tx.commit(&fixture.rest_catalog).await.unwrap();
let table = tx.commit(&rest_catalog).await.unwrap();

// check result again
let batch_stream = table
Original file line number Diff line number Diff line change
@@ -17,15 +17,11 @@

//! Integration test for partition data file
use std::collections::HashMap;
use std::sync::Arc;

use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, StringArray};
use futures::TryStreamExt;
use iceberg::spec::{
Literal, NestedField, PrimitiveLiteral, PrimitiveType, Schema, Struct, Transform, Type,
UnboundPartitionSpec,
};
use iceberg::spec::{Literal, PrimitiveLiteral, Struct, Transform, UnboundPartitionSpec};
use iceberg::table::Table;
use iceberg::transaction::Transaction;
use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
@@ -34,38 +30,19 @@ use iceberg::writer::file_writer::location_generator::{
};
use iceberg::writer::file_writer::ParquetWriterBuilder;
use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
use iceberg::{Catalog, Namespace, NamespaceIdent, TableCreation};
use iceberg_integration_tests::set_test_fixture;
use iceberg::{Catalog, TableCreation};
use iceberg_catalog_rest::RestCatalog;
use parquet::file::properties::WriterProperties;

use crate::get_shared_containers;
use crate::shared_tests::{random_ns, test_schema};

#[tokio::test]
async fn test_append_partition_data_file() {
let fixture = set_test_fixture("test_partition_data_file").await;

let ns = Namespace::with_properties(
NamespaceIdent::from_strs(["iceberg", "rust"]).unwrap(),
HashMap::from([
("owner".to_string(), "ray".to_string()),
("community".to_string(), "apache".to_string()),
]),
);

fixture
.rest_catalog
.create_namespace(ns.name(), ns.properties().clone())
.await
.unwrap();

let schema = 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();
let fixture = get_shared_containers();
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());
let ns = random_ns().await;
let schema = test_schema();

let unbound_partition_spec = UnboundPartitionSpec::builder()
.add_partition_field(2, "id", Transform::Identity)
@@ -82,8 +59,7 @@ async fn test_append_partition_data_file() {
.partition_spec(partition_spec)
.build();

let table = fixture
.rest_catalog
let table = rest_catalog
.create_table(ns.name(), table_creation)
.await
.unwrap();
@@ -148,7 +124,7 @@ async fn test_append_partition_data_file() {
.add_data_files(data_file_valid.clone())
.unwrap();
let tx = append_action.apply().await.unwrap();
let table = tx.commit(&fixture.rest_catalog).await.unwrap();
let table = tx.commit(&rest_catalog).await.unwrap();

// check result
let batch_stream = table
Original file line number Diff line number Diff line change
@@ -17,59 +17,37 @@

//! Integration tests for rest catalog.
use std::collections::HashMap;
use std::sync::Arc;

use arrow_array::{ArrayRef, BooleanArray, Int32Array, RecordBatch, StringArray};
use futures::TryStreamExt;
use iceberg::spec::{NestedField, PrimitiveType, Schema, Type};
use iceberg::transaction::Transaction;
use iceberg::writer::base_writer::data_file_writer::DataFileWriterBuilder;
use iceberg::writer::file_writer::location_generator::{
DefaultFileNameGenerator, DefaultLocationGenerator,
};
use iceberg::writer::file_writer::ParquetWriterBuilder;
use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
use iceberg::{Catalog, Namespace, NamespaceIdent, TableCreation};
use iceberg_integration_tests::set_test_fixture;
use iceberg::{Catalog, TableCreation};
use iceberg_catalog_rest::RestCatalog;
use parquet::file::properties::WriterProperties;

use crate::get_shared_containers;
use crate::shared_tests::{random_ns, test_schema};

#[tokio::test]
async fn test_append_data_file_conflict() {
let fixture = set_test_fixture("test_create_table").await;

let ns = Namespace::with_properties(
NamespaceIdent::from_strs(["apple", "ios"]).unwrap(),
HashMap::from([
("owner".to_string(), "ray".to_string()),
("community".to_string(), "apache".to_string()),
]),
);

fixture
.rest_catalog
.create_namespace(ns.name(), ns.properties().clone())
.await
.unwrap();

let schema = 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();
let fixture = get_shared_containers();
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());
let ns = random_ns().await;
let schema = test_schema();

let table_creation = TableCreation::builder()
.name("t1".to_string())
.schema(schema.clone())
.build();

let table = fixture
.rest_catalog
let table = rest_catalog
.create_table(ns.name(), table_creation)
.await
.unwrap();
@@ -120,7 +98,7 @@ async fn test_append_data_file_conflict() {
append_action.add_data_files(data_file.clone()).unwrap();
let tx2 = append_action.apply().await.unwrap();
let table = tx2
.commit(&fixture.rest_catalog)
.commit(&rest_catalog)
.await
.expect("The first commit should not fail.");

@@ -138,5 +116,5 @@ async fn test_append_data_file_conflict() {
assert_eq!(batches[0], batch);

// another commit should fail
assert!(tx1.commit(&fixture.rest_catalog).await.is_err());
assert!(tx1.commit(&rest_catalog).await.is_err());
}
Original file line number Diff line number Diff line change
@@ -25,17 +25,18 @@ use datafusion::catalog::TableProvider;
use datafusion::error::DataFusionError;
use datafusion::prelude::SessionContext;
use iceberg::{Catalog, TableIdent};
use iceberg_catalog_rest::RestCatalog;
use iceberg_datafusion::IcebergTableProvider;
use iceberg_integration_tests::set_test_fixture;
use parquet::arrow::PARQUET_FIELD_ID_META_KEY;

use crate::get_shared_containers;

#[tokio::test]
async fn test_basic_queries() -> Result<(), DataFusionError> {
let fixture = set_test_fixture("datafusion_basic_read").await;

let catalog = fixture.rest_catalog;
let fixture = get_shared_containers();
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());

let table = catalog
let table = rest_catalog
.load_table(&TableIdent::from_strs(["default", "types_test"]).unwrap())
.await
.unwrap();
65 changes: 65 additions & 0 deletions crates/integration_tests/tests/shared_tests/mod.rs
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The 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? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for the review! So initially I found that append_data_file_test.rs, append_partition_data_file_test.rs and conflict_commit_test.rs use the same schema, and I figured it made sense to extract it simply for de-duplication (and allowing any future tests where schema isn't that important to re-use it as well).

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it made sense to extract it simply for de-duplication (and allowing any future tests where schema isn't that important to re-use it as well).

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()
}
Original file line number Diff line number Diff line change
@@ -22,15 +22,16 @@ use futures::TryStreamExt;
use iceberg::expr::Reference;
use iceberg::spec::Datum;
use iceberg::{Catalog, TableIdent};
use iceberg_integration_tests::set_test_fixture;
use iceberg_catalog_rest::RestCatalog;

use crate::get_shared_containers;

#[tokio::test]
async fn test_evolved_schema() {
let fixture = set_test_fixture("read_evolved_schema").await;

let catalog = fixture.rest_catalog;
let fixture = get_shared_containers();
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());

let table = catalog
let table = rest_catalog
.load_table(&TableIdent::from_strs(["default", "test_rename_column"]).unwrap())
.await
.unwrap();
@@ -64,7 +65,7 @@ async fn test_evolved_schema() {
assert_eq!(actual, vec!["Java", "Python"]);

// Evolve column
let table = catalog
let table = rest_catalog
.load_table(&TableIdent::from_strs(["default", "test_promote_column"]).unwrap())
.await
.unwrap();
Original file line number Diff line number Diff line change
@@ -20,15 +20,16 @@
use futures::TryStreamExt;
use iceberg::ErrorKind::FeatureUnsupported;
use iceberg::{Catalog, TableIdent};
use iceberg_integration_tests::set_test_fixture;
use iceberg_catalog_rest::RestCatalog;

use crate::get_shared_containers;

#[tokio::test]
async fn test_read_table_with_positional_deletes() {
let fixture = set_test_fixture("read_table_with_positional_deletes").await;

let catalog = fixture.rest_catalog;
let fixture = get_shared_containers();
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());

let table = catalog
let table = rest_catalog
.load_table(
&TableIdent::from_strs(["default", "test_positional_merge_on_read_double_deletes"])
.unwrap(),
Original file line number Diff line number Diff line change
@@ -40,29 +40,21 @@ use iceberg::writer::file_writer::location_generator::{
};
use iceberg::writer::file_writer::ParquetWriterBuilder;
use iceberg::writer::{IcebergWriter, IcebergWriterBuilder};
use iceberg::{Catalog, Namespace, NamespaceIdent, TableCreation};
use iceberg_integration_tests::set_test_fixture;
use iceberg::{Catalog, TableCreation};
use iceberg_catalog_rest::RestCatalog;
use parquet::arrow::PARQUET_FIELD_ID_META_KEY;
use parquet::file::properties::WriterProperties;
use uuid::Uuid;

use crate::get_shared_containers;
use crate::shared_tests::random_ns;

#[tokio::test]
async fn test_scan_all_type() {
let fixture = set_test_fixture("test_scan_all_type").await;

let ns = Namespace::with_properties(
NamespaceIdent::from_strs(["apple", "ios"]).unwrap(),
HashMap::from([
("owner".to_string(), "ray".to_string()),
("community".to_string(), "apache".to_string()),
]),
);
let fixture = get_shared_containers();
let rest_catalog = RestCatalog::new(fixture.catalog_config.clone());
let ns = random_ns().await;

fixture
.rest_catalog
.create_namespace(ns.name(), ns.properties().clone())
.await
.unwrap();
let schema = Schema::builder()
.with_schema_id(1)
.with_identifier_field_ids(vec![2])
@@ -137,8 +129,7 @@ async fn test_scan_all_type() {
.schema(schema.clone())
.build();

let table = fixture
.rest_catalog
let table = rest_catalog
.create_table(ns.name(), table_creation)
.await
.unwrap();
@@ -321,7 +312,7 @@ async fn test_scan_all_type() {
let mut append_action = tx.fast_append(None, vec![]).unwrap();
append_action.add_data_files(data_file.clone()).unwrap();
let tx = append_action.apply().await.unwrap();
let table = tx.commit(&fixture.rest_catalog).await.unwrap();
let table = tx.commit(&rest_catalog).await.unwrap();

// check result
let batch_stream = table
44 changes: 24 additions & 20 deletions crates/test_utils/src/docker.rs
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ impl DockerCompose {
}
}

pub fn run(&self) {
pub fn up(&self) {
let mut cmd = Command::new("docker");
cmd.current_dir(&self.docker_compose_dir);

@@ -91,6 +91,28 @@ impl DockerCompose {
)
}

pub fn down(&self) {
let mut cmd = Command::new("docker");
cmd.current_dir(&self.docker_compose_dir);

cmd.args(vec![
"compose",
"-p",
self.project_name.as_str(),
"down",
"-v",
"--remove-orphans",
]);

run_command(
cmd,
format!(
"Stopping docker compose in {}, project name: {}",
self.docker_compose_dir, self.project_name
),
)
}

pub fn get_container_ip(&self, service_name: impl AsRef<str>) -> IpAddr {
let container_name = format!("{}-{}-1", self.project_name, service_name.as_ref());
let mut cmd = Command::new("docker");
@@ -114,24 +136,6 @@ impl DockerCompose {

impl Drop for DockerCompose {
fn drop(&mut self) {
let mut cmd = Command::new("docker");
cmd.current_dir(&self.docker_compose_dir);

cmd.args(vec![
"compose",
"-p",
self.project_name.as_str(),
"down",
"-v",
"--remove-orphans",
]);

run_command(
cmd,
format!(
"Stopping docker compose in {}, project name: {}",
self.docker_compose_dir, self.project_name
),
)
self.down()
}
}