You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by GitBox <gi...@apache.org> on 2022/01/05 09:59:47 UTC
[GitHub] [jmeter] mjmadhu commented on a change in pull request #640: 65041: httpclient.timeout property not working as expected
mjmadhu commented on a change in pull request #640:
URL: https://github.com/apache/jmeter/pull/640#discussion_r778689193
##########
File path: src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPHC4Impl.java
##########
@@ -119,4 +126,42 @@ public void testNotifyFirstSampleAfterLoopRestartWhenThreadIterationIsANewUser()
hc.notifyFirstSampleAfterLoopRestart();
assertTrue("Users are different, the state should be reset", HTTPHC4Impl.resetStateOnThreadGroupIteration.get());
}
+
+ @Test
+ public void testSocketTimeoutWithoutConfiguration() throws IOException {
+ HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
+ sampler.setThreadContext(jmctx);
+ HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
+ assertEquals("HTTP socket timeout not found as expected", 0, hc.getResponseTimeout());
+ }
+
+ @Test
+ public void testSocketTimeoutConfigurationFromJMeterProps() throws IOException {
+ Path props = Files.createTempFile("hcdummy1", ".properties");
+ JMeterUtils.loadJMeterProperties(props.toString());
+ JMeterUtils.getJMeterProperties().setProperty("httpclient.timeout", String.valueOf(100));
+ HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
+ sampler.setThreadContext(jmctx);
+ HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
+ assertEquals("HTTP socket timeout not configured via httpclient.timeout as expected", 100, hc.getResponseTimeout());
+ }
+
+ @Test
+ public void testSocketTimeoutConfigurationFromHCParams() throws IOException {
+ Path props = Files.createTempFile("hcdummy2", ".properties");
+ JMeterUtils.loadJMeterProperties(props.toString());
+ JMeterUtils.getJMeterProperties().setProperty("httpclient.timeout", String.valueOf(100));
+ JMeterUtils.getJMeterProperties().setProperty("hc.parameters.file", props.toString());
+ Properties hcParams = new Properties();
+ try(OutputStream outputStream = new FileOutputStream(props.toString())) {
+ hcParams.setProperty("http.socket.timeout$Integer", String.valueOf(120));
+ hcParams.store(outputStream, null);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
Review comment:
Thanks, have removed as it's writing to temp file just created above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org