Skip to content

Commit 2d3792c

Browse files
committed
test: Add CRD roundtrip test data
1 parent d45e00b commit 2d3792c

1 file changed

Lines changed: 148 additions & 2 deletions

File tree

  • rust/operator-binary/src/crd

rust/operator-binary/src/crd/mod.rs

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ pub fn build_recommended_labels<'a, T>(
11101110

11111111
#[cfg(test)]
11121112
mod tests {
1113+
use indoc::formatdoc;
11131114
use stackable_operator::{
11141115
commons::product_image_selection::ResolvedProductImage,
11151116
versioned::test_utils::RoundtripTestData,
@@ -1172,13 +1173,158 @@ mod tests {
11721173

11731174
impl RoundtripTestData for v1alpha1::AirflowClusterSpec {
11741175
fn roundtrip_test_data() -> Vec<Self> {
1175-
vec![]
1176+
let git_sync_section = r#"
1177+
dagsGitSync:
1178+
- repo: ssh://git@github.com/stackable-airflow/dags.git
1179+
- repo: https://github.com/stackable-airflow/dags
1180+
branch: main
1181+
credentialsSecret: my-basic-auth
1182+
wait: 5s
1183+
gitSyncConf:
1184+
foo: bar
1185+
gitFolder: "mount-dags-gitsync/dags_airflow3"
1186+
- repo: ssh://git@github.com/stackable-airflow/dags.git
1187+
"#;
1188+
let yaml = test_airflow_cluster_yaml(git_sync_section);
1189+
stackable_operator::utils::yaml_from_str_singleton_map(&yaml)
1190+
.expect("Failed to parse AirflowClusterSpec YAML")
11761191
}
11771192
}
11781193

11791194
impl RoundtripTestData for v1alpha2::AirflowClusterSpec {
11801195
fn roundtrip_test_data() -> Vec<Self> {
1181-
vec![]
1196+
let git_sync_section = r#"
1197+
dagsGitSync:
1198+
- repo: ssh://git@github.com/stackable-airflow/dags.git
1199+
- repo: https://github.com/stackable-airflow/dags
1200+
branch: main
1201+
credentials:
1202+
basicAuthSecretName: my-basic-auth
1203+
wait: 5s
1204+
gitSyncConf:
1205+
foo: bar
1206+
gitFolder: "mount-dags-gitsync/dags_airflow3"
1207+
- repo: ssh://git@github.com/stackable-airflow/dags.git
1208+
credentials:
1209+
sshPrivateKeySecretName: my-private-key
1210+
"#;
1211+
let yaml = test_airflow_cluster_yaml(git_sync_section);
1212+
stackable_operator::utils::yaml_from_str_singleton_map(&yaml)
1213+
.expect("Failed to parse AirflowClusterSpec YAML")
1214+
}
1215+
}
1216+
1217+
fn test_airflow_cluster_yaml(git_sync_section: &str) -> String {
1218+
formatdoc! {
1219+
r#"
1220+
- image:
1221+
productVersion: 1.2.3
1222+
pullPolicy: IfNotPresent
1223+
clusterConfig:
1224+
vectorAggregatorConfigMapName: vector-aggregator-discovery
1225+
loadExamples: true
1226+
credentialsSecretName: airflow-admin-credentials
1227+
metadataDatabase:
1228+
postgresql:
1229+
host: airflow-postgresql
1230+
database: airflow
1231+
credentialsSecretName: airflow-postgresql-credentials
1232+
authentication:
1233+
- authenticationClass: my-ldap
1234+
userRegistrationRole: Admin
1235+
authorization:
1236+
opa:
1237+
configMapName: test-opa
1238+
package: airflow
1239+
cache:
1240+
entryTimeToLive: 5s
1241+
maxEntries: 10
1242+
volumes:
1243+
- name: test-cm-dag
1244+
configMap:
1245+
name: test-cm-dag
1246+
volumeMounts:
1247+
- name: test-cm-dag
1248+
mountPath: /dags/example_trigger_target_dag.py
1249+
subPath: example_trigger_target_dag.py
1250+
{git_sync_section}
1251+
webservers:
1252+
roleConfig:
1253+
listenerClass: external-unstable
1254+
config:
1255+
resources:
1256+
cpu:
1257+
min: 100m
1258+
max: "1"
1259+
memory:
1260+
limit: 3001Mi
1261+
logging:
1262+
enableVectorAgent: true
1263+
configOverrides:
1264+
webserver_config.py:
1265+
FILE_HEADER: |
1266+
COMMON_HEADER_VAR = "role-value"
1267+
ROLE_HEADER_VAR = "role-value"
1268+
FILE_FOOTER: |
1269+
ROLE_FOOTER_VAR = "role-value"
1270+
podOverrides:
1271+
spec:
1272+
containers:
1273+
- name: airflow
1274+
resources:
1275+
requests:
1276+
cpu: 300m
1277+
limits:
1278+
cpu: 900m
1279+
roleGroups:
1280+
default:
1281+
replicas: 1
1282+
configOverrides:
1283+
webserver_config.py:
1284+
FILE_HEADER: |
1285+
COMMON_HEADER_VAR = "group-value"
1286+
celeryExecutors:
1287+
resultBackend:
1288+
postgresql:
1289+
host: airflow-postgresql
1290+
database: airflow
1291+
credentialsSecretName: airflow-postgresql-credentials
1292+
broker:
1293+
redis:
1294+
host: airflow-redis-master
1295+
credentialsSecretName: airflow-redis-credentials
1296+
config:
1297+
logging:
1298+
enableVectorAgent: true
1299+
roleGroups:
1300+
default:
1301+
replicas: 2
1302+
kubernetesExecutors:
1303+
config:
1304+
logging:
1305+
enableVectorAgent: true
1306+
schedulers:
1307+
config:
1308+
logging:
1309+
enableVectorAgent: true
1310+
roleGroups:
1311+
default:
1312+
replicas: 1
1313+
dagProcessors:
1314+
config:
1315+
logging:
1316+
enableVectorAgent: true
1317+
roleGroups:
1318+
default:
1319+
replicas: 1
1320+
triggerers:
1321+
config:
1322+
logging:
1323+
enableVectorAgent: true
1324+
roleGroups:
1325+
default:
1326+
replicas: 1
1327+
"#
11821328
}
11831329
}
11841330
}

0 commit comments

Comments
 (0)