You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Draelants Geert <ge...@gmail.com> on 2020/04/02 08:44:09 UTC

replace HTTP cache manager

Hi,

Does anybody know how I can replace the HTTP cache manager with my own implementation?

I’m trying to extend the default one with options to (1) consider all Cache-Control headers (and not just the last one) and (2) process the Pragma header.*

What I’ve done is extended CacheManager and CacheManagerGui and put my ‘plugin’ in lib\ext.
I can then add the element in the Test Plan but the HTTP sampler will not pick it up and continues to rely on org.apache.jmeter.protocol.http.control.CacheManager.

What am I missing? I am using JMeter v5.2.1 btw.
I know I can always replace the .class files in ApacheJMeter_http.jar but I’m not there yet.

Thanks in advance for your help!

Regards,
Geert

* Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know that.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: replace HTTP cache manager

Posted by Draelants Geert <ge...@gmail.com>.
Hi Mariusz,

The saved .jmx does contain my cache manager with the proper class in @guiclass.

If I enable it and disable the default cache manager then the tests run without any cache manager at all.
So no, I don’t see that debug line about ‘existing CacheManager superseded’ in the logs.

Regards,
Geert

> Op 2 apr. 2020, om 11:23 heeft Mariusz W <ma...@gmail.com> het volgende geschreven:
> 
> Hi,
> HttpSampler can only have one CacheManager. Do you see in logs: "Existing
> CacheManager {} superseded by {}"? - emitted by setCacheManager.
> 
> In code CacheManager it is selected that way as below.
> 
> @Override
> public void addTestElement(TestElement el) {
> if (el instanceof CookieManager) {
> setCookieManager((CookieManager) el);
> } else if (el instanceof CacheManager) {
> setCacheManager((CacheManager) el);
> } else if (el instanceof HeaderManager) {
> setHeaderManager((HeaderManager) el);
> } else if (el instanceof AuthManager) {
> setAuthManager((AuthManager) el);
> } else if (el instanceof DNSCacheManager) {
> setDNSResolver((DNSCacheManager) el);
> } else if (el instanceof KeystoreConfig) {
> setKeystoreConfigProperty((KeystoreConfig) el);
> } else {
> super.addTestElement(el);
> }
> }
> 
> Do you see your guiclass/testclass in saved jmx?
> 
> Regards,
> Mariusz
> 
> On Thu, 2 Apr 2020 at 10:43, Draelants Geert <ge...@gmail.com>
> wrote:
> 
>> Hi,
>> 
>> Does anybody know how I can replace the HTTP cache manager with my own
>> implementation?
>> 
>> I’m trying to extend the default one with options to (1) consider all
>> Cache-Control headers (and not just the last one) and (2) process the
>> Pragma header.*
>> 
>> What I’ve done is extended CacheManager and CacheManagerGui and put my
>> ‘plugin’ in lib\ext.
>> I can then add the element in the Test Plan but the HTTP sampler will not
>> pick it up and continues to rely on
>> org.apache.jmeter.protocol.http.control.CacheManager.
>> 
>> What am I missing? I am using JMeter v5.2.1 btw.
>> I know I can always replace the .class files in ApacheJMeter_http.jar but
>> I’m not there yet.
>> 
>> Thanks in advance for your help!
>> 
>> Regards,
>> Geert
>> 
>> * Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know
>> that.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>> 
>> 


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


Re: replace HTTP cache manager

Posted by Mariusz W <ma...@gmail.com>.
Can you check this example: https://github.com/mawasak/custom_jmeter_plugin
?

In jar folder you have compiled file ready to put in lib/ext - you will
have second CacheManager then  in Add->Config Element menu (named My
CacheManager)

Source code on github.

JMX is here
https://github.com/mawasak/custom_jmeter_plugin/blob/master/custom_cache_plugin.jmx
CacheManager in jmx:

<my.plugin.Library guiclass="my.plugin.LibraryGui" testclass="
my.plugin.Library" testname="My CacheManager" enabled="true">

Maybe it helps.

Mariusz

On Thu, 2 Apr 2020 at 16:21, Draelants Geert <ge...@gmail.com>
wrote:

> I think I’ve found the problem.
>
> HTTPSamplerBase.apples(ConfigTestElement) only accepts the default
> canonical name of CacheManagerGui.
> Because of that my updated implementation is never added to the sampler.
>
> Guess I’m gonna have to patch the jar after all.
>
> Regards,
> Geert
>
> > Op 2 apr. 2020, om 11:23 heeft Mariusz W <ma...@gmail.com> het
> volgende geschreven:
> >
> > Hi,
> > HttpSampler can only have one CacheManager. Do you see in logs: "Existing
> > CacheManager {} superseded by {}"? - emitted by setCacheManager.
> >
> > In code CacheManager it is selected that way as below.
> >
> > @Override
> > public void addTestElement(TestElement el) {
> > if (el instanceof CookieManager) {
> > setCookieManager((CookieManager) el);
> > } else if (el instanceof CacheManager) {
> > setCacheManager((CacheManager) el);
> > } else if (el instanceof HeaderManager) {
> > setHeaderManager((HeaderManager) el);
> > } else if (el instanceof AuthManager) {
> > setAuthManager((AuthManager) el);
> > } else if (el instanceof DNSCacheManager) {
> > setDNSResolver((DNSCacheManager) el);
> > } else if (el instanceof KeystoreConfig) {
> > setKeystoreConfigProperty((KeystoreConfig) el);
> > } else {
> > super.addTestElement(el);
> > }
> > }
> >
> > Do you see your guiclass/testclass in saved jmx?
> >
> > Regards,
> > Mariusz
> >
> > On Thu, 2 Apr 2020 at 10:43, Draelants Geert <ge...@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> Does anybody know how I can replace the HTTP cache manager with my own
> >> implementation?
> >>
> >> I’m trying to extend the default one with options to (1) consider all
> >> Cache-Control headers (and not just the last one) and (2) process the
> >> Pragma header.*
> >>
> >> What I’ve done is extended CacheManager and CacheManagerGui and put my
> >> ‘plugin’ in lib\ext.
> >> I can then add the element in the Test Plan but the HTTP sampler will
> not
> >> pick it up and continues to rely on
> >> org.apache.jmeter.protocol.http.control.CacheManager.
> >>
> >> What am I missing? I am using JMeter v5.2.1 btw.
> >> I know I can always replace the .class files in ApacheJMeter_http.jar
> but
> >> I’m not there yet.
> >>
> >> Thanks in advance for your help!
> >>
> >> Regards,
> >> Geert
> >>
> >> * Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know
> >> that.
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> >> For additional commands, e-mail: user-help@jmeter.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: replace HTTP cache manager

Posted by Geert <ge...@gmail.com>.
Thanks. I’ll do that.

Until then I’ve overridden the getProperty method for GUI_CLASS.
It is ugly but it gets the updated cache manager loaded.

Regards,
Geert

> Op 2 apr. 2020 om 16:23 heeft Philippe Mouawad <ph...@gmail.com> het volgende geschreven:
> 
> Hello,
> Why not contribute a patch to code of CacheManager ?
> 
> Regards
> 
>> On Thu, Apr 2, 2020 at 4:21 PM Draelants Geert <ge...@gmail.com>
>> wrote:
>> 
>> I think I’ve found the problem.
>> 
>> HTTPSamplerBase.apples(ConfigTestElement) only accepts the default
>> canonical name of CacheManagerGui.
>> Because of that my updated implementation is never added to the sampler.
>> 
>> Guess I’m gonna have to patch the jar after all.
>> 
>> Regards,
>> Geert
>> 
>>> Op 2 apr. 2020, om 11:23 heeft Mariusz W <ma...@gmail.com> het
>> volgende geschreven:
>>> 
>>> Hi,
>>> HttpSampler can only have one CacheManager. Do you see in logs: "Existing
>>> CacheManager {} superseded by {}"? - emitted by setCacheManager.
>>> 
>>> In code CacheManager it is selected that way as below.
>>> 
>>> @Override
>>> public void addTestElement(TestElement el) {
>>> if (el instanceof CookieManager) {
>>> setCookieManager((CookieManager) el);
>>> } else if (el instanceof CacheManager) {
>>> setCacheManager((CacheManager) el);
>>> } else if (el instanceof HeaderManager) {
>>> setHeaderManager((HeaderManager) el);
>>> } else if (el instanceof AuthManager) {
>>> setAuthManager((AuthManager) el);
>>> } else if (el instanceof DNSCacheManager) {
>>> setDNSResolver((DNSCacheManager) el);
>>> } else if (el instanceof KeystoreConfig) {
>>> setKeystoreConfigProperty((KeystoreConfig) el);
>>> } else {
>>> super.addTestElement(el);
>>> }
>>> }
>>> 
>>> Do you see your guiclass/testclass in saved jmx?
>>> 
>>> Regards,
>>> Mariusz
>>> 
>>> On Thu, 2 Apr 2020 at 10:43, Draelants Geert <ge...@gmail.com>
>>> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> Does anybody know how I can replace the HTTP cache manager with my own
>>>> implementation?
>>>> 
>>>> I’m trying to extend the default one with options to (1) consider all
>>>> Cache-Control headers (and not just the last one) and (2) process the
>>>> Pragma header.*
>>>> 
>>>> What I’ve done is extended CacheManager and CacheManagerGui and put my
>>>> ‘plugin’ in lib\ext.
>>>> I can then add the element in the Test Plan but the HTTP sampler will
>> not
>>>> pick it up and continues to rely on
>>>> org.apache.jmeter.protocol.http.control.CacheManager.
>>>> 
>>>> What am I missing? I am using JMeter v5.2.1 btw.
>>>> I know I can always replace the .class files in ApacheJMeter_http.jar
>> but
>>>> I’m not there yet.
>>>> 
>>>> Thanks in advance for your help!
>>>> 
>>>> Regards,
>>>> Geert
>>>> 
>>>> * Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know
>>>> that.
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>>>> For additional commands, e-mail: user-help@jmeter.apache.org
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>> 
>> 
> 
> -- 
> Cordialement.
> Philippe Mouawad.

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


Re: replace HTTP cache manager

Posted by Mariusz W <ma...@gmail.com>.
Yes, it's the best solution:)

Regards,
Mariusz

On Thu, 2 Apr 2020 at 16:23, Philippe Mouawad <ph...@gmail.com>
wrote:

> Hello,
> Why not contribute a patch to code of CacheManager ?
>
> Regards
>
> On Thu, Apr 2, 2020 at 4:21 PM Draelants Geert <ge...@gmail.com>
> wrote:
>
> > I think I’ve found the problem.
> >
> > HTTPSamplerBase.apples(ConfigTestElement) only accepts the default
> > canonical name of CacheManagerGui.
> > Because of that my updated implementation is never added to the sampler.
> >
> > Guess I’m gonna have to patch the jar after all.
> >
> > Regards,
> > Geert
> >
> > > Op 2 apr. 2020, om 11:23 heeft Mariusz W <ma...@gmail.com> het
> > volgende geschreven:
> > >
> > > Hi,
> > > HttpSampler can only have one CacheManager. Do you see in logs:
> "Existing
> > > CacheManager {} superseded by {}"? - emitted by setCacheManager.
> > >
> > > In code CacheManager it is selected that way as below.
> > >
> > > @Override
> > > public void addTestElement(TestElement el) {
> > > if (el instanceof CookieManager) {
> > > setCookieManager((CookieManager) el);
> > > } else if (el instanceof CacheManager) {
> > > setCacheManager((CacheManager) el);
> > > } else if (el instanceof HeaderManager) {
> > > setHeaderManager((HeaderManager) el);
> > > } else if (el instanceof AuthManager) {
> > > setAuthManager((AuthManager) el);
> > > } else if (el instanceof DNSCacheManager) {
> > > setDNSResolver((DNSCacheManager) el);
> > > } else if (el instanceof KeystoreConfig) {
> > > setKeystoreConfigProperty((KeystoreConfig) el);
> > > } else {
> > > super.addTestElement(el);
> > > }
> > > }
> > >
> > > Do you see your guiclass/testclass in saved jmx?
> > >
> > > Regards,
> > > Mariusz
> > >
> > > On Thu, 2 Apr 2020 at 10:43, Draelants Geert <
> geert.draelants@gmail.com>
> > > wrote:
> > >
> > >> Hi,
> > >>
> > >> Does anybody know how I can replace the HTTP cache manager with my own
> > >> implementation?
> > >>
> > >> I’m trying to extend the default one with options to (1) consider all
> > >> Cache-Control headers (and not just the last one) and (2) process the
> > >> Pragma header.*
> > >>
> > >> What I’ve done is extended CacheManager and CacheManagerGui and put my
> > >> ‘plugin’ in lib\ext.
> > >> I can then add the element in the Test Plan but the HTTP sampler will
> > not
> > >> pick it up and continues to rely on
> > >> org.apache.jmeter.protocol.http.control.CacheManager.
> > >>
> > >> What am I missing? I am using JMeter v5.2.1 btw.
> > >> I know I can always replace the .class files in ApacheJMeter_http.jar
> > but
> > >> I’m not there yet.
> > >>
> > >> Thanks in advance for your help!
> > >>
> > >> Regards,
> > >> Geert
> > >>
> > >> * Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know
> > >> that.
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > >> For additional commands, e-mail: user-help@jmeter.apache.org
> > >>
> > >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
> >
> >
>
> --
> Cordialement.
> Philippe Mouawad.
>

Re: replace HTTP cache manager

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
Why not contribute a patch to code of CacheManager ?

Regards

On Thu, Apr 2, 2020 at 4:21 PM Draelants Geert <ge...@gmail.com>
wrote:

> I think I’ve found the problem.
>
> HTTPSamplerBase.apples(ConfigTestElement) only accepts the default
> canonical name of CacheManagerGui.
> Because of that my updated implementation is never added to the sampler.
>
> Guess I’m gonna have to patch the jar after all.
>
> Regards,
> Geert
>
> > Op 2 apr. 2020, om 11:23 heeft Mariusz W <ma...@gmail.com> het
> volgende geschreven:
> >
> > Hi,
> > HttpSampler can only have one CacheManager. Do you see in logs: "Existing
> > CacheManager {} superseded by {}"? - emitted by setCacheManager.
> >
> > In code CacheManager it is selected that way as below.
> >
> > @Override
> > public void addTestElement(TestElement el) {
> > if (el instanceof CookieManager) {
> > setCookieManager((CookieManager) el);
> > } else if (el instanceof CacheManager) {
> > setCacheManager((CacheManager) el);
> > } else if (el instanceof HeaderManager) {
> > setHeaderManager((HeaderManager) el);
> > } else if (el instanceof AuthManager) {
> > setAuthManager((AuthManager) el);
> > } else if (el instanceof DNSCacheManager) {
> > setDNSResolver((DNSCacheManager) el);
> > } else if (el instanceof KeystoreConfig) {
> > setKeystoreConfigProperty((KeystoreConfig) el);
> > } else {
> > super.addTestElement(el);
> > }
> > }
> >
> > Do you see your guiclass/testclass in saved jmx?
> >
> > Regards,
> > Mariusz
> >
> > On Thu, 2 Apr 2020 at 10:43, Draelants Geert <ge...@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> Does anybody know how I can replace the HTTP cache manager with my own
> >> implementation?
> >>
> >> I’m trying to extend the default one with options to (1) consider all
> >> Cache-Control headers (and not just the last one) and (2) process the
> >> Pragma header.*
> >>
> >> What I’ve done is extended CacheManager and CacheManagerGui and put my
> >> ‘plugin’ in lib\ext.
> >> I can then add the element in the Test Plan but the HTTP sampler will
> not
> >> pick it up and continues to rely on
> >> org.apache.jmeter.protocol.http.control.CacheManager.
> >>
> >> What am I missing? I am using JMeter v5.2.1 btw.
> >> I know I can always replace the .class files in ApacheJMeter_http.jar
> but
> >> I’m not there yet.
> >>
> >> Thanks in advance for your help!
> >>
> >> Regards,
> >> Geert
> >>
> >> * Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know
> >> that.
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> >> For additional commands, e-mail: user-help@jmeter.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

-- 
Cordialement.
Philippe Mouawad.

Re: replace HTTP cache manager

Posted by Draelants Geert <ge...@gmail.com>.
I think I’ve found the problem.

HTTPSamplerBase.apples(ConfigTestElement) only accepts the default canonical name of CacheManagerGui.
Because of that my updated implementation is never added to the sampler.

Guess I’m gonna have to patch the jar after all.

Regards,
Geert

> Op 2 apr. 2020, om 11:23 heeft Mariusz W <ma...@gmail.com> het volgende geschreven:
> 
> Hi,
> HttpSampler can only have one CacheManager. Do you see in logs: "Existing
> CacheManager {} superseded by {}"? - emitted by setCacheManager.
> 
> In code CacheManager it is selected that way as below.
> 
> @Override
> public void addTestElement(TestElement el) {
> if (el instanceof CookieManager) {
> setCookieManager((CookieManager) el);
> } else if (el instanceof CacheManager) {
> setCacheManager((CacheManager) el);
> } else if (el instanceof HeaderManager) {
> setHeaderManager((HeaderManager) el);
> } else if (el instanceof AuthManager) {
> setAuthManager((AuthManager) el);
> } else if (el instanceof DNSCacheManager) {
> setDNSResolver((DNSCacheManager) el);
> } else if (el instanceof KeystoreConfig) {
> setKeystoreConfigProperty((KeystoreConfig) el);
> } else {
> super.addTestElement(el);
> }
> }
> 
> Do you see your guiclass/testclass in saved jmx?
> 
> Regards,
> Mariusz
> 
> On Thu, 2 Apr 2020 at 10:43, Draelants Geert <ge...@gmail.com>
> wrote:
> 
>> Hi,
>> 
>> Does anybody know how I can replace the HTTP cache manager with my own
>> implementation?
>> 
>> I’m trying to extend the default one with options to (1) consider all
>> Cache-Control headers (and not just the last one) and (2) process the
>> Pragma header.*
>> 
>> What I’ve done is extended CacheManager and CacheManagerGui and put my
>> ‘plugin’ in lib\ext.
>> I can then add the element in the Test Plan but the HTTP sampler will not
>> pick it up and continues to rely on
>> org.apache.jmeter.protocol.http.control.CacheManager.
>> 
>> What am I missing? I am using JMeter v5.2.1 btw.
>> I know I can always replace the .class files in ApacheJMeter_http.jar but
>> I’m not there yet.
>> 
>> Thanks in advance for your help!
>> 
>> Regards,
>> Geert
>> 
>> * Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know
>> that.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>> 
>> 


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


Re: replace HTTP cache manager

Posted by Mariusz W <ma...@gmail.com>.
Hi,
HttpSampler can only have one CacheManager. Do you see in logs: "Existing
CacheManager {} superseded by {}"? - emitted by setCacheManager.

In code CacheManager it is selected that way as below.

@Override
public void addTestElement(TestElement el) {
 if (el instanceof CookieManager) {
 setCookieManager((CookieManager) el);
 } else if (el instanceof CacheManager) {
 setCacheManager((CacheManager) el);
 } else if (el instanceof HeaderManager) {
 setHeaderManager((HeaderManager) el);
 } else if (el instanceof AuthManager) {
 setAuthManager((AuthManager) el);
 } else if (el instanceof DNSCacheManager) {
 setDNSResolver((DNSCacheManager) el);
 } else if (el instanceof KeystoreConfig) {
 setKeystoreConfigProperty((KeystoreConfig) el);
 } else {
 super.addTestElement(el);
 }
}

Do you see your guiclass/testclass in saved jmx?

Regards,
Mariusz

On Thu, 2 Apr 2020 at 10:43, Draelants Geert <ge...@gmail.com>
wrote:

> Hi,
>
> Does anybody know how I can replace the HTTP cache manager with my own
> implementation?
>
> I’m trying to extend the default one with options to (1) consider all
> Cache-Control headers (and not just the last one) and (2) process the
> Pragma header.*
>
> What I’ve done is extended CacheManager and CacheManagerGui and put my
> ‘plugin’ in lib\ext.
> I can then add the element in the Test Plan but the HTTP sampler will not
> pick it up and continues to rely on
> org.apache.jmeter.protocol.http.control.CacheManager.
>
> What am I missing? I am using JMeter v5.2.1 btw.
> I know I can always replace the .class files in ApacheJMeter_http.jar but
> I’m not there yet.
>
> Thanks in advance for your help!
>
> Regards,
> Geert
>
> * Yes, it is obsolete as of HTTP 1.1 but not all browsers seem to know
> that.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>