Skip to content

Commit 8fa3945

Browse files
committed
dividing 404
Signed-off-by: Katharina Trentau <[email protected]>
1 parent d5e4d76 commit 8fa3945

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
1616
41: Not able to bind PersitantVolume to PersitantVolumeClaim
1717
42: ReadWriteOnce is not a supported access mode
18-
43: PVC not found
19-
44: Pod not found
18+
43: Resource not found PVC not found
19+
44: Resource not found Pod not found
2020
2121
All return codes between (and including) 1-19 as well as all return codes ending on 9
2222
can be seen as failures.
@@ -92,22 +92,22 @@ def create_pvc_pod(
9292
# 1. Create PersistantVolumeClaim
9393
logger.debug(f"create pvc: {pvc_name}")
9494

95-
# pvc_meta = client.V1ObjectMeta(name=pvc_name)
96-
# pvc_resources = client.V1ResourceRequirements(
97-
# requests={"storage": "1Gi"},
98-
# )
99-
# pvc_spec = client.V1PersistentVolumeClaimSpec(
100-
# access_modes=["ReadWriteOnce"],
101-
# storage_class_name=storage_class,
102-
# resources=pvc_resources,
103-
# )
104-
# body_pvc = client.V1PersistentVolumeClaim(
105-
# api_version="v1", kind="PersistentVolumeClaim", metadata=pvc_meta, spec=pvc_spec
106-
# )
107-
108-
# api_response = k8s_api_instance.create_namespaced_persistent_volume_claim(
109-
# namespace, body_pvc
110-
# )
95+
pvc_meta = client.V1ObjectMeta(name=pvc_name)
96+
pvc_resources = client.V1ResourceRequirements(
97+
requests={"storage": "1Gi"},
98+
)
99+
pvc_spec = client.V1PersistentVolumeClaimSpec(
100+
access_modes=["ReadWriteOnce"],
101+
storage_class_name=storage_class,
102+
resources=pvc_resources,
103+
)
104+
body_pvc = client.V1PersistentVolumeClaim(
105+
api_version="v1", kind="PersistentVolumeClaim", metadata=pvc_meta, spec=pvc_spec
106+
)
107+
108+
api_response = k8s_api_instance.create_namespaced_persistent_volume_claim(
109+
namespace, body_pvc
110+
)
111111
try:
112112
k8s_api_instance.read_namespaced_persistent_volume_claim(name=pvc_name, namespace=namespace)
113113
logger.debug("created pvc successfully")
@@ -314,7 +314,17 @@ def __enter__(self):
314314

315315
def __exit__(self, exc_type, exc_value, traceback):
316316
if self.return_code != 43:
317-
self.clean()
317+
try:
318+
self.clean()
319+
except ApiException as api_exception:
320+
logger.info(f"code {api_exception.status}")
321+
if api_exception.status == 404: # might be obsolete
322+
logger.info(
323+
"resource not found, "
324+
"failed to build resources correctly"
325+
)
326+
self.return_code = 4
327+
self.return_message = "(404) resource not found"
318328
if self.return_code == 0:
319329
self.return_message = "all tests passed"
320330
if isinstance(exc_value, SCSTestException):
@@ -379,24 +389,24 @@ def main(argv):
379389
env.return_message = "(404) resource not found"
380390
return
381391
except ApiException as api_exception:
382-
logger.info(f"code {api_exception.status}")
383-
if api_exception.status == 404: # might be obsolete
384-
logger.info(
385-
"resource not found, "
386-
"failed to build resources correctly"
387-
)
388-
env.return_code = 4
389-
env.return_message = "(404) resource not found"
390-
return
391-
elif api_exception.status == 409:# might be obsolete
392-
logger.info(
393-
"conflicting resources, "
394-
"try to clean up left overs, then start again"
395-
)
396-
env.return_code = 3
397-
env.return_message = "(409) conflicting resources"
398-
return
399-
else:
392+
# logger.info(f"code {api_exception.status}")
393+
# if api_exception.status == 404: # might be obsolete
394+
# logger.info(
395+
# "resource not found, "
396+
# "failed to build resources correctly"
397+
# )
398+
# env.return_code = 4
399+
# env.return_message = "(404) resource not found"
400+
# return
401+
# elif api_exception.status == 409:# might be obsolete
402+
# logger.info(
403+
# "conflicting resources, "
404+
# "try to clean up left overs, then start again"
405+
# )
406+
# env.return_code = 3
407+
# env.return_message = "(409) conflicting resources"
408+
# return
409+
# else:
400410
logger.info(f"An API error occurred: {api_exception}")
401411
env.return_code = api_exception.status
402412
return

0 commit comments

Comments
 (0)