Skip to content

Commit

Permalink
Updated test-r (#1233)
Browse files Browse the repository at this point in the history
* Migrated key_value_storage tests to the new test-r dependency matrix feature

* Migrated indexed_storage tests to the new test-r dependency matrix feature

* Migrated blob_storage tests to the new test-r dependency matrix feature

* Updated dynamic test generators to the new api
  • Loading branch information
vigoo authored Jan 8, 2025
1 parent 7494669 commit d1a711c
Show file tree
Hide file tree
Showing 12 changed files with 2,824 additions and 2,394 deletions.
29 changes: 19 additions & 10 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ testcontainers-modules = { version = "0.11.4", features = [
"redis",
"minio",
] }
test-r = { version = "1.2.0", default-features = true }
test-r = { version = "2.0.1", default-features = true }
thiserror = "2.0.6"
tokio = { version = "1.42", features = [
"macros",
Expand Down
67 changes: 53 additions & 14 deletions golem-cli/tests/api_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
use std::sync::Arc;
use test_r::core::{DynamicTestRegistration, TestType};
use test_r::core::{DynamicTestRegistration, TestProperties, TestType};
use uuid::Uuid;

inherit_test_dep!(EnvBasedTestDependencies);
Expand All @@ -56,7 +56,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_json_import{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_import(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -67,7 +70,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_yaml_import{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_import(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -78,7 +84,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_yaml_add{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_add(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -89,7 +98,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_yaml_add_with_security{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_add_with_security(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -100,7 +112,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_json_add_with_security{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_add_with_security(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -111,7 +126,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_json_add{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_add(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -122,7 +140,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_yaml_update{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_update(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -133,7 +154,10 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_json_update{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_update(
(deps, name.to_string(), cli.with_args(short)),
Expand All @@ -144,39 +168,54 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_definition_update_immutable{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_update_immutable((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_definition_list{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_list((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_definition_list_versions{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_list_versions((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_definition_get{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_get((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_definition_delete{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_definition_delete((deps, name.to_string(), cli.with_args(short)))
}
Expand Down
27 changes: 21 additions & 6 deletions golem-cli/tests/api_deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use golem_cli::model::ApiSecurityScheme;
use golem_client::model::{ApiDeployment, HttpApiDefinitionResponseData};
use golem_test_framework::config::{EnvBasedTestDependencies, TestDependencies};
use std::sync::Arc;
use test_r::core::{DynamicTestRegistration, TestType};
use test_r::core::{DynamicTestRegistration, TestProperties, TestType};
use test_r::{add_test, inherit_test_dep, test_dep, test_gen};

inherit_test_dep!(EnvBasedTestDependencies);
Expand All @@ -44,39 +44,54 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_deployment_deploy{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_deploy((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_deployment_deploy_with_security{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_deploy_with_security((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_deployment_get{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_get((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_deployment_list{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_list((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_deployment_delete{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_delete((deps, name.to_string(), cli.with_args(short)))
}
Expand Down
17 changes: 13 additions & 4 deletions golem-cli/tests/api_deployment_fileserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use golem_common::uri::oss::urn::WorkerUrn;
use golem_test_framework::config::{EnvBasedTestDependencies, TestDependencies};
use std::io::Write;
use std::sync::Arc;
use test_r::core::{DynamicTestRegistration, TestType};
use test_r::core::{DynamicTestRegistration, TestProperties, TestType};
use test_r::{add_test, inherit_test_dep, test_dep, test_gen};

inherit_test_dep!(EnvBasedTestDependencies);
Expand All @@ -43,23 +43,32 @@ fn make(r: &mut DynamicTestRegistration, suffix: &'static str, name: &'static st
add_test!(
r,
format!("api_deployment_fileserver_simple{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_file_server_simple((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_deployment_fileserver_complex{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_fileserver_complex((deps, name.to_string(), cli.with_args(short)))
}
);
add_test!(
r,
format!("api_deployment_fileserver_stateful_worker{suffix}"),
TestType::IntegrationTest,
TestProperties {
test_type: TestType::IntegrationTest,
..TestProperties::default()
},
move |deps: &EnvBasedTestDependencies, cli: &CliLive, _tracing: &Tracing| {
api_deployment_fileserver_stateful_worker((
deps,
Expand Down
Loading

0 comments on commit d1a711c

Please sign in to comment.