Skip to content

Commit

Permalink
simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Dec 27, 2024
1 parent 580ac4b commit 4f98093
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 71 deletions.
74 changes: 40 additions & 34 deletions deploy/helm/nifi-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -656,24 +656,27 @@ spec:
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
type: object
jvmArgumentOverrides:
additionalProperties:
oneOf:
- required:
- argument
- required:
- flag
- required:
- remove
properties:
argument:
type: string
flag:
type: object
remove:
type: object
type: object
default: {}
default:
add: []
remove: []
removeRegex: []
description: Allows overriding JVM arguments.
properties:
add:
default: []
items:
type: string
type: array
remove:
default: []
items:
type: string
type: array
removeRegex:
default: []
items:
type: string
type: array
type: object
podOverrides:
default: {}
Expand Down Expand Up @@ -1137,24 +1140,27 @@ spec:
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
type: object
jvmArgumentOverrides:
additionalProperties:
oneOf:
- required:
- argument
- required:
- flag
- required:
- remove
properties:
argument:
type: string
flag:
type: object
remove:
type: object
type: object
default: {}
default:
add: []
remove: []
removeRegex: []
description: Allows overriding JVM arguments.
properties:
add:
default: []
items:
type: string
type: array
remove:
default: []
items:
type: string
type: array
removeRegex:
default: []
items:
type: string
type: array
type: object
podOverrides:
default: {}
Expand Down
60 changes: 23 additions & 37 deletions rust/operator-binary/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ pub fn build_bootstrap_conf(
jvm_argument_overrides: JvmArgumentOverrides::new_with_only_additions(jvm_args),
};

// Please note that merge order is different than we normally do!
// This is not trivial, as the merge operation is not purely additive (as it is with e.g.
// PodTemplateSpec).
// Please note that the merge order is different than we normally do!
// This is not trivial, as the merge operation is not purely additive (as it is with e.g. `PodTemplateSpec).
let mut role = role_java_common_config.clone();
role.merge(&operator_generated);
let mut role_group = role_group_java_common_config.clone();
Expand Down Expand Up @@ -764,21 +763,7 @@ mod tests {
default:
replicas: 1
"#;
let nifi: NifiCluster = serde_yaml::from_str(input).expect("illegal test input");

let role = NifiRole::Node;
let merged_config = nifi.merged_config(&role, "default").unwrap();
let nodes = nifi.spec.nodes.unwrap();
let (role_java_common_config, role_group_java_common_config) = nodes
.merged_product_specific_common_configs("default")
.unwrap();
let bootstrap_conf = build_bootstrap_conf(
&merged_config,
BTreeMap::new(),
role_java_common_config,
role_group_java_common_config,
)
.unwrap();
let bootstrap_conf = construct_bootstrap_conf(input);

assert_eq!(
bootstrap_conf,
Expand Down Expand Up @@ -846,25 +831,7 @@ mod tests {
- -Xmx40000m
- -Dhttps.proxyPort=1234
"#;
let nifi: NifiCluster = serde_yaml::from_str(input).expect("illegal test input");

let role = NifiRole::Node;
let merged_config = nifi.merged_config(&role, "default").unwrap();
let nodes = nifi.spec.nodes.unwrap();
let (role_java_common_config, role_group_java_common_config) = nodes
.merged_product_specific_common_configs("default")
.unwrap();

dbg!(&role_java_common_config);
dbg!(&role_group_java_common_config);

let bootstrap_conf = build_bootstrap_conf(
&merged_config,
BTreeMap::new(),
role_java_common_config,
role_group_java_common_config,
)
.unwrap();
let bootstrap_conf = construct_bootstrap_conf(input);

assert_eq!(
bootstrap_conf,
Expand Down Expand Up @@ -892,4 +859,23 @@ mod tests {
"}
);
}

fn construct_bootstrap_conf(nifi_cluster: &str) -> String {
let nifi: NifiCluster = serde_yaml::from_str(nifi_cluster).expect("illegal test input");

let role = NifiRole::Node;
let merged_config = nifi.merged_config(&role, "default").unwrap();
let nodes = nifi.spec.nodes.unwrap();
let (role_java_common_config, role_group_java_common_config) = nodes
.merged_product_specific_common_configs("default")
.unwrap();

build_bootstrap_conf(
&merged_config,
BTreeMap::new(),
role_java_common_config,
role_group_java_common_config,
)
.unwrap()
}
}

0 comments on commit 4f98093

Please sign in to comment.