|
26 | 26 | from openeogeotrellis.config.s3_config import S3Config
|
27 | 27 | from openeogeotrellis.integrations.kubernetes import k8s_render_manifest_template
|
28 | 28 | from openeogeotrellis.testing import gps_config_overrides
|
29 |
| -from openeogeotrellis.utils import UtcNowClock, utcnow |
30 | 29 |
|
31 | 30 |
|
32 | 31 | def test_extract_application_id():
|
@@ -674,28 +673,31 @@ def test_k8s_s3_profiles_and_token():
|
674 | 673 | )
|
675 | 674 |
|
676 | 675 |
|
677 |
| -def test_k8s_s3_profiles_and_token_must_be_cleanable(backend_config_path, fast_sleep): |
678 |
| - # GIVEN a specific time |
679 |
| - test_timestamp = utcnow() |
680 |
| - test_timestamp_epoch = test_timestamp.timestamp() |
681 |
| - |
682 |
| - # GIVEN the green infinity stone (to control the time dimension) |
683 |
| - with UtcNowClock.mock(now=test_timestamp): |
684 |
| - # WHEN we render the kubernetes manifest for s3 access |
685 |
| - token_path = get_backend_config().batch_job_config_dir / "token" |
686 |
| - app_dict = k8s_render_manifest_template( |
687 |
| - "batch_job_cfg_secret.yaml.j2", |
688 |
| - secret_name="my-app", |
689 |
| - job_id="test_id", |
690 |
| - token="test", |
691 |
| - profile_file_content=S3Config.from_backend_config("j-any", str(token_path)) |
692 |
| - ) |
| 676 | +def test_k8s_s3_profiles_and_token_must_be_cleanable(backend_config_path, fast_sleep, time_machine): |
| 677 | + time_machine.move_to(1745410732) # Wed 2025-04-23 12:18:52 UTC) |
| 678 | + # WHEN we render the kubernetes manifest for s3 access |
| 679 | + token_path = get_backend_config().batch_job_config_dir / "token" |
| 680 | + app_dict = k8s_render_manifest_template( |
| 681 | + "batch_job_cfg_secret.yaml.j2", |
| 682 | + secret_name="my-app", |
| 683 | + job_id="test_id", |
| 684 | + token="test", |
| 685 | + profile_file_content=S3Config.from_backend_config("j-any", str(token_path)), |
| 686 | + ) |
693 | 687 | # THEN we expect it to be cleanable by having a starttime set to the time it was created.
|
694 | 688 | # We can only clean files if we know they are stale
|
695 | 689 | assert app_dict == dirty_equals.IsPartialDict(
|
696 |
| - metadata=dirty_equals.IsPartialDict( |
697 |
| - annotations=dirty_equals.IsPartialDict(created_at=str(test_timestamp_epoch)) |
698 |
| - ), |
| 690 | + { |
| 691 | + "apiVersion": "v1", |
| 692 | + "kind": "Secret", |
| 693 | + "metadata": dirty_equals.IsPartialDict( |
| 694 | + { |
| 695 | + "labels": {"job_id": "test_id"}, |
| 696 | + "name": "my-app", |
| 697 | + "annotations": dirty_equals.IsPartialDict(created_at="1745403532.0"), |
| 698 | + } |
| 699 | + ), |
| 700 | + } |
699 | 701 | )
|
700 | 702 |
|
701 | 703 |
|
|
0 commit comments