mirror of
https://github.com/apache/nifi.git
synced 2025-02-06 01:58:32 +00:00
NIFI-9925 Adjust PutUDP and SNMP tests to run without preferring IPv4
This closes #5976 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
18a4182cb0
commit
0a94762119
@ -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
|
||||
|
@ -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")));
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user