Skip to content

Commit

Permalink
fix job resumption tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anikaweinmann committed Nov 15, 2024
1 parent 211c500 commit ed2565f
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions tests/test_job_resumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@
class JobResumptionProcessingTestCase(ActiniaResourceTestCaseBase):
cfg_file = os.environ.get("DEFAULT_CONFIG_PATH", "/etc/default/actinia")
tmp_cfg_file = "%s_tmp" % cfg_file
endpoint = "nc_spm_08/processing_async"
save_interim_results_value = None
endpoint = "/projects/nc_spm_08/processing_async"
resource_user_id = None
resource_resource_id = None
sleep_time = 15
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_notsaved_interim_results_by_success(self):
"""
tpl = Template(json_dumps(process_chain_1))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -364,18 +364,19 @@ def test_saved_interim_results(self):
"""Test if the interim results are not saved correctly"""
step = 4
tpl = Template(json_dumps(process_chain_1))
rv = self.server.post(
URL_PREFIX + self.endpoint,
# self.server.get(f"{URL_PREFIX}/{self.project_url_part}/nc_spm_08/mapsets",headers=self.admin_auth_header,content_type="application/json")
rv1 = self.server.post(
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation@PERMANENT", map2="baum555"),
content_type="application/json",
)
self.waitAsyncStatusAssertHTTP(
rv, headers=self.admin_auth_header, http_status=400, status="error"
rv1, headers=self.admin_auth_header, http_status=400, status="error"
)

# check if interim results are saved
resp_data = json_loads(rv.data)
resp_data = json_loads(rv1.data)
rv_user_id = resp_data["user_id"]
rv_resource_id = resp_data["resource_id"]
interim_dir = os.path.join(
Expand Down Expand Up @@ -407,7 +408,7 @@ def test_job_resumption(self):
"""Test job resumption with processing_async endpoint"""
tpl = Template(json_dumps(process_chain_1))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -450,7 +451,7 @@ def test_job_2_times_resumption(self):
"""Test job 2 times resumption with processing_async endpoint"""
tpl = Template(json_dumps(process_chain_1))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -512,7 +513,7 @@ def test_job_resumption_error_by_running(self):
"""
tpl = Template(json_dumps(process_chain_2_error))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(seconds=self.sleep_time),
content_type="application/json",
Expand Down Expand Up @@ -559,7 +560,7 @@ def test_job_resumption_importer(self):
"""Test job resumption with processing_async endpoint and importer"""
tpl = Template(json_dumps(process_chain_3_importer))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -604,7 +605,7 @@ def test_job_2_times_resumption_importer(self):
"""
tpl = Template(json_dumps(process_chain_3_importer))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -729,7 +730,7 @@ def test_job_resumption_stdout(self):
"""Test job resumption with processing_async endpoint and stdout"""
tpl = Template(json_dumps(process_chain_5_stdout))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -775,7 +776,7 @@ def test_job_2_times_resumption_stdout(self):
"""
tpl = Template(json_dumps(process_chain_5_stdout))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -916,7 +917,7 @@ def test_resource_endpoints(self):


class JobResumptionProcessingExportTestCase(JobResumptionProcessingTestCase):
endpoint = "/projects/nc_spm_08/processing_async_export"
endpoint = "nc_spm_08/processing_async_export"
resource_user_id = None
resource_resource_id = None

Expand All @@ -926,7 +927,7 @@ def test_job_resumption_exporter(self):
"""
tpl = Template(json_dumps(process_chain_4_exporter))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -993,7 +994,7 @@ def test_job_2_times_resumption_exporter(self):
"""
tpl = Template(json_dumps(process_chain_4_exporter))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -1077,22 +1078,22 @@ class JobResumptionPersistentProcessingTestCase(
):
project = "nc_spm_08"
mapset = "test_mapset"
endpoint = "/projects/%s/mapsets/%s/processing_async" % (project, mapset)
endpoint = f"{project}/mapsets/{mapset}/processing_async"
resource_user_id = None
resource_resource_id = None
mapset_created = True

def tearDown(self):
if self.mapset_created is True:
rv = self.server.delete(
URL_PREFIX
+ "/projects/%s/mapsets/%s/lock" % (self.project, self.mapset),
f"{URL_PREFIX}/{self.project_url_part}/{self.project}/mapsets/"
f"{self.mapset}/lock",
headers=self.admin_auth_header,
)
self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header)
rv2 = self.server.delete(
URL_PREFIX
+ "/projects/%s/mapsets/%s" % (self.project, self.mapset),
f"{URL_PREFIX}/{self.project_url_part}/{self.project}/mapsets/"
f"{self.mapset}",
headers=self.admin_auth_header,
)
self.waitAsyncStatusAssertHTTP(rv2, headers=self.admin_auth_header)
Expand All @@ -1105,7 +1106,7 @@ def test_saved_interim_results(self):
self.create_new_mapset(self.mapset, self.project)
tpl = Template(json_dumps(process_chain_1))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down Expand Up @@ -1148,15 +1149,15 @@ def test_resource_endpoints(self):


class JobResumptionErrorTestCase(ActiniaResourceTestCaseBase):
endpoint = "/projects/nc_spm_08/processing_async"
endpoint = "nc_spm_08/processing_async"

def test_job_resumption_config_error(self):
"""Test if the job resumption fails if save_interim_results is set to
False in the actinia.cfg
"""
tpl = Template(json_dumps(process_chain_1))
rv = self.server.post(
URL_PREFIX + self.endpoint,
f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}",
headers=self.admin_auth_header,
data=tpl.render(map1="elevation2@PERMANENT", map2="baum"),
content_type="application/json",
Expand Down

0 comments on commit ed2565f

Please sign in to comment.