After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 755124 - tests/proxy-continuous: Don't assume that SoupMessage:got-chunk will correspond exactly to the chunks written by the server
tests/proxy-continuous: Don't assume that SoupMessage:got-chunk will correspo...
Status: RESOLVED FIXED
Product: librest
Classification: Platform
Component: proxy
git master
Other All
: Normal normal
: ---
Assigned To: librest-maint
librest-maint
Depends on:
Blocks:
 
 
Reported: 2015-09-16 16:36 UTC by Debarshi Ray
Modified: 2015-09-17 12:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests/proxy-continuous: Server chunks can be different from client ones (3.37 KB, patch)
2015-09-16 16:42 UTC, Debarshi Ray
none Details | Review
tests/proxy-continuous: Server chunks can be different from client ones (3.42 KB, patch)
2015-09-17 12:09 UTC, Debarshi Ray
committed Details | Review
tests/proxy-continuous: Simplify the code (1.07 KB, patch)
2015-09-17 12:19 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2015-09-16 16:36:51 UTC
Currently tests/proxy-continuous has a SoupServer that writes chunks like:
1 1 1 1\n
2 2 2 2\n
...

And it expects that _call_continuous_cb will receive them in chunks like:
1 1 1 1\n
2 2 2 2\n
...

There is no guarantee that this will be the case. It can receive:
1 1 1
1\n
2 2
2 2\n
...

Usually this is not an issue, but some people are hitting this problem because I got a downstream report where the test failed due to this.

I suggest simplifying the test case to send a constant stream of integers (without the whitespaces), because then it is easier for the client to parse the responses without making any assumptions of about the chunks.
Comment 1 Debarshi Ray 2015-09-16 16:42:49 UTC
Created attachment 311492 [details] [review]
tests/proxy-continuous: Server chunks can be different from client ones
Comment 2 Christophe Fergeau 2015-09-17 11:16:50 UTC
Review of attachment 311492 [details] [review]:

Looks good to me, couple of minor comments. (I set commit-now, I actually am not sure what the status of librest is wrt various freezes. I'd say it does not follow GNOME release cycles).

::: tests/proxy-continuous.c
@@ +44,3 @@
   SoupBuffer *buf;
+  gint i;
+  gint8 data[SIZE_CHUNK];

guint i;
guint8 data[SIZE_CHUNK];

@@ +56,1 @@
   soup_message_body_append_buffer (msg->response_body, buf);

soup_message_body_append () would allow to skip the 'buf' temporary buffer (but this is a preexisting issue as the previous code could have used soup_message_body_append_take ())

@@ +89,3 @@
                      gpointer       userdata)
 {
+  gint i;

preference for guint i; here too
Comment 3 Debarshi Ray 2015-09-17 12:09:09 UTC
Created attachment 311547 [details] [review]
tests/proxy-continuous: Server chunks can be different from client ones
Comment 4 Debarshi Ray 2015-09-17 12:11:08 UTC
(In reply to Christophe Fergeau from comment #2)
> Review of attachment 311492 [details] [review] [review]:
> 
> Thanks for the review Christophe.
>
> ::: tests/proxy-continuous.c
> @@ +44,3 @@
>    SoupBuffer *buf;
> +  gint i;
> +  gint8 data[SIZE_CHUNK];
> 
> guint i;
> guint8 data[SIZE_CHUNK];

Fixed. I also changed server_count and client_count to be guint8 to avoid any compiler warnings related to assigning / comparing different integer types.
 
> @@ +56,1 @@
>    soup_message_body_append_buffer (msg->response_body, buf);
> 
> soup_message_body_append () would allow to skip the 'buf' temporary buffer
> (but this is a preexisting issue as the previous code could have used
> soup_message_body_append_take ())

I will fix this in a separate patch.

> @@ +89,3 @@
>                       gpointer       userdata)
>  {
> +  gint i;
> 
> preference for guint i; here too

Fixed.
Comment 5 Debarshi Ray 2015-09-17 12:19:11 UTC
Created attachment 311549 [details] [review]
tests/proxy-continuous: Simplify the code
Comment 6 Christophe Fergeau 2015-09-17 12:34:05 UTC
Review of attachment 311547 [details] [review]:

Looks good, thanks.
Comment 7 Christophe Fergeau 2015-09-17 12:35:26 UTC
Review of attachment 311549 [details] [review]:

ACK.
Comment 8 Debarshi Ray 2015-09-17 12:38:17 UTC
Thanks for those quick reviews! I have pushed them to master.