gas_load_tester 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63bf24d0e1745295a5cac7e77525b91eaa05b949
4
- data.tar.gz: 8643f94f09ba0e5f012ef675c35b464bdf794515
3
+ metadata.gz: 918752eef3cb87613c6cc409094209ed1f328ae1
4
+ data.tar.gz: 354fa0ab61aec5fe2cbd4c613b220a0d22bbff2b
5
5
  SHA512:
6
- metadata.gz: 1947cd2a087cf8e3d93f39b2d349ecbe7f94be70a7be4cb0696292de5b5a5d3862123f02819fd36b91b5fc1434878c70b865b25d1d110a5855921e27543f6d2e
7
- data.tar.gz: 7ee4f3e549cc3c1616eac32cd334002b5b188c8f0faac4672b7af60e7d61dfc24d8a13a6bd6ac50e496aaaf929be9506bbe09a82f3adce4e76e6e29e60112e4e
6
+ metadata.gz: e9dc2273e04f1f5b0793fe2245efc7fe2b85b9aa5931e6f391bdebd33e01e4d9e01e819f1d977fdde6a1f09a67264af7640e8e334ec926315ad495982375687a
7
+ data.tar.gz: 0ef6fdf4f06f7eb050bc5d7983d2c20484d60d92e22251b7a8f21946db413959917cb79d6cc4a6c7da0c9b7206da8ba703fca5a8a5234806ee70a3ba2e90739a
@@ -5,7 +5,7 @@ module GasLoadTester
5
5
 
6
6
  class ChartBuilder
7
7
  include Chartkick::Helper
8
- attr_accessor :file_name, :body
8
+ attr_accessor :file_name, :body, :header, :description
9
9
 
10
10
  DEFAULT_PAGE_HEAD = "<!DOCTYPE html>"\
11
11
  "<html>"\
@@ -23,7 +23,11 @@ module GasLoadTester
23
23
  def initialize(args = {})
24
24
  args ||= {}
25
25
  args[:file_name] ||= args['file_name']
26
+ args[:header] ||= args['header']
27
+ args[:description] ||= args['description']
26
28
  self.file_name = args[:file_name]
29
+ self.header = args[:header]
30
+ self.description = args[:description]
27
31
  end
28
32
 
29
33
  def save
@@ -38,23 +42,36 @@ module GasLoadTester
38
42
  end
39
43
 
40
44
  def build_body(test)
45
+ header_part = build_headpart || ""
46
+
41
47
  sum_body = build_sum_test(test)
42
48
 
43
- self.body = DEFAULT_PAGE_HEAD + sum_body + DEFAULT_PAGE_TAIL
49
+ self.body = DEFAULT_PAGE_HEAD + header_part + sum_body + DEFAULT_PAGE_TAIL
44
50
  end
45
51
 
46
52
  def build_group_body(group_test)
47
- sum_group_body = group_test.tests.collect{|test|
53
+ header_part = build_headpart || ""
54
+
55
+ sum_group_body = group_test.tests.select{|test|
56
+ test.is_run?
57
+ }.collect{|test|
48
58
  build_sum_test(test)
49
59
  }.join('<hr style="margin-top: 70px; margin-bottom: 70px;">')
50
60
 
51
61
  sum_group_table = build_sum_group_table(group_test)
52
62
 
53
- self.body = DEFAULT_PAGE_HEAD + sum_group_table + sum_group_body + DEFAULT_PAGE_TAIL
63
+ self.body = DEFAULT_PAGE_HEAD + header_part + sum_group_table + sum_group_body + DEFAULT_PAGE_TAIL
54
64
  end
55
65
 
56
66
  private
57
67
 
68
+ def build_headpart
69
+ "<div style=\"width: 100%;text-align: center;margin-top: 50px;\">
70
+ #{ header.nil? ? "" : "<span style=\"font-weight: bold;font-size: 20px;\">ah ah</span>" }
71
+ #{ description.nil? ? "" : description.split("\n").collect{|text| "<p>#{text.to_s}</p>" }.join }
72
+ </div><hr style=\"margin-top: 70px; margin-bottom: 70px;\">" if !self.header.nil? || !self.description.nil?
73
+ end
74
+
58
75
  def build_sum_group_table(group_test)
59
76
  "<div style=\"width: 100%; text-align: center; margin-top: 20px; margin-bottom: 20px;\">
60
77
  <span style=\"align: center; font-weight: bold; font-size: 20px;\">Comparison summary</span>
@@ -76,7 +93,7 @@ module GasLoadTester
76
93
  <th width=\"15%\" style=\"border: 1px solid black; border-collapse: collapse;\">error</th>
77
94
  </tr>
78
95
  #{
79
- group_data = group_test.tests.collect{|test|
96
+ group_data = group_test.tests.select{|test| test.is_run? }.collect{|test|
80
97
  [
81
98
  test.client,
82
99
  test.time,
@@ -15,19 +15,29 @@ module GasLoadTester
15
15
  def run(args = {}, &block)
16
16
  args[:output] ||= args['output']
17
17
  args[:file_name] ||= args['file_name']
18
+ args[:header] ||= args['header']
19
+ args[:description] ||= args['description']
20
+ args[:stop_when_error] ||= args['stop_when_error']
21
+ args[:error_count_to_stop] ||= args['error_count_to_stop']
22
+ error_counter = 0
18
23
  not_run_tests = self.tests.select{|test| !test.is_run? }
19
24
  not_run_tests.each_with_index do |test, index|
20
25
  print "[#{index+1}/#{not_run_tests.count}] "
21
26
  test.run(nil, &block) unless test.is_run?
27
+ error_counter += 1 if error_counter >= 1
28
+ break if error_counter >= (args[:error_count_to_stop] || 3)
29
+ if args[:stop_when_error] == true || !args[:error_count_to_stop].nil?
30
+ error_counter = 1 if error_counter == 0 && test.summary_error > 0
31
+ end
22
32
  end
23
33
  if args[:output]
24
- export_file({file_name: args[:file_name]})
34
+ export_file({file_name: args[:file_name], header: args[:header], description: args[:description]})
25
35
  end
26
36
  end
27
37
 
28
38
  def export_file(args = {})
29
39
  file = args[:file_name] || ''
30
- chart_builder = GasLoadTester::ChartBuilder.new(file_name: file)
40
+ chart_builder = GasLoadTester::ChartBuilder.new(file_name: file, header: args[:header], description: args[:description])
31
41
  chart_builder.build_group_body(self)
32
42
  chart_builder.save
33
43
  end
@@ -27,6 +27,8 @@ module GasLoadTester
27
27
  args ||= {}
28
28
  args[:output] ||= args['output']
29
29
  args[:file_name] ||= args['file_name']
30
+ args[:header] ||= args['header']
31
+ args[:description] ||= args['description']
30
32
  puts "Running test (client: #{self.client}, time: #{self.time})"
31
33
  @progressbar = ProgressBar.create(
32
34
  :title => "Load test",
@@ -38,7 +40,7 @@ module GasLoadTester
38
40
  )
39
41
  load_test(block)
40
42
  if args[:output]
41
- export_file({file_name: args[:file_name]})
43
+ export_file({file_name: args[:file_name], header: args[:header], description: args[:description]})
42
44
  end
43
45
  ensure
44
46
  @run = true
@@ -55,7 +57,7 @@ module GasLoadTester
55
57
  def export_file(args = {})
56
58
  args ||= {}
57
59
  file = args[:file_name] || ''
58
- chart_builder = GasLoadTester::ChartBuilder.new(file_name: file)
60
+ chart_builder = GasLoadTester::ChartBuilder.new(file_name: file, header: args[:header], description: args[:description])
59
61
  chart_builder.build_body(self)
60
62
  chart_builder.save
61
63
  end
@@ -1,3 +1,3 @@
1
1
  module GasLoadTester
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gas_load_tester
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanapat Sainak