flydata 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flydata-core/lib/flydata-core/table_def/redshift_table_def.rb +1 -1
- data/flydata-core/spec/table_def/redshift_table_def_spec.rb +6 -0
- data/flydata.gemspec +5 -3
- data/lib/flydata/command/base.rb +4 -0
- data/lib/flydata/command/exclusive_runnable.rb +74 -0
- data/lib/flydata/command/helper.rb +2 -1
- data/lib/flydata/command/restart.rb +1 -0
- data/lib/flydata/command/start.rb +1 -0
- data/lib/flydata/command/stop.rb +1 -0
- data/lib/flydata/command/sync.rb +21 -14
- data/spec/flydata/command/exclusive_runnable_spec.rb +129 -0
- data/spec/flydata/command/sync_spec.rb +13 -10
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0882affb434c077a4d37f2127b7ca91aab356603
|
4
|
+
data.tar.gz: 83d402b1b492178d70a4bb6f71a2ada8c515e43e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add50b1e166a42d338de4c386272e207bc4089b4ba746cdf52f961f8a344ecd0a676b6411bd0552239b6960d208d51bb9ac13f01448f85704a55a8805ec87104
|
7
|
+
data.tar.gz: 3028bb9b76675e98bf31eac4c6226ceb1abd001f019fa5702403632d29310b79b7e1a7b3f21a5e5bf71146ef3a778dfa62efe9db47c6f792f2552d505245bf44
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.5
|
@@ -334,6 +334,12 @@ EOT
|
|
334
334
|
it_behaves_like *examples
|
335
335
|
end
|
336
336
|
|
337
|
+
context 'when default_value is CURRENT_TIMESTAMP(6)' do
|
338
|
+
let(:default_value) { 'CURRENT_TIMESTAMP(6)' }
|
339
|
+
let(:default_value_sql) { "SYSDATE" }
|
340
|
+
it_behaves_like *examples
|
341
|
+
end
|
342
|
+
|
337
343
|
context 'when default_value is 0000-00-00 00:00:00' do
|
338
344
|
let(:default_value) { "'0000-00-00 00:00:00'" }
|
339
345
|
let(:default_value_sql) { "'0001-01-01 00:00:00.000000'" }
|
data/flydata.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flydata 0.5.
|
5
|
+
# stub: flydata 0.5.5 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.5"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
14
|
-
s.date = "2015-09-
|
14
|
+
s.date = "2015-09-11"
|
15
15
|
s.description = "FlyData Agent"
|
16
16
|
s.email = "sysadmin@flydata.com"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -101,6 +101,7 @@ Gem::Specification.new do |s|
|
|
101
101
|
"lib/flydata/command/conf.rb",
|
102
102
|
"lib/flydata/command/crontab.rb",
|
103
103
|
"lib/flydata/command/encrypt.rb",
|
104
|
+
"lib/flydata/command/exclusive_runnable.rb",
|
104
105
|
"lib/flydata/command/helper.rb",
|
105
106
|
"lib/flydata/command/kill_all.rb",
|
106
107
|
"lib/flydata/command/login.rb",
|
@@ -174,6 +175,7 @@ Gem::Specification.new do |s|
|
|
174
175
|
"spec/flydata/command/conf_spec.rb",
|
175
176
|
"spec/flydata/command/crontab_spec.rb",
|
176
177
|
"spec/flydata/command/encrypt_spec.rb",
|
178
|
+
"spec/flydata/command/exclusive_runnable_spec.rb",
|
177
179
|
"spec/flydata/command/helper_spec.rb",
|
178
180
|
"spec/flydata/command/kill_all_spec.rb",
|
179
181
|
"spec/flydata/command/login_spec.rb",
|
data/lib/flydata/command/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'slop'
|
2
2
|
require 'flydata/api_client'
|
3
3
|
require 'flydata/command_loggable'
|
4
|
+
require 'flydata/command/exclusive_runnable'
|
4
5
|
require 'flydata/preference/data_entry_preference'
|
5
6
|
|
6
7
|
|
@@ -8,6 +9,9 @@ module Flydata
|
|
8
9
|
module Command
|
9
10
|
class Base
|
10
11
|
include CommandLoggable
|
12
|
+
include ExclusiveRunnable
|
13
|
+
|
14
|
+
self.exclusive_run_home = FLYDATA_HOME
|
11
15
|
|
12
16
|
def initialize(options = Slop.new)
|
13
17
|
@api_client = ApiClient.instance
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Flydata
|
4
|
+
module Command
|
5
|
+
|
6
|
+
module ExclusiveRunnable
|
7
|
+
def self.included base
|
8
|
+
base.extend ClassMethods
|
9
|
+
|
10
|
+
base.class_variable_set(:@@exclusive_run_home, ENV['HOME'])
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def run_exclusive(method, options = {})
|
15
|
+
saved_method = :"__#{method}"
|
16
|
+
alias_method saved_method, method
|
17
|
+
|
18
|
+
define_method(method) do |*args|
|
19
|
+
result = nil
|
20
|
+
exclusive_run_info = nil
|
21
|
+
begin
|
22
|
+
info = self.class.load_exclusive_run_info
|
23
|
+
if info
|
24
|
+
raise "Command `#{info['command']}` is already running. Wait until the command completes or stop the command. (pid:#{info['pid']})"
|
25
|
+
end
|
26
|
+
exclusive_run_info = { command: self.class.command(method, options), pid: Process.pid }
|
27
|
+
self.class.save_exclusive_run_info(exclusive_run_info)
|
28
|
+
result = send(saved_method, *args)
|
29
|
+
ensure
|
30
|
+
self.class.delete_exclusive_run_info if exclusive_run_info
|
31
|
+
end
|
32
|
+
result
|
33
|
+
end
|
34
|
+
end
|
35
|
+
def exclusive_run_home
|
36
|
+
@@exclusive_run_home
|
37
|
+
end
|
38
|
+
def exclusive_run_home=(value)
|
39
|
+
@@exclusive_run_home = value
|
40
|
+
end
|
41
|
+
def exclusive_run_info_path
|
42
|
+
File.join(exclusive_run_home, "exclusive_run.info")
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_exclusive_run_info
|
46
|
+
path = exclusive_run_info_path
|
47
|
+
return nil unless File.exists?(path)
|
48
|
+
|
49
|
+
JSON.parse(File.open(path){|f| f.read})
|
50
|
+
end
|
51
|
+
|
52
|
+
def save_exclusive_run_info(info)
|
53
|
+
path = exclusive_run_info_path
|
54
|
+
File.open(path, "w"){|f| f.write(info.to_json)}
|
55
|
+
end
|
56
|
+
|
57
|
+
def delete_exclusive_run_info
|
58
|
+
path = exclusive_run_info_path
|
59
|
+
File.delete(path) if File.exists?(path)
|
60
|
+
end
|
61
|
+
|
62
|
+
def command(subcommand, options = {})
|
63
|
+
return options[:command] if options[:command]
|
64
|
+
|
65
|
+
modules = self.name.split('::')
|
66
|
+
|
67
|
+
cmd = modules.last.downcase
|
68
|
+
subcommand == :run ? cmd : "#{cmd}:#{subcommand}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
data/lib/flydata/command/stop.rb
CHANGED
data/lib/flydata/command/sync.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'fiber'
|
2
1
|
require 'msgpack'
|
3
2
|
require 'mysql2'
|
4
3
|
require 'rest_client'
|
@@ -23,6 +22,7 @@ module Flydata
|
|
23
22
|
|
24
23
|
class Sync < Base
|
25
24
|
include Helpers
|
25
|
+
|
26
26
|
INSERT_PROGRESS_INTERVAL = 1000
|
27
27
|
SERVER_DATA_PROCESSING_TIMEOUT = 3600 # seconds
|
28
28
|
|
@@ -101,6 +101,7 @@ module Flydata
|
|
101
101
|
last_message = ALL_DONE_MESSAGE_TEMPLATE % [redshift_console_url, dashboard_url]
|
102
102
|
log_info_stdout(last_message)
|
103
103
|
end
|
104
|
+
run_exclusive :run
|
104
105
|
|
105
106
|
# Public method
|
106
107
|
# - Called from Sender#start/restart
|
@@ -136,6 +137,7 @@ EOS
|
|
136
137
|
end
|
137
138
|
log_info_stdout("Buffers have been flushed and the sender process has been stopped.")
|
138
139
|
end
|
140
|
+
run_exclusive :flush
|
139
141
|
|
140
142
|
# Command: flydata sync:reset
|
141
143
|
# - Arguments
|
@@ -204,7 +206,7 @@ EOS
|
|
204
206
|
sync_fm.table_rev_file_paths(*@input_tables),
|
205
207
|
sync_fm.table_ddl_file_paths(*@input_tables)
|
206
208
|
]
|
207
|
-
new_tables_after_reset = @
|
209
|
+
new_tables_after_reset = @unsynced_tables + @input_tables
|
208
210
|
if @input_tables.empty? or @full_tables.empty? or @full_tables.all?{|ft| new_tables_after_reset.include?(ft)}
|
209
211
|
delete_files << sync_fm.binlog_path
|
210
212
|
delete_files << sync_fm.sent_binlog_path
|
@@ -215,6 +217,7 @@ EOS
|
|
215
217
|
sync_fm.close
|
216
218
|
log_info_stdout("Reset completed successfully.")
|
217
219
|
end
|
220
|
+
run_exclusive :reset
|
218
221
|
|
219
222
|
# Depricated Command: flydata sync:skip
|
220
223
|
# skip initial sync
|
@@ -228,6 +231,7 @@ EOS
|
|
228
231
|
log_info_stdout("-> #{binlog_path}")
|
229
232
|
log_info_stdout("Run 'flydata start' to start continuous sync.")
|
230
233
|
end
|
234
|
+
run_exclusive :skip
|
231
235
|
|
232
236
|
# Command: flydata sync:generate_table_ddl
|
233
237
|
# - Arguments
|
@@ -249,10 +253,11 @@ EOS
|
|
249
253
|
Flydata::MysqlCompatibilityCheck.new(dp, de['mysql_data_entry_preference']).check
|
250
254
|
|
251
255
|
# Set instance variables
|
252
|
-
set_current_tables(tables,
|
256
|
+
set_current_tables(tables, include_all_tables: true)
|
253
257
|
|
254
258
|
do_generate_table_ddl(de)
|
255
259
|
end
|
260
|
+
run_exclusive :generate_table_ddl
|
256
261
|
|
257
262
|
# Command: flydata sync:fix_binlogpos
|
258
263
|
# - Arguments
|
@@ -301,6 +306,7 @@ EOS
|
|
301
306
|
sync_fm.save_binlog(new_binlog_info)
|
302
307
|
log_info_stdout("Done!")
|
303
308
|
end
|
309
|
+
run_exclusive :fix_binlogpos
|
304
310
|
|
305
311
|
private
|
306
312
|
|
@@ -317,9 +323,9 @@ EOS
|
|
317
323
|
# #initial_sync knows where to resume from.
|
318
324
|
log_info_stdout("Resuming the initial sync...")
|
319
325
|
initial_sync(de, options.merge(sync_resumed: true))
|
320
|
-
elsif !@
|
326
|
+
elsif !@unsynced_tables.empty?
|
321
327
|
show_purpose_name
|
322
|
-
unsynced_table_message = "We've noticed that these tables have not been synced yet: #{@
|
328
|
+
unsynced_table_message = "We've noticed that these tables have not been synced yet: #{@unsynced_tables.join(", ")}\n"
|
323
329
|
unless @ddl_tables.empty?
|
324
330
|
unsynced_table_message <<
|
325
331
|
" WARNING: We've noticed that at least one of these tables have not had their DDL generated yet.\n" +
|
@@ -847,7 +853,7 @@ EOM
|
|
847
853
|
schema_name = (de['schema_name'] || nil)
|
848
854
|
mp = de['mysql_data_entry_preference']
|
849
855
|
|
850
|
-
tables = opts.all_tables? ? @full_tables : (@input_tables.empty? ? @
|
856
|
+
tables = opts.all_tables? ? @full_tables : (@input_tables.empty? ? @unsynced_tables : @input_tables)
|
851
857
|
|
852
858
|
raise "There are no valid unsynced tables, if you want to just get ddl for all tables, please run \`flydata sync:generate_table_ddl --all-tables\`" if tables.empty?
|
853
859
|
|
@@ -897,8 +903,7 @@ EOS
|
|
897
903
|
end
|
898
904
|
end
|
899
905
|
|
900
|
-
|
901
|
-
fixed_tables.each {|table| table_validity_hash[table] = nil }
|
906
|
+
tables_without_error.each {|table| table_validity_hash[table] = nil }
|
902
907
|
flydata.data_entry.update_table_validity(de['id'], {updated_tables: table_validity_hash}) unless table_validity_hash.empty?
|
903
908
|
|
904
909
|
sync_fm = create_sync_file_manager(de)
|
@@ -944,16 +949,17 @@ Thank you for using FlyData!
|
|
944
949
|
sync_info = sync_fm.load_sync_info
|
945
950
|
sync_resumed = options[:resume] && !!sync_info
|
946
951
|
|
947
|
-
|
948
|
-
@full_tables = options[:
|
952
|
+
#full_tables will either include all tables including invalid tables or all valid tables that aren't new tables
|
953
|
+
@full_tables = options[:include_all_tables] ? de['mysql_data_entry_preference']['tables'] + de['mysql_data_entry_preference']['invalid_tables'] :
|
954
|
+
de['mysql_data_entry_preference']['tables'] - de['mysql_data_entry_preference']['new_tables']
|
949
955
|
|
950
|
-
@
|
956
|
+
@unsynced_tables = sync_fm.get_new_table_list(@full_tables, "pos") # Get list of tables that do not have a .pos file
|
951
957
|
@ddl_tables = sync_fm.get_new_table_list(@full_tables, "generated_ddl")
|
952
958
|
|
953
959
|
@input_tables = sync_resumed ? sync_info[:tables] : input_tables
|
954
960
|
@input_tables ||= []
|
955
961
|
@full_initial_sync = sync_resumed ? sync_info[:initial_sync] :
|
956
|
-
(@
|
962
|
+
(@unsynced_tables == @full_tables)
|
957
963
|
|
958
964
|
sync_fm.close
|
959
965
|
|
@@ -980,7 +986,7 @@ Thank you for using FlyData!
|
|
980
986
|
elsif !@input_tables.empty?
|
981
987
|
@input_tables
|
982
988
|
else
|
983
|
-
@
|
989
|
+
@unsynced_tables
|
984
990
|
end
|
985
991
|
end
|
986
992
|
|
@@ -991,7 +997,7 @@ Thank you for using FlyData!
|
|
991
997
|
elsif !@input_tables.empty?
|
992
998
|
@input_tables
|
993
999
|
else
|
994
|
-
@
|
1000
|
+
@unsynced_tables
|
995
1001
|
end
|
996
1002
|
end
|
997
1003
|
|
@@ -1012,6 +1018,7 @@ Thank you for using FlyData!
|
|
1012
1018
|
mp['tables'] = mp['tables'].split(",").uniq
|
1013
1019
|
end
|
1014
1020
|
mp['invalid_tables'] = mp['invalid_tables'].kind_of?(String) ? mp['invalid_tables'].split(",").uniq : []
|
1021
|
+
mp['new_tables'] = mp['new_tables'].kind_of?(String) ? mp['new_tables'].split(",").uniq : []
|
1015
1022
|
|
1016
1023
|
unless mp['ssl_ca_content'].to_s.strip.empty?
|
1017
1024
|
sync_fm = create_sync_file_manager(de)
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'flydata/command/exclusive_runnable'
|
3
|
+
|
4
|
+
module Flydata
|
5
|
+
module Command
|
6
|
+
|
7
|
+
class Exclusiverunnabletest
|
8
|
+
include ExclusiveRunnable
|
9
|
+
|
10
|
+
def long_running_command
|
11
|
+
sleep 0.2
|
12
|
+
"result1"
|
13
|
+
end
|
14
|
+
run_exclusive :long_running_command
|
15
|
+
|
16
|
+
def normal_method_call
|
17
|
+
"result2"
|
18
|
+
end
|
19
|
+
run_exclusive :normal_method_call
|
20
|
+
end
|
21
|
+
|
22
|
+
describe Exclusiverunnabletest do
|
23
|
+
let(:subject_object) { described_class.new }
|
24
|
+
|
25
|
+
let(:file_path) { "/tmp" }
|
26
|
+
let(:lock_file) { File.join(file_path, 'exclusive_run.info') }
|
27
|
+
let(:lock_file_content) { { command: 'exclusiverunnabletest:long_running_command', pid: 234 } }
|
28
|
+
|
29
|
+
before do
|
30
|
+
described_class.exclusive_run_home = file_path
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#normal_method_call' do
|
34
|
+
subject { subject_object.normal_method_call }
|
35
|
+
it "runs the method body normally" do
|
36
|
+
is_expected.to eq "result2"
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when a lock file already exists" do
|
40
|
+
before do
|
41
|
+
File.open(lock_file, "w") {|f| f.write(lock_file_content)}
|
42
|
+
end
|
43
|
+
|
44
|
+
it "does not delete the lock file" do
|
45
|
+
expect{ subject }.to raise_error
|
46
|
+
|
47
|
+
expect(File.exists?(lock_file)).to eq true
|
48
|
+
end
|
49
|
+
|
50
|
+
after do
|
51
|
+
File.delete(lock_file) if File.exists?(lock_file)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#long_running_command' do
|
57
|
+
subject { subject_object.long_running_command }
|
58
|
+
context 'run alone' do
|
59
|
+
context "check while the command is running" do
|
60
|
+
it "creates a lock file" do
|
61
|
+
th = Thread.new{ subject }
|
62
|
+
|
63
|
+
sleep 0.1
|
64
|
+
|
65
|
+
expect(File.exists?(lock_file)).to eq true
|
66
|
+
|
67
|
+
th.join
|
68
|
+
end
|
69
|
+
end
|
70
|
+
context "check after the command is finished" do
|
71
|
+
it "creates a lock file but it's gone" do
|
72
|
+
th = Thread.new{ subject }
|
73
|
+
|
74
|
+
th.join
|
75
|
+
|
76
|
+
expect(File.exists?(lock_file)).to eq false
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'run two commands concurrently' do
|
82
|
+
it "raises an error for the second command" do
|
83
|
+
th = Thread.new{ subject }
|
84
|
+
sleep 0.1
|
85
|
+
expect{ subject_object.normal_method_call }.to raise_exception(
|
86
|
+
/`exclusiverunnabletest:long_running_command` is already running\..*\(pid: *[0-9]+\)/)
|
87
|
+
|
88
|
+
th.join
|
89
|
+
end
|
90
|
+
end
|
91
|
+
context 'run two commands sequentially' do
|
92
|
+
it "runs both commands successfully" do
|
93
|
+
th = Thread.new{ subject }
|
94
|
+
|
95
|
+
th.join
|
96
|
+
|
97
|
+
expect( subject_object.normal_method_call ).to eq "result2"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '.command' do
|
103
|
+
subject { described_class.command(method_symbol, options) }
|
104
|
+
|
105
|
+
let(:options) { {} }
|
106
|
+
context 'with :run' do
|
107
|
+
let(:method_symbol) { :run }
|
108
|
+
it 'uses the class name as the command' do
|
109
|
+
is_expected.to eq "exclusiverunnabletest"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
context 'with a method' do
|
113
|
+
let(:method_symbol) { :a_method }
|
114
|
+
it 'uses the class name and the method as the command ' do
|
115
|
+
is_expected.to eq "exclusiverunnabletest:a_method"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
context 'with a :command option' do
|
119
|
+
let(:options) { { command: 'another_command' } }
|
120
|
+
let(:method_symbol) { :a_method }
|
121
|
+
it 'uses the command given as an option' do
|
122
|
+
is_expected.to eq "another_command"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
@@ -33,8 +33,9 @@ module Flydata
|
|
33
33
|
"data_port_key"=>"a458c641",
|
34
34
|
"mysql_data_entry_preference" =>
|
35
35
|
{ "host"=>"localhost", "port"=>3306, "username"=>"masashi",
|
36
|
-
"password"=>"welcome", "database"=>"sync_test", "tables"=>["table1", "table2"],
|
36
|
+
"password"=>"welcome", "database"=>"sync_test", "tables"=>["table1", "table2", "table4"],
|
37
37
|
"invalid_tables"=>["table3"],
|
38
|
+
"new_tables"=>["table4"],
|
38
39
|
"mysqldump_dir"=>default_mysqldump_dir, "forwarder" => "tcpforwarder",
|
39
40
|
"data_servers"=>"localhost:9905" }
|
40
41
|
}
|
@@ -91,8 +92,9 @@ module Flydata
|
|
91
92
|
let (:db_byte) { 1 }
|
92
93
|
let (:disk_byte) { 100 }
|
93
94
|
before do
|
94
|
-
expect(subject).to receive(:flydata).and_return(flydata)
|
95
|
+
expect(subject).to receive(:flydata).and_return(flydata).at_least(:once)
|
95
96
|
expect(flydata).to receive(:data_port).and_return(dp)
|
97
|
+
allow(flydata).to receive(:data_entry).and_return(default_data_entry)
|
96
98
|
expect(dp).to receive(:get).and_return(default_data_port)
|
97
99
|
allow(File).to receive(:exists?).and_return(false)
|
98
100
|
expect(default_sync_fm).to receive(:load_dump_pos).and_return(default_dump_pos)
|
@@ -110,7 +112,7 @@ module Flydata
|
|
110
112
|
before do
|
111
113
|
expect(default_sync_fm).to receive(:save_sync_info).once
|
112
114
|
expect(subject).to receive(:free_disk_space).and_return(disk_byte)
|
113
|
-
|
115
|
+
expect(File).to receive(:dirname)
|
114
116
|
end
|
115
117
|
it 'will export to dump file' do
|
116
118
|
expect(subject).to receive(:call_block_or_return_io)
|
@@ -140,7 +142,7 @@ module Flydata
|
|
140
142
|
before do
|
141
143
|
allow(subject).to receive(:data_entry).and_return(default_data_entry)
|
142
144
|
allow_any_instance_of(Flydata::Api::DataEntry).to receive(:update_table_validity).and_return(true)
|
143
|
-
subject.send(:set_current_tables, nil,
|
145
|
+
subject.send(:set_current_tables, nil, include_all_tables: true)
|
144
146
|
end
|
145
147
|
shared_examples 'throws an error' do
|
146
148
|
it "throws an error" do
|
@@ -152,7 +154,7 @@ module Flydata
|
|
152
154
|
context 'with full options' do
|
153
155
|
it 'issues mysqldump command with expected parameters' do
|
154
156
|
expect(Open3).to receive(:popen3).with(
|
155
|
-
'mysqldump -h localhost -P 3306 -umasashi -p"welcome" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table3')
|
157
|
+
'mysqldump -h localhost -P 3306 -umasashi -p"welcome" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table4 table3')
|
156
158
|
subject.send(:do_generate_table_ddl, default_data_entry)
|
157
159
|
end
|
158
160
|
end
|
@@ -174,7 +176,7 @@ module Flydata
|
|
174
176
|
end
|
175
177
|
it "uses the default port" do
|
176
178
|
expect(Open3).to receive(:popen3).with(
|
177
|
-
'mysqldump -h localhost -umasashi -p"welcome" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table3')
|
179
|
+
'mysqldump -h localhost -umasashi -p"welcome" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table4 table3')
|
178
180
|
subject.send(:do_generate_table_ddl, default_data_entry)
|
179
181
|
end
|
180
182
|
end
|
@@ -184,7 +186,7 @@ module Flydata
|
|
184
186
|
end
|
185
187
|
it "uses the specified port" do
|
186
188
|
expect(Open3).to receive(:popen3).with(
|
187
|
-
'mysqldump -h localhost -P 1234 -umasashi -p"welcome" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table3')
|
189
|
+
'mysqldump -h localhost -P 1234 -umasashi -p"welcome" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table4 table3')
|
188
190
|
subject.send(:do_generate_table_ddl, default_data_entry)
|
189
191
|
end
|
190
192
|
end
|
@@ -206,7 +208,7 @@ module Flydata
|
|
206
208
|
end
|
207
209
|
it "call mysqldump without MYSQL_PW set" do
|
208
210
|
expect(Open3).to receive(:popen3).with(
|
209
|
-
'mysqldump -h localhost -P 3306 -umasashi --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table3')
|
211
|
+
'mysqldump -h localhost -P 3306 -umasashi --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table4 table3')
|
210
212
|
subject.send(:do_generate_table_ddl, default_data_entry)
|
211
213
|
end
|
212
214
|
end
|
@@ -217,7 +219,7 @@ module Flydata
|
|
217
219
|
end
|
218
220
|
it "call mysqldump with MYSQL_PW set with correct symbols" do
|
219
221
|
expect(Open3).to receive(:popen3).with(
|
220
|
-
'mysqldump -h localhost -P 3306 -umasashi -p"welcome&!@^@#^" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table3')
|
222
|
+
'mysqldump -h localhost -P 3306 -umasashi -p"welcome&!@^@#^" --default-character-set=utf8 --protocol=tcp -d sync_test table1 table2 table4 table3')
|
221
223
|
subject.send(:do_generate_table_ddl, default_data_entry)
|
222
224
|
end
|
223
225
|
end
|
@@ -238,8 +240,9 @@ module Flydata
|
|
238
240
|
before do
|
239
241
|
default_data_entry['mysql_data_entry_preference']['tables'] = []
|
240
242
|
default_data_entry['mysql_data_entry_preference']['invalid_tables'] = []
|
243
|
+
default_data_entry['mysql_data_entry_preference']['new_tables'] = []
|
241
244
|
allow(sync_cmd).to receive(:data_entry).and_return(default_data_entry)
|
242
|
-
sync_cmd.send(:set_current_tables, nil,
|
245
|
+
sync_cmd.send(:set_current_tables, nil, include_all_tables: true)
|
243
246
|
end
|
244
247
|
it 'should raise error' do
|
245
248
|
expect{sync_cmd.send(:do_generate_table_ddl, default_data_entry)}.to raise_error
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flydata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Fujikawa
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-09-
|
15
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rest-client
|
@@ -538,6 +538,7 @@ files:
|
|
538
538
|
- lib/flydata/command/conf.rb
|
539
539
|
- lib/flydata/command/crontab.rb
|
540
540
|
- lib/flydata/command/encrypt.rb
|
541
|
+
- lib/flydata/command/exclusive_runnable.rb
|
541
542
|
- lib/flydata/command/helper.rb
|
542
543
|
- lib/flydata/command/kill_all.rb
|
543
544
|
- lib/flydata/command/login.rb
|
@@ -611,6 +612,7 @@ files:
|
|
611
612
|
- spec/flydata/command/conf_spec.rb
|
612
613
|
- spec/flydata/command/crontab_spec.rb
|
613
614
|
- spec/flydata/command/encrypt_spec.rb
|
615
|
+
- spec/flydata/command/exclusive_runnable_spec.rb
|
614
616
|
- spec/flydata/command/helper_spec.rb
|
615
617
|
- spec/flydata/command/kill_all_spec.rb
|
616
618
|
- spec/flydata/command/login_spec.rb
|