stratocumulus 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +8 -13
- data/Gemfile +1 -1
- data/README.md +3 -2
- data/Rakefile +5 -5
- data/bin/stratocumulus +1 -1
- data/lib/stratocumulus.rb +6 -6
- data/lib/stratocumulus/cli.rb +3 -3
- data/lib/stratocumulus/database.rb +18 -20
- data/lib/stratocumulus/database/mysql.rb +6 -6
- data/lib/stratocumulus/database/pipe_io.rb +1 -1
- data/lib/stratocumulus/database/postgresql.rb +7 -7
- data/lib/stratocumulus/retention.rb +4 -4
- data/lib/stratocumulus/runner.rb +4 -4
- data/lib/stratocumulus/storage.rb +20 -15
- data/lib/stratocumulus/version.rb +1 -1
- data/spec/intergration/database_spec.rb +17 -60
- data/spec/spec_helper.rb +9 -9
- data/spec/unit/cli_spec.rb +5 -5
- data/spec/unit/database_spec.rb +38 -41
- data/spec/unit/mysql_spec.rb +33 -33
- data/spec/unit/pipe_io_spec.rb +7 -7
- data/spec/unit/postgresql_spec.rb +33 -33
- data/spec/unit/retention_spec.rb +19 -20
- data/spec/unit/runner_spec.rb +22 -22
- data/spec/unit/storage_spec.rb +96 -77
- data/stratocumulus.gemspec +19 -19
- metadata +32 -58
- data/.coveralls.yml +0 -1
- data/lib/stratocumulus/database/rethinkdb.rb +0 -39
data/spec/spec_helper.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
2
|
+
require "simplecov"
|
3
|
+
require "codeclimate-test-reporter"
|
4
|
+
require "stringio"
|
5
5
|
|
6
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
7
7
|
SimpleCov::Formatter::HTMLFormatter,
|
8
|
-
|
9
|
-
]
|
8
|
+
CodeClimate::TestReporter::Formatter,
|
9
|
+
])
|
10
10
|
|
11
11
|
SimpleCov.start do
|
12
12
|
minimum_coverage 100
|
13
13
|
end
|
14
14
|
|
15
|
-
require
|
15
|
+
require "bundler/setup"
|
16
16
|
Bundler.setup
|
17
17
|
|
18
|
-
require
|
18
|
+
require "stratocumulus"
|
19
19
|
Fog.mock!
|
20
20
|
|
21
21
|
RSpec.configure do |config|
|
22
|
-
config.default_formatter =
|
22
|
+
config.default_formatter = "doc" if config.files_to_run.one?
|
23
23
|
|
24
24
|
config.profile_examples = 10
|
25
25
|
config.order = :random
|
data/spec/unit/cli_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Stratocumulus::Cli do
|
5
|
-
describe
|
5
|
+
describe "#backups" do
|
6
6
|
let(:runner) { double }
|
7
7
|
|
8
|
-
it
|
8
|
+
it "calls the runner with the path" do
|
9
9
|
expect(Stratocumulus::Runner).to receive(:new)
|
10
|
-
.with(
|
10
|
+
.with("/path/to/config.yml").and_return(runner)
|
11
11
|
|
12
12
|
expect(runner).to receive(:run)
|
13
13
|
|
14
|
-
subject.backup
|
14
|
+
subject.backup "/path/to/config.yml"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/spec/unit/database_spec.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Stratocumulus::Database do
|
5
|
-
|
6
5
|
subject do
|
7
6
|
described_class.build(config)
|
8
7
|
end
|
@@ -11,111 +10,109 @@ describe Stratocumulus::Database do
|
|
11
10
|
|
12
11
|
let(:base_config) do
|
13
12
|
{
|
14
|
-
|
15
|
-
|
13
|
+
"name" => "stratocumulus_test",
|
14
|
+
"type" => type,
|
16
15
|
}
|
17
16
|
end
|
18
17
|
|
19
|
-
let(:type) {
|
18
|
+
let(:type) { "mysql" }
|
20
19
|
|
21
20
|
before do
|
22
21
|
allow_any_instance_of(Stratocumulus::Database).to(
|
23
|
-
receive(:system).and_return(true)
|
22
|
+
receive(:system).and_return(true),
|
24
23
|
)
|
25
24
|
end
|
26
25
|
|
27
|
-
describe
|
28
|
-
context
|
29
|
-
let(:config) { base_config.merge(
|
26
|
+
describe ".new" do
|
27
|
+
context "the database type is not supported" do
|
28
|
+
let(:config) { base_config.merge("type" => "nosqlioid") }
|
30
29
|
|
31
|
-
it
|
30
|
+
it "thows an error unless the type is supported" do
|
32
31
|
expect { subject }.to raise_error(
|
33
32
|
RuntimeError,
|
34
|
-
|
33
|
+
"nosqlioid is not a supported database",
|
35
34
|
)
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
|
-
context
|
40
|
-
it
|
38
|
+
context "mysql" do
|
39
|
+
it "throws an error if mysqldump is not installed" do
|
41
40
|
allow_any_instance_of(Stratocumulus::Database).to(
|
42
|
-
receive(:system).with(/which mysqldump/)
|
41
|
+
receive(:system).with(/which mysqldump/),
|
43
42
|
)
|
44
43
|
|
45
44
|
expect { subject }.to raise_error(
|
46
45
|
RuntimeError,
|
47
|
-
|
46
|
+
"mysqldump not available",
|
48
47
|
)
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
|
-
context
|
53
|
-
let(:type) {
|
51
|
+
context "postgresql" do
|
52
|
+
let(:type) { "psql" }
|
54
53
|
|
55
|
-
it
|
54
|
+
it "throws an error if pg_dump is not installed" do
|
56
55
|
allow_any_instance_of(Stratocumulus::Database)
|
57
|
-
|
56
|
+
.to receive(:system).with(/which pg_dump/)
|
58
57
|
|
59
58
|
expect { subject }.to raise_error(
|
60
59
|
RuntimeError,
|
61
|
-
|
60
|
+
"pg_dump not available",
|
62
61
|
)
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
|
-
it
|
65
|
+
it "throws an error if gzip is not installed" do
|
67
66
|
allow_any_instance_of(Stratocumulus::Database)
|
68
67
|
.to receive(:system).with(/which gzip/)
|
69
68
|
|
70
69
|
expect { subject }.to raise_error(
|
71
70
|
RuntimeError,
|
72
|
-
|
71
|
+
"gzip not available",
|
73
72
|
)
|
74
73
|
end
|
75
74
|
|
76
|
-
context
|
77
|
-
|
75
|
+
context "when no database name is provided" do
|
78
76
|
let(:config) do
|
79
|
-
{
|
77
|
+
{ "type" => "mysql" }
|
80
78
|
end
|
81
79
|
|
82
|
-
it
|
80
|
+
it "throws an error" do
|
83
81
|
expect { subject }.to raise_error(
|
84
82
|
RuntimeError,
|
85
|
-
|
83
|
+
"database name not specified",
|
86
84
|
)
|
87
85
|
end
|
88
|
-
|
89
86
|
end
|
90
87
|
end
|
91
88
|
|
92
|
-
describe
|
93
|
-
it
|
94
|
-
timestamp = Time.now.utc.strftime(
|
89
|
+
describe "#filename" do
|
90
|
+
it "calculates a filename based on the name and timestamp" do
|
91
|
+
timestamp = Time.now.utc.strftime("%Y%m%d%H%M")
|
95
92
|
filename = "stratocumulus_test/stratocumulus_test.#{timestamp}.sql.gz"
|
96
93
|
expect(subject.filename).to eq filename
|
97
94
|
end
|
98
95
|
|
99
|
-
it
|
96
|
+
it "stays the same for an instance even if time moves on" do
|
100
97
|
filename = subject.filename
|
101
98
|
allow(Time).to receive(:now).and_return(Time.now + 60 * 60 * 26)
|
102
99
|
expect(subject.filename).to eq filename
|
103
100
|
end
|
104
101
|
end
|
105
102
|
|
106
|
-
describe
|
107
|
-
describe
|
108
|
-
subject { FailingDatabase.new(
|
103
|
+
describe "#success?" do
|
104
|
+
describe "the dump fails" do
|
105
|
+
subject { FailingDatabase.new("name" => "test_database") }
|
109
106
|
|
110
|
-
it
|
107
|
+
it "returns false" do
|
111
108
|
expect(subject).to_not be_success
|
112
109
|
end
|
113
110
|
end
|
114
111
|
|
115
|
-
describe
|
116
|
-
subject { SucessDatabase.new(
|
112
|
+
describe "the dump is sucessfull" do
|
113
|
+
subject { SucessDatabase.new("name" => "test_database") }
|
117
114
|
|
118
|
-
it
|
115
|
+
it "returns false" do
|
119
116
|
expect(subject).to be_success
|
120
117
|
end
|
121
118
|
end
|
@@ -123,13 +120,13 @@ describe Stratocumulus::Database do
|
|
123
120
|
|
124
121
|
class SucessDatabase < described_class
|
125
122
|
def command
|
126
|
-
|
123
|
+
"echo boo"
|
127
124
|
end
|
128
125
|
end
|
129
126
|
|
130
127
|
class FailingDatabase < described_class
|
131
128
|
def command
|
132
|
-
|
129
|
+
"exit 127"
|
133
130
|
end
|
134
131
|
end
|
135
132
|
end
|
data/spec/unit/mysql_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Stratocumulus::MySQL do
|
5
5
|
subject do
|
@@ -7,96 +7,96 @@ describe Stratocumulus::MySQL do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
let(:config) do
|
10
|
-
{
|
10
|
+
{ "name" => "stratocumulus_test" }
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe "#dependencies" do
|
14
14
|
specify do
|
15
15
|
expect(subject.dependencies).to eq %w(gzip mysqldump)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
context
|
21
|
-
it
|
19
|
+
describe "#command" do
|
20
|
+
context "default" do
|
21
|
+
it "generates the dump command with sensible defaults" do
|
22
22
|
expect(subject.command).to eq(
|
23
|
-
|
23
|
+
"mysqldump --single-transaction -uroot stratocumulus_test",
|
24
24
|
)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context
|
28
|
+
context "with the password set" do
|
29
29
|
let(:config) do
|
30
30
|
{
|
31
|
-
|
32
|
-
|
31
|
+
"name" => "stratocumulus_test",
|
32
|
+
"password" => "seecrit",
|
33
33
|
}
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it "generates the dump command with a default host" do
|
37
37
|
expect(subject.command).to eq(
|
38
|
-
|
38
|
+
"mysqldump --single-transaction -uroot -pseecrit stratocumulus_test",
|
39
39
|
)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
context
|
43
|
+
context "with the port set" do
|
44
44
|
let(:config) do
|
45
45
|
{
|
46
|
-
|
47
|
-
|
46
|
+
"name" => "stratocumulus_test",
|
47
|
+
"port" => 13_306,
|
48
48
|
}
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it "generates the dump command with a default host" do
|
52
52
|
expect(subject.command).to eq(
|
53
|
-
|
53
|
+
"mysqldump --single-transaction -uroot -hlocalhost -P13306 stratocumulus_test" # rubocop:disable Metrics/LineLength
|
54
54
|
)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
context
|
58
|
+
context "with the host set" do
|
59
59
|
let(:config) do
|
60
60
|
{
|
61
|
-
|
62
|
-
|
61
|
+
"name" => "stratocumulus_test",
|
62
|
+
"host" => "db.example.com",
|
63
63
|
}
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it "generates the dump command with a default port" do
|
67
67
|
expect(subject.command).to eq(
|
68
|
-
|
68
|
+
"mysqldump --single-transaction -uroot -hdb.example.com -P3306 stratocumulus_test" # rubocop:disable Metrics/LineLength
|
69
69
|
)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
context
|
73
|
+
context "with the port and host set" do
|
74
74
|
let(:config) do
|
75
75
|
{
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
"name" => "stratocumulus_test",
|
77
|
+
"port" => 33_306,
|
78
|
+
"host" => "db.example.com",
|
79
79
|
}
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
82
|
+
it "generates the dump command with the port and host" do
|
83
83
|
expect(subject.command).to eq(
|
84
|
-
|
84
|
+
"mysqldump --single-transaction -uroot -hdb.example.com -P33306 stratocumulus_test" # rubocop:disable Metrics/LineLength
|
85
85
|
)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
context
|
89
|
+
context "with the username set" do
|
90
90
|
let(:config) do
|
91
91
|
{
|
92
|
-
|
93
|
-
|
92
|
+
"name" => "stratocumulus_test",
|
93
|
+
"username" => "susan",
|
94
94
|
}
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
97
|
+
it "generates the dump command with the username" do
|
98
98
|
expect(subject.command).to eq(
|
99
|
-
|
99
|
+
"mysqldump --single-transaction -ususan stratocumulus_test",
|
100
100
|
)
|
101
101
|
end
|
102
102
|
end
|
data/spec/unit/pipe_io_spec.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Stratocumulus::Database::PipeIO do
|
5
5
|
subject do
|
6
|
-
described_class.popen(
|
6
|
+
described_class.popen("echo foo")
|
7
7
|
end
|
8
8
|
|
9
9
|
after do
|
10
10
|
subject.close
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "behaves like IO" do
|
14
14
|
expect(subject.read).to eq "foo\n"
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
18
|
-
it
|
17
|
+
describe "#rewind" do
|
18
|
+
it "is not defined" do
|
19
19
|
expect(subject).to_not respond_to(:rewind)
|
20
20
|
end
|
21
21
|
end
|
@@ -24,11 +24,11 @@ end
|
|
24
24
|
describe IO do
|
25
25
|
subject do
|
26
26
|
described_class.open(
|
27
|
-
described_class.sysopen(
|
27
|
+
described_class.sysopen("spec/support/test_config_file.yml"),
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it "is not affected" do
|
32
32
|
subject.read
|
33
33
|
subject.rewind
|
34
34
|
expect(subject.read).to_not be_nil
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Stratocumulus::PostgreSQL do
|
5
5
|
subject do
|
@@ -7,96 +7,96 @@ describe Stratocumulus::PostgreSQL do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
let(:config) do
|
10
|
-
{
|
10
|
+
{ "name" => "stratocumulus_test" }
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe "#dependencies" do
|
14
14
|
specify do
|
15
15
|
expect(subject.dependencies).to eq %w(gzip pg_dump)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
context
|
21
|
-
it
|
19
|
+
describe "#command" do
|
20
|
+
context "default" do
|
21
|
+
it "generates the dump command with sensible defaults" do
|
22
22
|
expect(subject.command).to eq(
|
23
|
-
|
23
|
+
"pg_dump -Upostgres stratocumulus_test",
|
24
24
|
)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context
|
28
|
+
context "with the password set" do
|
29
29
|
let(:config) do
|
30
30
|
{
|
31
|
-
|
32
|
-
|
31
|
+
"name" => "stratocumulus_test",
|
32
|
+
"password" => "sekret",
|
33
33
|
}
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it "sets the password env var" do
|
37
37
|
expect(subject.command).to eq(
|
38
|
-
'PGPASSWORD="sekret" pg_dump -Upostgres stratocumulus_test'
|
38
|
+
'PGPASSWORD="sekret" pg_dump -Upostgres stratocumulus_test',
|
39
39
|
)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
context
|
43
|
+
context "with the port set" do
|
44
44
|
let(:config) do
|
45
45
|
{
|
46
|
-
|
47
|
-
|
46
|
+
"name" => "stratocumulus_test",
|
47
|
+
"port" => 15_432,
|
48
48
|
}
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it "generates the dump command with a default host" do
|
52
52
|
expect(subject.command).to eq(
|
53
|
-
|
53
|
+
"pg_dump -Upostgres -hlocalhost -p15432 stratocumulus_test",
|
54
54
|
)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
context
|
58
|
+
context "with the host set" do
|
59
59
|
let(:config) do
|
60
60
|
{
|
61
|
-
|
62
|
-
|
61
|
+
"name" => "stratocumulus_test",
|
62
|
+
"host" => "db.example.com",
|
63
63
|
}
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it "generates the dump command with a default port" do
|
67
67
|
expect(subject.command).to eq(
|
68
|
-
|
68
|
+
"pg_dump -Upostgres -hdb.example.com -p5432 stratocumulus_test",
|
69
69
|
)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
context
|
73
|
+
context "with the port and host set" do
|
74
74
|
let(:config) do
|
75
75
|
{
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
"name" => "stratocumulus_test",
|
77
|
+
"port" => 15_432,
|
78
|
+
"host" => "db.example.com",
|
79
79
|
}
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
82
|
+
it "generates the dump command with port and host set" do
|
83
83
|
expect(subject.command).to eq(
|
84
|
-
|
84
|
+
"pg_dump -Upostgres -hdb.example.com -p15432 stratocumulus_test",
|
85
85
|
)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
context
|
89
|
+
context "with the username set" do
|
90
90
|
let(:config) do
|
91
91
|
{
|
92
|
-
|
93
|
-
|
92
|
+
"name" => "stratocumulus_test",
|
93
|
+
"username" => "susan",
|
94
94
|
}
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
97
|
+
it "generates the dump command with the username" do
|
98
98
|
expect(subject.command).to eq(
|
99
|
-
|
99
|
+
"pg_dump -Ususan stratocumulus_test",
|
100
100
|
)
|
101
101
|
end
|
102
102
|
end
|