Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect value for the last variable in "CSV Data Set Config" - when the value is empty #2189

Closed
asfimport opened this issue Jan 7, 2009 · 15 comments

Comments

@asfimport
Copy link
Collaborator

Yaroslav (Bug 46491):
Use "CSV Data Set Config" element in your test-plan. Use there a few variables (3 or more) - assume there are {VAR1, VAR2, VAR3} (I'm using here "{ and }" for better explanation).
Create data file for it.
The first line has non-empty values - assume {1-1,1-2,1-3}.
The second line has {2-1,2-2,} where the third value is empty (I need like this TC).
So, when a thread is picking the second line from the CVS file - VAR3 value will be "1-3" (from previous line).

ER: VAR3 value is equal to value from the second line - in this case - empty(nothing).

The issue is valid only for the last variable in CVS file.
I'm trying also to use (Allow quoted data = True) in the CVS file like {2-1,2-2,""} and it does not help as well.

Severity: normal
OS: Windows XP

Duplicates:

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
The second line needs to be

2-1,2-2

If you use

2-1,2-2,
or
2-1,2-2,""

then you are defining the 3rd column as the empty string.

@asfimport
Copy link
Collaborator Author

Yaroslav (migrated from Bugzilla):
Reopened

That what I need - I need to have third parameter as empty string, but the value is not empty, it is equal the value from the previous line.
Sorry, if the description is not clear.
Assume, that CVS file has description {VAR1,VAR2,VAR3} and data are like these:
1st line: {1-1,1-2,1-3}
2nd line: {2-1,2-2,} - third parameter is empty

AR(ActualResult): when 2nd line is processing ${VAR3} will be equal "1-3" (from previous line);
ER(ExpectedResult): for 2nd line - ${VAR3} is equal "" (empty string);

This is issue valid only for the last variable of CVS file.

@asfimport
Copy link
Collaborator Author

Yaroslav (migrated from Bugzilla):
Sorry for annoying...

What are you going to do with this bug?

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Created attachment csv46491.csv: Data file

csv46491.csv
1-1,1-2,1-3
2-1,2-2
3-1,,3-3````

</details>

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Created attachment csv46491.jmx: Test plan

csv46491.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.1">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="csv46491" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">4</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1232802288000</longProp>
        <longProp name="ThreadGroup.end_time">1232802288000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
          <stringProp name="delimiter">,</stringProp>
          <stringProp name="fileEncoding"></stringProp>
          <stringProp name="filename">csv46491.csv</stringProp>
          <boolProp name="quotedData">false</boolProp>
          <boolProp name="recycle">true</boolProp>
          <stringProp name="shareMode">All threads</stringProp>
          <boolProp name="stopThread">false</boolProp>
          <stringProp name="variableNames">A,B,C</stringProp>
        </CSVDataSet>
        <hashTree/>
        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java Request" enabled="true">
          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="Sleep_Time" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Time</stringProp>
                <stringProp name="Argument.value">100</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="Sleep_Mask" elementType="Argument">
                <stringProp name="Argument.name">Sleep_Mask</stringProp>
                <stringProp name="Argument.value">0xFF</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="Label" elementType="Argument">
                <stringProp name="Argument.name">Label</stringProp>
                <stringProp name="Argument.value">A=${A} B=${B} C=${C}</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="ResponseCode" elementType="Argument">
                <stringProp name="Argument.name">ResponseCode</stringProp>
                <stringProp name="Argument.value"></stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="ResponseMessage" elementType="Argument">
                <stringProp name="Argument.name">ResponseMessage</stringProp>
                <stringProp name="Argument.value"></stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="Status" elementType="Argument">
                <stringProp name="Argument.name">Status</stringProp>
                <stringProp name="Argument.value">OK</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="SamplerData" elementType="Argument">
                <stringProp name="Argument.name">SamplerData</stringProp>
                <stringProp name="Argument.value"></stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
              <elementProp name="ResultData" elementType="Argument">
                <stringProp name="Argument.name">ResultData</stringProp>
                <stringProp name="Argument.value"></stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest</stringProp>
        </JavaSampler>
        <hashTree/>
      </hashTree>
      <ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="View Results in Table" enabled="true">
        <boolProp name="ResultCollector.error_logging">false</boolProp>
        <objProp>
          <name>saveConfig</name>
          <value class="SampleSaveConfiguration">
            <time>true</time>
            <latency>true</latency>
            <timestamp>true</timestamp>
            <success>true</success>
            <label>true</label>
            <code>true</code>
            <message>true</message>
            <threadName>true</threadName>
            <dataType>true</dataType>
            <encoding>false</encoding>
            <assertions>true</assertions>
            <subresults>true</subresults>
            <responseData>false</responseData>
            <samplerData>false</samplerData>
            <xml>false</xml>
            <fieldNames>false</fieldNames>
            <responseHeaders>false</responseHeaders>
            <requestHeaders>false</requestHeaders>
            <responseDataOnError>false</responseDataOnError>
            <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
            <assertionsResultsToSave>0</assertionsResultsToSave>
            <bytes>true</bytes>
          </value>
        </objProp>
        <stringProp name="filename">csv46491.jtl</stringProp>
      </ResultCollector>
      <hashTree/>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Created attachment csv46491.jtl: Sample output

csv46491.jtl
1232802434913,266,A=1-1 B=1-2 C=1-3,,,Thread Group 1-1,,true,0,0
1232802435226,312,A=2-1 B=2-2 C=1-3,,,Thread Group 1-1,,true,0,0
1232802435538,110,A=3-1 B= C=3-3,,,Thread Group 1-1,,true,0,0
1232802435648,218,A=1-1 B=1-2 C=1-3,,,Thread Group 1-1,,true,0,0

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Works fine for me - see attached test plan etc.

If it does not work for you, please reopen and attach the simplest possible test plan that shows the problem, together with data file and sample output.

@asfimport
Copy link
Collaborator Author

Yaroslav (migrated from Bugzilla):
Created attachment testcsv.txt: my cvs file

testcsv.txt
#,TC,ID,EMAIL-GROUP,PASSWORD,FIRSTNAME,LASTNAME,POSITION
SS-01-02-05,aaa5,bluerealm.com,dadada,firstName,                                  ,5
#,Invalid Position
SS-01-02-06,aaa6,bluerealm.com,dadada,firstName,lastName,

@asfimport
Copy link
Collaborator Author

Yaroslav (migrated from Bugzilla):
Hi Sebb-2

I've attached simple "my cvs file" - 4 lines only.
When I do a printing by beanshell it show incorrect value for the last line.
Here is my beanshell script:

print ("TC="+vars.get("TC") + "::" + "ID="+vars.get("ID") + "EmailGroup="+vars.get("EMAIL-GROUP") + "<>Password="+vars.get("PASSWORD") + "<>FirstName="+vars.get("FIRSTNAME") + "<>LastName=" + vars.get("LASTNAME") + "<>Position=" + vars.get("POSITION") + "<>");

Here are test-result:
TC=SS-01-02-05::ID=aaa5EmailGroup=bluerealm.com<>Password=dadada<>FirstName=firs
tName<>LastName= <>Position=5<>
TC=SS-01-02-06::ID=aaa6EmailGroup=bluerealm.com<>Password=dadada<>FirstName=firs
tName<>LastName=lastName<>Position=5<>

ER: the last line is shown as:
TC=SS-01-02-06::ID=aaa6EmailGroup=bluerealm.com<>Password=dadada<>FirstName=firs
tName<>LastName=lastName<>Position=null<>

========

@asfimport
Copy link
Collaborator Author

Yaroslav (migrated from Bugzilla):
I've also attached "simple TestPlan"

@asfimport
Copy link
Collaborator Author

Yaroslav (migrated from Bugzilla):
Created attachment TestCVS.jmx: simple TestPlan

TestCVS.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.1">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP Request Defaults" enabled="true">
        <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
          <collectionProp name="Arguments.arguments"/>
        </elementProp>
        <stringProp name="HTTPSampler.domain">storeshop3.qa.bluerealm.com</stringProp>
        <stringProp name="HTTPSampler.port"></stringProp>
        <stringProp name="HTTPSampler.protocol"></stringProp>
        <stringProp name="HTTPSampler.contentEncoding"></stringProp>
        <stringProp name="HTTPSampler.path"></stringProp>
      </ConfigTestElement>
      <hashTree/>
      <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
        <stringProp name="delimiter">,</stringProp>
        <stringProp name="fileEncoding"></stringProp>
        <stringProp name="filename">testcsv.txt</stringProp>
        <boolProp name="quotedData">true</boolProp>
        <boolProp name="recycle">false</boolProp>
        <stringProp name="shareMode">All threads</stringProp>
        <boolProp name="stopThread">true</boolProp>
        <stringProp name="variableNames">TC,ID,EMAIL-GROUP,PASSWORD,FIRSTNAME,LASTNAME,POSITION</stringProp>
      </CSVDataSet>
      <hashTree/>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="SS-01 - Register a new account" enabled="true">
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <intProp name="LoopController.loops">-1</intProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1229016075000</longProp>
        <longProp name="ThreadGroup.end_time">1229016075000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <IfController guiclass="IfControllerPanel" testclass="IfController" testname="If Controller" enabled="true">
          <stringProp name="IfController.condition">&quot;${TC}&quot; != &quot;#&quot;</stringProp>
          <stringProp name="IfController.evaluateAll">false</stringProp>
        </IfController>
        <hashTree>
          <BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="BeanShell Sampler" enabled="true">
            <stringProp name="BeanShellSampler.query">print (&quot;TC=&quot;+vars.get(&quot;TC&quot;) + &quot;::&quot; + &quot;ID=&quot;+vars.get(&quot;ID&quot;) + &quot;EmailGroup=&quot;+vars.get(&quot;EMAIL-GROUP&quot;) + &quot;&lt;&gt;Password=&quot;+vars.get(&quot;PASSWORD&quot;) + &quot;&lt;&gt;FirstName=&quot;+vars.get(&quot;FIRSTNAME&quot;) + &quot;&lt;&gt;LastName=&quot; + vars.get(&quot;LASTNAME&quot;) + &quot;&lt;&gt;Position=&quot; + vars.get(&quot;POSITION&quot;) + &quot;&lt;&gt;&quot;);</stringProp>
            <stringProp name="BeanShellSampler.filename"></stringProp>
            <stringProp name="BeanShellSampler.parameters"></stringProp>
            <boolProp name="BeanShellSampler.resetInterpreter">true</boolProp>
          </BeanShellSampler>
          <hashTree/>
        </hashTree>
      </hashTree>
      <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
        <boolProp name="ResultCollector.error_logging">false</boolProp>
        <objProp>
          <name>saveConfig</name>
          <value class="SampleSaveConfiguration">
            <time>true</time>
            <latency>true</latency>
            <timestamp>true</timestamp>
            <success>true</success>
            <label>true</label>
            <code>true</code>
            <message>true</message>
            <threadName>true</threadName>
            <dataType>true</dataType>
            <encoding>false</encoding>
            <assertions>true</assertions>
            <subresults>true</subresults>
            <responseData>false</responseData>
            <samplerData>false</samplerData>
            <xml>true</xml>
            <fieldNames>false</fieldNames>
            <responseHeaders>false</responseHeaders>
            <requestHeaders>false</requestHeaders>
            <responseDataOnError>false</responseDataOnError>
            <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
            <assertionsResultsToSave>0</assertionsResultsToSave>
            <bytes>true</bytes>
          </value>
        </objProp>
        <stringProp name="filename"></stringProp>
      </ResultCollector>
      <hashTree/>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
There is a subtle difference between the CSV Dataset settings in my test plan and yours - I put "Allow quoted data" = False, and you put True.

Try setting the value to False and see if that solves the problem. It does for me.

Of course, quoted data needs to behave the same as unquoted, so I'll investigate fixing that.

@asfimport
Copy link
Collaborator Author

Yaroslav (migrated from Bugzilla):
Yes, you are right.
"Quoted" flag is causing the problem, but even I've quoted the last field (like, {a,b,""}) with "quoted"=True - it will not help.

So, here are two "issues" (maybe related - I'm mean duplicated - this is just for myself when I a fix-verification will do):

  1. "quoted" flag == True when data are non-quoted;
  2. if the flag == True and data is quoted (all or partially) (like [a,b,""] or ["a","b",""] - it causes the problem as well;

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Setting the "Allow quoted data flag" to true should not affect how unquoted data is treated. However at present the routine that processes quoted data doesn't handle a trailing delimiter correctly. I'm in the process of fixing that.

If your data is not quoted, then don't set Allow Quoted = true.

If your data is quoted, then you need to set Allow Quoted = true, but in that case you cannot set the last variable to empty, as the code treats {abc,} exactly the same as {abc,""}. This is a bug.

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Fixed in SVN in r740183:

URL: http://svn.apache.org/viewvc?rev=740183&view=rev
Log:
#2189 - Incorrect value for the last variable in "CSV Data Set Config" (error in processing quoted strings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant