all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#30524: java-jeromq: non-deterministic test failures
@ 2018-02-19 14:16 Ricardo Wurmus
  2018-03-03 12:58 ` bug#30524: [PATCH] gnu: java-jeromq: Fix tests Gábor Boskovits
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2018-02-19 14:16 UTC (permalink / raw)
  To: 30524

Sometimes the check phase of java-jeromq fails:

--8<---------------cut here---------------start------------->8---
…
    [junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.427 sec
    [junit] Running zmq.InprocUnbindTest
    [junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.17 sec
    [junit] Running zmq.OptionsTest
    [junit] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.193 sec
    [junit] Running zmq.io.MetadataTest
    [junit] Sending ZAP reply
    [junit] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.527 sec
    [junit] Running zmq.io.V0ProtocolTest
    [junit] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.482 sec
    [junit] Running zmq.io.V1ProtocolTest
    [junit] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.014 sec

BUILD FAILED
/tmp/guix-build-java-jeromq-0.4.3.drv-0/source/build.xml:1: Test zmq.io.V1ProtocolTest failed
--8<---------------cut here---------------end--------------->8---


-- 
Ricardo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#30524: [PATCH] gnu: java-jeromq: Fix tests.
  2018-02-19 14:16 bug#30524: java-jeromq: non-deterministic test failures Ricardo Wurmus
@ 2018-03-03 12:58 ` Gábor Boskovits
  2018-03-06 21:40   ` Ricardo Wurmus
  2018-03-08 21:06 ` Gábor Boskovits
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Gábor Boskovits @ 2018-03-03 12:58 UTC (permalink / raw)
  To: 30524

* gnu/packages/patches/java-jeromq-fix-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
[arguments](#test-exclude): Disable more failing tests.
---
 gnu/local.mk                                     |   1 +
 gnu/packages/java.scm                            |  11 +-
 gnu/packages/patches/java-jeromq-fix-tests.patch | 247 +++++++++++++++++++++++
 3 files changed, 257 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/java-jeromq-fix-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9684d949f..2bae3660c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -782,6 +782,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/intltool-perl-compatibility.patch	\
   %D%/packages/patches/isl-0.11.1-aarch64-support.patch	\
   %D%/packages/patches/jacal-fix-texinfo.patch			\
+  %D%/packages/patches/java-jeromq-fix-tests.patch		\
   %D%/packages/patches/java-powermock-fix-java-files.patch		\
   %D%/packages/patches/java-xerces-bootclasspath.patch	\
   %D%/packages/patches/java-xerces-build_dont_unzip.patch	\
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 0f8c04e8b..85a8c9b3a 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -8117,7 +8117,8 @@ protocol-independent framework to build mail and messaging applications.")
               (file-name (string-append name "-" version "-checkout"))
               (sha256
                (base32
-                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))))
+                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))
+              (patches (search-patches "java-jeromq-fix-tests.patch"))))
     (build-system ant-build-system)
     (arguments
      `(#:jar-name "java-jeromq.jar"
@@ -8131,7 +8132,13 @@ protocol-independent framework to build mail and messaging applications.")
          ;; Failures
          "**/DealerSpecTest.java"
          "**/CustomDecoderTest.java"
-         "**/CustomEncoderTest.java")))
+         "**/CustomEncoderTest.java"
+         "**/ConnectRidTest.java"
+         "**/ReqSpecTest.java"
+         "**/PushPullSpecTest.java"
+         "**/PubSubHwmTest.java"
+         "**/RouterSpecTest.java"
+         "**/ProxyTest.java")))
     (inputs
      `(("java-jnacl" ,java-jnacl)))
     (native-inputs
diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch b/gnu/packages/patches/java-jeromq-fix-tests.patch
new file mode 100644
index 000000000..40fa64801
--- /dev/null
+++ b/gnu/packages/patches/java-jeromq-fix-tests.patch
@@ -0,0 +1,247 @@
+From 5803aadd3f209eba1ffbb2cf7bf16778019dbee1 Mon Sep 17 00:00:00 2001
+From: fredoboulo <fredoboulo@users.noreply.github.com>
+Date: Fri, 23 Feb 2018 23:55:57 +0100
+Subject: [PATCH] Fix #524 : V1 and V2 protocol downgrades handle received data
+ in handshake buffer
+
+---
+ src/main/java/zmq/io/StreamEngine.java            | 21 ++++++++++--
+ src/test/java/zmq/io/AbstractProtocolVersion.java | 41 +++++++++++++----------
+ src/test/java/zmq/io/V0ProtocolTest.java          | 12 +++++++
+ src/test/java/zmq/io/V1ProtocolTest.java          | 16 +++++++--
+ src/test/java/zmq/io/V2ProtocolTest.java          | 16 +++++++--
+ 5 files changed, 81 insertions(+), 25 deletions(-)
+
+diff --git a/src/main/java/zmq/io/StreamEngine.java b/src/main/java/zmq/io/StreamEngine.java
+index b8933c92..fe2f2d8d 100644
+--- a/src/main/java/zmq/io/StreamEngine.java
++++ b/src/main/java/zmq/io/StreamEngine.java
+@@ -816,9 +816,7 @@ private boolean handshake()
+             assert (bufferSize == headerSize);
+ 
+             //  Make sure the decoder sees the data we have already received.
+-            greetingRecv.flip();
+-            inpos = greetingRecv;
+-            insize = greetingRecv.limit();
++            decodeDataAfterHandshake(0);
+ 
+             //  To allow for interoperability with peers that do not forward
+             //  their subscriptions, we inject a phantom subscription message
+@@ -846,6 +844,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V1.revision) {
+             }
+             encoder = new V1Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V1Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             //  ZMTP/2.0 framing.
+@@ -859,6 +859,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             }
+             encoder = new V2Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V2Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else {
+             zmtpVersion = Protocol.V3;
+@@ -904,6 +906,19 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+         return true;
+     }
+ 
++    private void decodeDataAfterHandshake(int greetingSize)
++    {
++        final int pos = greetingRecv.position();
++        if (pos > greetingSize) {
++            // data is present after handshake
++            greetingRecv.position(greetingSize).limit(pos);
++
++            //  Make sure the decoder sees this extra data.
++            inpos = greetingRecv;
++            insize = greetingRecv.remaining();
++        }
++    }
++
+     private Msg identityMsg()
+     {
+         Msg msg = new Msg(options.identitySize);
+diff --git a/src/test/java/zmq/io/AbstractProtocolVersion.java b/src/test/java/zmq/io/AbstractProtocolVersion.java
+index e60db403..aa06b4a7 100644
+--- a/src/test/java/zmq/io/AbstractProtocolVersion.java
++++ b/src/test/java/zmq/io/AbstractProtocolVersion.java
+@@ -18,15 +18,18 @@
+ import zmq.SocketBase;
+ import zmq.ZError;
+ import zmq.ZMQ;
++import zmq.ZMQ.Event;
+ import zmq.util.Utils;
+ 
+ public abstract class AbstractProtocolVersion
+ {
++    protected static final int REPETITIONS = 1000;
++
+     static class SocketMonitor extends Thread
+     {
+-        private final Ctx             ctx;
+-        private final String          monitorAddr;
+-        private final List<ZMQ.Event> events = new ArrayList<>();
++        private final Ctx         ctx;
++        private final String      monitorAddr;
++        private final ZMQ.Event[] events = new ZMQ.Event[1];
+ 
+         public SocketMonitor(Ctx ctx, String monitorAddr)
+         {
+@@ -41,15 +44,15 @@ public void run()
+             boolean rc = s.connect(monitorAddr);
+             assertThat(rc, is(true));
+             // Only some of the exceptional events could fire
+-            while (true) {
+-                ZMQ.Event event = ZMQ.Event.read(s);
+-                if (event == null && s.errno() == ZError.ETERM) {
+-                    break;
+-                }
+-                assertThat(event, notNullValue());
+-
+-                events.add(event);
++
++            ZMQ.Event event = ZMQ.Event.read(s);
++            if (event == null && s.errno() == ZError.ETERM) {
++                s.close();
++                return;
+             }
++            assertThat(event, notNullValue());
++
++            events[0] = event;
+             s.close();
+         }
+     }
+@@ -69,11 +72,12 @@ public void run()
+         boolean rc = ZMQ.setSocketOption(receiver, ZMQ.ZMQ_LINGER, 0);
+         assertThat(rc, is(true));
+ 
+-        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
+-        monitor.start();
+         rc = ZMQ.monitorSocket(receiver, "inproc://monitor", ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL);
+         assertThat(rc, is(true));
+ 
++        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
++        monitor.start();
++
+         rc = ZMQ.bind(receiver, host);
+         assertThat(rc, is(true));
+ 
+@@ -81,17 +85,18 @@ public void run()
+         OutputStream out = sender.getOutputStream();
+         for (ByteBuffer raw : raws) {
+             out.write(raw.array());
+-            ZMQ.msleep(100);
+         }
+ 
+         Msg msg = ZMQ.recv(receiver, 0);
+         assertThat(msg, notNullValue());
+         assertThat(new String(msg.data(), ZMQ.CHARSET), is(payload));
+ 
+-        ZMQ.msleep(500);
+-        assertThat(monitor.events.size(), is(1));
+-        assertThat(monitor.events.get(0).event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
+-        assertThat((Integer) monitor.events.get(0).arg, is(version));
++        monitor.join();
++
++        final Event event = monitor.events[0];
++        assertThat(event, notNullValue());
++        assertThat(event.event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
++        assertThat((Integer) event.arg, is(version));
+ 
+         InputStream in = sender.getInputStream();
+         byte[] data = new byte[255];
+diff --git a/src/test/java/zmq/io/V0ProtocolTest.java b/src/test/java/zmq/io/V0ProtocolTest.java
+index bd547d23..1a5b7aef 100644
+--- a/src/test/java/zmq/io/V0ProtocolTest.java
++++ b/src/test/java/zmq/io/V0ProtocolTest.java
+@@ -10,6 +10,18 @@
+ 
+ public class V0ProtocolTest extends AbstractProtocolVersion
+ {
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion0short();
++        }
++        System.out.println();
++    }
++
+     @Test(timeout = 2000)
+     public void testProtocolVersion0short() throws IOException, InterruptedException
+     {
+diff --git a/src/test/java/zmq/io/V1ProtocolTest.java b/src/test/java/zmq/io/V1ProtocolTest.java
+index e1045f34..764159d0 100644
+--- a/src/test/java/zmq/io/V1ProtocolTest.java
++++ b/src/test/java/zmq/io/V1ProtocolTest.java
+@@ -10,7 +10,19 @@
+ 
+ public class V1ProtocolTest extends AbstractProtocolVersion
+ {
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion1short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion1short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+@@ -25,7 +37,7 @@ public void testProtocolVersion1short() throws IOException, InterruptedException
+         assertProtocolVersion(1, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion1long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+diff --git a/src/test/java/zmq/io/V2ProtocolTest.java b/src/test/java/zmq/io/V2ProtocolTest.java
+index d5e64bce..7fda31bc 100644
+--- a/src/test/java/zmq/io/V2ProtocolTest.java
++++ b/src/test/java/zmq/io/V2ProtocolTest.java
+@@ -21,7 +21,19 @@ protected ByteBuffer identity()
+                 .put((byte) 0);
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion2short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion2short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
+@@ -38,7 +50,7 @@ public void testProtocolVersion2short() throws IOException, InterruptedException
+         assertProtocolVersion(2, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion2long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#30524: [PATCH] gnu: java-jeromq: Fix tests.
  2018-03-03 12:58 ` bug#30524: [PATCH] gnu: java-jeromq: Fix tests Gábor Boskovits
@ 2018-03-06 21:40   ` Ricardo Wurmus
  2018-03-06 22:17     ` Gábor Boskovits
  0 siblings, 1 reply; 8+ messages in thread
From: Ricardo Wurmus @ 2018-03-06 21:40 UTC (permalink / raw)
  To: Gábor Boskovits; +Cc: 30524


Hi Gábor,

> * gnu/packages/patches/java-jeromq-fix-tests.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
> [arguments](#test-exclude): Disable more failing tests.
> ---

Thank you for this.

> diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch b/gnu/packages/patches/java-jeromq-fix-tests.patch
> new file mode 100644
> index 000000000..40fa64801
> --- /dev/null
> +++ b/gnu/packages/patches/java-jeromq-fix-tests.patch
> @@ -0,0 +1,247 @@

It would be good to add some information about the status of this
patch.  Is it part of the next release or will we have to carry this
patch for a longer time?

The patch is also pretty big.  Do we need all of it to make jeromq build
reliably?

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#30524: [PATCH] gnu: java-jeromq: Fix tests.
  2018-03-06 21:40   ` Ricardo Wurmus
@ 2018-03-06 22:17     ` Gábor Boskovits
  0 siblings, 0 replies; 8+ messages in thread
From: Gábor Boskovits @ 2018-03-06 22:17 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 30524

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

2018-03-06 22:40 GMT+01:00 Ricardo Wurmus <rekado@elephly.net>:

>
> Hi Gábor,
>
> > * gnu/packages/patches/java-jeromq-fix-tests.patch: New file.
> > * gnu/local.mk (dist_patch_DATA): Add it.
> > * gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
> > [arguments](#test-exclude): Disable more failing tests.
> > ---
>
> Thank you for this.
>
> > diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch
> b/gnu/packages/patches/java-jeromq-fix-tests.patch
> > new file mode 100644
> > index 000000000..40fa64801
> > --- /dev/null
> > +++ b/gnu/packages/patches/java-jeromq-fix-tests.patch
> > @@ -0,0 +1,247 @@
>
> It would be good to add some information about the status of this
> patch.  Is it part of the next release or will we have to carry this
> patch for a longer time?
>
>
Ok, i will send an updated patch. This is actually in a pull request,
awaiting merge. I think it will make to the next release.


> The patch is also pretty big.  Do we need all of it to make jeromq build
> reliably?
>
> --
> Ricardo
>
> GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
> https://elephly.net
>
>
>

[-- Attachment #2: Type: text/html, Size: 1898 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#30524: [PATCH] gnu: java-jeromq: Fix tests.
  2018-02-19 14:16 bug#30524: java-jeromq: non-deterministic test failures Ricardo Wurmus
  2018-03-03 12:58 ` bug#30524: [PATCH] gnu: java-jeromq: Fix tests Gábor Boskovits
@ 2018-03-08 21:06 ` Gábor Boskovits
  2018-03-09 20:26 ` Gábor Boskovits
  2018-03-10 10:45 ` Gábor Boskovits
  3 siblings, 0 replies; 8+ messages in thread
From: Gábor Boskovits @ 2018-03-08 21:06 UTC (permalink / raw)
  To: 30524

* gnu/packages/patches/java-jeromq-fix-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
[arguments](#test-exclude): Disable more failing tests.
---
 gnu/local.mk                                     |   1 +
 gnu/packages/java.scm                            |  11 +-
 gnu/packages/patches/java-jeromq-fix-tests.patch | 253 +++++++++++++++++++++++
 3 files changed, 263 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/java-jeromq-fix-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9684d949f..2bae3660c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -782,6 +782,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/intltool-perl-compatibility.patch	\
   %D%/packages/patches/isl-0.11.1-aarch64-support.patch	\
   %D%/packages/patches/jacal-fix-texinfo.patch			\
+  %D%/packages/patches/java-jeromq-fix-tests.patch		\
   %D%/packages/patches/java-powermock-fix-java-files.patch		\
   %D%/packages/patches/java-xerces-bootclasspath.patch	\
   %D%/packages/patches/java-xerces-build_dont_unzip.patch	\
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 0f8c04e8b..85a8c9b3a 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -8117,7 +8117,8 @@ protocol-independent framework to build mail and messaging applications.")
               (file-name (string-append name "-" version "-checkout"))
               (sha256
                (base32
-                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))))
+                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))
+              (patches (search-patches "java-jeromq-fix-tests.patch"))))
     (build-system ant-build-system)
     (arguments
      `(#:jar-name "java-jeromq.jar"
@@ -8131,7 +8132,13 @@ protocol-independent framework to build mail and messaging applications.")
          ;; Failures
          "**/DealerSpecTest.java"
          "**/CustomDecoderTest.java"
-         "**/CustomEncoderTest.java")))
+         "**/CustomEncoderTest.java"
+         "**/ConnectRidTest.java"
+         "**/ReqSpecTest.java"
+         "**/PushPullSpecTest.java"
+         "**/PubSubHwmTest.java"
+         "**/RouterSpecTest.java"
+         "**/ProxyTest.java")))
     (inputs
      `(("java-jnacl" ,java-jnacl)))
     (native-inputs
diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch b/gnu/packages/patches/java-jeromq-fix-tests.patch
new file mode 100644
index 000000000..9b8f42f1e
--- /dev/null
+++ b/gnu/packages/patches/java-jeromq-fix-tests.patch
@@ -0,0 +1,253 @@
+From 5803aadd3f209eba1ffbb2cf7bf16778019dbee1 Mon Sep 17 00:00:00 2001
+From: fredoboulo <fredoboulo@users.noreply.github.com>
+Date: Fri, 23 Feb 2018 23:55:57 +0100
+Subject: [PATCH] Fix #524 : V1 and V2 protocol downgrades handle received data
+ in handshake buffer
+
+This patch is upstream pull request, see:
+https://gihub.com/zeromq/jeromq/pull/527.
+
+Most probably it will get merged soon, and we can drop it on the
+0.4.4 release.
+
+---
+ src/main/java/zmq/io/StreamEngine.java            | 21 ++++++++++--
+ src/test/java/zmq/io/AbstractProtocolVersion.java | 41 +++++++++++++----------
+ src/test/java/zmq/io/V0ProtocolTest.java          | 12 +++++++
+ src/test/java/zmq/io/V1ProtocolTest.java          | 16 +++++++--
+ src/test/java/zmq/io/V2ProtocolTest.java          | 16 +++++++--
+ 5 files changed, 81 insertions(+), 25 deletions(-)
+
+diff --git a/src/main/java/zmq/io/StreamEngine.java b/src/main/java/zmq/io/StreamEngine.java
+index b8933c92..fe2f2d8d 100644
+--- a/src/main/java/zmq/io/StreamEngine.java
++++ b/src/main/java/zmq/io/StreamEngine.java
+@@ -816,9 +816,7 @@ private boolean handshake()
+             assert (bufferSize == headerSize);
+ 
+             //  Make sure the decoder sees the data we have already received.
+-            greetingRecv.flip();
+-            inpos = greetingRecv;
+-            insize = greetingRecv.limit();
++            decodeDataAfterHandshake(0);
+ 
+             //  To allow for interoperability with peers that do not forward
+             //  their subscriptions, we inject a phantom subscription message
+@@ -846,6 +844,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V1.revision) {
+             }
+             encoder = new V1Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V1Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             //  ZMTP/2.0 framing.
+@@ -859,6 +859,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             }
+             encoder = new V2Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V2Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else {
+             zmtpVersion = Protocol.V3;
+@@ -904,6 +906,19 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+         return true;
+     }
+ 
++    private void decodeDataAfterHandshake(int greetingSize)
++    {
++        final int pos = greetingRecv.position();
++        if (pos > greetingSize) {
++            // data is present after handshake
++            greetingRecv.position(greetingSize).limit(pos);
++
++            //  Make sure the decoder sees this extra data.
++            inpos = greetingRecv;
++            insize = greetingRecv.remaining();
++        }
++    }
++
+     private Msg identityMsg()
+     {
+         Msg msg = new Msg(options.identitySize);
+diff --git a/src/test/java/zmq/io/AbstractProtocolVersion.java b/src/test/java/zmq/io/AbstractProtocolVersion.java
+index e60db403..aa06b4a7 100644
+--- a/src/test/java/zmq/io/AbstractProtocolVersion.java
++++ b/src/test/java/zmq/io/AbstractProtocolVersion.java
+@@ -18,15 +18,18 @@
+ import zmq.SocketBase;
+ import zmq.ZError;
+ import zmq.ZMQ;
++import zmq.ZMQ.Event;
+ import zmq.util.Utils;
+ 
+ public abstract class AbstractProtocolVersion
+ {
++    protected static final int REPETITIONS = 1000;
++
+     static class SocketMonitor extends Thread
+     {
+-        private final Ctx             ctx;
+-        private final String          monitorAddr;
+-        private final List<ZMQ.Event> events = new ArrayList<>();
++        private final Ctx         ctx;
++        private final String      monitorAddr;
++        private final ZMQ.Event[] events = new ZMQ.Event[1];
+ 
+         public SocketMonitor(Ctx ctx, String monitorAddr)
+         {
+@@ -41,15 +44,15 @@ public void run()
+             boolean rc = s.connect(monitorAddr);
+             assertThat(rc, is(true));
+             // Only some of the exceptional events could fire
+-            while (true) {
+-                ZMQ.Event event = ZMQ.Event.read(s);
+-                if (event == null && s.errno() == ZError.ETERM) {
+-                    break;
+-                }
+-                assertThat(event, notNullValue());
+-
+-                events.add(event);
++
++            ZMQ.Event event = ZMQ.Event.read(s);
++            if (event == null && s.errno() == ZError.ETERM) {
++                s.close();
++                return;
+             }
++            assertThat(event, notNullValue());
++
++            events[0] = event;
+             s.close();
+         }
+     }
+@@ -69,11 +72,12 @@ public void run()
+         boolean rc = ZMQ.setSocketOption(receiver, ZMQ.ZMQ_LINGER, 0);
+         assertThat(rc, is(true));
+ 
+-        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
+-        monitor.start();
+         rc = ZMQ.monitorSocket(receiver, "inproc://monitor", ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL);
+         assertThat(rc, is(true));
+ 
++        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
++        monitor.start();
++
+         rc = ZMQ.bind(receiver, host);
+         assertThat(rc, is(true));
+ 
+@@ -81,17 +85,18 @@ public void run()
+         OutputStream out = sender.getOutputStream();
+         for (ByteBuffer raw : raws) {
+             out.write(raw.array());
+-            ZMQ.msleep(100);
+         }
+ 
+         Msg msg = ZMQ.recv(receiver, 0);
+         assertThat(msg, notNullValue());
+         assertThat(new String(msg.data(), ZMQ.CHARSET), is(payload));
+ 
+-        ZMQ.msleep(500);
+-        assertThat(monitor.events.size(), is(1));
+-        assertThat(monitor.events.get(0).event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
+-        assertThat((Integer) monitor.events.get(0).arg, is(version));
++        monitor.join();
++
++        final Event event = monitor.events[0];
++        assertThat(event, notNullValue());
++        assertThat(event.event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
++        assertThat((Integer) event.arg, is(version));
+ 
+         InputStream in = sender.getInputStream();
+         byte[] data = new byte[255];
+diff --git a/src/test/java/zmq/io/V0ProtocolTest.java b/src/test/java/zmq/io/V0ProtocolTest.java
+index bd547d23..1a5b7aef 100644
+--- a/src/test/java/zmq/io/V0ProtocolTest.java
++++ b/src/test/java/zmq/io/V0ProtocolTest.java
+@@ -10,6 +10,18 @@
+ 
+ public class V0ProtocolTest extends AbstractProtocolVersion
+ {
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion0short();
++        }
++        System.out.println();
++    }
++
+     @Test(timeout = 2000)
+     public void testProtocolVersion0short() throws IOException, InterruptedException
+     {
+diff --git a/src/test/java/zmq/io/V1ProtocolTest.java b/src/test/java/zmq/io/V1ProtocolTest.java
+index e1045f34..764159d0 100644
+--- a/src/test/java/zmq/io/V1ProtocolTest.java
++++ b/src/test/java/zmq/io/V1ProtocolTest.java
+@@ -10,7 +10,19 @@
+ 
+ public class V1ProtocolTest extends AbstractProtocolVersion
+ {
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion1short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion1short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+@@ -25,7 +37,7 @@ public void testProtocolVersion1short() throws IOException, InterruptedException
+         assertProtocolVersion(1, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion1long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+diff --git a/src/test/java/zmq/io/V2ProtocolTest.java b/src/test/java/zmq/io/V2ProtocolTest.java
+index d5e64bce..7fda31bc 100644
+--- a/src/test/java/zmq/io/V2ProtocolTest.java
++++ b/src/test/java/zmq/io/V2ProtocolTest.java
+@@ -21,7 +21,19 @@ protected ByteBuffer identity()
+                 .put((byte) 0);
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion2short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion2short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
+@@ -38,7 +50,7 @@ public void testProtocolVersion2short() throws IOException, InterruptedException
+         assertProtocolVersion(2, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion2long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#30524: [PATCH] gnu: java-jeromq: Fix tests.
  2018-02-19 14:16 bug#30524: java-jeromq: non-deterministic test failures Ricardo Wurmus
  2018-03-03 12:58 ` bug#30524: [PATCH] gnu: java-jeromq: Fix tests Gábor Boskovits
  2018-03-08 21:06 ` Gábor Boskovits
@ 2018-03-09 20:26 ` Gábor Boskovits
  2018-03-10 10:45 ` Gábor Boskovits
  3 siblings, 0 replies; 8+ messages in thread
From: Gábor Boskovits @ 2018-03-09 20:26 UTC (permalink / raw)
  To: 30524

* gnu/packages/patches/java-jeromq-fix-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
[arguments](#test-exclude): Disable more failing tests.
---
 gnu/local.mk                                     |   1 +
 gnu/packages/java.scm                            |  11 +-
 gnu/packages/patches/java-jeromq-fix-tests.patch | 253 +++++++++++++++++++++++
 3 files changed, 263 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/java-jeromq-fix-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9684d949f..2bae3660c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -782,6 +782,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/intltool-perl-compatibility.patch	\
   %D%/packages/patches/isl-0.11.1-aarch64-support.patch	\
   %D%/packages/patches/jacal-fix-texinfo.patch			\
+  %D%/packages/patches/java-jeromq-fix-tests.patch		\
   %D%/packages/patches/java-powermock-fix-java-files.patch		\
   %D%/packages/patches/java-xerces-bootclasspath.patch	\
   %D%/packages/patches/java-xerces-build_dont_unzip.patch	\
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 0f8c04e8b..85a8c9b3a 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -8117,7 +8117,8 @@ protocol-independent framework to build mail and messaging applications.")
               (file-name (string-append name "-" version "-checkout"))
               (sha256
                (base32
-                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))))
+                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))
+              (patches (search-patches "java-jeromq-fix-tests.patch"))))
     (build-system ant-build-system)
     (arguments
      `(#:jar-name "java-jeromq.jar"
@@ -8131,7 +8132,13 @@ protocol-independent framework to build mail and messaging applications.")
          ;; Failures
          "**/DealerSpecTest.java"
          "**/CustomDecoderTest.java"
-         "**/CustomEncoderTest.java")))
+         "**/CustomEncoderTest.java"
+         "**/ConnectRidTest.java"
+         "**/ReqSpecTest.java"
+         "**/PushPullSpecTest.java"
+         "**/PubSubHwmTest.java"
+         "**/RouterSpecTest.java"
+         "**/ProxyTest.java")))
     (inputs
      `(("java-jnacl" ,java-jnacl)))
     (native-inputs
diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch b/gnu/packages/patches/java-jeromq-fix-tests.patch
new file mode 100644
index 000000000..5466b9270
--- /dev/null
+++ b/gnu/packages/patches/java-jeromq-fix-tests.patch
@@ -0,0 +1,253 @@
+From 5803aadd3f209eba1ffbb2cf7bf16778019dbee1 Mon Sep 17 00:00:00 2001
+From: fredoboulo <fredoboulo@users.noreply.github.com>
+Date: Fri, 23 Feb 2018 23:55:57 +0100
+Subject: [PATCH] Fix #524 : V1 and V2 protocol downgrades handle received data
+ in handshake buffer
+
+This patch is upstream pull request, see:
+https://gihub.com/zeromq/jeromq/pull/527.
+
+It is merged on commit c2afa9c, and we can drop it on the
+0.4.4 release.
+
+---
+ src/main/java/zmq/io/StreamEngine.java            | 21 ++++++++++--
+ src/test/java/zmq/io/AbstractProtocolVersion.java | 41 +++++++++++++----------
+ src/test/java/zmq/io/V0ProtocolTest.java          | 12 +++++++
+ src/test/java/zmq/io/V1ProtocolTest.java          | 16 +++++++--
+ src/test/java/zmq/io/V2ProtocolTest.java          | 16 +++++++--
+ 5 files changed, 81 insertions(+), 25 deletions(-)
+
+diff --git a/src/main/java/zmq/io/StreamEngine.java b/src/main/java/zmq/io/StreamEngine.java
+index b8933c92..fe2f2d8d 100644
+--- a/src/main/java/zmq/io/StreamEngine.java
++++ b/src/main/java/zmq/io/StreamEngine.java
+@@ -816,9 +816,7 @@ private boolean handshake()
+             assert (bufferSize == headerSize);
+ 
+             //  Make sure the decoder sees the data we have already received.
+-            greetingRecv.flip();
+-            inpos = greetingRecv;
+-            insize = greetingRecv.limit();
++            decodeDataAfterHandshake(0);
+ 
+             //  To allow for interoperability with peers that do not forward
+             //  their subscriptions, we inject a phantom subscription message
+@@ -846,6 +844,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V1.revision) {
+             }
+             encoder = new V1Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V1Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             //  ZMTP/2.0 framing.
+@@ -859,6 +859,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             }
+             encoder = new V2Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V2Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else {
+             zmtpVersion = Protocol.V3;
+@@ -904,6 +906,19 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+         return true;
+     }
+ 
++    private void decodeDataAfterHandshake(int greetingSize)
++    {
++        final int pos = greetingRecv.position();
++        if (pos > greetingSize) {
++            // data is present after handshake
++            greetingRecv.position(greetingSize).limit(pos);
++
++            //  Make sure the decoder sees this extra data.
++            inpos = greetingRecv;
++            insize = greetingRecv.remaining();
++        }
++    }
++
+     private Msg identityMsg()
+     {
+         Msg msg = new Msg(options.identitySize);
+diff --git a/src/test/java/zmq/io/AbstractProtocolVersion.java b/src/test/java/zmq/io/AbstractProtocolVersion.java
+index e60db403..aa06b4a7 100644
+--- a/src/test/java/zmq/io/AbstractProtocolVersion.java
++++ b/src/test/java/zmq/io/AbstractProtocolVersion.java
+@@ -18,15 +18,18 @@
+ import zmq.SocketBase;
+ import zmq.ZError;
+ import zmq.ZMQ;
++import zmq.ZMQ.Event;
+ import zmq.util.Utils;
+ 
+ public abstract class AbstractProtocolVersion
+ {
++    protected static final int REPETITIONS = 1000;
++
+     static class SocketMonitor extends Thread
+     {
+-        private final Ctx             ctx;
+-        private final String          monitorAddr;
+-        private final List<ZMQ.Event> events = new ArrayList<>();
++        private final Ctx         ctx;
++        private final String      monitorAddr;
++        private final ZMQ.Event[] events = new ZMQ.Event[1];
+ 
+         public SocketMonitor(Ctx ctx, String monitorAddr)
+         {
+@@ -41,15 +44,15 @@ public void run()
+             boolean rc = s.connect(monitorAddr);
+             assertThat(rc, is(true));
+             // Only some of the exceptional events could fire
+-            while (true) {
+-                ZMQ.Event event = ZMQ.Event.read(s);
+-                if (event == null && s.errno() == ZError.ETERM) {
+-                    break;
+-                }
+-                assertThat(event, notNullValue());
+-
+-                events.add(event);
++
++            ZMQ.Event event = ZMQ.Event.read(s);
++            if (event == null && s.errno() == ZError.ETERM) {
++                s.close();
++                return;
+             }
++            assertThat(event, notNullValue());
++
++            events[0] = event;
+             s.close();
+         }
+     }
+@@ -69,11 +72,12 @@ public void run()
+         boolean rc = ZMQ.setSocketOption(receiver, ZMQ.ZMQ_LINGER, 0);
+         assertThat(rc, is(true));
+ 
+-        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
+-        monitor.start();
+         rc = ZMQ.monitorSocket(receiver, "inproc://monitor", ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL);
+         assertThat(rc, is(true));
+ 
++        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
++        monitor.start();
++
+         rc = ZMQ.bind(receiver, host);
+         assertThat(rc, is(true));
+ 
+@@ -81,17 +85,18 @@ public void run()
+         OutputStream out = sender.getOutputStream();
+         for (ByteBuffer raw : raws) {
+             out.write(raw.array());
+-            ZMQ.msleep(100);
+         }
+ 
+         Msg msg = ZMQ.recv(receiver, 0);
+         assertThat(msg, notNullValue());
+         assertThat(new String(msg.data(), ZMQ.CHARSET), is(payload));
+ 
+-        ZMQ.msleep(500);
+-        assertThat(monitor.events.size(), is(1));
+-        assertThat(monitor.events.get(0).event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
+-        assertThat((Integer) monitor.events.get(0).arg, is(version));
++        monitor.join();
++
++        final Event event = monitor.events[0];
++        assertThat(event, notNullValue());
++        assertThat(event.event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
++        assertThat((Integer) event.arg, is(version));
+ 
+         InputStream in = sender.getInputStream();
+         byte[] data = new byte[255];
+diff --git a/src/test/java/zmq/io/V0ProtocolTest.java b/src/test/java/zmq/io/V0ProtocolTest.java
+index bd547d23..1a5b7aef 100644
+--- a/src/test/java/zmq/io/V0ProtocolTest.java
++++ b/src/test/java/zmq/io/V0ProtocolTest.java
+@@ -10,6 +10,18 @@
+ 
+ public class V0ProtocolTest extends AbstractProtocolVersion
+ {
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion0short();
++        }
++        System.out.println();
++    }
++
+     @Test(timeout = 2000)
+     public void testProtocolVersion0short() throws IOException, InterruptedException
+     {
+diff --git a/src/test/java/zmq/io/V1ProtocolTest.java b/src/test/java/zmq/io/V1ProtocolTest.java
+index e1045f34..764159d0 100644
+--- a/src/test/java/zmq/io/V1ProtocolTest.java
++++ b/src/test/java/zmq/io/V1ProtocolTest.java
+@@ -10,7 +10,19 @@
+ 
+ public class V1ProtocolTest extends AbstractProtocolVersion
+ {
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion1short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion1short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+@@ -25,7 +37,7 @@ public void testProtocolVersion1short() throws IOException, InterruptedException
+         assertProtocolVersion(1, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion1long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+diff --git a/src/test/java/zmq/io/V2ProtocolTest.java b/src/test/java/zmq/io/V2ProtocolTest.java
+index d5e64bce..7fda31bc 100644
+--- a/src/test/java/zmq/io/V2ProtocolTest.java
++++ b/src/test/java/zmq/io/V2ProtocolTest.java
+@@ -21,7 +21,19 @@ protected ByteBuffer identity()
+                 .put((byte) 0);
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion2short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion2short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
+@@ -38,7 +50,7 @@ public void testProtocolVersion2short() throws IOException, InterruptedException
+         assertProtocolVersion(2, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion2long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#30524: [PATCH] gnu: java-jeromq: Fix tests.
  2018-02-19 14:16 bug#30524: java-jeromq: non-deterministic test failures Ricardo Wurmus
                   ` (2 preceding siblings ...)
  2018-03-09 20:26 ` Gábor Boskovits
@ 2018-03-10 10:45 ` Gábor Boskovits
  2018-03-11 19:13   ` Ricardo Wurmus
  3 siblings, 1 reply; 8+ messages in thread
From: Gábor Boskovits @ 2018-03-10 10:45 UTC (permalink / raw)
  To: 30524

* gnu/packages/patches/java-jeromq-fix-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
[arguments](#test-exclude): Disable more failing tests.
---
 gnu/local.mk                                     |   1 +
 gnu/packages/java.scm                            |  11 +-
 gnu/packages/patches/java-jeromq-fix-tests.patch | 253 +++++++++++++++++++++++
 3 files changed, 263 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/java-jeromq-fix-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9684d949f..2bae3660c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -782,6 +782,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/intltool-perl-compatibility.patch	\
   %D%/packages/patches/isl-0.11.1-aarch64-support.patch	\
   %D%/packages/patches/jacal-fix-texinfo.patch			\
+  %D%/packages/patches/java-jeromq-fix-tests.patch		\
   %D%/packages/patches/java-powermock-fix-java-files.patch		\
   %D%/packages/patches/java-xerces-bootclasspath.patch	\
   %D%/packages/patches/java-xerces-build_dont_unzip.patch	\
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 0f8c04e8b..85a8c9b3a 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -8117,7 +8117,8 @@ protocol-independent framework to build mail and messaging applications.")
               (file-name (string-append name "-" version "-checkout"))
               (sha256
                (base32
-                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))))
+                "1gxkp7lv2ahymgrqdw94ncq54bmp4m4sw5m1x9gkp7l5bxn0xsyj"))
+              (patches (search-patches "java-jeromq-fix-tests.patch"))))
     (build-system ant-build-system)
     (arguments
      `(#:jar-name "java-jeromq.jar"
@@ -8131,7 +8132,13 @@ protocol-independent framework to build mail and messaging applications.")
          ;; Failures
          "**/DealerSpecTest.java"
          "**/CustomDecoderTest.java"
-         "**/CustomEncoderTest.java")))
+         "**/CustomEncoderTest.java"
+         "**/ConnectRidTest.java"
+         "**/ReqSpecTest.java"
+         "**/PushPullSpecTest.java"
+         "**/PubSubHwmTest.java"
+         "**/RouterSpecTest.java"
+         "**/ProxyTest.java")))
     (inputs
      `(("java-jnacl" ,java-jnacl)))
     (native-inputs
diff --git a/gnu/packages/patches/java-jeromq-fix-tests.patch b/gnu/packages/patches/java-jeromq-fix-tests.patch
new file mode 100644
index 000000000..5466b9270
--- /dev/null
+++ b/gnu/packages/patches/java-jeromq-fix-tests.patch
@@ -0,0 +1,253 @@
+From 5803aadd3f209eba1ffbb2cf7bf16778019dbee1 Mon Sep 17 00:00:00 2001
+From: fredoboulo <fredoboulo@users.noreply.github.com>
+Date: Fri, 23 Feb 2018 23:55:57 +0100
+Subject: [PATCH] Fix #524 : V1 and V2 protocol downgrades handle received data
+ in handshake buffer
+
+This patch is upstream pull request, see:
+https://gihub.com/zeromq/jeromq/pull/527.
+
+It is merged on commit c2afa9c, and we can drop it on the
+0.4.4 release.
+
+---
+ src/main/java/zmq/io/StreamEngine.java            | 21 ++++++++++--
+ src/test/java/zmq/io/AbstractProtocolVersion.java | 41 +++++++++++++----------
+ src/test/java/zmq/io/V0ProtocolTest.java          | 12 +++++++
+ src/test/java/zmq/io/V1ProtocolTest.java          | 16 +++++++--
+ src/test/java/zmq/io/V2ProtocolTest.java          | 16 +++++++--
+ 5 files changed, 81 insertions(+), 25 deletions(-)
+
+diff --git a/src/main/java/zmq/io/StreamEngine.java b/src/main/java/zmq/io/StreamEngine.java
+index b8933c92..fe2f2d8d 100644
+--- a/src/main/java/zmq/io/StreamEngine.java
++++ b/src/main/java/zmq/io/StreamEngine.java
+@@ -816,9 +816,7 @@ private boolean handshake()
+             assert (bufferSize == headerSize);
+ 
+             //  Make sure the decoder sees the data we have already received.
+-            greetingRecv.flip();
+-            inpos = greetingRecv;
+-            insize = greetingRecv.limit();
++            decodeDataAfterHandshake(0);
+ 
+             //  To allow for interoperability with peers that do not forward
+             //  their subscriptions, we inject a phantom subscription message
+@@ -846,6 +844,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V1.revision) {
+             }
+             encoder = new V1Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V1Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             //  ZMTP/2.0 framing.
+@@ -859,6 +859,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+             }
+             encoder = new V2Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
+             decoder = new V2Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
++
++            decodeDataAfterHandshake(V2_GREETING_SIZE);
+         }
+         else {
+             zmtpVersion = Protocol.V3;
+@@ -904,6 +906,19 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
+         return true;
+     }
+ 
++    private void decodeDataAfterHandshake(int greetingSize)
++    {
++        final int pos = greetingRecv.position();
++        if (pos > greetingSize) {
++            // data is present after handshake
++            greetingRecv.position(greetingSize).limit(pos);
++
++            //  Make sure the decoder sees this extra data.
++            inpos = greetingRecv;
++            insize = greetingRecv.remaining();
++        }
++    }
++
+     private Msg identityMsg()
+     {
+         Msg msg = new Msg(options.identitySize);
+diff --git a/src/test/java/zmq/io/AbstractProtocolVersion.java b/src/test/java/zmq/io/AbstractProtocolVersion.java
+index e60db403..aa06b4a7 100644
+--- a/src/test/java/zmq/io/AbstractProtocolVersion.java
++++ b/src/test/java/zmq/io/AbstractProtocolVersion.java
+@@ -18,15 +18,18 @@
+ import zmq.SocketBase;
+ import zmq.ZError;
+ import zmq.ZMQ;
++import zmq.ZMQ.Event;
+ import zmq.util.Utils;
+ 
+ public abstract class AbstractProtocolVersion
+ {
++    protected static final int REPETITIONS = 1000;
++
+     static class SocketMonitor extends Thread
+     {
+-        private final Ctx             ctx;
+-        private final String          monitorAddr;
+-        private final List<ZMQ.Event> events = new ArrayList<>();
++        private final Ctx         ctx;
++        private final String      monitorAddr;
++        private final ZMQ.Event[] events = new ZMQ.Event[1];
+ 
+         public SocketMonitor(Ctx ctx, String monitorAddr)
+         {
+@@ -41,15 +44,15 @@ public void run()
+             boolean rc = s.connect(monitorAddr);
+             assertThat(rc, is(true));
+             // Only some of the exceptional events could fire
+-            while (true) {
+-                ZMQ.Event event = ZMQ.Event.read(s);
+-                if (event == null && s.errno() == ZError.ETERM) {
+-                    break;
+-                }
+-                assertThat(event, notNullValue());
+-
+-                events.add(event);
++
++            ZMQ.Event event = ZMQ.Event.read(s);
++            if (event == null && s.errno() == ZError.ETERM) {
++                s.close();
++                return;
+             }
++            assertThat(event, notNullValue());
++
++            events[0] = event;
+             s.close();
+         }
+     }
+@@ -69,11 +72,12 @@ public void run()
+         boolean rc = ZMQ.setSocketOption(receiver, ZMQ.ZMQ_LINGER, 0);
+         assertThat(rc, is(true));
+ 
+-        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
+-        monitor.start();
+         rc = ZMQ.monitorSocket(receiver, "inproc://monitor", ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL);
+         assertThat(rc, is(true));
+ 
++        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
++        monitor.start();
++
+         rc = ZMQ.bind(receiver, host);
+         assertThat(rc, is(true));
+ 
+@@ -81,17 +85,18 @@ public void run()
+         OutputStream out = sender.getOutputStream();
+         for (ByteBuffer raw : raws) {
+             out.write(raw.array());
+-            ZMQ.msleep(100);
+         }
+ 
+         Msg msg = ZMQ.recv(receiver, 0);
+         assertThat(msg, notNullValue());
+         assertThat(new String(msg.data(), ZMQ.CHARSET), is(payload));
+ 
+-        ZMQ.msleep(500);
+-        assertThat(monitor.events.size(), is(1));
+-        assertThat(monitor.events.get(0).event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
+-        assertThat((Integer) monitor.events.get(0).arg, is(version));
++        monitor.join();
++
++        final Event event = monitor.events[0];
++        assertThat(event, notNullValue());
++        assertThat(event.event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
++        assertThat((Integer) event.arg, is(version));
+ 
+         InputStream in = sender.getInputStream();
+         byte[] data = new byte[255];
+diff --git a/src/test/java/zmq/io/V0ProtocolTest.java b/src/test/java/zmq/io/V0ProtocolTest.java
+index bd547d23..1a5b7aef 100644
+--- a/src/test/java/zmq/io/V0ProtocolTest.java
++++ b/src/test/java/zmq/io/V0ProtocolTest.java
+@@ -10,6 +10,18 @@
+ 
+ public class V0ProtocolTest extends AbstractProtocolVersion
+ {
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion0short();
++        }
++        System.out.println();
++    }
++
+     @Test(timeout = 2000)
+     public void testProtocolVersion0short() throws IOException, InterruptedException
+     {
+diff --git a/src/test/java/zmq/io/V1ProtocolTest.java b/src/test/java/zmq/io/V1ProtocolTest.java
+index e1045f34..764159d0 100644
+--- a/src/test/java/zmq/io/V1ProtocolTest.java
++++ b/src/test/java/zmq/io/V1ProtocolTest.java
+@@ -10,7 +10,19 @@
+ 
+ public class V1ProtocolTest extends AbstractProtocolVersion
+ {
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion1short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion1short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+@@ -25,7 +37,7 @@ public void testProtocolVersion1short() throws IOException, InterruptedException
+         assertProtocolVersion(1, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion1long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(0);
+diff --git a/src/test/java/zmq/io/V2ProtocolTest.java b/src/test/java/zmq/io/V2ProtocolTest.java
+index d5e64bce..7fda31bc 100644
+--- a/src/test/java/zmq/io/V2ProtocolTest.java
++++ b/src/test/java/zmq/io/V2ProtocolTest.java
+@@ -21,7 +21,19 @@ protected ByteBuffer identity()
+                 .put((byte) 0);
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
++    public void testFixIssue524() throws IOException, InterruptedException
++    {
++        for (int idx = 0; idx < REPETITIONS; ++idx) {
++            if (idx % 100 == 0) {
++                System.out.print(idx + " ");
++            }
++            testProtocolVersion2short();
++        }
++        System.out.println();
++    }
++
++    @Test
+     public void testProtocolVersion2short() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
+@@ -38,7 +50,7 @@ public void testProtocolVersion2short() throws IOException, InterruptedException
+         assertProtocolVersion(2, raws, "abcdefg");
+     }
+ 
+-    @Test(timeout = 2000)
++    @Test
+     public void testProtocolVersion2long() throws IOException, InterruptedException
+     {
+         List<ByteBuffer> raws = raws(1);
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#30524: [PATCH] gnu: java-jeromq: Fix tests.
  2018-03-10 10:45 ` Gábor Boskovits
@ 2018-03-11 19:13   ` Ricardo Wurmus
  0 siblings, 0 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2018-03-11 19:13 UTC (permalink / raw)
  To: Gábor Boskovits; +Cc: 30524-done


Hi Gábor,

> * gnu/packages/patches/java-jeromq-fix-tests.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/java.scm (java-jeromq)[source](patches): Add it.
> [arguments](#test-exclude): Disable more failing tests.

Thank you for the fix.  I’ve pushed this patch to master.
I built java-jeromq with no problems.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-03-11 23:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-19 14:16 bug#30524: java-jeromq: non-deterministic test failures Ricardo Wurmus
2018-03-03 12:58 ` bug#30524: [PATCH] gnu: java-jeromq: Fix tests Gábor Boskovits
2018-03-06 21:40   ` Ricardo Wurmus
2018-03-06 22:17     ` Gábor Boskovits
2018-03-08 21:06 ` Gábor Boskovits
2018-03-09 20:26 ` Gábor Boskovits
2018-03-10 10:45 ` Gábor Boskovits
2018-03-11 19:13   ` Ricardo Wurmus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.