You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by jmeter list <jm...@yahoo.com> on 2007/02/12 23:49:52 UTC

is jmeter caching the hosts file ? the new hosts values are not picked during runtime

Hi,
  I'm having a problems with updating a hosts file during my test run and making an http request.
   
  Here is and example of the scenario
   
  1) 
  update hosts file to (ip1 is a working ip which should resolve correctly):
  ip1 test_domain
   
  2) make an http request with test_domain, which resolves to the ip1 and returns expected results string 
   
  3)
  update hosts file to (ip2 is a non-working ip which should not resolve or return anything):
  ip2 test_domain
   
  4) make an http request with test_domain, this request also returns the same results as step 2 which leads me to believe that somewhere jmeter caches the hosts during startup?
   
  At all phases of the test the hosts file is guaranteed to have only one entry 
  "ip1    test_domain" or  "ip2    test_domain"
   
  I use beanshell to write a new entry to my hosts file:
   
  ====================================
  String pattern =  "123.123.123    test_domain";
  
String fileName = "C:\WINDOWS\\system32\\drivers\\etc\\hosts";
  
try {
        BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
        out.write(pattern);
        out.close();
    } catch (Exception e) {
        System.out.println(e);
}
   
  ====================================
   
  The http request is made with an  http request sampler which is a get type request (keep alive and redirect boxes are not checked)
   
  I also tried using httpclient sampler with no success.
   
  What can i do to have jmeter pickup the hosts change during runtime and only during startup?
   
  Thanks,
Ken

 
---------------------------------
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.

Re: is jmeter caching the hosts file ? the new hosts values are not picked during runtime

Posted by sebb <se...@gmail.com>.
You may be able to define this in the system.properties file - depends
on when the JVM reads the value.

S.
On 13/02/07, jmeter list <jm...@yahoo.com> wrote:
> I just found out that jvm keeps the dns lookup cache until the end so even if i change the hosts during runtime it wont take affect unless i close and open jmeter again...  The only solution that I found for this problem is to have jvm not cache at all. You can do that by adding the following param -Dsun.net.inetaddr.ttl=0 when envoking java.  So in our case add this to the jmeter.bat
>
>  if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe -Dsun.net.inetaddr.ttl=0
>
> sebb <se...@gmail.com> wrote:
>  Host name resolution is done either by Java or more likely Windows.
>
> I don't know if you can change how long the names are cached for.
>
>
> On 12/02/07, jmeter list wrote:
> > Hi,
> > I'm having a problems with updating a hosts file during my test run and making an http request.
> >
> > Here is and example of the scenario
> >
> > 1)
> > update hosts file to (ip1 is a working ip which should resolve correctly):
> > ip1 test_domain
> >
> > 2) make an http request with test_domain, which resolves to the ip1 and returns expected results string
> >
> > 3)
> > update hosts file to (ip2 is a non-working ip which should not resolve or return anything):
> > ip2 test_domain
> >
> > 4) make an http request with test_domain, this request also returns the same results as step 2 which leads me to believe that somewhere jmeter caches the hosts during startup?
> >
> > At all phases of the test the hosts file is guaranteed to have only one entry
> > "ip1 test_domain" or "ip2 test_domain"
> >
> > I use beanshell to write a new entry to my hosts file:
> >
> > ====================================
> > String pattern = "123.123.123 test_domain";
> >
> > String fileName = "C:\WINDOWS\\system32\\drivers\\etc\\hosts";
> >
> > try {
> > BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
> > out.write(pattern);
> > out.close();
> > } catch (Exception e) {
> > System.out.println(e);
> > }
> >
> > ====================================
> >
> > The http request is made with an http request sampler which is a get type request (keep alive and redirect boxes are not checked)
> >
> > I also tried using httpclient sampler with no success.
> >
> > What can i do to have jmeter pickup the hosts change during runtime and only during startup?
> >
> > Thanks,
> > Ken
> >
> >
> > ---------------------------------
> > Be a PS3 game guru.
> > Get your game face on with the latest PS3 news and previews at Yahoo! Games.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------
> Don't be flakey. Get Yahoo! Mail for Mobile and
> always stay connected to friends.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: is jmeter caching the hosts file ? the new hosts values are not picked during runtime

Posted by jmeter list <jm...@yahoo.com>.
I just found out that jvm keeps the dns lookup cache until the end so even if i change the hosts during runtime it wont take affect unless i close and open jmeter again...  The only solution that I found for this problem is to have jvm not cache at all. You can do that by adding the following param -Dsun.net.inetaddr.ttl=0 when envoking java.  So in our case add this to the jmeter.bat 
   
  if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe -Dsun.net.inetaddr.ttl=0

sebb <se...@gmail.com> wrote:
  Host name resolution is done either by Java or more likely Windows.

I don't know if you can change how long the names are cached for.


On 12/02/07, jmeter list wrote:
> Hi,
> I'm having a problems with updating a hosts file during my test run and making an http request.
>
> Here is and example of the scenario
>
> 1)
> update hosts file to (ip1 is a working ip which should resolve correctly):
> ip1 test_domain
>
> 2) make an http request with test_domain, which resolves to the ip1 and returns expected results string
>
> 3)
> update hosts file to (ip2 is a non-working ip which should not resolve or return anything):
> ip2 test_domain
>
> 4) make an http request with test_domain, this request also returns the same results as step 2 which leads me to believe that somewhere jmeter caches the hosts during startup?
>
> At all phases of the test the hosts file is guaranteed to have only one entry
> "ip1 test_domain" or "ip2 test_domain"
>
> I use beanshell to write a new entry to my hosts file:
>
> ====================================
> String pattern = "123.123.123 test_domain";
>
> String fileName = "C:\WINDOWS\\system32\\drivers\\etc\\hosts";
>
> try {
> BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
> out.write(pattern);
> out.close();
> } catch (Exception e) {
> System.out.println(e);
> }
>
> ====================================
>
> The http request is made with an http request sampler which is a get type request (keep alive and redirect boxes are not checked)
>
> I also tried using httpclient sampler with no success.
>
> What can i do to have jmeter pickup the hosts change during runtime and only during startup?
>
> Thanks,
> Ken
>
>
> ---------------------------------
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo! Games.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org



 
---------------------------------
Don't be flakey. Get Yahoo! Mail for Mobile and 
always stay connected to friends.

Re: is jmeter caching the hosts file ? the new hosts values are not picked during runtime

Posted by sebb <se...@gmail.com>.
Host name resolution is done either by Java or more likely Windows.

I don't know if you can change how long the names are cached for.


On 12/02/07, jmeter list <jm...@yahoo.com> wrote:
> Hi,
>  I'm having a problems with updating a hosts file during my test run and making an http request.
>
>  Here is and example of the scenario
>
>  1)
>  update hosts file to (ip1 is a working ip which should resolve correctly):
>  ip1 test_domain
>
>  2) make an http request with test_domain, which resolves to the ip1 and returns expected results string
>
>  3)
>  update hosts file to (ip2 is a non-working ip which should not resolve or return anything):
>  ip2 test_domain
>
>  4) make an http request with test_domain, this request also returns the same results as step 2 which leads me to believe that somewhere jmeter caches the hosts during startup?
>
>  At all phases of the test the hosts file is guaranteed to have only one entry
>  "ip1    test_domain" or  "ip2    test_domain"
>
>  I use beanshell to write a new entry to my hosts file:
>
>  ====================================
>  String pattern =  "123.123.123    test_domain";
>
> String fileName = "C:\WINDOWS\\system32\\drivers\\etc\\hosts";
>
> try {
>        BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
>        out.write(pattern);
>        out.close();
>    } catch (Exception e) {
>        System.out.println(e);
> }
>
>  ====================================
>
>  The http request is made with an  http request sampler which is a get type request (keep alive and redirect boxes are not checked)
>
>  I also tried using httpclient sampler with no success.
>
>  What can i do to have jmeter pickup the hosts change during runtime and only during startup?
>
>  Thanks,
> Ken
>
>
> ---------------------------------
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo! Games.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org