Merge pull request #232 from luigi311/test_update
Update test validation to use logurupull/234/head
commit
846e18fffe
|
|
@ -3,11 +3,8 @@
|
||||||
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
||||||
DRYRUN = "True"
|
DRYRUN = "True"
|
||||||
|
|
||||||
## Additional logging information
|
|
||||||
DEBUG = "True"
|
|
||||||
|
|
||||||
## Debugging level, "info" is default, "debug" is more verbose
|
## Debugging level, "info" is default, "debug" is more verbose
|
||||||
DEBUG_LEVEL = "debug"
|
DEBUG_LEVEL = "trace"
|
||||||
|
|
||||||
## If set to true then the script will only run once and then exit
|
## If set to true then the script will only run once and then exit
|
||||||
RUN_ONLY_ONCE = "True"
|
RUN_ONLY_ONCE = "True"
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,8 @@
|
||||||
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
||||||
DRYRUN = "True"
|
DRYRUN = "True"
|
||||||
|
|
||||||
## Additional logging information
|
|
||||||
DEBUG = "True"
|
|
||||||
|
|
||||||
## Debugging level, "info" is default, "debug" is more verbose
|
## Debugging level, "info" is default, "debug" is more verbose
|
||||||
DEBUG_LEVEL = "debug"
|
DEBUG_LEVEL = "trace"
|
||||||
|
|
||||||
## If set to true then the script will only run once and then exit
|
## If set to true then the script will only run once and then exit
|
||||||
RUN_ONLY_ONCE = "True"
|
RUN_ONLY_ONCE = "True"
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,8 @@
|
||||||
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
||||||
DRYRUN = "True"
|
DRYRUN = "True"
|
||||||
|
|
||||||
## Additional logging information
|
|
||||||
DEBUG = "True"
|
|
||||||
|
|
||||||
## Debugging level, "info" is default, "debug" is more verbose
|
## Debugging level, "info" is default, "debug" is more verbose
|
||||||
DEBUG_LEVEL = "debug"
|
DEBUG_LEVEL = "trace"
|
||||||
|
|
||||||
## If set to true then the script will only run once and then exit
|
## If set to true then the script will only run once and then exit
|
||||||
RUN_ONLY_ONCE = "True"
|
RUN_ONLY_ONCE = "True"
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,8 @@
|
||||||
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
||||||
DRYRUN = "True"
|
DRYRUN = "True"
|
||||||
|
|
||||||
## Additional logging information
|
|
||||||
DEBUG = "True"
|
|
||||||
|
|
||||||
## Debugging level, "info" is default, "debug" is more verbose
|
## Debugging level, "info" is default, "debug" is more verbose
|
||||||
DEBUG_LEVEL = "debug"
|
DEBUG_LEVEL = "trace"
|
||||||
|
|
||||||
## If set to true then the script will only run once and then exit
|
## If set to true then the script will only run once and then exit
|
||||||
RUN_ONLY_ONCE = "True"
|
RUN_ONLY_ONCE = "True"
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,8 @@
|
||||||
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
||||||
DRYRUN = "True"
|
DRYRUN = "True"
|
||||||
|
|
||||||
## Additional logging information
|
|
||||||
DEBUG = "True"
|
|
||||||
|
|
||||||
## Debugging level, "info" is default, "debug" is more verbose
|
## Debugging level, "info" is default, "debug" is more verbose
|
||||||
DEBUG_LEVEL = "debug"
|
DEBUG_LEVEL = "trace"
|
||||||
|
|
||||||
## If set to true then the script will only run once and then exit
|
## If set to true then the script will only run once and then exit
|
||||||
RUN_ONLY_ONCE = "True"
|
RUN_ONLY_ONCE = "True"
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,8 @@
|
||||||
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
## Do not mark any shows/movies as played and instead just output to log if they would of been marked.
|
||||||
DRYRUN = "False"
|
DRYRUN = "False"
|
||||||
|
|
||||||
## Additional logging information
|
|
||||||
DEBUG = "True"
|
|
||||||
|
|
||||||
## Debugging level, "info" is default, "debug" is more verbose
|
## Debugging level, "info" is default, "debug" is more verbose
|
||||||
DEBUG_LEVEL = "debug"
|
DEBUG_LEVEL = "trace"
|
||||||
|
|
||||||
## If set to true then the script will only run once and then exit
|
## If set to true then the script will only run once and then exit
|
||||||
RUN_ONLY_ONCE = "True"
|
RUN_ONLY_ONCE = "True"
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,37 @@
|
||||||
# Check the mark.log file that is generated by the CI to make sure it contains the expected values
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
from loguru import logger
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
|
class MarkLogError(Exception):
|
||||||
|
"""Custom exception for mark.log validation failures."""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Check the mark.log file that is generated by the CI to make sure it contains the expected values"
|
description="Check the mark.log file that is generated by the CI to make sure it contains the expected values"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
group.add_argument(
|
||||||
"--guids", action="store_true", help="Check the mark.log file for guids"
|
"--guids", action="store_true", help="Check the mark.log file for guids"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"--locations", action="store_true", help="Check the mark.log file for locations"
|
"--locations", action="store_true", help="Check the mark.log file for locations"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"--write", action="store_true", help="Check the mark.log file for write-run"
|
"--write", action="store_true", help="Check the mark.log file for write-run"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"--plex", action="store_true", help="Check the mark.log file for Plex"
|
"--plex", action="store_true", help="Check the mark.log file for Plex"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"--jellyfin", action="store_true", help="Check the mark.log file for Jellyfin"
|
"--jellyfin", action="store_true", help="Check the mark.log file for Jellyfin"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"--emby", action="store_true", help="Check the mark.log file for Emby"
|
"--emby", action="store_true", help="Check the mark.log file for Emby"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -31,51 +40,47 @@ def parse_args():
|
||||||
|
|
||||||
def read_marklog():
|
def read_marklog():
|
||||||
marklog = os.path.join(os.getcwd(), "mark.log")
|
marklog = os.path.join(os.getcwd(), "mark.log")
|
||||||
with open(marklog, "r") as f:
|
try:
|
||||||
lines = f.readlines()
|
with open(marklog, "r") as f:
|
||||||
return lines
|
lines = [line.strip() for line in f if line.strip()]
|
||||||
|
return lines
|
||||||
|
except Exception as e:
|
||||||
|
raise MarkLogError(f"Error reading {marklog}: {e}")
|
||||||
|
|
||||||
|
|
||||||
def check_marklog(lines, expected_values):
|
def check_marklog(lines, expected_values):
|
||||||
try:
|
found_counter = Counter(lines)
|
||||||
# Check to make sure the marklog contains all the expected values and nothing else
|
expected_counter = Counter(expected_values)
|
||||||
found_values = []
|
|
||||||
for line in lines:
|
|
||||||
# Remove the newline character
|
|
||||||
line = line.strip()
|
|
||||||
if line not in expected_values:
|
|
||||||
raise Exception("Line not found in marklog: " + line)
|
|
||||||
|
|
||||||
found_values.append(line)
|
# Determine missing and extra items by comparing counts
|
||||||
|
missing = expected_counter - found_counter
|
||||||
|
extra = found_counter - expected_counter
|
||||||
|
|
||||||
# Check to make sure the marklog contains the same number of values as the expected values
|
if missing or extra:
|
||||||
if len(found_values) != len(expected_values):
|
if missing:
|
||||||
raise Exception(
|
logger.error("Missing expected entries (with counts):")
|
||||||
"Marklog did not contain the same number of values as the expected values, found "
|
for entry, count in missing.items():
|
||||||
+ str(len(found_values))
|
logger.error(f" {entry}: missing {count} time(s)")
|
||||||
+ " values, expected "
|
if extra:
|
||||||
+ str(len(expected_values))
|
logger.error("Unexpected extra entries found (with counts):")
|
||||||
+ " values\n"
|
for entry, count in extra.items():
|
||||||
+ "\n".join(found_values)
|
logger.error(f" {entry}: found {count} extra time(s)")
|
||||||
)
|
|
||||||
|
|
||||||
# Check that the two lists contain the same values
|
logger.error(
|
||||||
if sorted(found_values) != sorted(expected_values):
|
f"Entry count mismatch: found {len(lines)} entries, expected {len(expected_values)} entries."
|
||||||
raise Exception(
|
)
|
||||||
"Marklog did not contain the same values as the expected values, found:\n"
|
logger.error("Full mark.log content:")
|
||||||
+ "\n".join(sorted(found_values))
|
for line in sorted(lines):
|
||||||
+ "\n\nExpected:\n"
|
logger.error(f" {line}")
|
||||||
+ "\n".join(sorted(expected_values))
|
raise MarkLogError("mark.log validation failed.")
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
|
# Expected values defined for each check
|
||||||
expected_jellyfin = [
|
expected_jellyfin = [
|
||||||
"Plex/JellyPlex-CI/jellyplex_watched/Custom Movies/Movie Two (2021)",
|
"Plex/JellyPlex-CI/jellyplex_watched/Custom Movies/Movie Two (2021)",
|
||||||
"Plex/JellyPlex-CI/jellyplex_watched/Custom TV Shows/Greatest Show Ever 3000/Episode 2",
|
"Plex/JellyPlex-CI/jellyplex_watched/Custom TV Shows/Greatest Show Ever 3000/Episode 2",
|
||||||
|
|
@ -173,38 +178,39 @@ def main():
|
||||||
"Jellyfin/Jellyfin-Server/JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4",
|
"Jellyfin/Jellyfin-Server/JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Expected values for the mark.log file, dry-run is slightly different than write-run
|
# Determine which expected values to use based on the command-line flag
|
||||||
# due to some of the items being copied over from one server to another and now being there
|
|
||||||
# for the next server run.
|
|
||||||
if args.guids:
|
if args.guids:
|
||||||
expected_values = expected_guids
|
expected_values = expected_guids
|
||||||
|
check_type = "GUIDs"
|
||||||
elif args.locations:
|
elif args.locations:
|
||||||
expected_values = expected_locations
|
expected_values = expected_locations
|
||||||
|
check_type = "locations"
|
||||||
elif args.write:
|
elif args.write:
|
||||||
expected_values = expected_write
|
expected_values = expected_write
|
||||||
|
check_type = "write-run"
|
||||||
elif args.plex:
|
elif args.plex:
|
||||||
expected_values = expected_plex
|
expected_values = expected_plex
|
||||||
|
check_type = "Plex"
|
||||||
elif args.jellyfin:
|
elif args.jellyfin:
|
||||||
expected_values = expected_jellyfin
|
expected_values = expected_jellyfin
|
||||||
|
check_type = "Jellyfin"
|
||||||
elif args.emby:
|
elif args.emby:
|
||||||
expected_values = expected_emby
|
expected_values = expected_emby
|
||||||
|
check_type = "Emby"
|
||||||
else:
|
else:
|
||||||
print("No server specified")
|
raise MarkLogError("No server specified")
|
||||||
exit(1)
|
|
||||||
|
|
||||||
lines = read_marklog()
|
logger.info(f"Validating mark.log for {check_type}...")
|
||||||
if not check_marklog(lines, expected_values):
|
|
||||||
print("Failed to validate marklog")
|
|
||||||
for line in lines:
|
|
||||||
# Remove the newline character
|
|
||||||
line = line.strip()
|
|
||||||
|
|
||||||
print(line)
|
try:
|
||||||
|
lines = read_marklog()
|
||||||
|
check_marklog(lines, expected_values)
|
||||||
|
except MarkLogError as e:
|
||||||
|
logger.error(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
exit(1)
|
logger.success("Successfully validated mark.log")
|
||||||
|
sys.exit(0)
|
||||||
print("Successfully validated marklog")
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue