apache / camel-quarkus

Apache Camel Quarkus
https://camel.apache.org
Apache License 2.0
257 stars 191 forks source link

Snmp: Extend coverage of some smaller features #4850

Closed JiriOndrusek closed 1 year ago

JiriOndrusek commented 1 year ago

Missing coverage:

jamesnetherton commented 1 year ago

Reopening this because the tests seem a bit flaky / broken. On the main branch build I've seen:

2023-04-28T21:37:32.7963132Z 2023-04-28 21:37:32,795 INFO  [io.quarkus] (main) Installed features: [camel-core, camel-snmp, cdi, resteasy, smallrye-context-propagation, vertx]
2023-04-28T21:37:59.3476536Z [ERROR] Tests run: 12, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 33.538 s <<< FAILURE! - in org.apache.camel.quarkus.component.snmp.it.SnmpTest
2023-04-28T21:37:59.3477081Z [ERROR] testProducePDU{int}[2]  Time elapsed: 0.021 s  <<< FAILURE!
2023-04-28T21:37:59.3478527Z java.lang.AssertionError: 
2023-04-28T21:37:59.3478954Z 1 expectation failed.
2023-04-28T21:37:59.3480107Z Response body doesn't match expectation.
2023-04-28T21:37:59.3480499Z Expected: "Response from the test #1"
2023-04-28T21:37:59.3480750Z   Actual: Response from the test #2

On 2.13.x (see #4856) I see:

2023-04-29T07:53:31.1796125Z [ERROR] Tests run: 12, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 32.61 s <<< FAILURE! - in org.apache.camel.quarkus.component.snmp.it.SnmpTest
2023-04-29T07:53:31.1797823Z [ERROR] testPoll{int}[1]  Time elapsed: 3.504 s  <<< ERROR!
2023-04-29T07:53:31.1798192Z java.nio.BufferOverflowException
2023-04-29T07:53:31.1798598Z    at java.base/java.nio.Buffer.nextPutIndex(Buffer.java:722)
2023-04-29T07:53:31.1799038Z    at java.base/java.nio.HeapByteBuffer.put(HeapByteBuffer.java:209)
2023-04-29T07:53:31.1799500Z    at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:63)
2023-04-29T07:53:31.1799954Z    at org.snmp4j.asn1.BER.encodeHeader(BER.java:122)
2023-04-29T07:53:31.1800432Z    at org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:201)
2023-04-29T07:53:31.1800885Z    at org.snmp4j.PDU.encodeBER(PDU.java:644)
2023-04-29T07:53:31.1801359Z    at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:131)
2023-04-29T07:53:31.1801894Z    at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:500)
2023-04-29T07:53:31.1802382Z    at org.snmp4j.Snmp.sendMessage(Snmp.java:1087)
2023-04-29T07:53:31.1802804Z    at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:1864)
2023-04-29T07:53:31.1803483Z    at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
2023-04-29T07:53:31.1803912Z    at java.base/java.util.TimerThread.run(Timer.java:516)
2023-04-29T07:53:31.1805019Z 
2023-04-29T07:53:31.1806159Z [ERROR] testPollStartingDot{int}[2]  Time elapsed: 0.104 s  <<< ERROR!
2023-04-29T07:53:31.1806551Z java.nio.BufferOverflowException
2023-04-29T07:53:31.1806939Z    at java.base/java.nio.Buffer.nextPutIndex(Buffer.java:722)
2023-04-29T07:53:31.1807364Z    at java.base/java.nio.HeapByteBuffer.put(HeapByteBuffer.java:209)
2023-04-29T07:53:31.1807818Z    at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:63)
2023-04-29T07:53:31.1808236Z    at org.snmp4j.asn1.BER.encodeHeader(BER.java:122)
2023-04-29T07:53:31.1808672Z    at org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:201)
2023-04-29T07:53:31.1809091Z    at org.snmp4j.PDU.encodeBER(PDU.java:644)
2023-04-29T07:53:31.1809507Z    at org.snmp4j.mp.MPv2c.prepareOutgoingMessage(MPv2c.java:136)
2023-04-29T07:53:31.1810003Z    at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:500)
2023-04-29T07:53:31.1810452Z    at org.snmp4j.Snmp.sendMessage(Snmp.java:1087)
2023-04-29T07:53:31.1810848Z    at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:1864)
2023-04-29T07:53:31.1811271Z    at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
2023-04-29T07:53:31.1811675Z    at java.base/java.util.TimerThread.run(Timer.java:516)
JiriOndrusek commented 1 year ago

There is still a chance, that the java.nio.BufferOverflowException is caused by the tests. (There is an old comment in snmp4j - https://snmp4j.agentpp.narkive.com/ww7TdfMh/snmp-buffer-overflow-exception and one of the suggested explanations is: 1. The PDU or any contained VariableBinding is modified by another thread (for example the PDU sender) after calling asynchronous Snmp.send*.) I tried to fix such issue in https://github.com/apache/camel-quarkus/pull/4867