internethakai 0.2.0 → 0.2.1

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.
data/CHANGES CHANGED
@@ -1,12 +1,16 @@
1
+ 0.2.1:
2
+ * 実行時オプションのバグを修正
3
+ * -g オプション、-n オプションを追加
4
+
1
5
  0.2.0:
2
6
  * accesslog2yml を削除
3
- * hakaigen を追加
4
- * <b>重要</b>: concurrency を max_scenario に、fork を max_process に、変更しました(しばらくは後方互換性を残します)
7
+ * 設定ファイル生成スクリプトhakaigen を追加
8
+ * <b>重要</b>: concurrency を max_scenario に、fork を max_process に、変更しました(しばらくは後方互換性を残します)
5
9
 
6
10
  0.1.9:
7
11
  * 変数の記号を変更
8
- * <b>重要</b>: %%VAR%% という変数が使えなくなります。かわりに %(VAR)% を使用してください。
9
- * WAITする機能を追加。
12
+ * <b>重要</b>: %%VAR%% という変数が使えなくなります。かわりに %(VAR)% を使用してください
13
+ * WAITする機能を追加
10
14
 
11
15
  0.1.8:
12
16
  * オプション追加。cookie に対応
data/README CHANGED
@@ -27,6 +27,8 @@ CUIで使える高機能な負荷試験スクリプトです。
27
27
  [-r --max-request] リクエスト並列数を上書きします。
28
28
  [-s --max-scenario] シナリオ並列数を上書きします。
29
29
  [-l --loop] ループ回数を上書きします。
30
+ [-g --log-level] ログレベルを上書きします。
31
+ [-n --nth] n 番目のアクションだけを実行(0から数えます)。
30
32
  [--test] テストモードで実行。テストモードで実行すると、強制的に並列数を1、ループ数1、1プロセス、ログレベル3で実行します。リクエストが正常に送られているか確認するために使用できます。
31
33
 
32
34
 
@@ -14,7 +14,7 @@ GEMSPEC = Gem::Specification::new do |s|
14
14
  s.executables = Dir::glob("bin/*").map{|f|File::basename(f)}
15
15
  s.default_executable = 'internethakai'
16
16
  s.add_dependency('rev', '= 0.3.2')
17
- s.add_dependency('iobuffer', '= 0.1.3')
17
+ s.add_dependency('iobuffer', '>= 0.1.3')
18
18
  s.files = Dir::glob("{lib,bin}/**/*") + ['internethakai.gemspec']
19
19
  s.has_rdoc = true
20
20
  s.rdoc_options = %w(-U -c UTF-8 -t "インターネット破壊" --main=README)
@@ -251,7 +251,7 @@ module InternetHakai
251
251
  flag = true
252
252
  puts "error: SIGINT"
253
253
  @pids.each do |pid|
254
- Process::kill(:USR2, pid)
254
+ Process::kill(:USR2, pid) if pid
255
255
  end
256
256
  }
257
257
  Signal::trap(:USR2){
@@ -1,11 +1,21 @@
1
1
  module InternetHakai
2
2
  class Main
3
3
  require 'optparse'
4
+ attr_reader :config
4
5
  def load_config configpath, basepath = nil, args = nil
5
- args ||= {}
6
+ if args
7
+ setting = {}
8
+ setting['loop'] = args[:loop] if args.has_key? :loop
9
+ setting['max_request'] = args[:max_request] if args.has_key? :max_request
10
+ setting['max_scenario'] = args[:concurrency] if args.has_key? :concurrency
11
+ setting['log_level'] = args[:log_level] if args.has_key? :log_level
12
+ else
13
+ setting = nil
14
+ end
15
+
6
16
  @basepath = basepath || File::dirname(configpath)
7
17
  @scenario_builder = ScenarioBuilder::new(nil)
8
- @scenario_builder.load(configpath)
18
+ @scenario_builder.load(configpath, setting)
9
19
  @scenario_handler = BaseHandler::get_handler("ScenarioHandler")
10
20
  @config = @scenario_builder.get_config
11
21
  BaseHandler::set_config(@config)
@@ -20,16 +30,16 @@ module InternetHakai
20
30
  start = starttime.strftime( '%Y%m%d_%H%M%S' )
21
31
  reporter.set_dir(@basepath)
22
32
  reporter.init_filename(start)
23
- @config['loop'] = args[:loop] if args.has_key? :loop
24
- @config['max_request'] = args[:max_request] if args.has_key? :max_request
25
- @config['max_scenario'] = args[:concurrency] if args.has_key? :concurrency
33
+ if args && args.has_key?(:action_nth)
34
+ @config['actions'] = @config['actions'][args[:action_nth], 1]
35
+ end
26
36
  if @test
27
37
  @config['loop'] = 1
28
38
  @config['max_request'] = 1
29
39
  @config['concurrency'] = 1
30
40
  @config['max_scenario'] = 1
41
+ @config['max_process'] = 1
31
42
  @config.delete('fork')
32
- @config.delete('max_process')
33
43
  @config['max_request_show'] = 1
34
44
  @config['max_scenario_show'] = 1
35
45
  @config['log_level'] = 3
@@ -47,13 +57,6 @@ module InternetHakai
47
57
  end
48
58
  def main config=nil
49
59
  #引数か、同じディレクトリの「scenario.yml」を読み込みます。
50
- if config.nil?
51
- config = ARGV[0]
52
- end
53
- unless config
54
- puts "Usage: #{File::basename($0)} SCENARIO"
55
- exit
56
- end
57
60
  args = {}
58
61
  @test = false
59
62
  opts = OptionParser.new("Usage: #{File::basename($0)} SCENARIO")
@@ -65,14 +68,20 @@ module InternetHakai
65
68
  opts.on("--test", "exec in testmode") do
66
69
  @test = true
67
70
  end
68
- opts.on('-l', '--loop' 'loop') do |loop|
69
- args[:loop] = loop
71
+ opts.on('-l NUM', '--loop' 'loop') do |loop|
72
+ args[:loop] = loop.to_i
70
73
  end
71
- opts.on('-s', '--max-scenario', 'max-scenario') do |conc|
72
- args[:concurrency] = conc
74
+ opts.on('-s NUM', '--max-scenario', 'max-scenario') do |conc|
75
+ args[:concurrency] = conc.to_o
73
76
  end
74
- opts.on('-r', '--max-request', 'max-request') do |mr|
75
- args[:max_request] = mr
77
+ opts.on('-r NUM', '--max-request', 'max-request') do |mr|
78
+ args[:max_request] = mr.to_i
79
+ end
80
+ opts.on('-g NUM', '--log-level', 'log-level') do |l|
81
+ args[:log_level] = l.to_i
82
+ end
83
+ opts.on('-n NUM', '--nth', 'run only nth action') do |l|
84
+ args[:action_nth] = l.to_i
76
85
  end
77
86
  opts.on_tail("-h", "--help", "show this message") do
78
87
  puts opts
@@ -80,6 +89,13 @@ module InternetHakai
80
89
  end
81
90
  opts.version = InternetHakai::VERSION
82
91
  opts.parse!(ARGV)
92
+ if config.nil?
93
+ config = ARGV[0]
94
+ end
95
+ unless config
96
+ puts "Usage: #{File::basename($0)} SCENARIO"
97
+ exit
98
+ end
83
99
 
84
100
  load_config config, nil, args
85
101
 
@@ -148,16 +148,16 @@ module InternetHakai
148
148
  ch = BaseHandler::get_class(@config["client_handler"])
149
149
  @config = ch::on_config_load(@config)
150
150
  end
151
- def load path
151
+ def load path, setting=nil
152
152
  begin
153
153
  basedir = File::expand_path(File::dirname(path))
154
154
  str = File::open(path){|io|io.read}
155
- load_config(str, basedir)
155
+ load_config(str, basedir, setting)
156
156
  rescue
157
157
  raise $!
158
158
  end
159
159
  end
160
- def load_config str, basedir='.'
160
+ def load_config str, basedir='.', setting=nil
161
161
  default_config = DEFAULT_CONFIG
162
162
  if(RUBY_VERSION.to_f >= 1.9)
163
163
  str.force_encoding('UTF-8')
@@ -167,6 +167,7 @@ module InternetHakai
167
167
  str.gsub!('%%BASEDIR%%', basedir)
168
168
  end
169
169
  @config = ::YAML::load(str)
170
+ @config = @config.merge(setting) if setting
170
171
  raise "invalid file" unless @config
171
172
  @config = default_config.merge(@config)
172
173
  prepare_config
data/lib/internethakai.rb CHANGED
@@ -18,7 +18,7 @@ require 'internethakai/generator'
18
18
 
19
19
  module InternetHakai
20
20
  # インターネット破壊
21
- VERSION = '0.2.0'
21
+ VERSION = '0.2.1'
22
22
  GET="GET"
23
23
  POST="POST"
24
24
  PUT="PUT"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - takada-at
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-26 00:00:00 +09:00
17
+ date: 2011-03-04 00:00:00 +09:00
18
18
  default_executable: internethakai
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -36,7 +36,7 @@ dependencies:
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "="
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  segments:
42
42
  - 0