td 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/ChangeLog +5 -0
- data/README.rdoc +1 -0
- data/lib/td/command/job.rb +8 -1
- data/lib/td/version.rb +1 -1
- data/spec/td/command/connector_spec.rb +122 -51
- data/spec/td/command/job_spec.rb +17 -3
- data/td.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e20abc2bf25fadf9daeac46efc09aa0278f9d8cb
|
4
|
+
data.tar.gz: 83dfdb2445a9279810a3c651f979fc8b1af12ae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a78076ea4a0b05fdd923980e63e0a7836e9dac065baa76a16358e5b6b5cd3043f6f8a792f67ef5ed8ad01782ff237fa042b356d9685502cee1cb678412dba08
|
7
|
+
data.tar.gz: 4c25dd9af339f532470e8d32322c50bbcdce1b987cd2891269f3dae1bc38688a0a43963d97d210473217ca26787b2ba9d05990283b6904a6dd6044e94714ab36
|
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
= Treasure Data command line tool
|
2
2
|
{<img src="https://travis-ci.org/treasure-data/td.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/treasure-data/td]
|
3
|
+
{<img src="https://ci.appveyor.com/api/projects/status/github/treasure-data/td?branch=master&svg=true" alt="appveyor" />}[https://ci.appveyor.com/project/treasure-data/td/branch/master]
|
3
4
|
{<img src="https://coveralls.io/repos/treasure-data/td/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/treasure-data/td?branch=master]
|
4
5
|
|
5
6
|
This CUI utility wraps the {Ruby Client Library td-client-ruby}[https://github.com/treasure-data/td-client-ruby]
|
data/lib/td/command/job.rb
CHANGED
@@ -510,7 +510,14 @@ private
|
|
510
510
|
end
|
511
511
|
|
512
512
|
def sanitize_infinite_value(v)
|
513
|
-
|
513
|
+
case v
|
514
|
+
when Float
|
515
|
+
v.finite? ? v : v.to_s
|
516
|
+
when Hash, Array
|
517
|
+
Marshal.load(Marshal.dump(v), ->(x){(x.is_a?(Float) && !x.finite?) ? x.to_s : x})
|
518
|
+
else
|
519
|
+
v
|
520
|
+
end
|
514
521
|
end
|
515
522
|
|
516
523
|
def job_priority_name_of(id)
|
data/lib/td/version.rb
CHANGED
@@ -5,21 +5,42 @@ require 'td/command/connector'
|
|
5
5
|
|
6
6
|
module TreasureData::Command
|
7
7
|
describe 'connector commands' do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
let :command do
|
9
|
+
Class.new { include TreasureData::Command }.new
|
10
|
+
end
|
11
|
+
let(:bulk_load_yaml) { File.join("spec", "td", "fixture", "bulk_load.yml") }
|
12
|
+
let(:stdout_io) { StringIO.new }
|
13
|
+
let(:stderr_io) { StringIO.new }
|
14
|
+
|
15
|
+
around do |example|
|
16
|
+
stdout = $stdout.dup
|
17
|
+
stderr = $stderr.dup
|
18
|
+
|
19
|
+
begin
|
20
|
+
$stdout = stdout_io
|
21
|
+
$stderr = stderr_io
|
22
|
+
|
23
|
+
example.run
|
24
|
+
ensure
|
25
|
+
$stdout = stdout
|
26
|
+
$stderr = stderr
|
11
27
|
end
|
28
|
+
end
|
12
29
|
|
30
|
+
describe '#connector_guess' do
|
13
31
|
describe 'guess plugins' do
|
14
32
|
let(:guess_plugins) { %w(json query_string) }
|
15
|
-
|
16
|
-
let(:
|
17
|
-
let(:out_file) { Tempfile.new('out.yml').tap{|f| f.close } }
|
18
|
-
|
33
|
+
let(:stdout_io) { StringIO.new }
|
34
|
+
let(:stderr_io) { StringIO.new }
|
19
35
|
let(:option) {
|
20
36
|
List::CommandParser.new("connector:guess", ["config"], [], nil, [in_file.path, '-o', out_file.path, '--guess', guess_plugins.join(',')], true)
|
21
37
|
}
|
22
|
-
let(:
|
38
|
+
let(:response) {
|
39
|
+
{'config' => {'in' => {}, 'out' => {}}}
|
40
|
+
}
|
41
|
+
let(:client) { double(:client) }
|
42
|
+
let(:in_file) { Tempfile.new('in.yml').tap{|f| f.close } }
|
43
|
+
let(:out_file) { Tempfile.new('out.yml').tap{|f| f.close } }
|
23
44
|
|
24
45
|
before do
|
25
46
|
command.stub(:get_client).and_return(client)
|
@@ -46,27 +67,37 @@ module TreasureData::Command
|
|
46
67
|
command.connector_guess(option)
|
47
68
|
end
|
48
69
|
end
|
49
|
-
end
|
50
70
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
71
|
+
describe 'output config' do
|
72
|
+
let(:out_file) { Tempfile.new('out.yml').tap(&:close) }
|
73
|
+
let(:bulk_load_yaml) { File.join("spec", "td", "fixture", "bulk_load.yml") }
|
74
|
+
let(:option) {
|
75
|
+
List::CommandParser.new("connector:guess", ['config'], %w(access-id access-secret source out), nil, [bulk_load_yaml, '-o', out_file.path], true)
|
76
|
+
}
|
77
|
+
let(:response) {
|
78
|
+
{'config' => {'in' => {}, 'out' => {}}}
|
79
|
+
}
|
80
|
+
let(:client) {
|
81
|
+
double(:client, bulk_load_guess: response)
|
82
|
+
}
|
55
83
|
|
56
|
-
|
57
|
-
|
58
|
-
|
84
|
+
before do
|
85
|
+
command.stub(:get_client).and_return(client)
|
86
|
+
command.connector_guess(option)
|
87
|
+
end
|
59
88
|
|
60
|
-
|
61
|
-
|
89
|
+
it 'output yaml has [in, out] key' do
|
90
|
+
expect(YAML.load_file(out_file.path).keys).to eq(%w(in out))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
62
94
|
|
63
|
-
|
64
|
-
|
95
|
+
describe '#connector_preview' do
|
96
|
+
subject do
|
97
|
+
op = List::CommandParser.new("connector:preview", ["config"], [], nil, [bulk_load_yaml], true)
|
98
|
+
command.connector_preview(op)
|
65
99
|
|
66
|
-
|
67
|
-
ensure
|
68
|
-
$stdout = backup
|
69
|
-
end
|
100
|
+
stdout_io.string
|
70
101
|
end
|
71
102
|
|
72
103
|
let(:preview_result) do
|
@@ -97,30 +128,10 @@ module TreasureData::Command
|
|
97
128
|
end
|
98
129
|
|
99
130
|
describe '#connector_issue' do
|
100
|
-
let :command do
|
101
|
-
Class.new { include TreasureData::Command }.new
|
102
|
-
end
|
103
|
-
|
104
|
-
let(:stderr_io) do
|
105
|
-
StringIO.new
|
106
|
-
end
|
107
|
-
|
108
131
|
subject do
|
109
|
-
backup = $stdout.dup
|
110
|
-
stderr_backup = $stderr.dup
|
111
|
-
buf = StringIO.new
|
112
|
-
|
113
|
-
begin
|
114
|
-
$stdout = buf
|
115
|
-
$stderr = stderr_io
|
116
|
-
|
117
132
|
command.connector_issue(option)
|
118
133
|
|
119
|
-
|
120
|
-
ensure
|
121
|
-
$stdout = backup
|
122
|
-
$stderr = stderr_backup
|
123
|
-
end
|
134
|
+
stdout_io.string
|
124
135
|
end
|
125
136
|
|
126
137
|
describe 'queueing job' do
|
@@ -176,9 +187,6 @@ module TreasureData::Command
|
|
176
187
|
describe '#connector_run' do
|
177
188
|
include_context 'quiet_out'
|
178
189
|
|
179
|
-
let :command do
|
180
|
-
Class.new { include TreasureData::Command }.new
|
181
|
-
end
|
182
190
|
let(:client) { double(:client) }
|
183
191
|
let(:job_name) { 'job_1' }
|
184
192
|
|
@@ -218,9 +226,6 @@ module TreasureData::Command
|
|
218
226
|
describe 'connector history' do
|
219
227
|
include_context 'quiet_out'
|
220
228
|
|
221
|
-
let :command do
|
222
|
-
Class.new { include TreasureData::Command }.new
|
223
|
-
end
|
224
229
|
let(:name) { 'connector_test' }
|
225
230
|
|
226
231
|
subject do
|
@@ -282,5 +287,71 @@ module TreasureData::Command
|
|
282
287
|
end
|
283
288
|
end
|
284
289
|
end
|
290
|
+
|
291
|
+
describe '#connector_list' do
|
292
|
+
let(:option) {
|
293
|
+
List::CommandParser.new("connector:list", [], [], nil, [], true)
|
294
|
+
}
|
295
|
+
let(:response) {
|
296
|
+
[{
|
297
|
+
'name' => 'daily_mysql_import',
|
298
|
+
'cron' => '10 0 * * *',
|
299
|
+
'timezone' => 'UTC',
|
300
|
+
'delay' => 0,
|
301
|
+
'database' => 'td_sample_db',
|
302
|
+
'table' => 'td_sample_table',
|
303
|
+
'config' => {'type' => 'mysql'},
|
304
|
+
}]
|
305
|
+
}
|
306
|
+
let(:client) {
|
307
|
+
double(:client, bulk_load_list: response)
|
308
|
+
}
|
309
|
+
|
310
|
+
before do
|
311
|
+
command.stub(:get_client).and_return(client)
|
312
|
+
command.connector_list(option)
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'show list use table format' do
|
316
|
+
expect(stdout_io.string).to include <<-EOL
|
317
|
+
| daily_mysql_import | 10 0 * * * | UTC | 0 | td_sample_db | td_sample_table |
|
318
|
+
EOL
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
describe '#connector_create' do
|
323
|
+
let(:name) { 'daily_mysql_import' }
|
324
|
+
let(:cron) { '10 0 * * *' }
|
325
|
+
let(:database) { 'td_sample_db' }
|
326
|
+
let(:table) { 'td_sample_table' }
|
327
|
+
let(:config_file) {
|
328
|
+
Tempfile.new('config.json').tap {|tf|
|
329
|
+
tf.puts({}.to_json)
|
330
|
+
tf.close
|
331
|
+
}
|
332
|
+
}
|
333
|
+
let(:option) {
|
334
|
+
List::CommandParser.new("connector:create", %w(name cron database table config_file), [], nil, [name, cron, database, table, config_file.path], true)
|
335
|
+
}
|
336
|
+
let(:response) {
|
337
|
+
{'name' => name, 'cron' => cron, 'timezone' => 'UTC', 'delay' => 0, 'database' => database, 'table' => table, 'config' => ''}
|
338
|
+
}
|
339
|
+
let(:client) {
|
340
|
+
double(:client, bulk_load_create: response)
|
341
|
+
}
|
342
|
+
|
343
|
+
before do
|
344
|
+
command.stub(:get_table)
|
345
|
+
command.stub(:get_client).and_return(client)
|
346
|
+
command.connector_create(option)
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'show create result' do
|
350
|
+
expect(stdout_io.string).to include name
|
351
|
+
expect(stdout_io.string).to include cron
|
352
|
+
expect(stdout_io.string).to include database
|
353
|
+
expect(stdout_io.string).to include table
|
354
|
+
end
|
355
|
+
end
|
285
356
|
end
|
286
357
|
end
|
data/spec/td/command/job_spec.rb
CHANGED
@@ -232,7 +232,13 @@ module TreasureData::Command
|
|
232
232
|
let :job do
|
233
233
|
job = TreasureData::Job.new(nil, 12345, 'hive', 'select * from employee')
|
234
234
|
job.instance_eval do
|
235
|
-
|
235
|
+
inf = Float::INFINITY
|
236
|
+
nan = Float::NAN
|
237
|
+
@result = [
|
238
|
+
[[nan, inf, -inf], 1],
|
239
|
+
[[[nan, inf, -inf], 5.0, {key:6}], 2],
|
240
|
+
[["7", 8.0, {key:9}], 3],
|
241
|
+
]
|
236
242
|
@result_size = 3
|
237
243
|
@status = 'success'
|
238
244
|
end
|
@@ -245,12 +251,20 @@ module TreasureData::Command
|
|
245
251
|
|
246
252
|
it 'supports csv output' do
|
247
253
|
command.send(:show_result, job, file, nil, 'csv')
|
248
|
-
File.read(file.path).should ==
|
254
|
+
File.read(file.path).should == <<text
|
255
|
+
"""NaN""","""Infinity""","""-Infinity"""
|
256
|
+
"[""NaN"",""Infinity"",""-Infinity""]",5.0,"{""key"":6}"
|
257
|
+
7,8.0,"{""key"":9}"
|
258
|
+
text
|
249
259
|
end
|
250
260
|
|
251
261
|
it 'supports tsv output' do
|
252
262
|
command.send(:show_result, job, file, nil, 'tsv')
|
253
|
-
File.read(file.path).should ==
|
263
|
+
File.read(file.path).should == <<text
|
264
|
+
"NaN"\t"Infinity"\t"-Infinity"
|
265
|
+
["NaN","Infinity","-Infinity"]\t5.0\t{"key":6}
|
266
|
+
7\t8.0\t{"key":9}
|
267
|
+
text
|
254
268
|
end
|
255
269
|
end
|
256
270
|
end
|
data/td.gemspec
CHANGED
@@ -17,11 +17,11 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
gem.required_ruby_version = '>= 1.9'
|
19
19
|
|
20
|
-
gem.add_dependency "msgpack", [">= 0.4.4", "!= 0.5.0", "!= 0.5.1", "!= 0.5.2", "!= 0.5.3", "< 0.
|
20
|
+
gem.add_dependency "msgpack", [">= 0.4.4", "!= 0.5.0", "!= 0.5.1", "!= 0.5.2", "!= 0.5.3", "< 0.8.0"]
|
21
21
|
gem.add_dependency "yajl-ruby", "~> 1.1"
|
22
22
|
gem.add_dependency "hirb", ">= 0.4.5"
|
23
23
|
gem.add_dependency "parallel", "~> 0.6.1"
|
24
|
-
gem.add_dependency "td-client", "~> 0.8.
|
24
|
+
gem.add_dependency "td-client", "~> 0.8.78"
|
25
25
|
gem.add_dependency "td-logger", "~> 0.3.21"
|
26
26
|
gem.add_dependency "rubyzip", "~> 1.1.7"
|
27
27
|
gem.add_dependency "zip-zip", "~> 0.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Treasure Data, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: 0.5.3
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
34
|
+
version: 0.8.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
version: 0.5.3
|
54
54
|
- - "<"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.8.0
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: yajl-ruby
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,14 +102,14 @@ dependencies:
|
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.8.
|
105
|
+
version: 0.8.78
|
106
106
|
type: :runtime
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.8.
|
112
|
+
version: 0.8.78
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: td-logger
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|