jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Miller <mark.o.mil...@gmail.com>
Subject Re: Easy way to test If file exists
Date Wed, 07 Nov 2012 19:29:39 GMT
One approach:

This sounds 'if-then-elsey' enough to me that I would lean towards
BeanShell or JSR223 samplers to implement it. (Caveat: my perspective is
biased towards single thread, functionally oriented use of JMeter).

I have a JSR223 sampler that I run when I am developing a test - It runs in
the setup threadgroup and makes a backup copy of the testplan.jmx file (I
had one too many jmx file corruptions).

JRuby would give you a nice concise path do do what you are looking to do.
I wrote a little blog post about setting up JRuby in JMeter
here<http://remembermakethingsbetter.blogspot.ca/2012/10/jruby-and-apache-jmeter.html>
.

My 'Backup Test Plan' sampler code is simple and fairly concise:

require 'fileutils'
begin
  $log.info("Backing up the current JMX Test Plan File: ${__TestPlanName}")
  jmxFile = File.expand_path(Dir.pwd + "/../testplans/${__TestPlanName}")

  #create a backup folder wherever we are
  Dir.mkdir(File.expand_path("./testplanbackups")) unless
File.exists?(File.expand_path("./testplanbackups"))

  #copy the file
  if File.file?(jmxFile)
    FileUtils.copy(jmxFile,
File.expand_path("./testplanbackups/${__TestPlanName}.${__time(yyyyMMdd-HHmmss)}"))
    $SampleResult.setResponseData("SUCCESS")
  else
    $SampleResult.setResponseData("ERROR - Failed to make a backup copy of
the current test plan. Didn't find the JMX file to copy.")
    $SampleResult.setErrorCount(1)
    $SampleResult.setResponseCode("404")
  end
rescue  => e
    $SampleResult.setResponseData("ERROR - Failed to make a backup copy of
the current test plan. \n\n JRuby reported: #{e.message}")
    $SampleResult.setErrorCount(1)
    $SampleResult.setResponseCode("500")
end




On Wed, Nov 7, 2012 at 9:23 AM, Walker, Russell <russell.walker@sap.com>wrote:

>  I have what I think should be a simple question, however, its one I’ve
> been unable to find a solution to anywhere.****
>
> I’m super  very familiar with JMeter so perhaps I’m trying to solve this
> the wrong way.****
>
> My primary issue is that I often forget to remove old collector logs after
> a test run and when I restart a new test the data gets appended to the old
> log and creates a graph that is nearly impossible to understand.  I was
> unable to find a setting in either the GUI or properties files which
> configured these counters to truncate old data.****
>
> My solution to this problem was to create a OS process sampler which zips
> up the old logs with a time stamp and then deletes them.  This works fine,
> however, I’d like to be able to check the following:****
>
> **a)      **The log files exist before zipping.****
>
> **b)      **The zip was successful before deleting the logs.****
>
> Any help would be greatly appreciated.****
>
> Thank you.****
>
> ** **
>
> ** **
>
> ** **
>
> [image: Description: Description: Description: Description:
> sap_09_logo.JPG]****
>
> *Russell Walker *| Staff Eng QA | Unwired Enterprise Platform****
>
> Telephone: (603)230-7143 | Mobile: (603)369-9362    ****
>
> 6 Loudon Rd, Suite 501, Concord, NH, 03301, USA****
>
> ** **
>
> ** **
>



-- 
Mark Miller
mark.o.miller@gmail.com
[cell]    403.690.5169
[home] 403.283.3974

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message