Bug 52466

Summary: Upgrade Test Plan feature : NameUpdater does not upgrade properties (r1227589)
Product: JMeter - Now in Github Reporter: Philippe Mouawad <p.mouawad>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: p.mouawad
Priority: P2    
Version: Nightly (Please specify date)   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 52048    
Attachments: Test Plan to upgrade

Description Philippe Mouawad 2012-01-13 22:28:20 UTC
It seems upgrade system is broken.
Trying to add properties to handle upgrade for 52048, I noticed only NameUpdater#getCurrentName(String className) was used.

Other methods that upgrade property names are not used so rules like:
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/JDBCSampler.url=dbUrl

or org.apache.jmeter.config.ConfigTestElement|org.apache.jmeter.protocol.jdbc.config.gui.DbConfigGui=org.apache.jmeter.protocol.jdbc.config.DataSourceElement

don't work.



Should we fix this or abandon feature ?
Comment 1 Philippe Mouawad 2012-01-13 22:29:20 UTC
Affects 2.5.1.
Comment 2 Sebb 2012-01-16 10:45:11 UTC
The methods were originally all used by the OldSaveService class.
This handled the previous JMX format (Avalon).
Support for this format (and the OldSaveService class) was dropped in JMeter 2.4.

It's not clear why the methods were/are not used by the classes that handle the new format (which is loaded using XStream). Looks like this is an accidental omission that was never previously noticed.

It's also not clear why the getCurrentName(String) method is called by JMeterTreeModel, rather than the class that reads the JMX file format. 
This was added to JMeterTreeModel in r323315, but the SVN log entry is not very explicit about why the change was done there, rather than when reading the JMX file.

I think the old names can only originate from a JMX file, so if they are fixed as part of reading the file, then there should be no need to deal with the old names anywhere else in JMeter.
Comment 3 Sebb 2012-01-16 21:22:46 UTC
For reference, here's how the methods were used in OldSaveService.java [1]

private static TestElement createTestElement(...){
    ...
    testClass = value of "class" attribute
    gui_class = value of guiClass property
    ...
    newClass = NameUpdater.getCurrentTestName(testClass,gui_class);
    element = (TestElement) Class.forName(newClass).newInstance();
...
}

The above method was used for creating all TestElement instances.

private static JMeterProperty createProperty(...){
    ...
        // Do upgrade translation:
        name = NameUpdater.getCurrentName(name, testClass);
        if (TestElement.GUI_CLASS.equals(name)) {
            value = NameUpdater.getCurrentName(value);
        } else if (TestElement.TEST_CLASS.equals(name)) {
            value=testClass; // must always agree
        } else {
            value = NameUpdater.getCurrentName(value, name, testClass);
        }

        // Delete any properties whose name converts to the empty string
        if (oname.length() != 0 && name.length()==0) {
            return null;
        }

        // Create the property:
    ...
}

The above method was used for creating all properties.

[1] https://svn.apache.org/repos/asf/jmeter/tags/v2_3_4/src/core/org/apache/jmeter/save/OldSaveService.java
Comment 4 Sebb 2012-01-17 19:58:16 UTC
Fixed in SVN:

URL: http://svn.apache.org/viewvc?rev=1232550&view=rev
Log:
Bug 52466 - Upgrade Test Plan feature : NameUpdater does not upgrade properties

Modified:
   jmeter/trunk/bin/testfiles/GuiTest.jmx
   jmeter/trunk/src/core/org/apache/jmeter/gui/tree/JMeterTreeModel.java
   jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/BooleanPropertyConverter.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/ConversionHelp.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/IntegerPropertyConverter.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/LongPropertyConverter.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/StringPropertyConverter.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementConverter.java
   jmeter/trunk/src/reports/org/apache/jmeter/report/gui/tree/ReportTreeModel.java
   jmeter/trunk/xdocs/changes.xml


URL: http://svn.apache.org/viewvc?rev=1232554&view=rev
Log:
Bug 52466 - Upgrade Test Plan feature : NameUpdater does not upgrade properties
Allow for deleted properties

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/MultiPropertyConverter.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementConverter.java
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementPropertyConverter.java
Comment 5 Philippe Mouawad 2012-01-18 22:07:58 UTC
Created attachment 28171 [details]
Test Plan to upgrade

Test Plan to use to see strange behaviour
Comment 6 Philippe Mouawad 2012-01-18 22:11:06 UTC
I am not sure this issue is fixed.
Working on Bug 52048, I updated upgrade.properties to ensure compatibility.
I noticed upgrade is not working properly.

I don't think issue is in patch (at least all except upgrade.properties) so I suspect an issue in upgrade.


To reproduce issue, apply patch on Bug 52048 then try to upgrade attached Test Plan, you will see that the second BSH Sampler gets the same configuration as the first one.
Comment 7 Sebb 2012-01-19 01:17:51 UTC
Oops! wrong variable was being returned.

URL: http://svn.apache.org/viewvc?rev=1233146&view=rev
Log:
Bug 52466 - Upgrade Test Plan feature : NameUpdater does not upgrade properties (r1227589)
Fix typo: was returning original name rather than the updated property name

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/save/converters/ConversionHelp.java
Comment 8 Sebb 2012-01-25 00:05:00 UTC
Another fix needed to handle top level elements.

URL: http://svn.apache.org/viewvc?rev=1235564&view=rev
Log:
Bug 52466 - Upgrade Test Plan feature : NameUpdater does not upgrade properties (r1227589)
Also need to upgrade top-level element names
Comment 9 The ASF infrastructure team 2022-09-24 20:37:48 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2702