feat: capture specimen logs

This commit is contained in:
Aravinth Manivannan 2023-10-05 00:57:36 +05:30
parent 86c63f75ab
commit 639527744b
Signed by: realaravinth
GPG key ID: F8F50389936984FF
5 changed files with 44 additions and 22 deletions

View file

@ -108,12 +108,13 @@ async fn main() -> std::io::Result<()> {
}
crate::runner::suite::SuiteRunnerState::run_proxy(ctx.as_ref());
let (suite_results, init_containers) =
let (suite_results, init_containers, specimen_logs) =
crate::runner::target::run_target(ctx.as_ref(), path.clone()).await;
let content = crate::runner::results::ArchivableResult {
commit: "".into(),
suites: suite_results,
init_containers,
specimen_logs,
};
let results_file = path.join("results.json");
println!("Writing results to: {:?}", path.canonicalize());

View file

@ -23,12 +23,13 @@ pub async fn run(ctx: AppFullCtx, commit: &str) {
Git::checkout_commit(commit, &control);
for entry in crate::runner::target::get_targets(&control).iter() {
let (suite_results, init_containers) =
let (suite_results, init_containers, target_logs) =
crate::runner::target::run_target(ctx.as_ref(), entry.into()).await;
let content = ArchivableResult {
commit: commit.to_string(),
suites: suite_results,
init_containers,
specimen_logs : target_logs,
};
let results_repo = base_dir.join("results");

View file

@ -54,6 +54,7 @@ pub struct ArchivableResult {
pub commit: String,
pub suites: Vec<ArchivableSuiteResult>,
pub init_containers: Option<Vec<ArchivableInitResult>>,
pub specimen_logs: Vec<ArchivableContainer>,
}
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]

View file

@ -21,10 +21,11 @@ pub async fn run_target(
) -> (
Vec<ArchivableSuiteResult>,
Option<Vec<ArchivableInitResult>>,
Vec<ArchivableContainer>,
) {
let compose = DockerCompose::new(target.canonicalize().unwrap(), ctx.docker_().clone());
compose.up();
let services = compose.services();
let mut services = compose.services();
// Read test suite
let ftest_path = target.join(FTEST_TARGET_FILE);
@ -43,13 +44,17 @@ pub async fn run_target(
// shut down target instance
let mut target_logs = Vec::with_capacity(services.len());
for s in services.iter() {
target_logs.push(compose.logs(&s.service));
for s in services.drain(0..) {
let logs = compose.logs(&s.service);
target_logs.push(ArchivableContainer {
logs,
name: s.service,
});
}
compose.down(true, true);
(suite_results, init_containers)
(suite_results, init_containers, target_logs)
}
pub fn get_targets(control: &Path) -> Vec<PathBuf> {

View file

@ -33,23 +33,37 @@
<h2>Initialization Workflow</h2>
{% for init in payload.results.init_containers %}
<details>
{% if init.success %}
<summary>
<h3 class="test__name">[OK] {{init.container.name}}</h3>
</summary>
{% else %}
<summary>
<h3 class="test__name">[FAILED] {{init.container.name}}</h3>
</summary>
{% endif %}
<h4>STDOUT</h4>
<code>{{ init.container.logs.stdout | linebreaksbr }}</code>
<h4>STDERR</h4>
<code>{{ init.container.logs.stderr | linebreaksbr }}</code>
</details>
<details>
{% if init.success %}
<summary>
<h3 class="test__name">[OK] {{init.container.name}}</h3>
</summary>
{% else %}
<summary>
<h3 class="test__name">[FAILED] {{init.container.name}}</h3>
</summary>
{% endif %}
<h4>STDOUT</h4>
<code>{{ init.container.logs.stdout | linebreaksbr }}</code>
<h4>STDERR</h4>
<code>{{ init.container.logs.stderr | linebreaksbr }}</code>
</details>
{% endfor %} {% endif %}
<h2>Specimen Logs</h2>
{% for specimen in payload.results.specimen_logs %}
<details>
<summary>
<h3 class="test__name">{{specimen.name}}</h3>
</summary>
<h4>STDOUT</h4>
<code>{{ specimen.logs.stdout | linebreaksbr }}</code>
<h4>STDERR</h4>
<code>{{ specimen.logs.stderr | linebreaksbr }}</code>
</details>
{% endfor %}
</body>
<style>
.test__name {