linux_admin 1.2.1 → 2.0.1
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 +4 -4
- data/README.md +1 -1
- data/lib/linux_admin.rb +0 -8
- data/lib/linux_admin/chrony.rb +1 -0
- data/lib/linux_admin/disk.rb +31 -7
- data/lib/linux_admin/fstab.rb +29 -14
- data/lib/linux_admin/partition.rb +1 -1
- data/lib/linux_admin/registration_system.rb +8 -4
- data/lib/linux_admin/scap.rb +1 -1
- data/lib/linux_admin/service/sys_v_init_service.rb +2 -1
- data/lib/linux_admin/service/systemd_service.rb +6 -2
- data/lib/linux_admin/version.rb +1 -1
- metadata +36 -120
- data/lib/linux_admin/registration_system/rhn.rb +0 -111
- data/spec/chrony_spec.rb +0 -64
- data/spec/common_spec.rb +0 -37
- data/spec/data/rhn/output_rhn-channel_list +0 -2
- data/spec/data/rhn/output_rhn-channel_list_available +0 -4
- data/spec/data/rhn/systemid +0 -57
- data/spec/data/rhn/systemid.missing_system_id +0 -57
- data/spec/data/rpm/cmd_output_for_list_installed +0 -20
- data/spec/data/subscription_manager/output_list_all_available +0 -42
- data/spec/data/subscription_manager/output_list_installed_not_subscribed +0 -19
- data/spec/data/subscription_manager/output_list_installed_subscribed +0 -19
- data/spec/data/subscription_manager/output_orgs +0 -6
- data/spec/data/subscription_manager/output_repos +0 -18
- data/spec/data/time_date/timedatectl_output +0 -14
- data/spec/data/yum/first.repo +0 -19
- data/spec/data/yum/output_repo_list +0 -13
- data/spec/data/yum/output_repoquery_multiple +0 -3
- data/spec/data/yum/output_repoquery_single +0 -1
- data/spec/data/yum/second.repo +0 -9
- data/spec/deb_spec.rb +0 -52
- data/spec/disk_spec.rb +0 -244
- data/spec/distro_spec.rb +0 -77
- data/spec/dns_spec.rb +0 -105
- data/spec/etc_issue_spec.rb +0 -37
- data/spec/fstab_spec.rb +0 -66
- data/spec/hardware_spec.rb +0 -46
- data/spec/hosts_spec.rb +0 -150
- data/spec/ip_address_spec.rb +0 -148
- data/spec/logical_volume_spec.rb +0 -166
- data/spec/mountable_spec.rb +0 -182
- data/spec/network_interface/network_interface_rh_spec.rb +0 -291
- data/spec/network_interface_spec.rb +0 -284
- data/spec/partition_spec.rb +0 -24
- data/spec/physical_volume_spec.rb +0 -101
- data/spec/registration_system_spec.rb +0 -85
- data/spec/rhn_spec.rb +0 -144
- data/spec/rpm_spec.rb +0 -85
- data/spec/scap_spec.rb +0 -48
- data/spec/service/sys_v_init_service_spec.rb +0 -127
- data/spec/service/systemd_service_spec.rb +0 -133
- data/spec/service_spec.rb +0 -54
- data/spec/spec_helper.rb +0 -116
- data/spec/ssh_spec.rb +0 -53
- data/spec/subscription_manager_spec.rb +0 -228
- data/spec/system_spec.rb +0 -15
- data/spec/time_date_spec.rb +0 -106
- data/spec/volume_group_spec.rb +0 -99
- data/spec/yum_spec.rb +0 -155
data/spec/rhn_spec.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Rhn do
|
2
|
-
context "#registered?" do
|
3
|
-
it "with registered system_id" do
|
4
|
-
allow_any_instance_of(described_class).to receive_messages(:systemid_file => data_file_path("rhn/systemid"))
|
5
|
-
expect(described_class.new).to be_registered
|
6
|
-
end
|
7
|
-
|
8
|
-
it "with unregistered system_id" do
|
9
|
-
allow_any_instance_of(described_class).to receive_messages(:systemid_file => data_file_path("rhn/systemid.missing_system_id"))
|
10
|
-
expect(described_class.new).to_not be_registered
|
11
|
-
end
|
12
|
-
|
13
|
-
it "with missing systemid file" do
|
14
|
-
allow_any_instance_of(described_class).to receive_messages(:systemid_file => data_file_path("rhn/systemid.missing_file"))
|
15
|
-
expect(described_class.new).to_not be_registered
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "#register" do
|
20
|
-
it "no username or activation key" do
|
21
|
-
expect { described_class.new.register({}) }.to raise_error(ArgumentError)
|
22
|
-
end
|
23
|
-
|
24
|
-
context "with username and password" do
|
25
|
-
let(:base_options) { {:username => "SomeUser@SomeDomain.org",
|
26
|
-
:password => "SomePass",
|
27
|
-
:org => "2",
|
28
|
-
:proxy_address => "1.2.3.4",
|
29
|
-
:proxy_username => "ProxyUser",
|
30
|
-
:proxy_password => "ProxyPass",
|
31
|
-
:server_cert => "/path/to/cert",
|
32
|
-
}
|
33
|
-
}
|
34
|
-
let(:run_params) { {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass"}} }
|
35
|
-
|
36
|
-
it "with server_url" do
|
37
|
-
run_params.store_path(:params, "--systemorgid=", "2")
|
38
|
-
run_params.store_path(:params, "--serverUrl=", "https://server.url")
|
39
|
-
run_params.store_path(:params, "--sslCACert=", "/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT")
|
40
|
-
base_options.store_path(:server_url, "https://server.url")
|
41
|
-
|
42
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("rhnreg_ks", run_params)
|
43
|
-
expect(LinuxAdmin::Rpm).to receive(:upgrade).with("http://server.url/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm")
|
44
|
-
expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => "1.0"})
|
45
|
-
|
46
|
-
described_class.new.register(base_options)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "without server_url" do
|
50
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("rhnreg_ks", run_params)
|
51
|
-
expect_any_instance_of(described_class).not_to receive(:install_server_certificate)
|
52
|
-
expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => nil})
|
53
|
-
|
54
|
-
described_class.new.register(base_options)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it "with activation key" do
|
59
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("rhnreg_ks",
|
60
|
-
:params => {"--activationkey=" => "123abc",
|
61
|
-
"--proxy=" => "1.2.3.4",
|
62
|
-
"--proxyUser=" => "ProxyUser",
|
63
|
-
"--proxyPassword=" => "ProxyPass"})
|
64
|
-
expect(LinuxAdmin::Rpm).to receive(:list_installed).and_return({"rhn-org-trusted-ssl-cert" => nil})
|
65
|
-
|
66
|
-
described_class.new.register(
|
67
|
-
:activationkey => "123abc",
|
68
|
-
:proxy_address => "1.2.3.4",
|
69
|
-
:proxy_username => "ProxyUser",
|
70
|
-
:proxy_password => "ProxyPass",
|
71
|
-
)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
it "#enable_channel" do
|
76
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -a",
|
77
|
-
:params => {"--user=" => "SomeUser",
|
78
|
-
"--password=" => "SomePass",
|
79
|
-
"--channel=" => 123})
|
80
|
-
|
81
|
-
described_class.new.enable_channel(123, :username => "SomeUser", :password => "SomePass")
|
82
|
-
end
|
83
|
-
|
84
|
-
it "#enabled_channels" do
|
85
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -l")
|
86
|
-
.and_return(double(:output => sample_output("rhn/output_rhn-channel_list")))
|
87
|
-
|
88
|
-
expect(described_class.new.enabled_channels).to eq(["rhel-x86_64-server-6", "rhel-x86_64-server-6-cf-me-2"])
|
89
|
-
end
|
90
|
-
|
91
|
-
it "#disable_channel" do
|
92
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -r", :params => {"--user=" => "SomeUser",
|
93
|
-
"--password=" => "SomePass",
|
94
|
-
"--channel=" => 123})
|
95
|
-
|
96
|
-
described_class.new.disable_channel(123, :username => "SomeUser", :password => "SomePass")
|
97
|
-
end
|
98
|
-
|
99
|
-
it "#available_channels" do
|
100
|
-
credentials = {
|
101
|
-
:username => "some_user",
|
102
|
-
:password => "password"
|
103
|
-
}
|
104
|
-
expected = [
|
105
|
-
"rhel-x86_64-server-6-cf-me-2",
|
106
|
-
"rhel-x86_64-server-6-cf-me-2-beta",
|
107
|
-
"rhel-x86_64-server-6-cf-me-3",
|
108
|
-
"rhel-x86_64-server-6-cf-me-3-beta"
|
109
|
-
]
|
110
|
-
cmd = "rhn-channel -L"
|
111
|
-
params = {
|
112
|
-
:params => {
|
113
|
-
"--user=" => "some_user",
|
114
|
-
"--password=" => "password"
|
115
|
-
}
|
116
|
-
}
|
117
|
-
|
118
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with(cmd, params)
|
119
|
-
.and_return(double(:output => sample_output("rhn/output_rhn-channel_list_available")))
|
120
|
-
|
121
|
-
expect(described_class.new.available_channels(credentials)).to eq(expected)
|
122
|
-
end
|
123
|
-
|
124
|
-
it "#all_repos" do
|
125
|
-
credentials = {
|
126
|
-
:username => "some_user",
|
127
|
-
:password => "password"
|
128
|
-
}
|
129
|
-
expected = [
|
130
|
-
{:repo_id => "rhel-x86_64-server-6-cf-me-2", :enabled => true},
|
131
|
-
{:repo_id => "rhel-x86_64-server-6-cf-me-2-beta", :enabled => false},
|
132
|
-
{:repo_id => "rhel-x86_64-server-6-cf-me-3", :enabled => false},
|
133
|
-
{:repo_id => "rhel-x86_64-server-6-cf-me-3-beta", :enabled => false},
|
134
|
-
{:repo_id => "rhel-x86_64-server-6", :enabled => true}
|
135
|
-
]
|
136
|
-
|
137
|
-
expect(LinuxAdmin::Common).to receive(:run!).once
|
138
|
-
.and_return(double(:output => sample_output("rhn/output_rhn-channel_list_available")))
|
139
|
-
expect(LinuxAdmin::Common).to receive(:run!).once.with("rhn-channel -l")
|
140
|
-
.and_return(double(:output => sample_output("rhn/output_rhn-channel_list")))
|
141
|
-
|
142
|
-
expect(described_class.new.all_repos(credentials)).to eq(expected)
|
143
|
-
end
|
144
|
-
end
|
data/spec/rpm_spec.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Rpm do
|
2
|
-
it ".list_installed" do
|
3
|
-
allow(LinuxAdmin::Common).to receive(:run!)
|
4
|
-
.and_return(double(:output => sample_output("rpm/cmd_output_for_list_installed")))
|
5
|
-
expect(described_class.list_installed).to eq({
|
6
|
-
"ruby193-rubygem-some_really_long_name" =>"1.0.7-1.el6",
|
7
|
-
"fipscheck-lib" =>"1.2.0-7.el6",
|
8
|
-
"aic94xx-firmware" =>"30-2.el6",
|
9
|
-
"latencytop-common" =>"0.5-9.el6",
|
10
|
-
"uuid" =>"1.6.1-10.el6",
|
11
|
-
"ConsoleKit" =>"0.4.1-3.el6",
|
12
|
-
"cpuspeed" =>"1.5-19.el6",
|
13
|
-
"mailcap" =>"2.1.31-2.el6",
|
14
|
-
"freetds" =>"0.82-7.1.el6cf",
|
15
|
-
"elinks" =>"0.12-0.21.pre5.el6_3",
|
16
|
-
"abrt-cli" =>"2.0.8-15.el6",
|
17
|
-
"libattr" =>"2.4.44-7.el6",
|
18
|
-
"passwd" =>"0.77-4.el6_2.2",
|
19
|
-
"vim-enhanced" =>"7.2.411-1.8.el6",
|
20
|
-
"popt" =>"1.13-7.el6",
|
21
|
-
"hesiod" =>"3.1.0-19.el6",
|
22
|
-
"pinfo" =>"0.6.9-12.el6",
|
23
|
-
"libpng" =>"1.2.49-1.el6_2",
|
24
|
-
"libdhash" =>"0.4.2-9.el6",
|
25
|
-
"zlib-devel" =>"1.2.3-29.el6",
|
26
|
-
})
|
27
|
-
end
|
28
|
-
|
29
|
-
it ".import_key" do
|
30
|
-
expect(LinuxAdmin::Common).to receive(:run!).with("rpm", :params => {"--import" => "abc"})
|
31
|
-
expect { described_class.import_key("abc") }.to_not raise_error
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#info" do
|
35
|
-
it "returns package metadata" do
|
36
|
-
# as output w/ rpm -qi ruby on F19
|
37
|
-
data = <<EOS
|
38
|
-
Name : ruby
|
39
|
-
Version : 2.0.0.247
|
40
|
-
Release : 15.fc19
|
41
|
-
Architecture: x86_64
|
42
|
-
Install Date: Sat 19 Oct 2013 08:17:20 PM EDT
|
43
|
-
Group : Development/Languages
|
44
|
-
Size : 64473
|
45
|
-
License : (Ruby or BSD) and Public Domain
|
46
|
-
Signature : RSA/SHA256, Thu 01 Aug 2013 02:07:03 PM EDT, Key ID 07477e65fb4b18e6
|
47
|
-
Source RPM : ruby-2.0.0.247-15.fc19.src.rpm
|
48
|
-
Build Date : Wed 31 Jul 2013 08:26:49 AM EDT
|
49
|
-
Build Host : buildvm-16.phx2.fedoraproject.org
|
50
|
-
Relocations : (not relocatable)
|
51
|
-
Packager : Fedora Project
|
52
|
-
Vendor : Fedora Project
|
53
|
-
URL : http://ruby-lang.org/
|
54
|
-
Summary : An interpreter of object-oriented scripting language
|
55
|
-
Description :
|
56
|
-
Ruby is the interpreted scripting language for quick and easy
|
57
|
-
object-oriented programming. It has many features to process text
|
58
|
-
files and to do system management tasks (as in Perl). It is simple,
|
59
|
-
straight-forward, and extensible.
|
60
|
-
EOS
|
61
|
-
arguments = [described_class.rpm_cmd, :params => {"-qi" => "ruby"}]
|
62
|
-
result = AwesomeSpawn::CommandResult.new("", data, "", 0)
|
63
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(*arguments).and_return(result)
|
64
|
-
metadata = described_class.info("ruby")
|
65
|
-
expect(metadata['name']).to eq('ruby')
|
66
|
-
expect(metadata['version']).to eq('2.0.0.247')
|
67
|
-
expect(metadata['release']).to eq('15.fc19')
|
68
|
-
expect(metadata['architecture']).to eq('x86_64')
|
69
|
-
expect(metadata['group']).to eq('Development/Languages')
|
70
|
-
expect(metadata['size']).to eq('64473')
|
71
|
-
expect(metadata['license']).to eq('(Ruby or BSD) and Public Domain')
|
72
|
-
expect(metadata['source_rpm']).to eq('ruby-2.0.0.247-15.fc19.src.rpm')
|
73
|
-
expect(metadata['build_host']).to eq('buildvm-16.phx2.fedoraproject.org')
|
74
|
-
expect(metadata['packager']).to eq('Fedora Project')
|
75
|
-
expect(metadata['vendor']).to eq('Fedora Project')
|
76
|
-
expect(metadata['summary']).to eq('An interpreter of object-oriented scripting language')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it ".upgrade" do
|
81
|
-
expect(LinuxAdmin::Common).to receive(:run).with("rpm -U", :params => {nil => "abc"})
|
82
|
-
.and_return(double(:exit_status => 0))
|
83
|
-
expect(described_class.upgrade("abc")).to be_truthy
|
84
|
-
end
|
85
|
-
end
|
data/spec/scap_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Scap do
|
2
|
-
subject { described_class.new("rhel7") }
|
3
|
-
|
4
|
-
describe "#lockdown" do
|
5
|
-
it "raises if given no rules" do
|
6
|
-
allow(described_class).to receive(:openscap_available?).and_return(true)
|
7
|
-
allow(described_class).to receive(:ssg_available?).and_return(true)
|
8
|
-
|
9
|
-
expect { subject.lockdown("value1" => true) }.to raise_error(RuntimeError)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#profile_xml (private)" do
|
14
|
-
it "creates a Profile tag" do
|
15
|
-
profile_xml = subject.send(:profile_xml, "test-profile", [], {})
|
16
|
-
expect(profile_xml).to match(%r{<Profile id="test-profile">.*</Profile>}m)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "creates a title tag" do
|
20
|
-
profile_xml = subject.send(:profile_xml, "test-profile", [], {})
|
21
|
-
expect(profile_xml).to match(%r{<title>test-profile</title>}m)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "creates a description tag" do
|
25
|
-
profile_xml = subject.send(:profile_xml, "test-profile", [], {})
|
26
|
-
expect(profile_xml).to match(%r{<description>test-profile</description>}m)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "creates a select tag for each rule" do
|
30
|
-
profile_xml = subject.send(:profile_xml, "test-profile", %w(rule1 rule2), {})
|
31
|
-
expect(profile_xml).to match(%r{<select idref="rule1" selected="true"/>}m)
|
32
|
-
expect(profile_xml).to match(%r{<select idref="rule2" selected="true"/>}m)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "creates a refine-value tag for each value" do
|
36
|
-
profile_xml = subject.send(:profile_xml, "test-profile", [], "key1" => "val1", "key2" => "val2")
|
37
|
-
expect(profile_xml).to match(%r{<refine-value idref="key1" selector="val1"/>}m)
|
38
|
-
expect(profile_xml).to match(%r{<refine-value idref="key2" selector="val2"/>}m)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".ds_file" do
|
43
|
-
it "returns the platform ds file path" do
|
44
|
-
file = described_class.ds_file("rhel7")
|
45
|
-
expect(file.to_s).to eq("/usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::SysVInitService do
|
2
|
-
before do
|
3
|
-
@service = described_class.new 'foo'
|
4
|
-
end
|
5
|
-
|
6
|
-
describe "#running?" do
|
7
|
-
it "checks service" do
|
8
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
9
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
10
|
-
:params => {nil => %w(foo status)}).and_return(double(:exit_status => 0))
|
11
|
-
@service.running?
|
12
|
-
end
|
13
|
-
|
14
|
-
context "service is running" do
|
15
|
-
it "returns true" do
|
16
|
-
@service = described_class.new :id => :foo
|
17
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
|
18
|
-
expect(@service).to be_running
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "service is not running" do
|
23
|
-
it "returns false" do
|
24
|
-
@service = described_class.new :id => :foo
|
25
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
|
26
|
-
expect(@service).not_to be_running
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#enable" do
|
32
|
-
it "enables service" do
|
33
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
34
|
-
.with(LinuxAdmin::Common.cmd(:chkconfig),
|
35
|
-
:params => {nil => %w(foo on)})
|
36
|
-
@service.enable
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns self" do
|
40
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out cmd invocation
|
41
|
-
expect(@service.enable).to eq(@service)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#disable" do
|
46
|
-
it "disable service" do
|
47
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
48
|
-
.with(LinuxAdmin::Common.cmd(:chkconfig),
|
49
|
-
:params => {nil => %w(foo off)})
|
50
|
-
@service.disable
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns self" do
|
54
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
55
|
-
expect(@service.disable).to eq(@service)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#start" do
|
60
|
-
it "starts service" do
|
61
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
62
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
63
|
-
:params => {nil => %w(foo start)})
|
64
|
-
@service.start
|
65
|
-
end
|
66
|
-
|
67
|
-
it "returns self" do
|
68
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
69
|
-
expect(@service.start).to eq(@service)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#stop" do
|
74
|
-
it "stops service" do
|
75
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
76
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
77
|
-
:params => {nil => %w(foo stop)})
|
78
|
-
@service.stop
|
79
|
-
end
|
80
|
-
|
81
|
-
it "returns self" do
|
82
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
83
|
-
expect(@service.stop).to eq(@service)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "#restart" do
|
88
|
-
it "stops service" do
|
89
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
90
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
91
|
-
:params => {nil => %w(foo restart)}).and_return(double(:exit_status => 0))
|
92
|
-
@service.restart
|
93
|
-
end
|
94
|
-
|
95
|
-
context "service restart fails" do
|
96
|
-
it "manually stops/starts service" do
|
97
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
|
98
|
-
expect(@service).to receive(:stop)
|
99
|
-
expect(@service).to receive(:start)
|
100
|
-
@service.restart
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
it "returns self" do
|
105
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
|
106
|
-
expect(@service.restart).to eq(@service)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "#reload" do
|
111
|
-
it "reloads service" do
|
112
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
113
|
-
.with(LinuxAdmin::Common.cmd(:service), :params => %w(foo reload))
|
114
|
-
expect(@service.reload).to eq(@service)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe "#status" do
|
119
|
-
it "returns the service status" do
|
120
|
-
status = "service status here"
|
121
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
122
|
-
.with(LinuxAdmin::Common.cmd(:service),
|
123
|
-
:params => %w(foo status)).and_return(double(:output => status))
|
124
|
-
expect(@service.status).to eq(status)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::SystemdService do
|
2
|
-
let(:command) { LinuxAdmin::Common.cmd(:systemctl) }
|
3
|
-
|
4
|
-
before do
|
5
|
-
@service = described_class.new 'foo'
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#running?" do
|
9
|
-
it "checks service" do
|
10
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
11
|
-
.with(command, :params => %w(status foo)).and_return(double(:success? => true))
|
12
|
-
@service.running?
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns true when service is running" do
|
16
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:success? => true))
|
17
|
-
expect(@service).to be_running
|
18
|
-
end
|
19
|
-
|
20
|
-
it "returns false when service is not running" do
|
21
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:success? => false))
|
22
|
-
expect(@service).not_to be_running
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#enable" do
|
27
|
-
it "enables service" do
|
28
|
-
expect(LinuxAdmin::Common).to receive(:run!) .with(command, :params => %w(enable foo))
|
29
|
-
@service.enable
|
30
|
-
end
|
31
|
-
|
32
|
-
it "returns self" do
|
33
|
-
expect(LinuxAdmin::Common).to receive(:run!) # stub out cmd invocation
|
34
|
-
expect(@service.enable).to eq(@service)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#disable" do
|
39
|
-
it "disables service" do
|
40
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(disable foo))
|
41
|
-
@service.disable
|
42
|
-
end
|
43
|
-
|
44
|
-
it "returns self" do
|
45
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
46
|
-
expect(@service.disable).to eq(@service)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#start" do
|
51
|
-
it "starts service" do
|
52
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(start foo))
|
53
|
-
@service.start
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns self" do
|
57
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
58
|
-
expect(@service.start).to eq(@service)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#stop" do
|
63
|
-
it "stops service" do
|
64
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(stop foo))
|
65
|
-
@service.stop
|
66
|
-
end
|
67
|
-
|
68
|
-
it "returns self" do
|
69
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
70
|
-
expect(@service.stop).to eq(@service)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#restart" do
|
75
|
-
it "restarts service" do
|
76
|
-
expect(LinuxAdmin::Common).to receive(:run).with(command, :params => %w(restart foo)).and_return(double(:exit_status => 0))
|
77
|
-
@service.restart
|
78
|
-
end
|
79
|
-
|
80
|
-
it "manually stops then starts service when restart fails" do
|
81
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 1))
|
82
|
-
expect(@service).to receive(:stop)
|
83
|
-
expect(@service).to receive(:start)
|
84
|
-
@service.restart
|
85
|
-
end
|
86
|
-
|
87
|
-
it "returns self" do
|
88
|
-
expect(LinuxAdmin::Common).to receive(:run).and_return(double(:exit_status => 0))
|
89
|
-
expect(@service.restart).to eq(@service)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "#reload" do
|
94
|
-
it "reloads service" do
|
95
|
-
expect(LinuxAdmin::Common).to receive(:run!).with(command, :params => %w(reload foo))
|
96
|
-
expect(@service.reload).to eq(@service)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#status" do
|
101
|
-
it "returns the service status" do
|
102
|
-
status = "service status here"
|
103
|
-
expect(LinuxAdmin::Common).to receive(:run)
|
104
|
-
.with(command, :params => %w(status foo)).and_return(double(:output => status))
|
105
|
-
expect(@service.status).to eq(status)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "#show" do
|
110
|
-
it "returns a hash of runtime information" do
|
111
|
-
output = <<-EOS
|
112
|
-
MainPID=29189
|
113
|
-
ExecMainStartTimestamp=Wed 2017-02-08 13:49:57 EST
|
114
|
-
ExecStart={ path=/bin/sh ; argv[]=/bin/sh -c /bin/evmserver.sh start ; status=0/0 }
|
115
|
-
ExecStop={ path=/bin/sh ; argv[]=/bin/sh -c /bin/evmserver.sh stop ; status=0/0 }
|
116
|
-
ControlGroup=/system.slice/evmserverd.service
|
117
|
-
MemoryCurrent=2865373184
|
118
|
-
EOS
|
119
|
-
|
120
|
-
hash = {
|
121
|
-
"MainPID" => 29_189,
|
122
|
-
"ExecMainStartTimestamp" => Time.new(2017, 2, 8, 13, 49, 57, "-05:00"),
|
123
|
-
"ExecStart" => {"path" => "/bin/sh", "argv[]" => "/bin/sh -c /bin/evmserver.sh start", "status" => "0/0"},
|
124
|
-
"ExecStop" => {"path" => "/bin/sh", "argv[]" => "/bin/sh -c /bin/evmserver.sh stop", "status" => "0/0"},
|
125
|
-
"ControlGroup" => "/system.slice/evmserverd.service",
|
126
|
-
"MemoryCurrent" => 2_865_373_184
|
127
|
-
}
|
128
|
-
expect(LinuxAdmin::Common).to receive(:run!)
|
129
|
-
.with(command, :params => %w(show foo)).and_return(double(:output => output))
|
130
|
-
expect(@service.show).to eq(hash)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|