gatling-rake 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDFlZmM4N2QzZTBjYjA0Njk3ZDY2MzliODMwZWU3Y2I5MjI4ZDk2Yw==
4
+ NDNiYTY3OTA5MDZlMzljZGVhOGI0YjZkMmRmMDM2MTc3NDNlODNjMw==
5
5
  data.tar.gz: !binary |-
6
- Y2YzNmIyODRhMTMzYjg2OTE4ZTkzZjI4ZjEwMDAyMzE3NmRkNjU1YQ==
6
+ ODY3MmUwNTc1YzFhNjUxYWVmODUxNzU5NjI5ODUxN2I5NmY1NmQ3ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjY5Y2RmODZiYTZlMGVlNTM0MzU4Y2FlM2Q3YTVhZDY2NGE0ZjJkYWViNGQ1
10
- MGQ2Yzg4NzJlMWRiNzExM2Q5YmY5ZWIwZWY3ZGZmZTcyZTdiOGM5N2NiOThk
11
- ZWE3YWI4YjE0NGM5Yzc2MDAwNWZiZDA3ZWE2OGEyZDYwZjNkNDM=
9
+ MjZjMDUxMjM0NWM3OGI5NjYwNTA0M2ZkMmRjMWFkYzc2ODNkZjhmN2UxOTRl
10
+ MjMyMjE4ZTI5MzJlOWFlZDU1YzYxYzM5ZWY1NjgyMTVlNjM4YTcyMjU1NjMw
11
+ MTQ5MzAwNDRhMmFkY2QzNjJjZTgyNGFlOTU3YzIwN2U5ZGJjNjk=
12
12
  data.tar.gz: !binary |-
13
- NWRmNWRkMTZjYmU1ZTA3MWEyNmNjMjVhM2Q4YjBiZWE5ZTgzZDJkZTJiZTRm
14
- ODNkZDIyNjhkOWZkOWFlZWNlNGVmYmMwNDgwMzA4MzUyOTRiMGVlYmEwNmM0
15
- MGI0NzNlOTIxNTgyZTFlMTk2MDZmMWZjZDRhNDk2ZjJkNjVjNjg=
13
+ ZGE5YTBlZTA4NmM0OGI4YzJmYWUyZTM1YTA0NzdlZDIxMzAyZmYwNDA1MWY5
14
+ OWI4NjM5OWJhNjgwOTllOGMzM2RjZTYzNTk1MGI0NmE4YTI0MzYzZDU0ZDFm
15
+ M2I4YzZhNmUzY2FmNTkzMGQ3M2Y2NGQ3MTM4OTBhZWUxY2MyZDk=
@@ -1,5 +1,6 @@
1
1
  require_relative './src/Gatling'
2
2
  require_relative './src/Shell'
3
+ require_relative './src/ResultsRepository'
3
4
  include Rake::DSL
4
5
 
5
6
  def gatling(*args, &block)
@@ -19,7 +20,8 @@ class GatlingWrapper
19
20
  def run()
20
21
  configuration = GatlingConfiguration.new
21
22
  @block.call(configuration)
22
- Gatling.new(@shell).start(
23
+ results_repository = ResultsRepository.new(configuration.results_directory)
24
+ Gatling.new(@shell, results_repository).start(
23
25
  results_directory: configuration.results_directory,
24
26
  gatling_file_location: configuration.gatling_file_location,
25
27
  load_test_root: configuration.load_test_root,
@@ -1,17 +1,20 @@
1
1
  require_relative 'GatlingCommand'
2
+ require_relative 'ResultMonitor'
2
3
 
3
4
  module RakeGatling
4
5
  class Gatling
5
6
  include Commands
6
- def initialize(shell)
7
+ def initialize(shell, results_repository)
7
8
  @shell = shell
8
9
  @run_gatling = GatlingCommand.new(shell)
10
+ @result_monitor = ResultMonitor.new(results_repository)
9
11
  end
10
12
 
11
13
  def start(parameters)
12
14
  @shell.remove_directory(parameters[:results_directory])
13
15
  @run_gatling.execute(parameters)
14
16
  @shell.move_directory_contents_up(parameters[:results_directory])
17
+ @result_monitor.check_for_failures
15
18
  end
16
19
  end
17
20
  end
@@ -0,0 +1,21 @@
1
+ module RakeGatling
2
+ class ResultMonitor
3
+ ERROR_MESSAGE = "Gatling results contain one or more KOs"
4
+
5
+ def initialize(results_repository)
6
+ @results_repository = results_repository
7
+ end
8
+
9
+ def check_for_failures
10
+ results = @results_repository.get
11
+ results.keys.each do |record_key|
12
+ record = results[record_key]
13
+ ko = record['ko']
14
+ raise KOsError, ERROR_MESSAGE if !ko.nil? && ko > 0
15
+ end
16
+ end
17
+ end
18
+
19
+ class KOsError < StandardError
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ require 'json'
2
+
3
+ module RakeGatling
4
+ class ResultsRepository
5
+ def initialize(results_directory)
6
+ @results_file = "#{results_directory}/js/global_stats.json"
7
+ end
8
+
9
+ def get
10
+ JSON.parse( IO.read(@results_file) )
11
+ end
12
+ end
13
+ end
@@ -11,10 +11,10 @@ module RakeGatling
11
11
  def move_directory_contents_up(location)
12
12
  directories = Dir.glob("#{location}/*")
13
13
  Dir.glob("#{location}/*/*") {
14
- |f| mv File.expand_path(f), location
14
+ |folder_object| mv File.expand_path(folder_object), location
15
15
  }
16
- directories.each do | f |
17
- rm_rf File.expand_path(f)
16
+ directories.each do | directory |
17
+ rm_rf File.expand_path(directory)
18
18
  end
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gatling-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - iainjmitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-15 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: iainjmitchell@gmail.com
@@ -20,6 +20,8 @@ files:
20
20
  - lib/src/Gatling.rb
21
21
  - lib/src/GatlingCommand.rb
22
22
  - lib/src/GatlingParameterBuilder.rb
23
+ - lib/src/ResultMonitor.rb
24
+ - lib/src/ResultsRepository.rb
23
25
  - lib/src/Shell.rb
24
26
  homepage: https://github.com/code-computerlove/gatling-rake
25
27
  licenses: