drntest 1.1.9 → 1.2.0

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: d31944a909862aa00b606d449ea226c0dce448e5
4
- data.tar.gz: 87a72b69c7c79df457a39e3569ce8d04787ab805
3
+ metadata.gz: 27b62dbe0468bc4888089e7039c970faaaffe456
4
+ data.tar.gz: fd4b33fde9987e00a7121d54c4865ce34d7d8f77
5
5
  SHA512:
6
- metadata.gz: ec0642a7e4af6688491e30a1754f5c71d48cdc5c8392499dedeccd23532e934c503c5f2d749943c696ebf304495c1a8948861a5a7b0b809335784600642498ee
7
- data.tar.gz: be5b39894f8844cd6f26ced91b370e4dec9bff201a7bdf5d524601ca49e6812c187a05d92f59631375414c9284186b5710c9543e8eb4d330c2a2d4f815f4c86b
6
+ metadata.gz: 434fa2cdae0a39c5578b99ebcfca1465a0eb426ab6bf92892a65090cad6ba7750d7cc400ef21afecd9f4cfcfd512258cd386d18f261ae2983cd2207c317fd2a2
7
+ data.tar.gz: a17db9680240ec2e0a246797bf39936404c69359c46e5d2f4fb6f94093cc81b3875461002d7e7636e5d862e6ac83455a679426008bb4afdad86e90be9159c1ef
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 Droonga Project
1
+ # Copyright (C) 2013-2015 Droonga Project
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -55,4 +55,47 @@ module Drntest
55
55
  @version = version
56
56
  end
57
57
  end
58
+
59
+ class EnableCompletionDirective < Directive
60
+ end
61
+
62
+ class DisableCompletionDirective < Directive
63
+ end
64
+
65
+ class EnableValidationDirective < Directive
66
+ end
67
+
68
+ class DisableValidationDirective < Directive
69
+ end
70
+
71
+ class SubscribeUntil < Directive
72
+ attr_reader :max_messages, :timeout_seconds
73
+
74
+ DEFAULT_TIMEOUT_SECONDS = 1
75
+
76
+ ONE_MINUTE_IN_SECONDS = 60
77
+ ONE_HOUR_IN_SECONDS = ONE_MINUTE_IN_SECONDS * 60
78
+
79
+ def initialize(parameters)
80
+ @max_messages = nil
81
+ @timeout_seconds = nil
82
+
83
+ parameters.each do |parameter|
84
+ case parameter
85
+ when /\A(\d+)(?:messages|msg)?\z/
86
+ @max_messages = $1.to_i
87
+ when /\A(\d+\.?|\.\d+|\d+\.\d+)s(?:ec(?:onds?)?)?\z/
88
+ @timeout_seconds = $1.to_f
89
+ when /\A(\d+\.?|\.\d+|\d+\.\d+)m(?:inutes?)?\z/
90
+ @timeout_seconds = $1.to_f * ONE_MINUTE_IN_SECONDS
91
+ when /\A(\d+\.?|\.\d+|\d+\.\d+)h(?:ours?)?\z/
92
+ @timeout_seconds = $1.to_f * ONE_HOUR_IN_SECONDS
93
+ end
94
+ end
95
+
96
+ if @max_messages.nil? and @timeout_seconds.nil?
97
+ @timeout_seconds = DEFAULT_TIMEOUT_SECONDS
98
+ end
99
+ end
100
+ end
58
101
  end
@@ -39,6 +39,8 @@ module Drntest
39
39
  normalize_groonga_command_response!(body)
40
40
  elsif search_command?
41
41
  normalize_search_command_response!(body)
42
+ elsif system_status_command?
43
+ normalize_system_status_command_response!(body)
42
44
  end
43
45
  end
44
46
 
@@ -61,6 +63,10 @@ module Drntest
61
63
  @request["type"] == "search"
62
64
  end
63
65
 
66
+ def system_status_command?
67
+ @request["type"] == "system.status"
68
+ end
69
+
64
70
  def normalize_droonga_message_envelope!(message)
65
71
  normalized_in_reply_to = "request-id"
66
72
  in_reply_to = message["inReplyTo"]
@@ -70,6 +76,10 @@ module Drntest
70
76
  normalize_error_body!(message["body"])
71
77
  end
72
78
 
79
+ if message["date"].is_a?(String)
80
+ message["date"] = "0000-00-00T00:00:00.000000Z"
81
+ end
82
+
73
83
  errors = message["errors"]
74
84
  message["errors"] = normalize_errors(errors) if errors
75
85
  end
@@ -87,6 +97,7 @@ module Drntest
87
97
  end
88
98
 
89
99
  def normalize_error_body!(body)
100
+ return body unless body
90
101
  case body["name"]
91
102
  when "InvalidValue"
92
103
  message = body["message"]
@@ -97,6 +108,7 @@ module Drntest
97
108
  end
98
109
 
99
110
  def normalize_groonga_command_response!(response)
111
+ return unless response.is_a?(Array)
100
112
  normalize_groonga_command_header!(response[0])
101
113
  normalize_groonga_command_body!(response[1..-1])
102
114
  end
@@ -116,7 +128,8 @@ module Drntest
116
128
  end
117
129
 
118
130
  def normalize_groonga_command_body!(body)
119
- return if not body.is_a?(Array) or body.empty?
131
+ return unless body.is_a?(Array)
132
+ return if body.empty?
120
133
 
121
134
  case @request["type"]
122
135
  when "table_list"
@@ -128,6 +141,8 @@ module Drntest
128
141
 
129
142
  TABLE_PATH_COLUMN_INDEX = 2
130
143
  def normalize_groonga_table_list_command_body!(body)
144
+ return unless body.is_a?(Array)
145
+ return if body.empty?
131
146
  tables = body[0][1..-1]
132
147
  return unless tables.is_a?(Array)
133
148
  tables.each do |table|
@@ -139,6 +154,8 @@ module Drntest
139
154
 
140
155
  COLUMN_PATH_COLUMN_INDEX = 2
141
156
  def normalize_groonga_column_list_command_body!(body)
157
+ return unless body.is_a?(Array)
158
+ return if body.empty?
142
159
  columns = body[0][1..-1]
143
160
  return unless columns.is_a?(Array)
144
161
  columns.each do |column|
@@ -157,6 +174,13 @@ module Drntest
157
174
  end
158
175
  end
159
176
 
177
+ def normalize_system_status_command_response!(response)
178
+ reporter = response["reporter"]
179
+ if reporter
180
+ response["reporter"] = reporter.sub(/:\d+/, ":0")
181
+ end
182
+ end
183
+
160
184
  def valid_start_time?(start_time)
161
185
  start_time.is_a?(Float) and start_time > 0
162
186
  end
@@ -21,9 +21,13 @@ module Drntest
21
21
  end
22
22
 
23
23
  def normalize
24
- return @responses unless dump_command?
25
-
26
- normalize_dump_responses
24
+ if dump_command?
25
+ normalize_dump_responses
26
+ elsif system_absorb_data_command?
27
+ normalize_system_absorb_data_responses
28
+ else
29
+ @responses
30
+ end
27
31
  end
28
32
 
29
33
  private
@@ -34,6 +38,7 @@ module Drntest
34
38
  DUMP_TYPE_ORDER = [
35
39
  "dump.start",
36
40
  "dump.result",
41
+ "dump.forecast",
37
42
  "dump.table",
38
43
  "dump.column",
39
44
  "dump.record",
@@ -41,10 +46,15 @@ module Drntest
41
46
  ]
42
47
  def normalize_dump_responses
43
48
  @responses.sort_by do |response|
49
+ if response["error"] and response["response"]
50
+ response = response["response"]
51
+ end
44
52
  type = response["type"]
45
- type_order = DUMP_TYPE_ORDER.index(type)
53
+ type_order = DUMP_TYPE_ORDER.index(type) || -1
46
54
  body = response["body"]
47
55
  case type
56
+ when "dump.forecast"
57
+ body_order = body["nMessages"]
48
58
  when "dump.table"
49
59
  body_order = body["name"]
50
60
  when "dump.column"
@@ -57,5 +67,33 @@ module Drntest
57
67
  [type_order, body_order]
58
68
  end
59
69
  end
70
+
71
+ def system_absorb_data_command?
72
+ @request["type"] == "system.absorb-data"
73
+ end
74
+
75
+ SYSTEM_ABSORB_DATA_ORDER = [
76
+ "system.absorb.start",
77
+ "system.absorb.result",
78
+ "system.absorb.progress",
79
+ "system.absorb.end",
80
+ ]
81
+ def normalize_system_absorb_data_responses
82
+ @responses.sort_by do |response|
83
+ if response["error"] and response["response"]
84
+ response = response["response"]
85
+ end
86
+ type = response["type"]
87
+ type_order = SYSTEM_ABSORB_DATA_ORDER.index(type) || -1
88
+ body = response["body"]
89
+ case type
90
+ when "system.absorb.progress"
91
+ body_order = body["nProcessedMessages"]
92
+ else
93
+ body_order = ""
94
+ end
95
+ [type_order, body_order]
96
+ end
97
+ end
60
98
  end
61
99
  end
@@ -63,6 +63,8 @@ module Drntest
63
63
  @requests = []
64
64
  @responses = []
65
65
  @logging = true
66
+ @completion = nil
67
+ @validation = nil
66
68
  end
67
69
 
68
70
  def execute(operation)
@@ -98,19 +100,45 @@ module Drntest
98
100
  @results.omit(message)
99
101
  abort_execution
100
102
  end
103
+ when EnableCompletionDirective
104
+ @completion = true
105
+ when DisableCompletionDirective
106
+ @completion = false
107
+ when EnableValidationDirective
108
+ @validation = true
109
+ when DisableValidationDirective
110
+ @validation = false
111
+ when SubscribeUntil
112
+ @subscribe = true
113
+ @timeout_seconds = directive.timeout_seconds
114
+ @max_messages = directive.max_messages
101
115
  end
102
116
  end
103
117
 
104
118
  def execute_request(request)
119
+ options = {}
120
+ options[:completion] = @completion unless @completion.nil?
121
+ options[:validation] = @validation unless @validation.nil?
122
+
105
123
  if @logging
106
124
  responses = []
107
- request_process = @client.request(request) do |raw_response|
108
- responses << clean_response(request, raw_response)
125
+ if @subscribe
126
+ options[:subscription_timeout] = @timeout_seconds
127
+ options[:max_messages] = @max_messages
128
+ request_process = @client.subscribe(request, options) do |raw_response|
129
+ responses << clean_response(request, raw_response)
130
+ end
131
+ request_process.wait
132
+ @subscribe = false
133
+ else
134
+ request_process = @client.request(request, options) do |raw_response|
135
+ responses << clean_response(request, raw_response)
136
+ end
137
+ request_process.wait
109
138
  end
110
- request_process.wait
111
139
  @responses.concat(normalize_responses(request, responses))
112
140
  else
113
- @requests << @client.request(request) do
141
+ @requests << @client.request(request, options) do
114
142
  end
115
143
  end
116
144
  end
@@ -91,6 +91,16 @@ module Drntest
91
91
  OmitDirective.new(options.first)
92
92
  when :require_catalog_version
93
93
  RequireCatalogVersionDirective.new(Integer(options.first))
94
+ when :enable_completion
95
+ EnableCompletionDirective.new
96
+ when :disable_completion
97
+ DisableCompletionDirective.new
98
+ when :enable_validation
99
+ EnableValidationDirective.new
100
+ when :disable_validation
101
+ DisableValidationDirective.new
102
+ when :subscribe_until
103
+ SubscribeUntil.new(options)
94
104
  else
95
105
  UnknownDirective.new(type, options)
96
106
  end
@@ -26,6 +26,9 @@ require "drntest/engine"
26
26
  require "drntest/input-error"
27
27
 
28
28
  module Drntest
29
+ class EngineStalled < StandardError
30
+ end
31
+
29
32
  class TestRunner
30
33
  def initialize(config, target)
31
34
  @config = config
@@ -39,6 +42,7 @@ module Drntest
39
42
  @engine.start(@target_path)
40
43
  begin
41
44
  results = process_requests
45
+ raise EngineStalled.new if results.status == :no_response
42
46
  ensure
43
47
  @engine.stop
44
48
  end
@@ -14,5 +14,5 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  module Drntest
17
- VERSION = "1.1.9"
17
+ VERSION = "1.2.0"
18
18
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drntest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droonga Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-13 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: yajl-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: droonga-client
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.1.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: packnga
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: kramdown
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: ''
@@ -145,17 +145,17 @@ require_paths:
145
145
  - lib
146
146
  required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
- - - ">="
148
+ - - '>='
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
- - - ">="
153
+ - - '>='
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.2.2
158
+ rubygems_version: 2.4.1
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Drntest is a testing framework for Droonga. You can write a test for Droonga