Skip to content

Commit

Permalink
Update status to display multiple test retries
Browse files Browse the repository at this point in the history
  • Loading branch information
ecpullen committed Mar 21, 2022
1 parent 5c122b7 commit 03bf195
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 216 deletions.
16 changes: 12 additions & 4 deletions agent/test-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub use k8s_client::ClientError;
use log::info;
use model::clients::TestClient;
pub use model::{Configuration, TestResults};
use model::{SecretName, SecretType};
use model::{Outcome, SecretName, SecretType};
use std::collections::BTreeMap;
use std::fmt::{Debug, Display};
use std::path::PathBuf;
Expand Down Expand Up @@ -65,10 +65,16 @@ pub trait Runner: Sized + Send {
/// Rerun a failed test.
async fn rerun_failed(
&mut self,
prev_test_result: &TestResults,
_prev_test_result: &TestResults,
) -> Result<TestResults, Self::E> {
info!("Tried to rerun test, but no retry method was defined.");
Ok(prev_test_result.clone())
Ok(TestResults {
outcome: Outcome::Fail,
num_failed: 1,
num_passed: 0,
num_skipped: 0,
other_info: Some("No retry_failed method defined".to_string()),
})
}

/// Cleans up prior to program exit.
Expand Down Expand Up @@ -116,7 +122,9 @@ pub trait Client: Sized {
/// Set the appropriate status field to represent that the test has started.
async fn send_test_starting(&self) -> Result<(), Self::E>;

/// Set the appropriate status fields once the test has `TestResults` available.
/// Add a TestResults object to the CRDs array of TestResults without signaling that the test
/// is complete. This is used to send TestResults when some failures have occured and we are
/// going to re-run the failed test cases.
async fn send_test_results(&self, results: TestResults) -> Result<(), Self::E>;

/// Set the appropriate status fields once the test has finished.
Expand Down
9 changes: 0 additions & 9 deletions bottlerocket/agents/src/bin/sonobuoy-test-agent/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ impl test_agent::Runner for SonobuoyTestRunner {
setup_test_env(self, aws_secret_name).await?;
}

if let Some(wireguard_secret_name) = &self.wireguard_secret_name {
// If a wireguard secret is specified, try to set up an wireguard connection with the
// wireguard configuration stored in the secret.
let wireguard_secret = self
.get_secret(wireguard_secret_name)
.context(error::SecretMissingSnafu)?;
setup_wireguard(&wireguard_secret).await?;
}

delete_sonobuoy(TEST_CLUSTER_KUBECONFIG_PATH).await?;

decode_write_kubeconfig(&self.config.kubeconfig_base64, TEST_CLUSTER_KUBECONFIG_PATH)
Expand Down
4 changes: 2 additions & 2 deletions testsys/src/run_aws_k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub(crate) struct RunAwsK8s {

/// Allow the sonobuoy test agent to rerun failed test.
#[structopt(long)]
allow_retries: Option<u32>,
retry_failed_attempts: Option<u32>,

/// Perform an upgrade downgrade test.
#[structopt(long, requires_all(&["starting-version", "upgrade-version", "migration-agent-image"]))]
Expand Down Expand Up @@ -429,7 +429,7 @@ impl RunAwsK8s {
cluster_resource_name.to_string(),
],
depends_on,
retries: self.allow_retries,
retries: self.retry_failed_attempts,
agent: Agent {
name: "sonobuoy-test-agent".to_string(),
image: self.test_agent_image.clone(),
Expand Down
4 changes: 2 additions & 2 deletions testsys/src/run_vmware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub(crate) struct RunVmware {

/// Allow the sonobuoy test agent to rerun failed test.
#[structopt(long)]
allow_retries: Option<u32>,
retry_failed_attempts: Option<u32>,

/// Perform an upgrade downgrade test.
#[structopt(long, requires_all(&["starting-version", "upgrade-version"]))]
Expand Down Expand Up @@ -377,7 +377,7 @@ impl RunVmware {
spec: TestSpec {
resources: vec![vm_resource_name.to_string()],
depends_on,
retries: self.allow_retries,
retries: self.retry_failed_attempts,
agent: Agent {
name: "vmware-sonobuoy-test-agent".to_string(),
image: self.test_agent_image.clone(),
Expand Down
Loading

0 comments on commit 03bf195

Please sign in to comment.