← Back to team overview

canonical-ubuntu-qa team mailing list archive

Re: [Merge] ~hyask/auto-upgrade-testing-specifications:skia/var_crash_ignore_list into auto-upgrade-testing-specifications:main

 


Diff comments:

> diff --git a/tests/check-var-crash-empty b/tests/check-var-crash-empty
> index db856b4..04e8a7a 100755
> --- a/tests/check-var-crash-empty
> +++ b/tests/check-var-crash-empty
> @@ -1,17 +1,85 @@
> -#!/bin/sh
> +#!/usr/bin/env python3
>  
> -set -e
> +import json
> +import sys
> +import subprocess
> +from datetime import date
> +from pathlib import Path
>  
> -crashdir=/var/crash
>  
> -echo "Checking for (absence of) crash files in $crashdir."
> +print("#### Checking /var/crash ####")
>  
> -if find "$crashdir" -maxdepth 0 ! -empty -exec false {} +; then
> -    echo "PASS: $crashdir is empty (good)"
> -else
> -    echo "FAIL: $crashdir is not empty. Crash files sorted by creation time:"
> -    ls -gGh -tr --time=creation --full-time "$crashdir"
> -    sudo systemctl start whoopsie.service --wait
> -    find /var/crash -name "*.uploaded" -exec tail -n +1 {} +
> -    exit 1
> -fi
> +print("Ensuring `whoopsie` is finished running")
> +try:
> +    subprocess.run(
> +        ["sudo", "systemctl", "start", "whoopsie.service", "--wait"],
> +        check=True,
> +    )
> +except subprocess.CalledProcessError as e:
> +    print(f"\tError waiting for `whoopsie` ({e}), continuing anyway")
> +    print(f"\tstdout: {e.stdout}")
> +    print(f"\tstderr: {e.stderr}")

Did this actually happen, or is this "just in case" code?

> +
> +today = date.today()
> +print(f"Today is {today}")
> +
> +try:
> +    data_path = Path("scripts_data.json")
> +    with open(data_path) as f:
> +        data = json.load(f)
> +    ignore_list = data["var_crash_ignore_list"]
> +    print(f"Loaded ignore list from `scripts_data.json`: {ignore_list}")
> +except Exception as e:
> +    ignore_list = []
> +    print(f"Failed to load ignore list from `scripts_data.json`: {e}")
> +
> +crash_list = []
> +
> +for crash in Path("/var/crash").glob("*.crash"):
> +    print(f"Found crash `{crash}`")
> +
> +    uploaded_file = crash.with_suffix(".uploaded")
> +    try:
> +        info = uploaded_file.read_text().strip()
> +        print(f"\tUpload details: {info}")
> +    except FileNotFoundError:
> +        print(f"\t{uploaded_file} not found, there's no detail to display")
> +
> +    print("\tChecking against ignore list")
> +    for entry in ignore_list:
> +        expiry_date = date.fromisoformat(entry["expiry_date"])
> +        pattern = entry["pattern"]
> +        print(
> +            f"\t\tChecking against `{pattern}` (expires on {expiry_date}) ... ",
> +            end="",
> +        )
> +        if crash.match(pattern):
> +            if expiry_date <= today:
> +                print(
> +                    f"matched expired entry, reporting the crash (please fix that bug: {entry['bug_link']})"
> +                )
> +                crash_list.append(crash)
> +            else:
> +                print(
> +                    f"matched, ignoring the crash (details should be here: {entry['bug_link']})"
> +                )
> +            break
> +        else:
> +            print("no match")
> +    else:
> +        print("\tNo entry matched, reporting this crash")
> +        crash_list.append(crash)
> +
> +exit_code = 0
> +
> +if len(crash_list) > 0:
> +    exit_code = 1
> +
> +    crash_list.sort(key=lambda c: c.stat().st_ctime)
> +    print("FAIL: /var/crash is not empty. Crash files sorted by ctime:")
> +    print("\n".join([f"- {crash}" for crash in crash_list]))
> +else:
> +    print("PASS: /var/crash is empty (good)")
> +
> +print(f"#### /var/crash checked (exit_code: {exit_code}) ####")
> +sys.exit(exit_code)


-- 
https://code.launchpad.net/~hyask/auto-upgrade-testing-specifications/+git/auto-upgrade-testing-specifications/+merge/458928
Your team Canonical Platform QA Team is requested to review the proposed merge of ~hyask/auto-upgrade-testing-specifications:skia/var_crash_ignore_list into auto-upgrade-testing-specifications:main.



References