mysql_isolated_server 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.md +22 -17
- data/Rakefile +1 -0
- data/lib/mysql_isolated_server/version.rb +1 -1
- data/lib/mysql_isolated_server.rb +6 -3
- metadata +3 -2
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,29 +1,34 @@
|
|
1
|
-
#
|
1
|
+
# Mysql Isolated Servers -- a gem for testing mysql stuff
|
2
2
|
|
3
|
-
|
3
|
+
This gem provides functionality to quickly bring up and tear down mysql instances for the
|
4
|
+
purposes of testing code against more advanced mysql topologies -- replication, vertical
|
5
|
+
partitions, etc.
|
4
6
|
|
5
|
-
|
7
|
+
I developed this as part of my testing strategy for implementing http://github.com/osheroff/ar_mysql_flexmaster, but it's
|
8
|
+
been useful in developement of a couple of other projects too (http://github.com/osheroff/mmtop).
|
6
9
|
|
7
|
-
|
10
|
+
## Usage
|
8
11
|
|
9
|
-
|
12
|
+
```
|
13
|
+
$mysql_master = MysqlIsolatedServer.new(allow_output: false)
|
14
|
+
$mysql_master.boot!
|
10
15
|
|
11
|
-
|
16
|
+
puts "mysql master booted on port #{$mysql_master.port} -- access with mysql -uroot -h127.0.0.1 --port=#{$mysql_master.port} mysql"
|
12
17
|
|
13
|
-
|
18
|
+
$mysql_slave = MysqlIsolatedServer.new
|
19
|
+
$mysql_slave.boot!
|
14
20
|
|
15
|
-
|
21
|
+
puts "mysql slave booted on port #{$mysql_slave.port} -- access with mysql -uroot -h127.0.0.1 --port=#{$mysql_slave.port} mysql"
|
16
22
|
|
17
|
-
|
23
|
+
$mysql_slave_2 = MysqlIsolatedServer.new
|
24
|
+
$mysql_slave_2.boot!
|
18
25
|
|
19
|
-
|
26
|
+
puts "mysql chained slave booted on port #{$mysql_slave_2.port} -- access with mysql -uroot -h127.0.0.1 --port=#{$mysql_slave_2.port} mysql"
|
20
27
|
|
21
|
-
|
28
|
+
$mysql_slave.make_slave_of($mysql_master)
|
29
|
+
$mysql_slave_2.make_slave_of($mysql_slave)
|
22
30
|
|
23
|
-
|
31
|
+
$mysql_slave.set_rw(false)
|
32
|
+
sleep if __FILE__ == $0
|
33
|
+
```
|
24
34
|
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -43,13 +43,15 @@ class MysqlIsolatedServer
|
|
43
43
|
|
44
44
|
def locate_executable(*candidates)
|
45
45
|
output = `which #{candidates.join(' ')}`
|
46
|
-
|
46
|
+
raise "I couldn't find any of these: #{candidates.join(',')} in $PATH" if output.chomp.empty?
|
47
47
|
output.split("\n").first
|
48
48
|
end
|
49
49
|
|
50
50
|
def up!
|
51
|
+
mysqld = locate_executable("mysqld")
|
52
|
+
|
51
53
|
exec_server <<-EOL
|
52
|
-
mysqld --no-defaults --default-storage-engine=innodb \
|
54
|
+
#{mysqld} --no-defaults --default-storage-engine=innodb \
|
53
55
|
--datadir=#{@mysql_data_dir} --pid-file=#{@base}/mysqld.pid --port=#{@port} \
|
54
56
|
#{@params} --socket=#{@mysql_data_dir}/mysql.sock --log-bin --log-slave-updates
|
55
57
|
EOL
|
@@ -75,7 +77,8 @@ class MysqlIsolatedServer
|
|
75
77
|
system("cp -a #{@load_data_path}/* #{@mysql_data_dir}")
|
76
78
|
system("rm -f #{@mysql_data_dir}/relay-log.info")
|
77
79
|
else
|
78
|
-
mysql_install_db =
|
80
|
+
mysql_install_db = locate_executable("mysql_install_db")
|
81
|
+
|
79
82
|
idb_path = File.dirname(mysql_install_db)
|
80
83
|
system("(cd #{idb_path}/..; mysql_install_db --datadir=#{@mysql_data_dir} --user=`whoami`) >/dev/null 2>&1")
|
81
84
|
system("cp #{File.expand_path(File.dirname(__FILE__))}/tables/user.* #{@mysql_data_dir}/mysql")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_isolated_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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: 2013-
|
12
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A small library that allows you to easily spin up new local mysql servers
|
15
15
|
for testing purposes.
|
@@ -56,3 +56,4 @@ specification_version: 3
|
|
56
56
|
summary: A small library that allows you to easily spin up new local mysql servers
|
57
57
|
for testing purposes.
|
58
58
|
test_files: []
|
59
|
+
has_rdoc:
|