Skip to content

Commit 0dce603

Browse files
authored
feat(interu): Add --check-test-options flag (#30)
1 parent 320eae6 commit 0dce603

File tree

7 files changed

+341
-47
lines changed

7 files changed

+341
-47
lines changed

tools/interu/fixtures/interu.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runners:
66
- name: default
77
arch: amd64
88
size: large
9-
disk: 50
9+
disk-gb: 50
1010
nodes: 3
1111

1212
default-arm64:
@@ -16,7 +16,7 @@ runners:
1616
- name: default
1717
arch: arm64
1818
size: large
19-
disk: 50
19+
disk-gb: 50
2020
nodes: 3
2121

2222
default-mixed:
@@ -26,12 +26,12 @@ runners:
2626
- name: amd64-nodes
2727
arch: amd64
2828
size: large
29-
disk: 50
29+
disk-gb: 50
3030
nodes: 3
3131
- name: arm64-nodes
3232
arch: arm64
3333
size: large
34-
disk: 50
34+
disk-gb: 50
3535
nodes: 3
3636

3737
profiles:
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# COPIED FROM AIRFLOW-OPERATOR
2+
---
3+
dimensions:
4+
- name: airflow
5+
values:
6+
- 2.9.2
7+
- 2.9.3
8+
- 2.10.2
9+
# To use a custom image, add a comma and the full name after the product version
10+
# - 2.8.1,docker.stackable.tech/sandbox/airflow:2.8.1-stackable0.0.0-dev
11+
- name: airflow-latest
12+
values:
13+
- 2.10.2
14+
# To use a custom image, add a comma and the full name after the product version
15+
# - 2.8.1,docker.stackable.tech/sandbox/airflow:2.8.1-stackable0.0.0-dev
16+
- name: ldap-authentication
17+
values:
18+
- no-tls
19+
- insecure-tls
20+
- server-verification-tls
21+
- name: openshift
22+
values:
23+
- "false"
24+
- name: executor
25+
values:
26+
- celery
27+
- kubernetes
28+
tests:
29+
- name: smoke
30+
dimensions:
31+
- airflow
32+
- openshift
33+
- executor
34+
- name: mount-dags-configmap
35+
dimensions:
36+
- airflow-latest
37+
- openshift
38+
- executor
39+
- name: mount-dags-gitsync
40+
dimensions:
41+
- airflow-latest
42+
- openshift
43+
- executor
44+
- name: ldap
45+
dimensions:
46+
- airflow-latest
47+
- openshift
48+
- ldap-authentication
49+
- executor
50+
- name: oidc
51+
dimensions:
52+
- airflow
53+
- openshift
54+
- name: resources
55+
dimensions:
56+
- airflow-latest
57+
- openshift
58+
- name: orphaned-resources
59+
dimensions:
60+
- airflow-latest
61+
- openshift
62+
- name: logging
63+
dimensions:
64+
- airflow
65+
- openshift
66+
- executor
67+
- name: cluster-operation
68+
dimensions:
69+
- airflow-latest
70+
- openshift
71+
- name: overrides
72+
dimensions:
73+
- airflow-latest
74+
- openshift
75+
suites:
76+
- name: nightly
77+
# Run nightly with the latest airflow
78+
patch:
79+
- dimensions:
80+
- name: airflow
81+
expr: last
82+
- name: smoke-latest
83+
# Useful for development
84+
select:
85+
- smoke
86+
patch:
87+
- dimensions:
88+
- expr: last
89+
- name: openshift
90+
# Run on OpenShift with latest airflow
91+
patch:
92+
- dimensions:
93+
- expr: last
94+
- dimensions:
95+
- name: airflow
96+
expr: last
97+
- name: openshift
98+
expr: "true"

tools/interu/src/cli.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ pub struct Cli {
2323
option,
2424
short = 'o',
2525
long = "output",
26-
description = "write configuration key=value pairs separated by newlines to file
27-
Useful for CI tools which give a file to write env vars and outputs to which are used in subsequent steps"
26+
description = "write configuration key=value pairs separated by newlines to file. Useful for CI tools which give a file to write env vars and outputs to which are used in subsequent steps"
2827
)]
2928
pub output: Option<PathBuf>,
3029

@@ -33,6 +32,19 @@ pub struct Cli {
3332
#[argh(switch, short = 'q', long = "quiet")]
3433
pub quiet: bool,
3534

35+
/// validate the beku test definition of the selected profile
36+
#[argh(switch, long = "check-test-definitions")]
37+
pub check_test_definitions: bool,
38+
39+
/// path to beku test-definition file [default = tests/test-definition.yaml]
40+
#[argh(
41+
option,
42+
short = 't',
43+
long = "test-definitions",
44+
default = r#"PathBuf::from("tests/test-definition.yaml")"#
45+
)]
46+
pub test_definitions: PathBuf,
47+
3648
/// which test profile to use
3749
#[argh(positional)]
3850
pub profile: String,

tools/interu/src/config/mod.rs

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tracing::instrument;
1111

1212
use crate::{
1313
config::{
14-
profile::{Profile, StrategyValidationError, TestRun},
14+
profile::{Profile, StrategyValidationError, TestOptions, TestRun},
1515
runner::{
1616
ConvertNodeGroupError, Distribution, ReplicatedNodeGroup, Runner, RunnerValidationError,
1717
},
@@ -21,6 +21,7 @@ use crate::{
2121

2222
pub mod profile;
2323
pub mod runner;
24+
pub mod test;
2425

2526
/// Errors which can be encountered when reading and validating the config file.
2627
#[derive(Debug, Snafu)]
@@ -43,6 +44,9 @@ pub enum Error {
4344
path: PathBuf,
4445
},
4546

47+
#[snafu(display("failed to validate test options"))]
48+
ValidateTestOptions { source: StrategyValidationError },
49+
4650
#[snafu(display("failed to find profile named {profile_name:?}"))]
4751
UnknownProfileName { profile_name: String },
4852

@@ -92,25 +96,19 @@ impl Config {
9296
Ok(config)
9397
}
9498

95-
#[instrument(name = "validate_config", skip(self))]
96-
fn validate(&self) -> Result<(), ValidationError> {
97-
for (runner_name, runner) in &self.runners {
98-
tracing::debug!(runner_name, "validate runner");
99-
100-
runner
101-
.validate(runner_name)
102-
.context(InvalidRunnerConfigSnafu)?;
103-
}
104-
105-
for (profile_name, profile) in &self.profiles {
106-
tracing::debug!(profile_name, "validate profile");
107-
108-
profile
109-
.validate(profile_name, &self.runners)
110-
.context(InvalidProfileConfigSnafu)?;
111-
}
99+
pub fn get_profile(&self, profile_name: &String) -> Result<&Profile, Error> {
100+
self.profiles
101+
.get(profile_name)
102+
.context(UnknownProfileNameSnafu { profile_name })
103+
}
112104

113-
Ok(())
105+
pub fn validate_test_options<P>(&self, profile_name: &String, path: P) -> Result<(), Error>
106+
where
107+
P: AsRef<Path>,
108+
{
109+
self.get_profile(profile_name)?
110+
.validate_test_options(&profile_name, path)
111+
.context(ValidateTestOptionsSnafu)
114112
}
115113

116114
/// Determines the final expanded parameters based on the provided profile.
@@ -120,10 +118,7 @@ impl Config {
120118
instances: &'a Instances,
121119
) -> Result<Parameters<'a>, Error> {
122120
// First, lookup the profile by name. Error if the profile does't exist.
123-
let profile = self
124-
.profiles
125-
.get(profile_name)
126-
.context(UnknownProfileNameSnafu { profile_name })?;
121+
let profile = self.get_profile(profile_name)?;
127122

128123
// Next, lookup the runner ref based on the profile strategy
129124
let runner_ref = match &profile.strategy {
@@ -144,7 +139,11 @@ impl Config {
144139
let runner = self.runners.get(runner_ref).unwrap();
145140

146141
// Get test options
147-
let (test_parallelism, test_run, test_parameter) = profile.strategy.get_test_options();
142+
let TestOptions {
143+
parallelism,
144+
test_run,
145+
test_parameter,
146+
} = profile.strategy.get_test_options();
148147

149148
// Convert our node groups to replicated node groups
150149
let node_groups = runner
@@ -158,13 +157,34 @@ impl Config {
158157
Ok(Parameters {
159158
kubernetes_distribution: &runner.platform.distribution,
160159
kubernetes_version: &runner.platform.version,
160+
test_parallelism: *parallelism,
161161
cluster_ttl: &runner.ttl,
162-
test_parallelism,
163162
test_parameter,
164163
node_groups,
165164
test_run,
166165
})
167166
}
167+
168+
#[instrument(name = "validate_config", skip(self))]
169+
fn validate(&self) -> Result<(), ValidationError> {
170+
for (runner_name, runner) in &self.runners {
171+
tracing::debug!(runner_name, "validate runner");
172+
173+
runner
174+
.validate(runner_name)
175+
.context(InvalidRunnerConfigSnafu)?;
176+
}
177+
178+
for (profile_name, profile) in &self.profiles {
179+
tracing::debug!(profile_name, "validate profile");
180+
181+
profile
182+
.validate(profile_name, &self.runners)
183+
.context(InvalidProfileConfigSnafu)?;
184+
}
185+
186+
Ok(())
187+
}
168188
}
169189

170190
/// Parameters which will be expanded into environment variables via the [`Display`] implementation.
@@ -221,7 +241,7 @@ impl<'a> Display for Parameters<'a> {
221241
}
222242

223243
#[cfg(test)]
224-
mod test {
244+
mod tests {
225245
use std::path::PathBuf;
226246

227247
use super::*;

0 commit comments

Comments
 (0)