Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 3 additions & 4 deletions crates/stackable-certs/src/ca/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,19 +467,18 @@ fn format_leaf_certificate_subject(name: &str, scope: &str) -> Result<Name> {
}

#[cfg(test)]
mod test {

mod tests {
use super::*;

#[tokio::test]
async fn test_rsa_key_generation() {
async fn rsa_key_generation() {
let mut ca = CertificateAuthority::new_rsa().unwrap();
ca.generate_rsa_leaf_certificate("Airflow", "pod", Duration::from_secs(3600))
.unwrap();
}

#[tokio::test]
async fn test_ecdsa_key_generation() {
async fn ecdsa_key_generation() {
let mut ca = CertificateAuthority::new_ecdsa().unwrap();
ca.generate_ecdsa_leaf_certificate("Airflow", "pod", Duration::from_secs(3600))
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/src/builder/configmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod tests {
use std::collections::BTreeMap;

#[test]
fn test_configmap_builder() {
fn configmap_builder() {
let mut data = BTreeMap::new();
data.insert("foo".to_string(), "bar".to_string());
let configmap = ConfigMapBuilder::new()
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/src/builder/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ mod tests {
use crate::builder::pod::PodBuilder;

#[test]
fn test_event_builder() {
fn event_builder() {
let pod = PodBuilder::new()
.metadata_builder(|builder| builder.name("testpod"))
.build()
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/src/builder/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ mod tests {
use k8s_openapi::api::core::v1::Pod;

#[test]
fn test_objectmeta_builder() {
fn objectmeta_builder() {
let mut pod = Pod::default();
pod.metadata.name = Some("pod".to_string());
pod.metadata.uid = Some("uid".to_string());
Expand Down
8 changes: 5 additions & 3 deletions crates/stackable-operator/src/builder/pdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl PodDisruptionBudgetBuilder<ObjectMeta, LabelSelector, PodDisruptionBudgetCo
}

#[cfg(test)]
mod test {
mod tests {
use std::collections::BTreeMap;

use k8s_openapi::{
Expand All @@ -214,7 +214,7 @@ mod test {
use super::PodDisruptionBudgetBuilder;

#[test]
pub fn test_normal_build() {
pub fn normal_build() {
#[allow(deprecated)]
let pdb = PodDisruptionBudgetBuilder::new()
.new_with_metadata(
Expand Down Expand Up @@ -255,7 +255,7 @@ mod test {
}

#[test]
pub fn test_build_from_role() {
pub fn build_from_role() {
#[derive(
Clone, CustomResource, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize,
)]
Expand All @@ -273,10 +273,12 @@ mod test {
",
)
.unwrap();

let app_name = "trino";
let role = "worker";
let operator_name = "trino.stackable.tech";
let controller_name = "trino-operator-trino-controller";

let pdb = PodDisruptionBudgetBuilder::new_with_role(
&trino,
app_name,
Expand Down
21 changes: 11 additions & 10 deletions crates/stackable-operator/src/builder/pod/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ mod tests {
};

#[test]
fn test_container_builder() {
fn builder() {
let container_port: i32 = 10000;
let container_port_name = "foo_port_name";
let container_port_1: i32 = 20000;
Expand Down Expand Up @@ -428,7 +428,7 @@ mod tests {
}

#[test]
fn test_container_builder_lifecycle() {
fn builder_lifecycle() {
let post_start = LifecycleHandler {
exec: Some(ExecAction {
command: Some(vec!["hello".to_string(), "world".to_string()]),
Expand Down Expand Up @@ -456,7 +456,7 @@ mod tests {
}

#[test]
fn test_container_port_builder() {
fn port_builder() {
let port: i32 = 10000;
let name = "FooBar";
let protocol = "http";
Expand All @@ -477,15 +477,16 @@ mod tests {
}

#[test]
pub fn test_field_ref_env_var_serialization() {
pub fn field_ref_env_var_serialization() {
assert_eq!(
"metadata.labels['some-label-name']",
FieldPathEnvVar::Labels("some-label-name".to_string()).to_string()
);
}

// TODO (@Techassi): Use rstest for name validation below
#[test]
fn test_container_name_max_len() {
fn name_max_len() {
let long_container_name =
"lengthexceededlengthexceededlengthexceededlengthexceededlengthex";
assert_eq!(long_container_name.len(), 64); // 63 characters is the limit for container names
Expand All @@ -512,12 +513,12 @@ mod tests {
}

#[test]
fn test_container_name_alphabet_only() {
fn name_alphabet_only() {
ContainerBuilder::new("okname").unwrap();
}

#[test]
fn test_container_name_hyphen() {
fn name_hyphen() {
assert!(ContainerBuilder::new("name-with-hyphen").is_ok());
assert_container_builder_err(
ContainerBuilder::new("ends-with-hyphen-"),
Expand All @@ -530,12 +531,12 @@ mod tests {
}

#[test]
fn test_container_name_contains_number() {
fn name_contains_number() {
assert!(ContainerBuilder::new("1name-0-name1").is_ok());
}

#[test]
fn test_container_name_contains_underscore() {
fn name_contains_underscore() {
assert!(ContainerBuilder::new("name_name").is_err());
assert_container_builder_err(
ContainerBuilder::new("name_name"),
Expand All @@ -544,7 +545,7 @@ mod tests {
}

#[test]
fn test_container_cpu_and_memory_resource_requirements() {
fn cpu_and_memory_resource_requirements() {
let resources = ResourceRequirementsBuilder::new()
.with_cpu_request("2000m")
.with_cpu_limit("3000m")
Expand Down
10 changes: 5 additions & 5 deletions crates/stackable-operator/src/builder/pod/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ mod tests {
}

#[rstest]
fn test_pod_builder_pod_name() {
fn builder_pod_name() {
let pod = PodBuilder::new()
.metadata_builder(|builder| builder.name("foo"))
.build()
Expand All @@ -656,7 +656,7 @@ mod tests {
}

#[rstest]
fn test_pod_builder(pod_affinity: PodAffinity, dummy_container: Container) {
fn builder(pod_affinity: PodAffinity, dummy_container: Container) {
let init_container = ContainerBuilder::new("init-containername")
.expect("ContainerBuilder not created")
.image("stackable/zookeeper:2.4.14")
Expand Down Expand Up @@ -707,7 +707,7 @@ mod tests {
}

#[rstest]
fn test_pod_builder_image_pull_secrets(mut pod_builder_with_name_and_container: PodBuilder) {
fn builder_image_pull_secrets(mut pod_builder_with_name_and_container: PodBuilder) {
let pod = pod_builder_with_name_and_container
.image_pull_secrets(vec!["company-registry-secret".to_string()].into_iter())
.build()
Expand All @@ -722,7 +722,7 @@ mod tests {
}

#[rstest]
fn test_pod_builder_restart_policy(mut pod_builder_with_name_and_container: PodBuilder) {
fn builder_restart_policy(mut pod_builder_with_name_and_container: PodBuilder) {
let pod = pod_builder_with_name_and_container
.restart_policy("Always")
.build()
Expand All @@ -731,7 +731,7 @@ mod tests {
}

#[test]
fn test_pod_builder_too_long_termination_grace_period() {
fn builder_too_long_termination_grace_period() {
let too_long_duration = Duration::from_secs(i64::MAX as u64 + 1);
let mut pod_builder = PodBuilder::new();

Expand Down
4 changes: 2 additions & 2 deletions crates/stackable-operator/src/builder/pod/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ impl ResourceRequirementsBuilder<Quantity, Quantity, Quantity, Quantity> {
}

#[cfg(test)]
mod test {
mod tests {
use super::*;

#[test]
fn test_builder() {
fn builder() {
let resources = ResourceRequirements {
limits: Some(
[
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/src/builder/pod/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ mod tests {
use k8s_openapi::api::core::v1::{PodSecurityContext, SELinuxOptions, SeccompProfile, Sysctl};

#[test]
fn test_security_context_builder() {
fn security_context_builder() {
let mut builder = PodSecurityContextBuilder::new();
let context = builder
.fs_group(1000)
Expand Down
6 changes: 3 additions & 3 deletions crates/stackable-operator/src/builder/pod/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ mod tests {
use std::collections::BTreeMap;

#[test]
fn test_volume_builder() {
fn builder() {
let mut volume_builder = VolumeBuilder::new("name");
volume_builder.with_config_map("configmap");
let vol = volume_builder.build();
Expand Down Expand Up @@ -595,7 +595,7 @@ mod tests {
}

#[test]
fn test_volume_mount_builder() {
fn mount_builder() {
let mut volume_mount_builder = VolumeMountBuilder::new("name", "mount_path");
volume_mount_builder
.mount_propagation("mount_propagation")
Expand All @@ -614,7 +614,7 @@ mod tests {
}

#[test]
fn test_listener_operator_volume_source_builder() {
fn listener_operator_volume_source_builder() {
let labels: Labels = Labels::try_from(BTreeMap::<String, String>::new()).unwrap();

let builder = ListenerOperatorVolumeSourceBuilder::new(
Expand Down
8 changes: 4 additions & 4 deletions crates/stackable-operator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ mod tests {
DEPLOY_FILE_PATH
)]
#[case(None, vec!["bad", DEFAULT_FILE_PATH], DEFAULT_FILE_PATH, DEFAULT_FILE_PATH)]
fn test_resolve_path_good(
fn resolve_path_good(
#[case] user_provided_path: Option<&str>,
#[case] default_locations: Vec<&str>,
#[case] path_to_create: &str,
Expand Down Expand Up @@ -343,12 +343,12 @@ mod tests {

#[test]
#[should_panic]
fn test_resolve_path_user_path_not_existing() {
fn resolve_path_user_path_not_existing() {
resolve_path(Some(USER_PROVIDED_PATH.as_ref()), &[DEPLOY_FILE_PATH]).unwrap();
}

#[test]
fn test_resolve_path_nothing_found_errors() {
fn resolve_path_nothing_found_errors() {
if let Err(Error::RequiredFileMissing { search_path }) =
resolve_path(None, &[DEPLOY_FILE_PATH, DEFAULT_FILE_PATH])
{
Expand All @@ -365,7 +365,7 @@ mod tests {
}

#[test]
fn test_product_operator_run_watch_namespace() {
fn product_operator_run_watch_namespace() {
// clean env var to not interfere if already set
env::remove_var(WATCH_NAMESPACE);

Expand Down
8 changes: 4 additions & 4 deletions crates/stackable-operator/src/commons/affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ mod tests {
use super::*;

#[test]
fn test_affinity_merge_new_attributes() {
fn merge_new_attributes() {
let default_affinity = StackableAffinityFragment {
pod_affinity: None,
pod_anti_affinity: Some(PodAntiAffinity {
Expand Down Expand Up @@ -254,7 +254,7 @@ mod tests {
}

#[test]
fn test_affinity_merge_overwrite_existing_attribute() {
fn merge_overwrite_existing_attribute() {
let default_affinity = StackableAffinityFragment {
pod_affinity: None,
pod_anti_affinity: Some(PodAntiAffinity {
Expand Down Expand Up @@ -319,7 +319,7 @@ mod tests {
}

#[test]
fn test_affinity_between_role_pods() {
fn between_role_pods() {
let app_name = "kafka";
let cluster_name = "simple-kafka";
let role = "broker";
Expand Down Expand Up @@ -352,7 +352,7 @@ mod tests {
}

#[test]
fn test_affinity_between_cluster_pods() {
fn between_cluster_pods() {
let app_name = "kafka";
let cluster_name = "simple-kafka";

Expand Down
10 changes: 6 additions & 4 deletions crates/stackable-operator/src/commons/authentication/ldap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ impl Default for FieldNames {
}

#[cfg(test)]
mod test {
mod tests {
use super::*;

#[test]
fn test_ldap_minimal() {
fn minimal() {
let ldap = serde_yaml::from_str::<AuthenticationProvider>(
"
hostname: my.ldap.server
Expand All @@ -232,7 +232,7 @@ mod test {
}

#[test]
fn test_ldap_with_bind_credentials() {
fn with_bind_credentials() {
let _ldap = serde_yaml::from_str::<AuthenticationProvider>(
"
hostname: my.ldap.server
Expand All @@ -246,7 +246,7 @@ mod test {
}

#[test]
fn test_ldap_full() {
fn full() {
let input = r#"
hostname: my.ldap.server
port: 42
Expand All @@ -273,6 +273,7 @@ mod test {
ldap.tls.tls_ca_cert_mount_path(),
Some("/stackable/secrets/ldap-ca-cert/ca.crt".to_string())
);

let (tls_volumes, tls_mounts) = ldap.tls.volumes_and_mounts().unwrap();
assert_eq!(
tls_volumes,
Expand Down Expand Up @@ -300,6 +301,7 @@ mod test {
"/stackable/secrets/openldap-bind-credentials/password".to_string()
))
);

let (ldap_volumes, ldap_mounts) = ldap.volumes_and_mounts().unwrap();
assert_eq!(
ldap_volumes,
Expand Down
Loading