orc-cli 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cli/client_collector.rb +7 -1
- data/lib/cli/commands/test_suite_management.rb +44 -4
- data/lib/cli/consts.rb +1 -1
- data/lib/cli/runner.rb +11 -1
- data/lib/cli/version.rb +1 -1
- data/lib/cli.rb +2 -0
- metadata +2 -2
data/lib/cli/client_collector.rb
CHANGED
@@ -4,6 +4,7 @@ module CTT::Cli
|
|
4
4
|
class ClientCollector
|
5
5
|
|
6
6
|
def initialize(command, suite, runner)
|
7
|
+
@url = runner.url
|
7
8
|
@info = {}
|
8
9
|
@suite = suite
|
9
10
|
@suites = runner.suites
|
@@ -11,6 +12,7 @@ module CTT::Cli
|
|
11
12
|
|
12
13
|
@info[:suite] = @suite
|
13
14
|
@info[:command] = command
|
15
|
+
|
14
16
|
end
|
15
17
|
|
16
18
|
def post
|
@@ -23,7 +25,7 @@ module CTT::Cli
|
|
23
25
|
#retry 3 times
|
24
26
|
3.times do
|
25
27
|
begin
|
26
|
-
response = RestClient.post("#{
|
28
|
+
response = RestClient.post("#{@url}/upload", payload)
|
27
29
|
break if response.code == 200
|
28
30
|
rescue
|
29
31
|
end
|
@@ -33,6 +35,7 @@ module CTT::Cli
|
|
33
35
|
|
34
36
|
def collect
|
35
37
|
get_os
|
38
|
+
get_ruby_version
|
36
39
|
get_test_reports
|
37
40
|
get_uuid
|
38
41
|
get_timestamp
|
@@ -74,6 +77,9 @@ module CTT::Cli
|
|
74
77
|
end
|
75
78
|
end
|
76
79
|
|
80
|
+
def get_ruby_version
|
81
|
+
@info[:ruby_version] = `ruby -v`
|
82
|
+
end
|
77
83
|
|
78
84
|
def get_test_reports
|
79
85
|
suite_config_path = File.absolute_path(File.join(@suites.suites["suites"][@suite], TEST_SUITE_CONFIG_FILE))
|
@@ -16,10 +16,12 @@ module CTT::Cli::Command
|
|
16
16
|
pieces.insert(0, "") if pieces.size == 1
|
17
17
|
action, suite = pieces
|
18
18
|
|
19
|
-
@action
|
20
|
-
@suite
|
21
|
-
@configs
|
22
|
-
@suites
|
19
|
+
@action = action
|
20
|
+
@suite = suite
|
21
|
+
@configs = runner.configs
|
22
|
+
@suites = runner.suites
|
23
|
+
@url = runner.url
|
24
|
+
@log = runner.log
|
23
25
|
end
|
24
26
|
|
25
27
|
def run
|
@@ -115,6 +117,7 @@ module CTT::Cli::Command
|
|
115
117
|
end
|
116
118
|
|
117
119
|
def check_configuration
|
120
|
+
check_orc_version
|
118
121
|
unless @suites.suites["suites"].has_key?(@suite)
|
119
122
|
say("suite configure file: #{@suites.file} did not has key: #{@suite}")
|
120
123
|
exit(1)
|
@@ -184,5 +187,42 @@ module CTT::Cli::Command
|
|
184
187
|
end
|
185
188
|
@suite_configs
|
186
189
|
end
|
190
|
+
|
191
|
+
def check_orc_version
|
192
|
+
response = nil
|
193
|
+
#retry 3 times
|
194
|
+
3.times do
|
195
|
+
begin
|
196
|
+
response = RestClient.get("#{@url}/version")
|
197
|
+
@log.debug("check version. response body: #{response.to_s}, response code: #{response.code}")
|
198
|
+
break if response.code == 200
|
199
|
+
rescue Exception => e
|
200
|
+
@log.error("check version. url: #{@url}/version, #{e.to_s}")
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
if response
|
205
|
+
target = JSON.parse(response.to_s)["version"]
|
206
|
+
if need_upgrade?(VERSION, target)
|
207
|
+
say("your orc-cli gem should be >= #{target}. Abort!", :red)
|
208
|
+
exit(1)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def need_upgrade?(current, target)
|
214
|
+
upgrade = false
|
215
|
+
curr_vers = current.split(".")
|
216
|
+
targ_vers = target.split(".")
|
217
|
+
|
218
|
+
targ_vers.each_with_index do |item, index|
|
219
|
+
if item > curr_vers[index]
|
220
|
+
upgrade = true
|
221
|
+
break
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
upgrade
|
226
|
+
end
|
187
227
|
end
|
188
228
|
end
|
data/lib/cli/consts.rb
CHANGED
data/lib/cli/runner.rb
CHANGED
@@ -3,7 +3,7 @@ module CTT::Cli
|
|
3
3
|
|
4
4
|
class Runner
|
5
5
|
|
6
|
-
attr_reader :commands, :uuid, :command
|
6
|
+
attr_reader :commands, :uuid, :command, :url, :log
|
7
7
|
attr_accessor :configs, :suites
|
8
8
|
|
9
9
|
|
@@ -22,6 +22,9 @@ module CTT::Cli
|
|
22
22
|
@commands = @configs.commands
|
23
23
|
@suites = Suites.new
|
24
24
|
@uuid = UUIDTools::UUID.random_create
|
25
|
+
@log = Logger.new(File.join(ENV["HOME"], ".orc/orc.log"), 'weekly')
|
26
|
+
@url = ENV['ORC_RESULTS_SERVER_URL'] ?
|
27
|
+
format_url(ENV['ORC_RESULTS_SERVER_URL']) : RESULTS_SERVER_URL
|
25
28
|
end
|
26
29
|
|
27
30
|
def run
|
@@ -130,5 +133,12 @@ module CTT::Cli
|
|
130
133
|
nil
|
131
134
|
end
|
132
135
|
end
|
136
|
+
|
137
|
+
def format_url(url)
|
138
|
+
unless url =~ /^http/
|
139
|
+
url = "http://#{url}"
|
140
|
+
end
|
141
|
+
url
|
142
|
+
end
|
133
143
|
end
|
134
144
|
end
|
data/lib/cli/version.rb
CHANGED
data/lib/cli.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orc-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|