rsynconrails 0.1.0
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/.gitignore +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/README.license +92 -0
- data/README.md +10 -0
- data/config/system_config.yml +15 -0
- data/lib/cli_funcs.rb +54 -0
- data/lib/cli_funcs_cpio.rb +38 -0
- data/lib/cli_funcs_rpm.rb +268 -0
- data/lib/cli_funcs_rpm2cpio.rb +28 -0
- data/lib/cli_funcs_rsync.rb +351 -0
- data/lib/cli_utils.rb +70 -0
- data/lib/host.rb +194 -0
- data/lib/package.rb +66 -0
- data/lib/ssh_funcs.rb +29 -0
- data/lib/system_config.rb +8 -0
- data/spec/cli_funcs_cpio_spec.rb +20 -0
- data/spec/cli_funcs_rpm2cpio_spec.rb +15 -0
- data/spec/cli_funcs_rpm_spec.rb +89 -0
- data/spec/cli_funcs_rsync_spec.rb +91 -0
- data/spec/cli_funcs_spec.rb +34 -0
- data/spec/cli_utils_spec.rb +13 -0
- data/spec/host_spec.rb +91 -0
- data/spec/package_spec.rb +39 -0
- data/spec/spec_helper.rb +127 -0
- data/spec/ssh_funcs_spec.rb +14 -0
- data/testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm +0 -0
- data/testfiles/postfix-2.6.6-2.2.el6_1.x86_64.rpm +0 -0
- metadata +111 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper.rb'
|
|
2
|
+
require 'cli_funcs_rpm2cpio.rb'
|
|
3
|
+
require 'cli_funcs_cpio.rb'
|
|
4
|
+
|
|
5
|
+
describe Cpio do
|
|
6
|
+
|
|
7
|
+
it "should take binary data and un-cpio to test dir" do
|
|
8
|
+
r = Rpm2Cpio.new
|
|
9
|
+
r.rpm_file = "testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm"
|
|
10
|
+
r.rpm2cpio
|
|
11
|
+
c = Cpio.new
|
|
12
|
+
c.cpio_data = r.output
|
|
13
|
+
c.extract_dir = "#{c.data_dir}/cpio"
|
|
14
|
+
c.cpio
|
|
15
|
+
File.exist?("#{c.data_dir}/cpio/usr/share/doc/libcom_err-1.41.12/COPYING").should be_true
|
|
16
|
+
File.exist?("#{c.data_dir}/cpio/lib64/libcom_err.so.2").should be_true
|
|
17
|
+
File.exist?("#{c.data_dir}/cpio/lib64/libcom_err.so.2.1").should be_true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper.rb'
|
|
2
|
+
require 'cli_funcs_rpm2cpio.rb'
|
|
3
|
+
require 'digest'
|
|
4
|
+
|
|
5
|
+
describe Rpm2Cpio do
|
|
6
|
+
|
|
7
|
+
it "should convert an rpm into cpio binary data" do
|
|
8
|
+
r = Rpm2Cpio.new
|
|
9
|
+
r.rpm_file = "testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm"
|
|
10
|
+
r.rpm2cpio
|
|
11
|
+
digest = Digest::MD5.hexdigest r.output.to_s
|
|
12
|
+
digest.should == "65e970823fd7c819d3706ae66a704bd3"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'spec_helper.rb'
|
|
2
|
+
require 'cli_funcs_rpm.rb'
|
|
3
|
+
|
|
4
|
+
describe Rpm do
|
|
5
|
+
|
|
6
|
+
it "should query a package for it's control information" do
|
|
7
|
+
r = Rpm.new
|
|
8
|
+
r.rpm_file = "testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm"
|
|
9
|
+
r.set_control
|
|
10
|
+
r.control["Name"].should == "libcom_err"
|
|
11
|
+
r.control["Version"].should == "1.41.12"
|
|
12
|
+
r.control["Release"].should == "14.el6_4.2"
|
|
13
|
+
r.control["Install Date"].should == "(not installed)"
|
|
14
|
+
r.control["Group"].should == "Development/Libraries"
|
|
15
|
+
r.control["Size"].should == "59233"
|
|
16
|
+
r.control["Signature"].should == "RSA/SHA1, Tue 25 Jun 2013 02:03:51 AM PDT, Key ID 0946fca2c105b9de"
|
|
17
|
+
r.control["Packager"].should == "CentOS BuildSystem <http://bugs.centos.org>"
|
|
18
|
+
r.control["URL"].should == "http://e2fsprogs.sourceforge.net/"
|
|
19
|
+
r.control["Summary"].should == "Common error description library"
|
|
20
|
+
r.control["Relocations"].should == "(not relocatable)"
|
|
21
|
+
r.control["Vendor"].should == "CentOS"
|
|
22
|
+
r.control["Build Date"].should == "Tue 25 Jun 2013 01:51:13 AM PDT"
|
|
23
|
+
r.control["Build Host"].should == "c6b7.bsys.dev.centos.org"
|
|
24
|
+
r.control["Source RPM"].should == "e2fsprogs-1.41.12-14.el6_4.2.src.rpm"
|
|
25
|
+
r.control["License"].should == "MIT"
|
|
26
|
+
#r.control["Description"].should == ""
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should query a package for it's dependency information" do
|
|
30
|
+
r = Rpm.new
|
|
31
|
+
r.rpm_file = "testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm"
|
|
32
|
+
r.set_dependencies
|
|
33
|
+
r.dependencies.should have_key "/sbin/ldconfig"
|
|
34
|
+
r.dependencies.should have_key "ld-linux-x86-64.so.2()(64bit)"
|
|
35
|
+
r.dependencies.should have_key "ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)"
|
|
36
|
+
r.dependencies.should have_key "libc.so.6()(64bit)"
|
|
37
|
+
r.dependencies.should have_key "libc.so.6(GLIBC_2.2.5)(64bit)"
|
|
38
|
+
r.dependencies.should have_key "libc.so.6(GLIBC_2.3.4)(64bit)"
|
|
39
|
+
r.dependencies.should have_key "libc.so.6(GLIBC_2.4)(64bit)"
|
|
40
|
+
r.dependencies.should have_key "libcom_err.so.2()(64bit)"
|
|
41
|
+
r.dependencies.should have_key "libpthread.so.0()(64bit)"
|
|
42
|
+
r.dependencies.should have_key "libpthread.so.0(GLIBC_2.2.5)(64bit)"
|
|
43
|
+
r.dependencies.should have_key "rpmlib(CompressedFileNames)"
|
|
44
|
+
r.dependencies["rpmlib(CompressedFileNames)"].should == "<= 3.0.4-1"
|
|
45
|
+
r.dependencies.should have_key "rpmlib(FileDigests)"
|
|
46
|
+
r.dependencies["rpmlib(FileDigests)"].should == "<= 4.6.0-1"
|
|
47
|
+
r.dependencies.should have_key "rpmlib(PayloadFilesHavePrefix)"
|
|
48
|
+
r.dependencies["rpmlib(PayloadFilesHavePrefix)"].should == "<= 4.0-1"
|
|
49
|
+
r.dependencies.should have_key "rtld(GNU_HASH)"
|
|
50
|
+
r.dependencies.should have_key "rpmlib(PayloadIsXz)"
|
|
51
|
+
r.dependencies["rpmlib(PayloadIsXz)"].should == "<= 5.2-1"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should query a package for it's provides information" do
|
|
55
|
+
r = Rpm.new
|
|
56
|
+
r.rpm_file = "testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm"
|
|
57
|
+
r.set_provides
|
|
58
|
+
r.provides.should have_key "libcom_err.so.2()(64bit)"
|
|
59
|
+
r.provides.should have_key "libcom_err"
|
|
60
|
+
r.provides["libcom_err"].should == "1.41.12-14.el6_4.2"
|
|
61
|
+
r.provides.should have_key "libcom_err(x86-64)"
|
|
62
|
+
r.provides["libcom_err(x86-64)"].should == "1.41.12-14.el6_4.2"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should query a package for it's file list information" do
|
|
66
|
+
r = Rpm.new
|
|
67
|
+
r.rpm_file = "testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm"
|
|
68
|
+
r.set_filelist
|
|
69
|
+
r.filelist.should == ['/lib64/libcom_err.so.2', '/lib64/libcom_err.so.2.1', '/usr/share/doc/libcom_err-1.41.12', '/usr/share/doc/libcom_err-1.41.12/COPYING']
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should query a package for it's install scripts" do
|
|
73
|
+
r = Rpm.new
|
|
74
|
+
r.rpm_file = "testfiles/postfix-2.6.6-2.2.el6_1.x86_64.rpm"
|
|
75
|
+
r.set_scripts
|
|
76
|
+
r.scripts["preinstall"].should match /# Add user and groups if necessary/
|
|
77
|
+
r.scripts["postinstall"].should match /--slave \/usr\/share\/man\/man5\/aliases.5.gz mta-aliasesman/
|
|
78
|
+
r.scripts["preuninstall"].should match /\/sbin\/chkconfig --del postfix/
|
|
79
|
+
r.scripts["postuninstall"].should match /\/sbin\/service postfix condrestart/
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should extract rpm content into specified directory" do
|
|
83
|
+
r = Rpm.new
|
|
84
|
+
r.rpm_file = "testfiles/postfix-2.6.6-2.2.el6_1.x86_64.rpm"
|
|
85
|
+
r.set_info
|
|
86
|
+
r.do_extract
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'spec_helper.rb'
|
|
2
|
+
require 'cli_funcs_rsync.rb'
|
|
3
|
+
require 'ssh_funcs.rb'
|
|
4
|
+
|
|
5
|
+
describe Rsync do
|
|
6
|
+
|
|
7
|
+
it "should verify that the base run flags are correct" do
|
|
8
|
+
r = Rsync.new
|
|
9
|
+
r.flags_run.should == ["-a", "-vv", "-i", "--delete", "--stats"]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should verify that we've added 'dryrun' flag to base flags" do
|
|
13
|
+
r = Rsync.new
|
|
14
|
+
r.flag_dryrun
|
|
15
|
+
r.flags_run.should == ["-a", "-vv", "-i", "--delete", "--stats", "-n"]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should verify that source is set correctly" do
|
|
19
|
+
r = Rsync.new
|
|
20
|
+
r.source = "testing"
|
|
21
|
+
r.source.should == "testing"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should verify that destination is set correctly" do
|
|
25
|
+
r = Rsync.new
|
|
26
|
+
r.destination = "testing"
|
|
27
|
+
r.destination.should == "testing"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should track changes for a source and dest which aren't different" do
|
|
31
|
+
r = Rsync.new
|
|
32
|
+
r.flag_dryrun
|
|
33
|
+
1.upto(9) do |n|
|
|
34
|
+
r.source.push("#{r.data_dir}/rsync/testing/source/pkg#{n}/files/")
|
|
35
|
+
end
|
|
36
|
+
r.destination = "localhost:#{r.data_dir}/rsync/testing/source_nochanges/"
|
|
37
|
+
r.rsync
|
|
38
|
+
r.output_process
|
|
39
|
+
r.uptodate.size.should == 28
|
|
40
|
+
r.deleted.size.should == 0
|
|
41
|
+
r.modified.size.should == 0
|
|
42
|
+
r.created.size.should == 0
|
|
43
|
+
r.duplicates.size.should == 8
|
|
44
|
+
(r.uptodate.size + r.modified.size + r.created.size + r.ignored.size + r.duplicates.size).should == r.transfer_stats['Number of files'].to_i
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should track changes for a source and dest which are different" do
|
|
48
|
+
r = Rsync.new
|
|
49
|
+
r.flag_dryrun
|
|
50
|
+
1.upto(9) do |n|
|
|
51
|
+
r.source.push("#{r.data_dir}/rsync/testing/source/pkg#{n}/files/")
|
|
52
|
+
end
|
|
53
|
+
r.destination = "localhost:#{r.data_dir}/rsync/testing/source_changes/"
|
|
54
|
+
r.flag_exclude("/excluded_file")
|
|
55
|
+
r.flag_exclude("/3/excluded_file")
|
|
56
|
+
r.flag_exclude("/3/excluded_file with space in name")
|
|
57
|
+
r.flag_exclude("/12")
|
|
58
|
+
r.rsync
|
|
59
|
+
r.output_process
|
|
60
|
+
r.uptodate.size.should == 17
|
|
61
|
+
r.deleted.size.should == 5
|
|
62
|
+
r.modified.size.should == 4
|
|
63
|
+
r.created.size.should == 3
|
|
64
|
+
r.excluded.size.should == 4
|
|
65
|
+
(r.uptodate.size + r.modified.size + r.created.size + r.ignored.size + r.duplicates.size).should == r.transfer_stats["Number of files"].to_i
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should verify that rsync source ordering is working" do
|
|
69
|
+
# In the test setup, we have 4 directories, number 2 though 5
|
|
70
|
+
# By passing in directory 2 first, it should win over other directories
|
|
71
|
+
# which contain the same file name
|
|
72
|
+
r = Rsync.new
|
|
73
|
+
1.upto(9) do |n|
|
|
74
|
+
r.source.push("#{r.data_dir}/rsync/testing/source_ordering/pkg#{n}/files/")
|
|
75
|
+
end
|
|
76
|
+
r.destination = "localhost:#{r.data_dir}/rsync/testing/destination_ordering/"
|
|
77
|
+
r.rsync
|
|
78
|
+
r.output_process
|
|
79
|
+
r.uptodate.size.should == 0
|
|
80
|
+
r.deleted.size.should == 0
|
|
81
|
+
r.modified.size.should == 0
|
|
82
|
+
r.created.size.should == 29
|
|
83
|
+
r.duplicates.size.should == 11
|
|
84
|
+
(r.uptodate.size + r.deleted.size + r.modified.size + r.created.size + r.ignored.size + r.duplicates.size).should == r.transfer_stats["Number of files"].to_i
|
|
85
|
+
s = SSHFuncs.new("localhost")
|
|
86
|
+
s.run_cmd("cat #{r.data_dir}/rsync/testing/destination_ordering/file_contains_win")
|
|
87
|
+
s.output.chomp.should == "win"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'cli_funcs.rb'
|
|
2
|
+
require 'cli_utils.rb'
|
|
3
|
+
|
|
4
|
+
describe CliFuncs do
|
|
5
|
+
it "should set environment to development" do
|
|
6
|
+
c = CliFuncs.new
|
|
7
|
+
ENV["RSYNCONRAILS_CONFIG"].should == "development"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should test that base_dir is set" do
|
|
11
|
+
c = CliFuncs.new
|
|
12
|
+
c.base_dir.should_not == nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should test that data_dir is set" do
|
|
16
|
+
c = CliFuncs.new
|
|
17
|
+
c.data_dir.should_not == nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "runs a command with no arguments and captures it's output" do
|
|
21
|
+
u = CliUtils.new("rsync")
|
|
22
|
+
f = CliFuncs.new
|
|
23
|
+
f.ignore_bad_exit = true
|
|
24
|
+
f.run_and_capture(u.utility_path)
|
|
25
|
+
f.output[-1].should =~ /rsync error: syntax or usage error/
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "runs a command with 1 argument and captures it's output" do
|
|
29
|
+
u = CliUtils.new("rsync")
|
|
30
|
+
f = CliFuncs.new
|
|
31
|
+
f.run_and_capture(u.utility_path, "--version")
|
|
32
|
+
f.output[-1].chomp.should == "General Public Licence for details."
|
|
33
|
+
end
|
|
34
|
+
end
|
data/spec/host_spec.rb
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'spec_helper.rb'
|
|
2
|
+
require 'host.rb'
|
|
3
|
+
|
|
4
|
+
describe Host do
|
|
5
|
+
|
|
6
|
+
it "verifies that hosts_dir is set" do
|
|
7
|
+
c = Host.new()
|
|
8
|
+
c.find_host
|
|
9
|
+
c.hosts_dir.split("/")[-1].should == "hosts"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "verifies that host_dir is set" do
|
|
13
|
+
c = Host.new("hostname.already.exists")
|
|
14
|
+
c.find_host
|
|
15
|
+
c.host_dir.split("/")[-1].should == "hostname"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "handles a hostname.domain fqdn" do
|
|
19
|
+
c = Host.new("hostname.domain.tld")
|
|
20
|
+
c.find_host
|
|
21
|
+
c.host.should == "hostname"
|
|
22
|
+
c.domain.should == "domain.tld"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "handles a hostname.subdomain.domain.tld fqdn" do
|
|
26
|
+
c = Host.new("hostname.subdomain.domain.tld")
|
|
27
|
+
c.find_host
|
|
28
|
+
c.host.should == "hostname"
|
|
29
|
+
c.domain.should == "subdomain.domain.tld"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "validates host directory and yml file" do
|
|
33
|
+
c = Host.new("hostname.already.exists")
|
|
34
|
+
c.find_host
|
|
35
|
+
c.host_valid?.should == true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "finds a host named newly.created.tld" do
|
|
39
|
+
c = Host.new("newly.created.tld")
|
|
40
|
+
c.autocreate = true
|
|
41
|
+
c.find_host
|
|
42
|
+
c.found_host.should == "created.tld/newly"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "finds a host named hostname" do
|
|
46
|
+
c = Host.new("hostname")
|
|
47
|
+
c.find_host
|
|
48
|
+
c.found_host.should == "already.exists/hostname"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "finds a host named hostname.already.exists" do
|
|
52
|
+
c = Host.new("hostname.already.exists")
|
|
53
|
+
c.find_host
|
|
54
|
+
c.found_host.should == "already.exists/hostname"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "shouldn't find a host, then create one with no domain and validate it" do
|
|
58
|
+
c = Host.new("newhost")
|
|
59
|
+
c.autocreate = true
|
|
60
|
+
c.find_host
|
|
61
|
+
c.found_host.should == "newhost"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "shouldn't find a host, then create one with domain and validate it" do
|
|
65
|
+
c = Host.new("newhost.tld")
|
|
66
|
+
c.autocreate = true
|
|
67
|
+
c.find_host
|
|
68
|
+
c.found_host.should == "tld/newhost"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "shouldn't find a host" do
|
|
72
|
+
c = Host.new("does.not.exist")
|
|
73
|
+
c.find_host
|
|
74
|
+
c.found_host.should == ""
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should read and verify values from host.yml" do
|
|
78
|
+
c = Host.new("hostname.already.exists")
|
|
79
|
+
c.find_host
|
|
80
|
+
c.host_yml_values["config"]["package_base"].should == "test_dist"
|
|
81
|
+
c.host_yml_values["config"]["release_tag"].should == "current"
|
|
82
|
+
c.host_yml_values["config"]["rsync_path"].should == nil
|
|
83
|
+
c.host_yml_values["config"]["ssh_port"].should == nil
|
|
84
|
+
c.host_yml_values["config"]["session_mode"].should == nil
|
|
85
|
+
c.host_yml_values["include"].should == nil
|
|
86
|
+
c.host_yml_values["exclude"].should == nil
|
|
87
|
+
c.host_yml_values["exclude_backup"].should == nil
|
|
88
|
+
c.host_yml_values["execute"].should == nil
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper.rb'
|
|
2
|
+
require 'package.rb'
|
|
3
|
+
|
|
4
|
+
describe Package do
|
|
5
|
+
|
|
6
|
+
it "verifies that packages_dir is set" do
|
|
7
|
+
p = Package.new()
|
|
8
|
+
p.packages_dir.split("/")[-1].should == "packages"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "verifies that package is set when given as argument" do
|
|
12
|
+
p = Package.new("section1/package1")
|
|
13
|
+
p.package.should == "section1/package1"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "verifies that package is set when set after init" do
|
|
17
|
+
p = Package.new()
|
|
18
|
+
p.package = "section1/package1"
|
|
19
|
+
p.package.should == "section1/package1"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "verifies that package_base, package_release_tag, and package_dir are set, based on host.yml" do
|
|
23
|
+
h = Host.new("hostname.already.exists")
|
|
24
|
+
h.find_host
|
|
25
|
+
p = Package.new("section1/package1")
|
|
26
|
+
p.set_properties(h)
|
|
27
|
+
p.package_base.should == "test_dist"
|
|
28
|
+
p.package_release_tag.should == "current"
|
|
29
|
+
p.package_dir.should == "#{p.packages_dir}/test_dist/section1/package1/current"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "verifies that package is valid" do
|
|
33
|
+
h = Host.new("hostname.already.exists")
|
|
34
|
+
h.find_host
|
|
35
|
+
p = Package.new("section1/package1")
|
|
36
|
+
p.set_properties(h)
|
|
37
|
+
p.package_valid?.should == true
|
|
38
|
+
end
|
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require 'system_config'
|
|
2
|
+
|
|
3
|
+
$datadir = SYSTEM_CONFIG["data_dir"]
|
|
4
|
+
|
|
5
|
+
def clean_up
|
|
6
|
+
print "Cleaning up testing work area..."
|
|
7
|
+
system("rm -rf #{$datadir}")
|
|
8
|
+
puts "done."
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def setup_source(name)
|
|
12
|
+
num = 9
|
|
13
|
+
path = "rsync/testing/#{name}"
|
|
14
|
+
# Create source dir
|
|
15
|
+
1.upto(num) do |n|
|
|
16
|
+
system("mkdir -p #{$datadir}/#{path}/pkg#{n}/files/#{n}")
|
|
17
|
+
system("echo #{n} > #{$datadir}/#{path}/pkg#{n}/files/file#{n}")
|
|
18
|
+
system("echo #{n} > #{$datadir}/#{path}/pkg#{n}/files/#{n}/file#{n}")
|
|
19
|
+
end
|
|
20
|
+
# Rsync all sources to source_nochanges before we run test
|
|
21
|
+
sources = Array.new
|
|
22
|
+
1.upto(num) do |n|
|
|
23
|
+
sources.push("#{$datadir}/#{path}/pkg#{n}/files/")
|
|
24
|
+
end
|
|
25
|
+
# Create dest that won't have any changes
|
|
26
|
+
system("rsync -a #{sources.join(" ")} #{$datadir}/rsync/testing/source_nochanges/")
|
|
27
|
+
# Create dest that will have changes
|
|
28
|
+
system("rsync -a #{sources.join(" ")} #{$datadir}/rsync/testing/source_changes/")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def setup_changes(name)
|
|
32
|
+
path = "rsync/testing/#{name}"
|
|
33
|
+
# Create destination, with modified, added, deleted stuff
|
|
34
|
+
n = 10
|
|
35
|
+
system("mkdir -p #{$datadir}/#{path}/#{n}")
|
|
36
|
+
system("echo #{n} > #{$datadir}/#{path}/file#{n}")
|
|
37
|
+
system("echo #{n} > #{$datadir}/#{path}/#{n}/file#{n}")
|
|
38
|
+
|
|
39
|
+
# Modify some of our files, create new files, and delete some
|
|
40
|
+
system("echo 1 > #{$datadir}/#{path}/2/file2")
|
|
41
|
+
system("echo 2 > #{$datadir}/#{path}/3/file3")
|
|
42
|
+
system("echo 'weeee' > #{$datadir}/#{path}/fileweeee")
|
|
43
|
+
system("echo 'weeeehaw' > #{$datadir}/#{path}/7/fileweeehaw")
|
|
44
|
+
system("chmod 777 #{$datadir}/#{path}/6/file6")
|
|
45
|
+
system("chown 2 #{$datadir}/#{path}/5/file5")
|
|
46
|
+
system("echo 1 > #{$datadir}/#{path}/excluded_file")
|
|
47
|
+
system("echo 1 > #{$datadir}/#{path}/3/excluded_file")
|
|
48
|
+
system("echo 1 > '#{$datadir}/#{path}/3/excluded_file with space in name'")
|
|
49
|
+
system("mkdir '#{$datadir}/#{path}/12'")
|
|
50
|
+
system("echo 1 > '#{$datadir}/#{path}/12/excluded_file_12_because_of_directory'")
|
|
51
|
+
system("rm #{$datadir}/#{path}/4/file4")
|
|
52
|
+
system("rm -rf #{$datadir}/#{path}/9")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def setup_ordering(name)
|
|
56
|
+
num = 9
|
|
57
|
+
path = "rsync/testing/#{name}"
|
|
58
|
+
# Create source dir
|
|
59
|
+
1.upto(num) do |n|
|
|
60
|
+
system("mkdir -p #{$datadir}/#{path}/pkg#{n}/files/#{n}")
|
|
61
|
+
system("echo #{n} > #{$datadir}/#{path}/pkg#{n}/files/file#{n}")
|
|
62
|
+
system("echo #{n} > #{$datadir}/#{path}/pkg#{n}/files/#{n}/file#{n}")
|
|
63
|
+
end
|
|
64
|
+
system("echo 'win' > #{$datadir}/#{path}/pkg2/files/file_contains_win")
|
|
65
|
+
system("echo 'lose' > #{$datadir}/#{path}/pkg3/files/file_contains_win")
|
|
66
|
+
system("echo 'lose' > #{$datadir}/#{path}/pkg4/files/file_contains_win")
|
|
67
|
+
system("echo 'lose' > #{$datadir}/#{path}/pkg5/files/file_contains_win")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def setup_testhost
|
|
71
|
+
system("mkdir -p #{$datadir}/hosts/already.exists/hostname/overrides")
|
|
72
|
+
File::open("#{$datadir}/hosts/already.exists/hostname/host.yml", "w") do |f|
|
|
73
|
+
f.puts("
|
|
74
|
+
config:
|
|
75
|
+
package_base: test_dist
|
|
76
|
+
release_tag: current
|
|
77
|
+
rsync_path:
|
|
78
|
+
ssh_port:
|
|
79
|
+
session_mode:
|
|
80
|
+
include:
|
|
81
|
+
# - section/packagename
|
|
82
|
+
exclude:
|
|
83
|
+
# - /somefile
|
|
84
|
+
exclude_backup:
|
|
85
|
+
# - /somefile
|
|
86
|
+
execute:
|
|
87
|
+
# - some arbitrary command
|
|
88
|
+
")
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def setup_testpackage
|
|
93
|
+
path = "#{$datadir}/packages/test_dist/section1/package1"
|
|
94
|
+
system("mkdir -p #{path}/1.0/files")
|
|
95
|
+
system("ln -s #{path}/1.0 #{path}/current")
|
|
96
|
+
File::open("#{path}/1.0/package.yml", "w") do |f|
|
|
97
|
+
f.puts("
|
|
98
|
+
rank:
|
|
99
|
+
include:
|
|
100
|
+
# - section/packagename
|
|
101
|
+
exclude:
|
|
102
|
+
# - /somefile
|
|
103
|
+
exclude_backup:
|
|
104
|
+
# - /somefile
|
|
105
|
+
execute:
|
|
106
|
+
# - some arbitrary command
|
|
107
|
+
")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def setup_test_env
|
|
113
|
+
print "Setting up new testing work area..."
|
|
114
|
+
setup_source("source")
|
|
115
|
+
setup_ordering("source_ordering")
|
|
116
|
+
setup_testhost
|
|
117
|
+
setup_testpackage
|
|
118
|
+
# Sleep for 1.1 seconds ensures that the modify timestamp on the stuff which gets changed by 'setup_changes'
|
|
119
|
+
# will be at least 1.1 seconds different than the source otherwise, rsync may not count it as being different
|
|
120
|
+
# because of the 'quick check' we do by default with rsync.
|
|
121
|
+
sleep 1.1
|
|
122
|
+
setup_changes("source_changes")
|
|
123
|
+
puts "done."
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
clean_up
|
|
127
|
+
setup_test_env
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'ssh_funcs.rb'
|
|
2
|
+
|
|
3
|
+
describe SSHFuncs do
|
|
4
|
+
|
|
5
|
+
it "opens an ssh channel to localhost and gets hostname output" do
|
|
6
|
+
c = SSHFuncs.new("localhost")
|
|
7
|
+
c.run_cmd("uname")
|
|
8
|
+
c.output.chomp.should == "Linux"
|
|
9
|
+
c.run_cmd("echo \"cool\"")
|
|
10
|
+
c.output.chomp.should == "cool"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
Binary file
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rsynconrails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Joshua McClintock
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.3'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
description: A gem for the rsynconrails app
|
|
42
|
+
email: joshua@gravityedge.com
|
|
43
|
+
executables: []
|
|
44
|
+
extensions: []
|
|
45
|
+
extra_rdoc_files: []
|
|
46
|
+
files:
|
|
47
|
+
- .gitignore
|
|
48
|
+
- .ruby-gemset
|
|
49
|
+
- .ruby-version
|
|
50
|
+
- Gemfile
|
|
51
|
+
- Gemfile.lock
|
|
52
|
+
- README.license
|
|
53
|
+
- README.md
|
|
54
|
+
- config/system_config.yml
|
|
55
|
+
- lib/cli_funcs.rb
|
|
56
|
+
- lib/cli_funcs_cpio.rb
|
|
57
|
+
- lib/cli_funcs_rpm.rb
|
|
58
|
+
- lib/cli_funcs_rpm2cpio.rb
|
|
59
|
+
- lib/cli_funcs_rsync.rb
|
|
60
|
+
- lib/cli_utils.rb
|
|
61
|
+
- lib/host.rb
|
|
62
|
+
- lib/package.rb
|
|
63
|
+
- lib/ssh_funcs.rb
|
|
64
|
+
- lib/system_config.rb
|
|
65
|
+
- spec/cli_funcs_cpio_spec.rb
|
|
66
|
+
- spec/cli_funcs_rpm2cpio_spec.rb
|
|
67
|
+
- spec/cli_funcs_rpm_spec.rb
|
|
68
|
+
- spec/cli_funcs_rsync_spec.rb
|
|
69
|
+
- spec/cli_funcs_spec.rb
|
|
70
|
+
- spec/cli_utils_spec.rb
|
|
71
|
+
- spec/host_spec.rb
|
|
72
|
+
- spec/package_spec.rb
|
|
73
|
+
- spec/spec_helper.rb
|
|
74
|
+
- spec/ssh_funcs_spec.rb
|
|
75
|
+
- testfiles/libcom_err-1.41.12-14.el6_4.2.x86_64.rpm
|
|
76
|
+
- testfiles/postfix-2.6.6-2.2.el6_1.x86_64.rpm
|
|
77
|
+
homepage: https://github.com/helperton/rsynconrails
|
|
78
|
+
licenses:
|
|
79
|
+
- GPL-2
|
|
80
|
+
metadata: {}
|
|
81
|
+
post_install_message:
|
|
82
|
+
rdoc_options: []
|
|
83
|
+
require_paths:
|
|
84
|
+
- lib
|
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - '>='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - '>='
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
requirements: []
|
|
96
|
+
rubyforge_project:
|
|
97
|
+
rubygems_version: 2.0.3
|
|
98
|
+
signing_key:
|
|
99
|
+
specification_version: 4
|
|
100
|
+
summary: rsynconrails
|
|
101
|
+
test_files:
|
|
102
|
+
- spec/cli_funcs_cpio_spec.rb
|
|
103
|
+
- spec/cli_funcs_rpm2cpio_spec.rb
|
|
104
|
+
- spec/cli_funcs_rpm_spec.rb
|
|
105
|
+
- spec/cli_funcs_rsync_spec.rb
|
|
106
|
+
- spec/cli_funcs_spec.rb
|
|
107
|
+
- spec/cli_utils_spec.rb
|
|
108
|
+
- spec/host_spec.rb
|
|
109
|
+
- spec/package_spec.rb
|
|
110
|
+
- spec/spec_helper.rb
|
|
111
|
+
- spec/ssh_funcs_spec.rb
|