add short demo jobs for demos and parallel testing
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def main() -> None:
|
||||
seconds = int(sys.argv[1]) if len(sys.argv) > 1 else 20
|
||||
print(f"Demo job started, running for {seconds} seconds.", flush=True)
|
||||
for elapsed in range(1, seconds + 1):
|
||||
time.sleep(1)
|
||||
if elapsed % 5 == 0:
|
||||
print(f"Progress: {elapsed}/{seconds} seconds.", flush=True)
|
||||
print("Demo job finished successfully.", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -14,12 +14,21 @@ case "$JOB" in
|
||||
# Print counts for the aktuell / aktuell_postproc indices (read-only).
|
||||
exec python sync.py --stats
|
||||
;;
|
||||
demo-a)
|
||||
exec python demo.py 20
|
||||
;;
|
||||
demo-b)
|
||||
exec python demo.py 25
|
||||
;;
|
||||
demo-c)
|
||||
exec python demo.py 30
|
||||
;;
|
||||
"")
|
||||
echo "No job given. Available jobs: news, news-stats" >&2
|
||||
echo "No job given. Available jobs: news, news-stats, demo-a, demo-b, demo-c" >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown job: $JOB. Available jobs: news, news-stats" >&2
|
||||
echo "Unknown job: $JOB. Available jobs: news, news-stats, demo-a, demo-b, demo-c" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -13,6 +13,9 @@ from sqlmodel import Field, SQLModel
|
||||
class BackgroundJobName(StrEnum):
|
||||
NEWS = "news"
|
||||
NEWS_STATS = "news-stats"
|
||||
DEMO_A = "demo-a"
|
||||
DEMO_B = "demo-b"
|
||||
DEMO_C = "demo-c"
|
||||
|
||||
|
||||
class JobRunStatus(StrEnum):
|
||||
|
||||
@@ -33,6 +33,39 @@ PREDEFINED_JOB_DEFINITIONS: list[dict] = [
|
||||
"schedule": None,
|
||||
"enabled": True,
|
||||
},
|
||||
{
|
||||
"name": "Demo-Job A",
|
||||
"description": (
|
||||
"Testjob für Demos: läuft ca. 20 Sekunden, schreibt Fortschritt "
|
||||
"ins Log und verändert nichts."
|
||||
),
|
||||
"target_index": "-",
|
||||
"job": BackgroundJobName.DEMO_A,
|
||||
"schedule": None,
|
||||
"enabled": True,
|
||||
},
|
||||
{
|
||||
"name": "Demo-Job B",
|
||||
"description": (
|
||||
"Testjob für Demos: läuft ca. 25 Sekunden, schreibt Fortschritt "
|
||||
"ins Log und verändert nichts."
|
||||
),
|
||||
"target_index": "-",
|
||||
"job": BackgroundJobName.DEMO_B,
|
||||
"schedule": None,
|
||||
"enabled": True,
|
||||
},
|
||||
{
|
||||
"name": "Demo-Job C",
|
||||
"description": (
|
||||
"Testjob für Demos: läuft ca. 30 Sekunden, schreibt Fortschritt "
|
||||
"ins Log und verändert nichts."
|
||||
),
|
||||
"target_index": "-",
|
||||
"job": BackgroundJobName.DEMO_C,
|
||||
"schedule": None,
|
||||
"enabled": True,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Jobs known to the background-jobs image\'s entrypoint.sh dispatcher.
|
||||
*/
|
||||
export const BackgroundJobName = {
|
||||
News: 'news',
|
||||
NewsStats: 'news-stats',
|
||||
DemoA: 'demo-a',
|
||||
DemoB: 'demo-b',
|
||||
DemoC: 'demo-c',
|
||||
} as const;
|
||||
export type BackgroundJobName =
|
||||
(typeof BackgroundJobName)[keyof typeof BackgroundJobName];
|
||||
|
||||
Reference in New Issue
Block a user