td 0.11.13 → 0.11.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/lib/td/command/connector.rb +8 -8
- data/lib/td/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/td/command/import_spec.rb +168 -12
- data/spec/td/command/table_spec.rb +4 -4
- data/td.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 970c5f406c0af987d8e95c4d569eaab07d0d77a6
|
4
|
+
data.tar.gz: ca5eca4aa36566e7d30197ea564c2727f59ccbf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 992fb900d224d6d31f16becc16d9f3bdc06c08903fc679f937ebae31bd55ca9543b15302d34d5d78813edf23a3ca4e0ecf412eee67e809583f7351e7612b903a
|
7
|
+
data.tar.gz: 4f6e03812097e77553e7ea8e3941837922a2cbd76cbc5bd05449de0562863960cafa515ed945b85e262ed26c824c030c6ff93c6c340dc6655c24301ef0c98520
|
data/ChangeLog
CHANGED
data/lib/td/command/connector.rb
CHANGED
@@ -230,15 +230,15 @@ module Command
|
|
230
230
|
client = get_client()
|
231
231
|
rows = client.bulk_load_history(name).map { |e|
|
232
232
|
{
|
233
|
-
:JobID => e
|
234
|
-
:Status => e
|
235
|
-
:Records => e
|
233
|
+
:JobID => e['job_id'],
|
234
|
+
:Status => e['status'],
|
235
|
+
:Records => e['records'],
|
236
236
|
# TODO: td-client-ruby should retuan only name
|
237
|
-
:Database => e
|
238
|
-
:Table => e
|
239
|
-
:Priority => e
|
240
|
-
:Started => Time.at(e
|
241
|
-
:Duration => (e
|
237
|
+
:Database => e['database']['name'],
|
238
|
+
:Table => e['table']['name'],
|
239
|
+
:Priority => e['priority'],
|
240
|
+
:Started => Time.at(e['start_at']),
|
241
|
+
:Duration => (e['end_at'].nil? ? Time.now.to_i : e['end_at']) - e['start_at'],
|
242
242
|
}
|
243
243
|
}
|
244
244
|
$stdout.puts cmd_render_table(rows, :fields => fields, :render_format => op.render_format)
|
data/lib/td/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,25 +1,181 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'td/command/common'
|
3
|
+
require 'td/command/list'
|
3
4
|
require 'td/command/import'
|
4
5
|
|
5
6
|
module TreasureData::Command
|
6
7
|
describe 'import commands' do
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
let(:command) {
|
9
|
+
Class.new { include TreasureData::Command }.new
|
10
|
+
}
|
11
|
+
let(:stdout_io) { StringIO.new }
|
12
|
+
let(:stderr_io) { StringIO.new }
|
13
|
+
|
14
|
+
around do |example|
|
15
|
+
stdout = $stdout.dup
|
16
|
+
stderr = $stderr.dup
|
17
|
+
|
18
|
+
begin
|
19
|
+
$stdout = stdout_io
|
20
|
+
$stderr = stderr_io
|
21
|
+
|
22
|
+
example.run
|
23
|
+
ensure
|
24
|
+
$stdout = stdout
|
25
|
+
$stderr = stderr
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#import_list' do
|
30
|
+
let(:option) {
|
31
|
+
List::CommandParser.new("import:list", [], [], nil, [], true)
|
32
|
+
}
|
33
|
+
let(:database) { 'database' }
|
34
|
+
let(:table) { 'table' }
|
35
|
+
let(:response) {
|
36
|
+
[
|
37
|
+
double(:bulk_import,
|
38
|
+
name: 'bulk_import',
|
39
|
+
database: database,
|
40
|
+
table: table,
|
41
|
+
status: :committed,
|
42
|
+
upload_frozen?: true,
|
43
|
+
job_id: '123456',
|
44
|
+
valid_parts: '',
|
45
|
+
error_parts: '',
|
46
|
+
valid_records: '',
|
47
|
+
error_records: '',
|
48
|
+
)
|
49
|
+
]
|
50
|
+
}
|
51
|
+
|
52
|
+
before do
|
53
|
+
client = double(:client, bulk_imports: response)
|
54
|
+
command.stub(:get_client).and_return(client)
|
55
|
+
|
56
|
+
command.import_list(option)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'show import list' do
|
60
|
+
expect(stdout_io.string).to include [database, table].join('.')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#import_list' do
|
65
|
+
let(:option) {
|
66
|
+
List::CommandParser.new("import:list", [], [], nil, [], true)
|
67
|
+
}
|
68
|
+
let(:database) { 'database' }
|
69
|
+
let(:table) { 'table' }
|
70
|
+
let(:response) {
|
71
|
+
[
|
72
|
+
double(:bulk_import,
|
73
|
+
name: 'bulk_import',
|
74
|
+
database: database,
|
75
|
+
table: table,
|
76
|
+
status: :committed,
|
77
|
+
upload_frozen?: true,
|
78
|
+
job_id: '123456',
|
79
|
+
valid_parts: '',
|
80
|
+
error_parts: '',
|
81
|
+
valid_records: '',
|
82
|
+
error_records: '',
|
83
|
+
)
|
84
|
+
]
|
85
|
+
}
|
86
|
+
|
87
|
+
before do
|
88
|
+
client = double(:client, bulk_imports: response)
|
89
|
+
command.stub(:get_client).and_return(client)
|
90
|
+
|
91
|
+
command.import_list(option)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'show import list' do
|
95
|
+
expect(stdout_io.string).to include [database, table].join('.')
|
10
96
|
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#import_show' do
|
100
|
+
let(:import_name) { 'bulk_import' }
|
101
|
+
let(:option) {
|
102
|
+
List::CommandParser.new("import:show", ['name'], [], nil, [import_name], true)
|
103
|
+
}
|
104
|
+
let(:client) { double(:client) }
|
105
|
+
|
106
|
+
before do
|
107
|
+
command.stub(:get_client).and_return(client)
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'not exists import' do
|
111
|
+
it 'should be error' do
|
112
|
+
client.should_receive(:bulk_import).with(import_name).and_return(nil)
|
113
|
+
command.should_receive(:exit).with(1).and_return { raise CallSystemExitError }
|
11
114
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
115
|
+
expect {
|
116
|
+
command.import_show(option)
|
117
|
+
}.to raise_error CallSystemExitError
|
118
|
+
end
|
16
119
|
end
|
17
120
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
121
|
+
context 'exist import' do
|
122
|
+
let(:import_name) { 'bulk_import' }
|
123
|
+
let(:bulk_import) {
|
124
|
+
double(:bulk_import,
|
125
|
+
name: import_name,
|
126
|
+
database: 'database',
|
127
|
+
table: 'table',
|
128
|
+
status: :committed,
|
129
|
+
upload_frozen?: true,
|
130
|
+
job_id: '123456',
|
131
|
+
valid_parts: '',
|
132
|
+
error_parts: '',
|
133
|
+
valid_records: '',
|
134
|
+
error_records: '',
|
135
|
+
)
|
136
|
+
}
|
137
|
+
let(:bulk_import_parts) {
|
138
|
+
%w(part1 part2 part3)
|
139
|
+
}
|
140
|
+
|
141
|
+
before do
|
142
|
+
client.should_receive(:bulk_import).with(import_name).and_return(bulk_import)
|
143
|
+
client.should_receive(:list_bulk_import_parts).with(import_name).and_return(bulk_import_parts)
|
144
|
+
|
145
|
+
command.import_show(option)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'stderr should be include import name' do
|
149
|
+
expect(stderr_io.string).to include import_name
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'stdout should be include import parts' do
|
153
|
+
bulk_import_parts.each do |part|
|
154
|
+
expect(stdout_io.string).to include part
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe '#import_create' do
|
161
|
+
let(:import_name) { 'bulk_import' }
|
162
|
+
let(:database) { 'database' }
|
163
|
+
let(:table) { 'table' }
|
164
|
+
let(:option) {
|
165
|
+
List::CommandParser.new("import:create", %w(name, db_name, table_name), [], nil, [import_name, database, table], true)
|
166
|
+
}
|
167
|
+
let(:client) { double(:client) }
|
168
|
+
|
169
|
+
before do
|
170
|
+
command.stub(:get_client).and_return(client)
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'create bulk import' do
|
174
|
+
client.should_receive(:create_bulk_import).with(import_name, database, table, {})
|
175
|
+
|
176
|
+
command.import_create(option)
|
177
|
+
|
178
|
+
expect(stderr_io.string).to include import_name
|
23
179
|
end
|
24
180
|
end
|
25
181
|
end
|
@@ -17,7 +17,7 @@ module TreasureData::Command
|
|
17
17
|
create_tables = lambda {|db_name|
|
18
18
|
(1..6).map {|i|
|
19
19
|
schema = TreasureData::Schema.new.from_json(JSON.parse('[]'))
|
20
|
-
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, 500, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil
|
20
|
+
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, 500, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil)
|
21
21
|
}
|
22
22
|
}
|
23
23
|
db_tables = create_tables.call(db.name)
|
@@ -44,7 +44,7 @@ module TreasureData::Command
|
|
44
44
|
create_tables = lambda {|db_name|
|
45
45
|
(1..6).map {|i|
|
46
46
|
schema = TreasureData::Schema.new.from_json(JSON.parse('[]'))
|
47
|
-
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, 500, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil
|
47
|
+
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, 500, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil)
|
48
48
|
}
|
49
49
|
}
|
50
50
|
qo_db_tables = create_tables.call(qo_db.name)
|
@@ -92,7 +92,7 @@ module TreasureData::Command
|
|
92
92
|
create_tables = lambda {|db_name|
|
93
93
|
(1..6).map {|i|
|
94
94
|
schema = TreasureData::Schema.new.from_json(JSON.parse('[]'))
|
95
|
-
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, 500, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil
|
95
|
+
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, 500, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil)
|
96
96
|
}
|
97
97
|
}
|
98
98
|
qo_db_tables = create_tables.call(qo_db.name)
|
@@ -131,7 +131,7 @@ module TreasureData::Command
|
|
131
131
|
create_tables = lambda {|db_name|
|
132
132
|
(1..6).map {|i|
|
133
133
|
schema = TreasureData::Schema.new.from_json(JSON.parse('[]'))
|
134
|
-
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, number_raw, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil
|
134
|
+
TreasureData::Table.new(client, db_name, db_name + "_table_#{i}", 'log', schema, number_raw, Time.now.to_i, Time.now.to_i, 0, nil, nil, nil)
|
135
135
|
}
|
136
136
|
}
|
137
137
|
db_tables = create_tables.call(db.name)
|
data/td.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
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.74"
|
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.11.
|
4
|
+
version: 0.11.14
|
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: 2015-
|
11
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -102,14 +102,14 @@ dependencies:
|
|
102
102
|
requirements:
|
103
103
|
- - ~>
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.8.
|
105
|
+
version: 0.8.74
|
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.74
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: td-logger
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|