Incorrect parsing of response in the test. #12

Closed
opened 2025-12-28 18:13:50 +00:00 by sami · 2 comments
Owner

Originally created by @tatiana-nspcc on GitHub (Dec 28, 2023).

Originally assigned to: @MaxGelbakhiani on GitHub.

When I run the test "Test Put over HTTP/Curl, Get over HTTP/Curl for large object" or "Test Put/Get over HTTP using Curl utility," it incorrectly parses the response. This one is OK:

REQUEST: 'http://http.neofs.devenv/upload/8RCBdQbqkvA8Ua83DBZY8ra5JTXrzcx5BDFXjtn8wme'
RESPONSE:
 {'object_id': 'irY8nYGk4ibL3rWnEykK27esGo3zsvZhxCUMMMW5xeT', 'container_id': '8RCBdQbqkvA8Ua83DBZY8ra5JTXrzcx5BDFXjtn8wme'}

Current Behavior

This response is marked as wrong:

{"container_id":"41cxpZjt9C7r1MpV3PBmnfurRP7xFEkAhhp8NjCy5UQc","object_id":"3kKzfjWtRRoYkPEh9nXNV8eB3gVVttKLZYgxefrWKbgt"}

I've got a message:

File "/home/tanya/neo/projects/nspcc-dev/neofs-testcases/venv.local-pytest/lib/python3.10/site-packages/allure_commons/_allure.py", line 192, in impl
    return func(*a, **kw)
  File "/home/tanya/neo/projects/nspcc-dev/neofs-testcases/robot/resources/lib/python_keywords/http_gate.py", line 245, in upload_via_http_gate_curl
    raise AssertionError(f'Could not find "object_id" in {output}')

Expected Behavior

An extra space or an absent space shouldn't cause the test to fail.

Possible Solution

Perhaps it would be better to properly parse the JSON response here.:
nspcc-dev/neofs-testcases@ef04906bea/robot/resources/lib/python_keywords/http_gate.py (L243)

Context

I encountered this issue while testing the rest-gw.

Originally created by @tatiana-nspcc on GitHub (Dec 28, 2023). Originally assigned to: @MaxGelbakhiani on GitHub. <!-- Provide a general summary of the issue in the Title above --> When I run the test "Test Put over HTTP/Curl, Get over HTTP/Curl for large object" or "Test Put/Get over HTTP using Curl utility," it incorrectly parses the response. This one is OK: ``` REQUEST: 'http://http.neofs.devenv/upload/8RCBdQbqkvA8Ua83DBZY8ra5JTXrzcx5BDFXjtn8wme' RESPONSE: {'object_id': 'irY8nYGk4ibL3rWnEykK27esGo3zsvZhxCUMMMW5xeT', 'container_id': '8RCBdQbqkvA8Ua83DBZY8ra5JTXrzcx5BDFXjtn8wme'} ``` ## Current Behavior <!-- Tell us what happens instead of the expected behavior --> This response is marked as wrong: ``` {"container_id":"41cxpZjt9C7r1MpV3PBmnfurRP7xFEkAhhp8NjCy5UQc","object_id":"3kKzfjWtRRoYkPEh9nXNV8eB3gVVttKLZYgxefrWKbgt"} ``` I've got a message: ``` File "/home/tanya/neo/projects/nspcc-dev/neofs-testcases/venv.local-pytest/lib/python3.10/site-packages/allure_commons/_allure.py", line 192, in impl return func(*a, **kw) File "/home/tanya/neo/projects/nspcc-dev/neofs-testcases/robot/resources/lib/python_keywords/http_gate.py", line 245, in upload_via_http_gate_curl raise AssertionError(f'Could not find "object_id" in {output}') ``` ## Expected Behavior <!-- Tell us what should happen --> An extra space or an absent space shouldn't cause the test to fail. ## Possible Solution <!-- Not obligatory, but suggest a fix/reason for the bug --> Perhaps it would be better to properly parse the JSON response here.: https://github.com/nspcc-dev/neofs-testcases/blob/ef04906beaba71ca8d6e633b01601456f0582f47/robot/resources/lib/python_keywords/http_gate.py#L243 ## Context <!-- How has this issue affected you? What are you trying to accomplish? Providing context helps us come up with a solution that is most useful in the real world --> I encountered this issue while testing the rest-gw.
sami 2025-12-28 18:13:50 +00:00
  • closed this issue
  • added the
    bug
    S4
    U1
    I4
    labels
Author
Owner

@roman-khimov commented on GitHub (Jan 15, 2024):

JSON is JSON and must be treated accordingly.

@roman-khimov commented on GitHub (Jan 15, 2024): JSON is JSON and must be treated accordingly.
Author
Owner

@MaxGelbakhiani commented on GitHub (Jan 22, 2024):

The problem was caused by the output format. output might contain something like:

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\n  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\n100  575k    0     0    0  575k      0  2884k --:--:-- --:--:-- --:--:-- 2879k\n100 1537k    0     0    0 1537k      0  1258k --:--:--  0:00:01 --:--:-- 1258k{\n\t"object_id": "CUf93a2T6NocdLud77CtZcbsEfgQNMHBjfKjXQ3zKSe1",\n\t"container_id": "kLJKURtdNXpGc31qVhMmyD4zsjcY2nMTVXdbDBC3CHw"\n}\n\n100 1537k  100   129    0 1537k     75   895k  0:00:01  0:00:01 --:--:--  895k\n

So I've added options to extract JSON out of it, including multiline cases, which I believe caused @tatiana-nspcc 's issue. And added JSON parsing as well

@MaxGelbakhiani commented on GitHub (Jan 22, 2024): The problem was caused by the output format. output might contain something like: ``` % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\n 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\n100 575k 0 0 0 575k 0 2884k --:--:-- --:--:-- --:--:-- 2879k\n100 1537k 0 0 0 1537k 0 1258k --:--:-- 0:00:01 --:--:-- 1258k{\n\t"object_id": "CUf93a2T6NocdLud77CtZcbsEfgQNMHBjfKjXQ3zKSe1",\n\t"container_id": "kLJKURtdNXpGc31qVhMmyD4zsjcY2nMTVXdbDBC3CHw"\n}\n\n100 1537k 100 129 0 1537k 75 895k 0:00:01 0:00:01 --:--:-- 895k\n ``` So I've added options to extract JSON out of it, including multiline cases, which I believe caused @tatiana-nspcc 's issue. And added JSON parsing as well
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-testlib#12
No description provided.