Bug 63394 - JMeter should fail with non-zero when test execution fails (due to missing test plan or other reason)
Summary: JMeter should fail with non-zero when test execution fails (due to missing te...
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.1.1
Hardware: Macintosh All
: P2 minor (vote)
Target Milestone: JMETER_5.2
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2019-05-02 04:27 UTC by amer g
Modified: 2020-02-28 09:01 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description amer g 2019-05-02 04:27:16 UTC
nit: I'm on Mac OS X 10.14 but that wasn't available in your selection

problem: jmeter exits 0, e.g. success, despite not being able to open the test plan. this results in pipeline jobs consuming the false positive and promoting a revision under the presumption that load testing completed successfully

expected behavior: if test plan could not be opened, jmeter exits with non-zero

steps to reproduce:

```
% jmeter -n -t somefilenamethatisntatestplan.jmx ; echo $?
Could not open somefilenamethatisntatestplan.jmx
0
```

i've looked through the commandline options and cannot see a flag that would allow it to run in a stricter fashion (e.g. failing non-zero on "could not open"). please advise. many thanks!

/a
Comment 1 UbikLoadPack support 2019-05-06 10:14:17 UTC
Hello,
Just for information, we're working on a fix and will contribute a PR soon.

Regards
Comment 2 Felix Schumacher 2019-05-12 08:34:50 UTC
Just saw that there is a PR 456 that could be used. I haven't seen UbikLoads answer and worked on this, too. My solution was pretty similar to the PR except that it used a ConfigurationException instead of a FileNotFoundException.

Are you working on a more complete solution than just checking for file existance?
Comment 3 Philippe Mouawad 2019-05-12 14:56:44 UTC
(In reply to Felix Schumacher from comment #2)
> Just saw that there is a PR 456 that could be used. I haven't seen UbikLoads
> answer and worked on this, too. My solution was pretty similar to the PR
> except that it used a ConfigurationException instead of a
> FileNotFoundException.
> 
> Are you working on a more complete solution than just checking for file
> existance?

Hi Felix,

Yes we're working on a little more complete solution and will provide a test case also.

Regards
Comment 4 Philippe Mouawad 2019-05-13 10:02:33 UTC
Hello Felix,

PR:

https://github.com/apache/jmeter/pull/458


I let you review it and merge it as you'll have an external eye.

Thanks
Regards
Comment 5 Philippe Mouawad 2019-05-21 08:33:06 UTC
Author: pmouawad
Date: Tue May 21 08:32:36 2019
New Revision: 1859615

URL: http://svn.apache.org/viewvc?rev=1859615&view=rev
Log:
Bug 63394 - JMeter should fail with non-zero when test execution fails (due to missing test plan or other reason)

Contributed by UbikLoadPack

This closes #458
This closes #456
Bugzilla Id: 63394

Added:
    jmeter/trunk/test/src/org/apache/jmeter/JMeterTest.java   (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
    jmeter/trunk/xdocs/changes.xml
Comment 6 Konstantin Kalinin 2020-02-28 09:01:03 UTC
Let me continue the discussion. The fix covers only "missing test plan" but not "other reason" mentioned in the summary.

It would also be nice to have a non-zero exit code for the situation of CSV and other data files unavailability that leads to test interruption.

E.g., I'm trying to read non-existent CSV using the CSV Data Set Config element.

2020-02-28 11:35:46,665 INFO o.a.j.s.FileServer: Stored: 123.csv
2020-02-28 11:35:46,666 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: Could not read file header line for file 123.csv
	at org.apache.jmeter.services.FileServer.reserveFile(FileServer.java:284) ~[ApacheJMeter_core.jar:5.2.1]
	at org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java:189) ~[ApacheJMeter_components.jar:5.2.1]
	at org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:399) ~[ApacheJMeter_core.jar:5.2.1]
	at org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:391) ~[ApacheJMeter_core.jar:5.2.1]
...
2020-02-28 11:35:46,752 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2020-02-28 11:35:46,754 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
...
Comment 7 The ASF infrastructure team 2022-09-24 20:38:16 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5057