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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 844dda6ec2ea3ce703d94332d12f07da0c8130c1
4
- data.tar.gz: 2fe722894996e437589d8841b06dcf0d8da0534d
3
+ metadata.gz: 970c5f406c0af987d8e95c4d569eaab07d0d77a6
4
+ data.tar.gz: ca5eca4aa36566e7d30197ea564c2727f59ccbf4
5
5
  SHA512:
6
- metadata.gz: 467d5b84f145cb1a2e11926b8332018eed6734fab410bbae0271873b4481ea1755c2aea6475e5835cef7981fb3f18605e7a5b8fbe983f9a608fbd2ca447ae12c
7
- data.tar.gz: c1fae992cf68fc41304fe1b8326e8d1782ca29ad0b6b52828bb75553f66df0b4aa85ebf33888a0516e04929bbcdd1a406abb6cd25f68b77a043741e1c79ccb3b
6
+ metadata.gz: 992fb900d224d6d31f16becc16d9f3bdc06c08903fc679f937ebae31bd55ca9543b15302d34d5d78813edf23a3ca4e0ecf412eee67e809583f7351e7612b903a
7
+ data.tar.gz: 4f6e03812097e77553e7ea8e3941837922a2cbd76cbc5bd05449de0562863960cafa515ed945b85e262ed26c824c030c6ff93c6c340dc6655c24301ef0c98520
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 2015-08-03 version 0.11.14
2
+
3
+ * fix connector:history was broken.
4
+
1
5
  == 2015-07-29 version 0.11.13
2
6
 
3
7
  * allow retry when `td query -w` fail show result.
@@ -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.job_id,
234
- :Status => e.status,
235
- :Records => e.records,
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.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,
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
@@ -1,3 +1,3 @@
1
1
  module TreasureData
2
- TOOLBELT_VERSION = '0.11.13'
2
+ TOOLBELT_VERSION = '0.11.14'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -47,3 +47,5 @@ def execute_td(command_line)
47
47
 
48
48
  [captured_stderr.string, captured_stdout.string]
49
49
  end
50
+
51
+ class CallSystemExitError < RuntimeError; end
@@ -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
- describe CommandExecutor do
8
- it 'executes command' do
9
- CommandExecutor.new(['echo'], nil).execute.exitstatus.should == 0
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
- it 'executes command' do
13
- expect {
14
- CommandExecutor.new(['exit', '1'], nil).execute
15
- }.to raise_error BulkImportExecutionError, /td-bulk-import\.log/
115
+ expect {
116
+ command.import_show(option)
117
+ }.to raise_error CallSystemExitError
118
+ end
16
119
  end
17
120
 
18
- it 'terminates process on timeout' do
19
- CommandExecutor.new(['sleep', '1'], 2).execute
20
- expect {
21
- CommandExecutor.new(['sleep', '2'], 1).execute
22
- }.to raise_error BulkImportExecutionError, /timed out/
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, 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, 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, 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, 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.73"
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.13
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-07-29 00:00:00.000000000 Z
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.73
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.73
112
+ version: 0.8.74
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: td-logger
115
115
  requirement: !ruby/object:Gem::Requirement