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 for issue4149 in case of requestForwarding #4275

Merged

Conversation

ArqamFarooqui110719
Copy link
Contributor

Fix issue #4149

@ArqamFarooqui110719
Copy link
Contributor Author

Currently total 16 sets of existing test cases (with cache and without cache) are failing.
We have investigated and observed that some of the existing test cases are failing due to our code changes. We are fixing the same  and will update the PR.

@ArqamFarooqui110719
Copy link
Contributor Author

ArqamFarooqui110719 commented Feb 20, 2023

Hi @fgalan ,
I have updated the code for 13 sets of failed test cases and modified the 3 existing FTs because those FTs are related with request forwarding.
Currently all the test cases are passing successfully. Kindly review the PR.

@@ -107,7 +107,7 @@ Date: REGEX(.*)

03. Dump accumulator and check that E/A was forwarded (not including B or C)
============================================================================
POST http://localhost:REGEX(\d+)/v2/op/query
POST http://localhost:REGEX(\d+)/v2/op/query?limit=20&offset=0&options=count
Copy link
Member

Choose a reason for hiding this comment

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

Existing tests should be modified by this PR.

If we change to rollback the change this way

Suggested change
POST http://localhost:REGEX(\d+)/v2/op/query?limit=20&offset=0&options=count
POST http://localhost:REGEX(\d+)/v2/op/query

does the test pass?

Copy link
Member

Choose a reason for hiding this comment

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

NTC (answered as general comment here)

@ArqamFarooqui110719
Copy link
Contributor Author

No, without modification test was failing. 

Because we have modified the forwarding URL in case of request forwarding with pagination parameters if pagination parameters are not given in the API so default pagination parameters will be passed.

Due to which existing FT need to be modified.

# 25. Create entity C10/T with attribute A2, in CP2
# 26. Register entities of type T, with ID .*, and attribute A1, for CP1
# 27. Register entities of type T, with ID .*, and attribute A2, for CP2
# 28. GET /v2/entities with limit=5 and check no limit forwarded to CP
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# 28. GET /v2/entities with limit=5 and check no limit forwarded to CP
# 28. GET /v2/entities with limit=3 and check no limit forwarded to CP

As this is the actually step

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07




echo "28. GET /v2/entities with limit<5 and check no limit forwarded to CP"
Copy link
Member

Choose a reason for hiding this comment

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

To be precise:

Suggested change
echo "28. GET /v2/entities with limit<5 and check no limit forwarded to CP"
echo "28. GET /v2/entities with limit=3 and check no limit forwarded to CP"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07




echo "29. GET /v2/entities with limit=5 and check no limit forwarded to CP"
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't match with the text in the step description for step 29, which is:

  1. GET /v2/entities with limit=10 and check remaining limit forwarded to CP

Please, review the overall file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07




echo "32. GET /v2/entities with offset<5 and check no offset is forwarded to CP"
Copy link
Member

Choose a reason for hiding this comment

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

Please don't use < and > in the text, but precise statements with =. Otherwise, the steps could be more difficult to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07

Comment on lines 35 to 45
# 01. Create entity A1/T in CB
# 02. Create entity A2/T in CB
# 03. Create entity A3/T in CB
# 04. Create entity A4/T in CB
# 05. Create entity A5/T in CB
# 06. GET /v2/entities with limit=5
# 07. GET /v2/entities with offset=2
# 08. GET /v2/entities with options=count
# 09. GET /v2/entities with limit=5 and offset=2
# 10. GET /v2/entities with limit=2 and options=count
# 11. GET /v2/entities with offset=2 and options=count
Copy link
Member

Choose a reason for hiding this comment

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

According to this script, this .test doesn't do anything related with CPr. Thus, it doesn't seem to be related with issue #4149. Or maybe I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these FTs are not related with CPr. These FTs are related with pagination in normal case.
We have included these FTs, to confirm that existing pagination functionality (Without Request Forwarding) is also working fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these FTs are not related with CPr. These FTs are related with pagination in normal case.
We have included these FTs, to test that existing pagination functionality (Without Request Forwarding) is also working fine.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. It doesn't hurt :)

Let's keep the test. Although maybe it's better to use a better name. Suggestion: pagination_check_regular_functionality_does_not_break.test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07

Comment on lines 242 to 245
int providerLimit,
int providerOffset,
ApiVersion apiVersion,
CURL* _curl,
Copy link
Member

Choose a reason for hiding this comment

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

As a common practise, we keep the existing argument order in functions and add new arguments at the end (i.e. after timeoutInMilliseconds).

Copy link
Member

Choose a reason for hiding this comment

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

Moreover, I think apiVersion can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, new parameters should be added before the timeoutInMilliseconds, as timeoutInMilliseconds is a default parameter.

So if we are keeping the newly added parameters after the timeoutInMilliseconds then it is taking incorrect values in httpRequestSend.cpp file, (I have added LM_E level log to print the values of new parametes), for e.g.

If we keep the parameters after the timeoutInMilliseconds:
Actual value of new parameters inside postQueryContext.cpp file, before httpRequestSend.cpp() function call:

time=2023-05-19T04:06:05.984Z | lvl=ERROR | corr=7a3c718e-f5fa-11ed-8540-e3fa43514f13 | trans=1684469149-080-00000000001 | from=127.0.0.1 | srv= | subsrv= | comp=Orion | op=postQueryContext.cpp[305]:queryForward | msg=Arqam-17may23 Error (providerLimit value in postQueryContext/queryForward at L304: '15')
time=2023-05-19T04:06:05.984Z | lvl=ERROR | corr=7a3c718e-f5fa-11ed-8540-e3fa43514f13 | trans=1684469149-080-00000000001 | from=127.0.0.1 | srv= | subsrv= | comp=Orion | op=postQueryContext.cpp[306]:queryForward | msg=Arqam-17may23 Error (providerOffset value in postQueryContext/queryForward at L305: '0')

Incorrect value of new parameters being passed inside httpRequestSend.cpp file:

time=2023-05-19T04:06:05.984Z | lvl=ERROR | corr=7a3c718e-f5fa-11ed-8540-e3fa43514f13 | trans=1684469149-080-00000000001 | from=127.0.0.1 | srv= | subsrv= | comp=Orion | op=httpRequestSend.cpp[267]:httpRequestSend | msg=Arqam-17may23 Error (providerLimit value in httpRequestSend at L267: '0')
time=2023-05-19T04:06:05.984Z | lvl=ERROR | corr=7a3c718e-f5fa-11ed-8540-e3fa43514f13 | trans=1684469149-080-00000000001 | from=127.0.0.1 | srv= | subsrv= | comp=Orion | op=httpRequestSend.cpp[268]:httpRequestSend | msg=Arqam-17may23 Error (providerOffset value in httpRequestSend at L268: '0')

If we keep the parameters before the parameter timeoutInMilliseconds:
In that case correct values are being received in httpRequestSend.cpp file (I have added LM_E level log to print the values):

Actual values of new parameters inside postQueryContext.cpp file, before httpRequestSend.cpp() function call:

time=2023-05-19T04:16:58.653Z | lvl=ERROR | corr=ff41bbfe-f5fb-11ed-8540-e3fa43514f13 | trans=1684469739-808-00000000001 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=postQueryContext.cpp[305]:queryForward | msg=Arqam-17may23 Error (providerLimit value in postQueryContext/queryForward at L304: '15')
time=2023-05-19T04:16:58.653Z | lvl=ERROR | corr=ff41bbfe-f5fb-11ed-8540-e3fa43514f13 | trans=1684469739-808-00000000001 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=postQueryContext.cpp[306]:queryForward | msg=Arqam-17may23 Error (providerOffset value in postQueryContext/queryForward at L305: '0')

Correct values of new parameters being passed inside httpRequestSend.cpp file:

time=2023-05-19T04:16:58.653Z | lvl=ERROR | corr=ff41bbfe-f5fb-11ed-8540-e3fa43514f13 | trans=1684469739-808-00000000001 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=httpRequestSend.cpp[267]:httpRequestSend | msg=Arqam-17may23 Error (providerLimit value in httpRequestSend at L267: '15')
time=2023-05-19T04:16:58.653Z | lvl=ERROR | corr=ff41bbfe-f5fb-11ed-8540-e3fa43514f13 | trans=1684469739-808-00000000001 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=httpRequestSend.cpp[268]:httpRequestSend | msg=Arqam-17may23 Error (providerOffset value in httpRequestSend at L268: '0')

Copy link
Member

Choose a reason for hiding this comment

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

Suggested signature:

extern int httpRequestSend
(
  CURL*                                      curl,
  const std::string&                         idStringForLogs,
  ...
  long long*                                 statusCodeP,
  const std::map<std::string, std::string>&  extraHeaders,
  int                                        providerLimit = -1,
  int                                        providerOffset = -1,
  const std::string&                         acceptFormat          = "",
  long                                       timeoutInMilliseconds = -1
);

Note the suggestion to make providerLimit and priverOffset default parameter. The usage of -1 as default is aligned with previous comments and would make some parts of the code simpler (the ones in notification logic and in update forward logic, where CPrs pagination doesn't make sense).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07

Comment on lines 62 to 64
int providerLimit = DEFAULT_PAGINATION_LIMIT_INT;
int providerOffset = DEFAULT_PAGINATION_OFFSET_INT;
ApiVersion apiVersion = V1;
Copy link
Member

Choose a reason for hiding this comment

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

Remove this block and use -1 for providerLimit and provideOffset in the call to httpRequestSend() below, meaning with <0 value that the parameter hasn't to be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07

Comment on lines 579 to 589

if (apiVersion == V2 && verb == "POST" && resource == "/v2/op/query")
{
std::string pLimit = std::to_string(providerLimit);
std::string pOffset = std::to_string(providerOffset);
url = protocol + url + ":" + portAsString + (resource.at(0) == '/'? "" : "/") + resource + "?limit=" + pLimit + "&offset=" + pOffset + "&options=count";
}
else
{
url = protocol + url + ":" + portAsString + (resource.at(0) == '/'? "" : "/") + resource;
}
Copy link
Member

Choose a reason for hiding this comment

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

Related with previous comments (apiVersion not needed and >=0 to mean you want to include some of the new URL query parameters), I'd suggest to do something like this:

Suggested change
if (apiVersion == V2 && verb == "POST" && resource == "/v2/op/query")
{
std::string pLimit = std::to_string(providerLimit);
std::string pOffset = std::to_string(providerOffset);
url = protocol + url + ":" + portAsString + (resource.at(0) == '/'? "" : "/") + resource + "?limit=" + pLimit + "&offset=" + pOffset + "&options=count";
}
else
{
url = protocol + url + ":" + portAsString + (resource.at(0) == '/'? "" : "/") + resource;
}
url = protocol + url + ":" + portAsString + (resource.at(0) == '/'? "" : "/") + resource;
if (providerLimit >= 0) && (providerOffset >=0)
{
std::string pLimit = std::to_string(providerLimit);
std::string pOffset = std::to_string(providerOffset);
url += "?limit=" + pLimit + "&offset=" + pOffset + "&options=count";
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07

Comment on lines 154 to 155
int providerLimit = DEFAULT_PAGINATION_LIMIT_INT;
int providerOffset = DEFAULT_PAGINATION_OFFSET_INT;
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment to the one done at src/lib/ngsiNotify/doNotify.cpp:

Remove this block and use -1 for providerLimit and provideOffset in the call to httpRequestSend() below, meaning with <0 value that the parameter hasn't to be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e47b07

Comment on lines -490 to +536
if ((ciP->apiVersion == V2) && (ciP->uriParamOptions["count"]))
std::string georel = ciP->uriParam["georel"];
if ((ciP->apiVersion == V2))
{
countP = &count;
if (!((ciP->inMimeType == JSON && strstr(ciP->payload, "near")) || strstr(georel.c_str(), "near")))
{
countP = &count;
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on the changes done in this part?

I don't get the part related with geolocation ("georel", "near", etc), as it seems geolocation hasn't nothing to do with issue #4149...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the above geolocation check, all the FTs related with geolocation attributes ("georel", "near") were failing for e.g. FT 1038_ngsiv2_geo_location_entities, 1177_geometry_and_coords and 4114_geojson_feature_support.
So we have added a georel related check here for those FTs.

Copy link
Member

Choose a reason for hiding this comment

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

I'm trying to "decode" the logical expression... it's hard:

  • (!((ciP->inMimeType == JSON && strstr(ciP->payload, "near")) || strstr(georel.c_str(), "near")))
    • ciP->inMimeType == JSON && strstr(ciP->payload, "near": the mime type in the request is JSON and the string near is in the payload of the request
    • strstr(georel.c_str(), "near"): the georeal (assuming georeal has been specified) is near

So, in sum

IF NOT (("the mime type in the request is JSON and the string near is in the payload of the request") OR "the georeal (assuming georeal has been specified) is near")

I don't get why this is needed to avoid some test to fail. What kind of fail did you get in those FT? Could you provide the diff in this tests (preveribly in a graphical way, e.g. meld?

I'd like to understand this in deep before applying the "guard" you propose...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we are not applying the above geolocation check then below error is occurring on FT.

I have attach the screenshot of .out file for failed FT test/functionalTest/cases/4114_geojson_feature_support/geojson_feature_support.test

Functional Test case:
Orion_4114_FT

Output of FT:
output_of_failing_FT_without_geolocation_check

Earlier we have used a simple check at postQueryContext.cpp (L#533) as below:

  if (ciP->apiVersion == V2)
  {
     countP = &count;
 }

But due to some FTs were failing related with geolocation attribute, so we have added an extra check (at L#536) as below i.e. related with geolocation attributes so that our code changes does not affect the geolocation attribute related APIs:

  std::string georel  =  ciP->uriParam["georel"];
  if ((ciP->apiVersion == V2))
  {
    if (!((ciP->inMimeType == JSON && strstr(ciP->payload, "near")) || strstr(georel.c_str(), "near")))
    {
      countP = &count;
    }
  }

Copy link
Member

Choose a reason for hiding this comment

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

That's weird... I'd need to have a look to the code and debug myself.

Given this is the only pending comment at this point, I'd suggest to merge your PR in a pre-landing branch in the repository (issue-4149-prelanding) so I can debug in it. Then, we will continue if needed in that new PR.

Copy link
Member

Choose a reason for hiding this comment

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

That PR is #4341

Copy link
Member

Choose a reason for hiding this comment

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

I have tested to revert to the original code, this way:

diff --git a/src/lib/serviceRoutines/postQueryContext.cpp b/src/lib/serviceRoutines/postQueryContext.cpp
index a2952d7b9..64201e799 100644
--- a/src/lib/serviceRoutines/postQueryContext.cpp
+++ b/src/lib/serviceRoutines/postQueryContext.cpp
@@ -531,13 +531,17 @@ std::string postQueryContext
   // In API version 2, this has changed completely. Here, the total count of local entities is returned
   // if the URI parameter 'count' is set to 'true', and it is returned in the HTTP header Fiware-Total-Count.
   //
-  std::string georel  =  ciP->uriParam["georel"];
+  /*std::string georel  =  ciP->uriParam["georel"];
   if ((ciP->apiVersion == V2))
   {
     if (!((ciP->inMimeType == JSON && strstr(ciP->payload, "near")) || strstr(georel.c_str(), "near")))
     {
       countP = &count;
     }
+  }*/
+  if ((ciP->apiVersion == V2) && (ciP->uriParamOptions["count"]))
+  {
+    countP = &count;
   }
   else if ((ciP->apiVersion == V1) && (ciP->uriParam["details"] == "on"))
   {

and it's seem it's working:

$ ./testHarness.sh cases/4114_geojson_feature_support
lun 05 jun 2023 10:00:11 CEST
Run tests 0 to 0
0001/6: geojson_feature_errors.test ..................................................................................  04 seconds
0002/6: geojson_feature_errors_ignoretype.test .......................................................................  04 seconds
0003/6: geojson_feature_support.test .................................................................................  02 seconds
0004/6: geojson_feature_support_ignoretype.test ......................................................................  03 seconds
0005/6: geojson_featurecollection_support.test .......................................................................  02 seconds
0006/6: geojson_featurecollection_support_ignoretype.test ............................................................  03 seconds
Total test time: 18.30 seconds

$ ./testHarness.sh cases/1038_ngsiv2_geo_location_entities/
lun 05 jun 2023 10:00:41 CEST
Run tests 0 to 0
0001/16: entity_location_shape_changes.test ...........................................................................  05 seconds
0002/16: errors_general.test ..........................................................................................  04 seconds
0003/16: errors_geobox.test ...........................................................................................  04 seconds
0004/16: errors_geoline.test ..........................................................................................  05 seconds
0005/16: errors_geopoint.test .........................................................................................  03 seconds
0006/16: errors_geopolygon.test .......................................................................................  04 seconds
0007/16: geoquery_box_geobox.test .....................................................................................  03 seconds
0008/16: geoquery_box_geobox_after_update.test ........................................................................  03 seconds
0009/16: geoquery_box_geoline.test ....................................................................................  03 seconds
0010/16: geoquery_box_geoline_after_update.test .......................................................................  03 seconds
0011/16: geoquery_box_geopolygon.test .................................................................................  02 seconds
0012/16: geoquery_box_geopolygon_after_update.test ....................................................................  03 seconds
0013/16: geoquery_circle_geopoint.test ................................................................................  05 seconds
0014/16: geoquery_circle_geopoint_after_update.test ...................................................................  04 seconds
0015/16: geoquery_polygon_geopoint.test ...............................................................................  06 seconds
0016/16: geoquery_polygon_geopoint_after_update.test ..................................................................  06 seconds
Total test time: 62.86 seconds

$ ./testHarness.sh cases/1177_geometry_and_coords/
lun 05 jun 2023 10:02:29 CEST
Run tests 0 to 0
0001/2: geometry_and_coords.test .....................................................................................  03 seconds
0002/2: geometry_and_coords_errors.test ..............................................................................  03 seconds
Total test time: 6.20 seconds

Comment on lines +858 to +866
if ((ciP->apiVersion == V2) && (ciP->uriParamOptions["count"]))
{
char cV[32];

snprintf(cV, sizeof(cV), "%llu", *countP);

ciP->httpHeader.push_back(HTTP_FIWARE_TOTAL_COUNT);
ciP->httpHeaderValue.push_back(cV);
}
Copy link
Member

Choose a reason for hiding this comment

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

It seems this block has been moved, from old L526 to this point. Could you elaborate on which that movement is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we have moved the block, because at old location i.e. at L#526, ciP->httpHeader vector were holding the count of only CB entities.
Now in new location i.e. at L#858, ciP->httpHeader vector is holding count of all the entities including CB+CP. Because Total count of all the entities (CP+CB) is available only after queryForward() function call i.e. at L#785.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the clarification. I'd suggest to add an explanatory comment about it

NTC (with regards to this comment thread)

* And we can get the actualTotalCount value that includes total Entities of CP+CB.
*
*/
void getProviderCount (std::string cpResponse, long long* totalCount)
Copy link
Member

Choose a reason for hiding this comment

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

Style

Suggested change
void getProviderCount (std::string cpResponse, long long* totalCount)
static void getProviderCount(std::string cpResponse, long long* totalCount)

Copy link
Member

Choose a reason for hiding this comment

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

Btw, this function is somehow a "hack" to get the value of a given header but maybe a more general solution would be to process all the headers in the response (in a std:map, for instance) so we can easily access to the fiware-total-count header just doing something like reponseHeaders["fiware-total-count"].

In the same sense we have a function to get the response payload (I think is jsonPayloadClean()) we should have some responseHeaders() function for that. However, this can be deferred to a next PR, no need to include that in this (except if you think is easy and you want to do it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are investigating on this comment. As per your suggestion we will raise a separate PR for this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After the merge of PR #4321, you probably would need to change the order of some headres in the .test expectations.

Fixed in 1e47b07

Copy link
Member

Choose a reason for hiding this comment

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

NTC (beyond the fix in 1e47b07)

@fgalan
Copy link
Member

fgalan commented May 16, 2023

Please include an entry in CHANGES_NEXT_RELEASE file briefly describing (a line is enough) the functionality implemented in this PR, citing the corresponding issues (#4149 and maybe others, such as #847).

@fgalan
Copy link
Member

fgalan commented May 16, 2023

After the merge of PR #4321, you probably would need to change the order of some headres in the .test expectations.

@ArqamFarooqui110719
Copy link
Contributor Author

Please include an entry in CHANGES_NEXT_RELEASE file briefly describing (a line is enough) the functionality implemented in this PR, citing the corresponding issues (#4149 and maybe others, such as #847).

Is it good for CNR entry?

- Fix: Pagination functionality in case of request forwarding (#4149, #847)

@fgalan
Copy link
Member

fgalan commented May 19, 2023

As alternative suggestion:

@ArqamFarooqui110719
Copy link
Contributor Author

[1e47b07](/telefonicaid/fiware-orion/pull/4275/commits/1e47b077ce86f15d09438331b764710751bf1910)

Fixed in 1e47b07

@@ -13,3 +13,4 @@
- Fix: MQTT disconnection when MQTT publish fail (so re-connection is forced at next MQTT notification)
- Fix: lineMaxSize and infoPayloadMaxSize in the log admin REST API (#3707)
- Fix: check for service database name too long at cache sync logic (#2848)
- Fix: pagination support in request query forwarding to Context Providers (#4149, #847)
Copy link
Member

Choose a reason for hiding this comment

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

@mapedraza reviewed time ago all the issues related with CPrs and forwarding. It would be great to have his feedback, just in case some other issue should be mentioned here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Added a new issue ( #4337 ) containing the list of all issues related with CPrs. Adding this issue to the CNR should help as @fgalan mentioned above

Suggested change
- Fix: pagination support in request query forwarding to Context Providers (#4149, #847)
- Fix: pagination support in request query forwarding to Context Providers (#4149, #847, #4337)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c7e89b0

*
* getProviderCount is created for extrating the 'Fiware-Total-Count' header value so that we can add the same into total count,
* And we can get the actualTotalCount value that includes total Entities of CP+CB.
*
Copy link
Member

@fgalan fgalan May 25, 2023

Choose a reason for hiding this comment

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

I'd suggest to describe the potential improvement in the logic we have discussed previously

Suggested change
*
*
* FIXME: this functions relies in text-based processing of the HTTP response stream (which includes headers).
* It would be smarted to parse all the response headers in the response (for instance in a std::map) in the part
* of the code dealing with response processing, so in this part we can just access to 'fiware-total-count' easility
* using something like reponseHeaders["fiware-total-count"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c7e89b0

@@ -781,6 +854,16 @@ std::string postQueryContext
}
}

if ((ciP->apiVersion == V2) && (ciP->uriParamOptions["count"]))
Copy link
Member

Choose a reason for hiding this comment

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

Based in our previous discussion, I'd suggest to add an explanatory comment here:

Suggested change
if ((ciP->apiVersion == V2) && (ciP->uriParamOptions["count"]))
// Before implementing pagination for CPrs, this block of code was part of step 02.
// However, in that step we only have the count for CB entities. It is in the new location
// (after queryForward() invocation) when we have the total count CB+CPr
if ((ciP->apiVersion == V2) && (ciP->uriParamOptions["count"]))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c7e89b0

@fgalan
Copy link
Member

fgalan commented May 25, 2023

I have provide a new round of feedback after your recent changes. The PR is getting better :)

Most of my comment are minor, but this one is specially remarkable.

@fgalan fgalan changed the base branch from master to issue-4149-prelanding May 25, 2023 16:29
Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

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

LGTM to merge in prelanding branch

@fgalan fgalan merged commit d66d090 into telefonicaid:issue-4149-prelanding May 25, 2023
12 checks passed
@fgalan
Copy link
Member

fgalan commented May 25, 2023

Continuation PR #4341

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.

None yet

4 participants