Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tavern):[#503] fix failing ess tests #675

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions local/testing/api-tests/irs-api-tests.tavern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,15 @@ stages:
- function: local.testing.api-tests.tavern_helpers:supplyChainImpacted_is_as_expected
extra_kwargs:
expectedSupplyChainImpacted: "Unknown"
- function: local.testing.api-tests.tavern_helpers:tombstone_for_EssValidation_are_correct
- function: local.testing.api-tests.tavern_helpers:tombstones_have_size
extra_kwargs:
number_of_tombstones: 2
- function: local.testing.api-tests.tavern_helpers:tombstone_for_submodel_validation_is_correct
extra_kwargs:
expected_error_detail: "Submodel payload validation failed. $.sites[0]: required property 'catenaXsiteId' not found."
- function: local.testing.api-tests.tavern_helpers:tombstone_for_ess_validation_is_correct
extra_kwargs:
expectedTombstone: "'PartSiteInformationAsPlanned' exists, but catenaXSiteId could not be found."
expected_error_detail: "AspectType 'PartSiteInformationAsPlanned' not found in Job."
headers:
content-type: application/json

Expand Down Expand Up @@ -749,7 +755,7 @@ stages:
- function: local.testing.api-tests.tavern_helpers:ESS_job_parameter_are_as_requested
- function: local.testing.api-tests.tavern_helpers:supplyChainFirstLevelBpn_is_as_expected
extra_kwargs:
expectedBpnl: BPNL00ARBITRARY10
expectedBpnl: BPNL0ARBITRARY10
headers:
content-type: application/json

Expand Down
58 changes: 39 additions & 19 deletions local/testing/api-tests/tavern_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,39 @@ def ESS_job_parameter_are_as_requested(response):
assert 'urn:samm:io.catenax.part_as_planned:1.0.1#PartAsPlanned' in aspects_list


def tombstone_for_EssValidation_are_correct(response, expectedTombstone):
error_list = response.json().get("tombstones")
def tombstone_for_ess_validation_is_correct(response, expected_error_detail):
response_contains_expected_error(response, expected_error_detail, 'EssValidation')

for i in error_list:
print("Given tombstone: ", i)
catenaXId = i.get("catenaXId")
print("Given catenaXID: ", catenaXId)
processingErrorStep = i.get("processingError").get("processStep")
print("Processstep in ProcessingError: ", processingErrorStep)
processingErrorDetail = i.get("processingError").get("errorDetail")
print("ErrorMessage: ", processingErrorDetail)
processingErrorLastAttempt = i.get("processingError").get("lastAttempt")
print("LastAttempt: ", processingErrorLastAttempt)
processingErrorRetryCounter = i.get("processingError").get("retryCounter")
print("RetryCounter: ", processingErrorRetryCounter)
assert 'EssValidation' in processingErrorStep
assert expectedTombstone in processingErrorDetail
assert processingErrorLastAttempt is not None
assert 0 is processingErrorRetryCounter

def tombstone_for_submodel_validation_is_correct(response, expected_error_detail):
response_contains_expected_error(response, expected_error_detail, 'SchemaValidation')


def check_tombstones(tombstones, criteria):
for tombstone in tombstones:
for criterion in criteria:
if (tombstone.get("processingError").get("processStep") == criterion.get("processStep") and
tombstone.get("processingError").get("errorDetail") == criterion.get("errorDetail")):
return True
return False


def response_contains_expected_error(response, expected_error_detail, expected_process_step):
error_list = response.json().get("tombstones")
criteria = [
{
"processStep": expected_process_step,
"errorDetail": expected_error_detail
}
]
check_tombstones(error_list, criteria)
for tombstone in error_list:
processing_error_last_attempt = tombstone.get("processingError").get("lastAttempt")
print("LastAttempt: ", processing_error_last_attempt)
processing_error_retry_counter = tombstone.get("processingError").get("retryCounter")
print("RetryCounter: ", processing_error_retry_counter)
assert processing_error_last_attempt is not None
assert 0 == processing_error_retry_counter


############################## /\ ESS helpers /\ ##############################
Expand All @@ -90,6 +104,12 @@ def tombstones_are_empty(response):
assert len(response.json().get("tombstones")) == 0


def tombstones_have_size(response, number_of_tombstones):
print(response.json().get("tombstones"))
print("Check if tombstones have expected number of elements: ", number_of_tombstones)
assert len(response.json().get("tombstones")) == number_of_tombstones


def tombstones_are_not_empty(response):
print(response.json().get("tombstones"))
print("Check if tombstones are not empty number:", len(response.json().get("tombstones")))
Expand Down Expand Up @@ -163,7 +183,7 @@ def errors_for_unknown_globalAssetId_are_correct(response):
assert 'DigitalTwinRequest' in processingErrorStep
#assert 'Shell for identifier urn:uuid:cce14502-958a-42e1-8bb7-f4f41aaaaaaa not found' in processingErrorDetail #commented out since this error message is not possible currently after DTR changes
assert processingErrorLastAttempt is not None
assert 3 is processingErrorRetryCounter
assert 3 == processingErrorRetryCounter


def status_of_jobs_are_as_expected(response, expected_status):
Expand Down
Loading