You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2022/04/19 19:13:23 UTC

[nifi] branch main updated: NIFI-9925 Adjust PutUDP and SNMP tests to run without preferring IPv4

This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 0a94762119 NIFI-9925 Adjust PutUDP and SNMP tests to run without preferring IPv4
0a94762119 is described below

commit 0a9476211907df520e58256fdca2b17686b396a2
Author: Paul Grey <gr...@yahoo.com>
AuthorDate: Thu Apr 14 13:48:47 2022 -0400

    NIFI-9925 Adjust PutUDP and SNMP tests to run without preferring IPv4
    
    This closes #5976
    
    Signed-off-by: David Handermann <ex...@apache.org>
---
 .../org/apache/nifi/snmp/factory/core/V1V2cSNMPFactoryTest.java  | 5 ++++-
 .../org/apache/nifi/snmp/factory/core/V3SNMPFactoryTest.java     | 4 +++-
 .../java/org/apache/nifi/processors/standard/TestPutUDP.java     | 9 ++++-----
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V1V2cSNMPFactoryTest.java b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V1V2cSNMPFactoryTest.java
index 7da6426ff9..80ef139582 100644
--- a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V1V2cSNMPFactoryTest.java
+++ b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V1V2cSNMPFactoryTest.java
@@ -25,10 +25,13 @@ import org.snmp4j.Snmp;
 import org.snmp4j.Target;
 import org.snmp4j.security.SecurityLevel;
 
+import java.util.regex.Pattern;
+
 import static org.apache.nifi.snmp.helper.configurations.SNMPConfigurationFactory.LOCALHOST;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsInstanceOf.instanceOf;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
@@ -62,7 +65,7 @@ public class V1V2cSNMPFactoryTest {
         final Snmp snmpManager = snmpFactory.createSnmpManagerInstance(snmpConfiguration);
 
         final String address = snmpManager.getMessageDispatcher().getTransportMappings().iterator().next().getListenAddress().toString();
-        assertEquals("0.0.0.0" + "/" + managerPort, address);
+        assertTrue(Pattern.compile("0.+?0/" + managerPort).matcher(address).matches());
     }
 
     @Test
diff --git a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V3SNMPFactoryTest.java b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V3SNMPFactoryTest.java
index e2c48dc0af..88cafe3fb5 100644
--- a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V3SNMPFactoryTest.java
+++ b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/factory/core/V3SNMPFactoryTest.java
@@ -28,6 +28,8 @@ import org.snmp4j.security.USM;
 import org.snmp4j.smi.Integer32;
 import org.snmp4j.smi.OctetString;
 
+import java.util.regex.Pattern;
+
 import static org.apache.nifi.snmp.helper.configurations.SNMPConfigurationFactory.LOCALHOST;
 import static org.apache.nifi.snmp.helper.configurations.SNMPV3ConfigurationFactory.AUTH_PASSPHRASE;
 import static org.apache.nifi.snmp.helper.configurations.SNMPV3ConfigurationFactory.AUTH_PROTOCOL;
@@ -73,7 +75,7 @@ public class V3SNMPFactoryTest {
 
         final String address = snmpManager.getMessageDispatcher().getTransportMappings().iterator().next().getListenAddress().toString();
         USM usm = (USM) SecurityModels.getInstance().getSecurityModel(new Integer32(3));
-        assertEquals("0.0.0.0" + "/" + managerPort, address);
+        assertTrue(Pattern.compile("0.+?0/" + managerPort).matcher(address).matches());
         assertTrue(usm.hasUser(null, new OctetString("SHAAES128")));
     }
 
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutUDP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutUDP.java
index 104cec1989..bb8a1029cf 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutUDP.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutUDP.java
@@ -58,7 +58,7 @@ public class TestPutUDP {
     private final static char CONTENT_CHAR = 'x';
     private final static int DATA_WAIT_PERIOD = 50;
     private final static int DEFAULT_TEST_TIMEOUT_PERIOD = 10000;
-    private final static int LONG_TEST_TIMEOUT_PERIOD = 100000;
+    private final static int LONG_TEST_TIMEOUT_PERIOD = 30000;
 
     private TestRunner runner;
     private int port;
@@ -187,18 +187,17 @@ public class TestPutUDP {
         runner.assertValid();
     }
 
-    private void sendTestData(final String[] testData) throws InterruptedException {
+    private void sendTestData(final String[] testData) {
         sendTestData(testData, DEFAULT_ITERATIONS, DEFAULT_THREAD_COUNT);
     }
 
-    private void sendTestData(final String[] testData, final int iterations, final int threadCount) throws InterruptedException {
+    private void sendTestData(final String[] testData, final int iterations, final int threadCount) {
         for (String item : testData) {
             runner.setThreadCount(threadCount);
             for (int i = 0; i < iterations; i++) {
                 runner.enqueue(item.getBytes());
-                runner.run(1, false);
-                Thread.sleep(1);
             }
+            runner.run(iterations, false);
         }
 
         // ensure @OnStopped methods get called