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

Fix using limit=0 and details=on to get only the count of elements #1492 #3994

Merged
merged 25 commits into from
Apr 27, 2022

Conversation

Anjali-NEC
Copy link
Contributor

Fix issue #1492

@fgalan
Copy link
Member

fgalan commented Nov 10, 2021

This PR should include .test files to cover the cases described in #1492 (comment)

In addition, some existing .test are failing. They has to be reviewed and fixed.

@Anjali-NEC
Copy link
Contributor Author

This PR should include .test files to cover the cases described in #1492 (comment)

In addition, some existing .test are failing. They has to be reviewed and fixed.

Added new .test file and fixed existing .test are which are failing.

@fgalan
Copy link
Member

fgalan commented Nov 12, 2021

Reviwing this PR I have realized that in line L161

        OrionError error(SccBadRequest, std::string("Bad pagination limit: /") + value + "/ [must be a decimal number]");

should be changed to a more precise message:

        OrionError error(SccBadRequest, std::string("Bad pagination limit: /") + value + "/ [must be a positive integer number]");

Could you do that change in the PR, please?

"code": "400",
"details": "Bad pagination limit: /000000/ [a value of ZERO is unacceptable]",
"details": "JSON Parse Error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"JSON Parse Error" doesn't seem to be a right message in this case, as actually the request in step 3 doesn't have any payload...

In fact, a OK response seems to be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"JSON Parse Error" doesn't seem to be a right message in this case, as actually the request in step 3 doesn't have any payload...

In fact, a OK response seems to be better.

In step 3 everything is OK but it shows "JSON Parse Error". I didn't find reason for this error. Could you please suggest what modification should be done in this test case?

Copy link
Member

@fgalan fgalan Nov 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the response in this case should be the same you get when do a /v1/queryContext operation without any matching result. You can test yourself using this curl:

curl -vvv localhost:1026/v1/queryContext -H 'content-type: application/json' -d @- <<EOF
{
    "entities": [
        {
            "type": "foo",
            "isPattern": "false",
            "id": "bar"
        }
    ]
}
EOF

You should get something like this:

< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Content-Length: 70
< Content-Type: application/json
< Fiware-Correlator: aaee0e26-4621-11ec-9ae3-000c29583ca5
< Date: Mon, 15 Nov 2021 14:38:15 GMT
< 
* Connection #0 to host localhost left intact
{"errorCode":{"code":"404","reasonPhrase":"No context element found"}}

The expectation in the step should resemble that. The reason behind the "JSON Parser Error" in this case should be analyzed.

@Anjali-NEC
Copy link
Contributor Author

Reviwing this PR I have realized that in line L161

        OrionError error(SccBadRequest, std::string("Bad pagination limit: /") + value + "/ [must be a decimal number]");

should be changed to a more precise message:

        OrionError error(SccBadRequest, std::string("Bad pagination limit: /") + value + "/ [must be a positive integer number]");

Could you do that change in the PR, please?

Fix in 8879a39

@fgalan
Copy link
Member

fgalan commented Nov 23, 2021

Note that the PR is not passing code style check at the present point. It seems the problems is:

...
0002 errors of category 'Weird number of spaces at line-start'
=================================================================
...
src/lib/serviceRoutinesV2/getEntities.cpp:308:  Weird number of spaces at line-start.  Are you using a 2-space indent?  [whitespace/indent] [3]
src/lib/serviceRoutinesV2/getEntities.cpp:309:  Weird number of spaces at line-start.  Are you using a 2-space indent?  [whitespace/indent] [3]
...
Total errors found: 17

@Anjali-NEC
Copy link
Contributor Author

Note that the PR is not passing code style check at the present point. It seems the problems is:

...
0002 errors of category 'Weird number of spaces at line-start'
=================================================================
...
src/lib/serviceRoutinesV2/getEntities.cpp:308:  Weird number of spaces at line-start.  Are you using a 2-space indent?  [whitespace/indent] [3]
src/lib/serviceRoutinesV2/getEntities.cpp:309:  Weird number of spaces at line-start.  Are you using a 2-space indent?  [whitespace/indent] [3]
...
Total errors found: 17

Fixed in 64cf793

@fgalan
Copy link
Member

fgalan commented Dec 3, 2021

@Anjali-NEC taking into account the upcoming FIWARE TSC on Orion, could you provide an status update of this PR (or be prepared to attend to the TSC and report at the meeting), please? Thanks!

@Anjali-NEC
Copy link
Contributor Author

Anjali-NEC commented Jan 24, 2022

Please, find a new round of comments provided. Basically, I think you should deal the check for limit 0 at mongoBackend layer and not add serviceRoutine layer. Maybe after fixing that also the V1 ParseError issue gets also solved.
I have done some code changes at mongoBackend layer to check for limit=0. it works in case of GET subscription and registration but in case of GET entities and types it doesn't show the expected response.
In case of GET v2/entities with limit=0 it show Fiware-Total-Count: 0 and in case of GET /v2/types the response is empty payload instead of []. I have tried to fix this but I haven't found suitable solution for this.
Can you please suggest what change need to be done for getting expected response.

@fgalan Gentle Reminder!!!

@fgalan
Copy link
Member

fgalan commented Mar 3, 2022

I have done a new round of review. The PR looks better than last time. Congrats :)

However, there are new comments that need to be addressed. The main one is this: #3994 (comment), but the other are also important, related with indent, unnecessary whitelines, etc.

@fgalan
Copy link
Member

fgalan commented Mar 3, 2022

In adddition, the coflict in CHANGES_NEXT_RELEASE should be solved, so functional tests get another pass.

@Anjali-NEC
Copy link
Contributor Author

I have done a new round of review. The PR looks better than last time. Congrats :)

However, there are new comments that need to be addressed. The main one is this: #3994 (comment), but the other are also important, related with indent, unnecessary whitelines, etc.

The two test cases are still failing:

----------- Failing tests ------------------
  o  1492_limit_zero/limit_zero_entities.test
  o  1492_limit_zero/limit_zero_types.test

@fgalan
Copy link
Member

fgalan commented Mar 4, 2022

I have done a new round of review. The PR looks better than last time. Congrats :)
However, there are new comments that need to be addressed. The main one is this: #3994 (comment), but the other are also important, related with indent, unnecessary whitelines, etc.

The two test cases are still failing:

----------- Failing tests ------------------
  o  1492_limit_zero/limit_zero_entities.test
  o  1492_limit_zero/limit_zero_types.test

I have had a look to the limit_zero_entities.test and limit_zero_types.test and they seems to be correct, so it seems there is some fail in your implementation. Could you review it and fix, please?

@Anjali-NEC
Copy link
Contributor Author

I have had a look to the limit_zero_entities.test and limit_zero_types.test and they seems to be correct, so it seems there is some fail in your implementation. Could you review it and fix, please?

Hi @fgalan Sir,

Now all test cases are pass in my latest commit ff2b225. Please review it and if it is ok please merge it into master.
Thanks

@Anjali-NEC
Copy link
Contributor Author

@fgalan Gentle Reminder!!

@Anjali-NEC
Copy link
Contributor Author

Hi @fgalan Sir,
Please review my PR and if it is ok please merge it into master.
Thanks

@fgalan fgalan changed the base branch from master to issue1492-prelanding April 27, 2022 13:30
@fgalan
Copy link
Member

fgalan commented Apr 27, 2022

Work is not finished, but let's merge in pre-landing branch (issue1492-prelanding) to get easy further analysis and modifications.

@fgalan fgalan merged commit c20bd31 into telefonicaid:issue1492-prelanding Apr 27, 2022
@fgalan
Copy link
Member

fgalan commented Apr 27, 2022

Work is not finished, but let's merge in pre-landing branch (issue1492-prelanding) to get easy further analysis and modifications.

Continues in PR #4104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants