pennyworth-tool 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.hound.yml +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +18 -0
- data/CONTRIBUTING.md +67 -0
- data/COPYING +674 -0
- data/Gemfile +28 -0
- data/README.md +339 -0
- data/Rakefile +33 -0
- data/bin/pennyworth +26 -0
- data/config/setup.yml +17 -0
- data/examples/README.md +23 -0
- data/examples/kiwi/definitions/base_opensuse13.1_kvm/config.sh +87 -0
- data/examples/kiwi/definitions/base_opensuse13.1_kvm/config.xml +64 -0
- data/examples/kiwi/definitions/base_opensuse13.1_kvm/root/etc/sysconfig/network/ifcfg-eth0 +2 -0
- data/examples/kiwi/definitions/base_opensuse13.1_kvm/root/home/vagrant/.ssh/authorized_keys +1 -0
- data/examples/vagrant/Vagrantfile +14 -0
- data/files/99-libvirt.rules +2 -0
- data/files/image_test-template.xml +43 -0
- data/files/pool-default.xml +6 -0
- data/lib/image_runner.rb +89 -0
- data/lib/pennyworth.rb +65 -0
- data/lib/pennyworth/cli.rb +339 -0
- data/lib/pennyworth/cli_host_controller.rb +107 -0
- data/lib/pennyworth/commands/base_command.rb +96 -0
- data/lib/pennyworth/commands/boot_command.rb +29 -0
- data/lib/pennyworth/commands/build_base_command.rb +103 -0
- data/lib/pennyworth/commands/command.rb +43 -0
- data/lib/pennyworth/commands/down_command.rb +25 -0
- data/lib/pennyworth/commands/import_base_command.rb +112 -0
- data/lib/pennyworth/commands/import_ssh_keys_command.rb +27 -0
- data/lib/pennyworth/commands/list_command.rb +41 -0
- data/lib/pennyworth/commands/setup_command.rb +209 -0
- data/lib/pennyworth/commands/shutdown_command.rb +28 -0
- data/lib/pennyworth/commands/status_command.rb +26 -0
- data/lib/pennyworth/commands/up_command.rb +27 -0
- data/lib/pennyworth/exceptions.rb +39 -0
- data/lib/pennyworth/helper.rb +39 -0
- data/lib/pennyworth/host_config.rb +86 -0
- data/lib/pennyworth/host_runner.rb +133 -0
- data/lib/pennyworth/image_runner.rb +89 -0
- data/lib/pennyworth/libvirt.rb +93 -0
- data/lib/pennyworth/local_command_runner.rb +77 -0
- data/lib/pennyworth/local_runner.rb +34 -0
- data/lib/pennyworth/lock_service.rb +87 -0
- data/lib/pennyworth/remote_command_runner.rb +144 -0
- data/lib/pennyworth/runner.rb +27 -0
- data/lib/pennyworth/settings.rb +42 -0
- data/lib/pennyworth/spec.rb +96 -0
- data/lib/pennyworth/spec_profiler.rb +85 -0
- data/lib/pennyworth/ssh_keys_importer.rb +107 -0
- data/lib/pennyworth/urls.rb +28 -0
- data/lib/pennyworth/vagrant.rb +81 -0
- data/lib/pennyworth/vagrant_command.rb +120 -0
- data/lib/pennyworth/vagrant_runner.rb +44 -0
- data/lib/pennyworth/version.rb +22 -0
- data/lib/pennyworth/vm.rb +62 -0
- data/man/.gitignore +2 -0
- data/man/pennyworth.1.md +28 -0
- data/pennyworth.gemspec +57 -0
- data/prophet/Gemfile +3 -0
- data/prophet/prophet.rb +82 -0
- data/spec/base_command_spec.rb +30 -0
- data/spec/build_base_command_spec.rb +147 -0
- data/spec/cli_host_controller_spec.rb +113 -0
- data/spec/data/hosts.yaml +10 -0
- data/spec/data/kiwi/base_opensuse12.3_kvm.box +1 -0
- data/spec/data/kiwi/base_opensuse13.1_kvm.box +1 -0
- data/spec/data/kiwi/definitions/base_opensuse12.3_kvm/config.sh +1 -0
- data/spec/data/kiwi/definitions/base_opensuse12.3_kvm/config.xml +1 -0
- data/spec/data/kiwi/definitions/base_opensuse12.3_kvm/root/home/vagrant/.ssh/authorized_keys +1 -0
- data/spec/data/kiwi/definitions/base_opensuse13.1_kvm/config.sh +1 -0
- data/spec/data/kiwi/definitions/base_opensuse13.1_kvm/config.xml +1 -0
- data/spec/data/kiwi/definitions/base_opensuse13.1_kvm/root/home/vagrant/.ssh/authorized_keys +1 -0
- data/spec/data/kiwi2/box_state.yaml +14 -0
- data/spec/data/kiwi2/definitions/base_opensuse12.3_kvm/config.sh +1 -0
- data/spec/data/kiwi2/definitions/base_opensuse12.3_kvm/config.xml +1 -0
- data/spec/data/kiwi2/definitions/base_opensuse12.3_kvm/root/home/vagrant/.ssh/authorized_keys +1 -0
- data/spec/data/kiwi2/definitions/base_opensuse13.1_kvm/config.sh +1 -0
- data/spec/data/kiwi2/definitions/base_opensuse13.1_kvm/config.xml +1 -0
- data/spec/data/kiwi2/definitions/base_opensuse13.1_kvm/root/home/vagrant/.ssh/authorized_keys +1 -0
- data/spec/data/kiwi3/box_state.yaml +13 -0
- data/spec/data/kiwi3/definitions/base_opensuse12.3_kvm/.gitkeep +0 -0
- data/spec/data/kiwi3/definitions/base_opensuse13.1_kvm/.gitkeep +0 -0
- data/spec/data/kiwi3/import_state.yaml +3 -0
- data/spec/data/kiwi4/definitions/base_opensuse12.3_kvm/.gitkeep +0 -0
- data/spec/data/kiwi4/definitions/base_opensuse13.1_kvm/.gitkeep +0 -0
- data/spec/data/kiwi4/import_state.yaml +3 -0
- data/spec/data/kiwi5/import_state.yaml +3 -0
- data/spec/data/vagrant/.gitkeep +0 -0
- data/spec/host_config_spec.rb +197 -0
- data/spec/host_runner_spec.rb +112 -0
- data/spec/image_runner_spec.rb +62 -0
- data/spec/import_base_command_spec.rb +189 -0
- data/spec/local_command_runner_spec.rb +117 -0
- data/spec/local_runner_spec.rb +42 -0
- data/spec/lock_service_spec.rb +95 -0
- data/spec/remote_command_runner_spec.rb +115 -0
- data/spec/settings_spec.rb +26 -0
- data/spec/setup_command_spec.rb +49 -0
- data/spec/spec_helper.rb +50 -0
- data/spec/spec_profiler_spec.rb +63 -0
- data/spec/spec_spec.rb +99 -0
- data/spec/support/command_runner_examples.rb +29 -0
- data/spec/support/runner_examples.rb +34 -0
- data/spec/urls_spec.rb +46 -0
- data/spec/vagrant_command_spec.rb +51 -0
- data/spec/vagrant_runner_spec.rb +40 -0
- data/spec/vagrant_spec.rb +288 -0
- data/spec/vm_spec.rb +56 -0
- metadata +257 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
require "spec_helper"
|
19
|
+
|
20
|
+
describe Pennyworth::Settings do
|
21
|
+
|
22
|
+
it "is not verbose by default" do
|
23
|
+
expect(Pennyworth::Settings.new.verbose).to be(false)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
require_relative "../lib/pennyworth/commands/setup_command.rb"
|
18
|
+
|
19
|
+
describe Pennyworth::SetupCommand do
|
20
|
+
let(:setup_command) { Pennyworth::SetupCommand.new }
|
21
|
+
|
22
|
+
describe "#show_warning_for_unsupported_platforms" do
|
23
|
+
it "shows warning if current distribution is openSUSE 13.1" do
|
24
|
+
openSUSE131_release_file = <<-EOF
|
25
|
+
NAME=openSUSE
|
26
|
+
VERSION="13.1 (Bottle)"
|
27
|
+
VERSION_ID="13.1"
|
28
|
+
EOF
|
29
|
+
expect(setup_command).to receive(:read_os_release_file).and_return(openSUSE131_release_file)
|
30
|
+
expect(setup_command).to receive(:log).with(
|
31
|
+
"Warning: Pennyworth is not tested upstream on this platform. " \
|
32
|
+
"Use at your own risk."
|
33
|
+
)
|
34
|
+
setup_command.show_warning_for_unsupported_platforms
|
35
|
+
end
|
36
|
+
|
37
|
+
it "shows no warning for supported SLES 12 distribution" do
|
38
|
+
sles12_release_file = <<-EOF
|
39
|
+
NAME="SLES"
|
40
|
+
VERSION="12"
|
41
|
+
VERSION_ID="12"
|
42
|
+
PRETTY_NAME="SUSE Linux Enterprise Server 12"
|
43
|
+
EOF
|
44
|
+
expect(setup_command).to receive(:read_os_release_file).and_return(sles12_release_file)
|
45
|
+
expect(setup_command).not_to receive(:log)
|
46
|
+
setup_command.show_warning_for_unsupported_platforms
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
require "pennyworth"
|
19
|
+
require "pennyworth/spec"
|
20
|
+
require "webmock/rspec"
|
21
|
+
require "given_filesystem/spec_helpers"
|
22
|
+
|
23
|
+
Dir[File.expand_path("../../spec/support/*.rb", __FILE__)].each do |f|
|
24
|
+
require f
|
25
|
+
end
|
26
|
+
|
27
|
+
bin_path = File.expand_path( "../../bin/", __FILE__ )
|
28
|
+
|
29
|
+
if ENV['PATH'] !~ /#{bin_path}/
|
30
|
+
ENV['PATH'] = bin_path + File::PATH_SEPARATOR + ENV['PATH']
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_data_dir
|
34
|
+
File.expand_path("../data/", __FILE__)
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.configure do |config|
|
38
|
+
# In the pennyworth unit tests we don't want to actually run images only test
|
39
|
+
# pennyworth and its rspec helper. Thus we have to disable the libvirt setup
|
40
|
+
# code in order to not be prompted for the root password each time the tests
|
41
|
+
# are run. We also don't want to profile the pennyworth tests, so that is
|
42
|
+
# disabled in pennyworth mode as well.
|
43
|
+
config.add_setting :pennyworth_mode, default: false
|
44
|
+
config.add_setting :vagrant_dir
|
45
|
+
config.add_setting :hosts_file
|
46
|
+
|
47
|
+
config.vagrant_dir = File.expand_path("../../vagrant", __FILE__)
|
48
|
+
config.hosts_file = File.join(test_data_dir, "hosts.yaml")
|
49
|
+
config.pennyworth_mode = true
|
50
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
require 'pennyworth/spec'
|
19
|
+
|
20
|
+
describe 'Spec Profiler' do
|
21
|
+
it "measures top level items" do
|
22
|
+
@measurements = []
|
23
|
+
measure("top level item") {}
|
24
|
+
|
25
|
+
expect(@measurements.size).to eq(1)
|
26
|
+
expect(@measurements.first[:label]).to eq("top level item")
|
27
|
+
expect(@measurements.first[:child_measurements]).to be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it "measures multiple top level items" do
|
31
|
+
@measurements = []
|
32
|
+
measure("top level item 1") {}
|
33
|
+
measure("top level item 2") {}
|
34
|
+
|
35
|
+
expect(@measurements.size).to eq(2)
|
36
|
+
expect(@measurements.first[:label]).to eq("top level item 1")
|
37
|
+
expect(@measurements.last[:label]).to eq("top level item 2")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "measures nested items" do
|
41
|
+
@measurements = []
|
42
|
+
measure("top level item") do
|
43
|
+
measure("level 1.1") do
|
44
|
+
measure("level 2.1") {}
|
45
|
+
end
|
46
|
+
measure("level 1.2") {}
|
47
|
+
end
|
48
|
+
|
49
|
+
expect(@measurements.size).to eq(1)
|
50
|
+
expect(@measurements.first[:label]).to eq("top level item")
|
51
|
+
|
52
|
+
children = @measurements.first[:child_measurements]
|
53
|
+
expect(children.size).to eq(3)
|
54
|
+
|
55
|
+
expect(children[0][:label]).to eq("level 1.1")
|
56
|
+
child_children = children[0][:child_measurements]
|
57
|
+
expect(child_children.size).to eq(2)
|
58
|
+
expect(child_children[0][:label]).to eq("level 2.1")
|
59
|
+
|
60
|
+
expect(children[1][:child_measurements].size).to eq(0)
|
61
|
+
expect(children[2][:label]).to eq("Other")
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_spec.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
require "pennyworth/spec"
|
19
|
+
|
20
|
+
describe Pennyworth::SpecHelper do
|
21
|
+
let(:system_one) { "openSUSE_13.1" }
|
22
|
+
let(:system_two) { "openSUSE_12.3" }
|
23
|
+
let(:image_one) { "/path/to/openSUSE_13.1.iso" }
|
24
|
+
let(:image_two) { "/path/to/openSUSE_12.3.iso" }
|
25
|
+
|
26
|
+
after(:each) do
|
27
|
+
# Clear list of started systems, otherwise the helper will try to shutdown
|
28
|
+
# boxes which weren't actually started because those calls are stubbed in
|
29
|
+
# the tests.
|
30
|
+
@pennyworth_systems = []
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#start_system" do
|
34
|
+
it "raises an exception if no valid image parameter is given" do
|
35
|
+
expect {
|
36
|
+
start_system(foo: "bar")
|
37
|
+
}.to raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "starts the given vagrant boxes" do
|
41
|
+
runner_one = double
|
42
|
+
expect(Pennyworth::VagrantRunner).to receive(:new).with(system_one, anything, anything) { runner_one }
|
43
|
+
expect(runner_one).to receive(:start)
|
44
|
+
runner_two = double
|
45
|
+
expect(Pennyworth::VagrantRunner).to receive(:new).with(system_two, anything, anything) { runner_two }
|
46
|
+
expect(runner_two).to receive(:start)
|
47
|
+
expect(Pennyworth::SshKeysImporter).to receive(:import).twice
|
48
|
+
|
49
|
+
expect(self.class).to receive(:after).twice
|
50
|
+
start_system(box: system_one)
|
51
|
+
start_system(box: system_two)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "starts the given images" do
|
55
|
+
runner_one = double
|
56
|
+
expect(Pennyworth::ImageRunner).to receive(:new).with(image_one, anything) { runner_one }
|
57
|
+
expect(runner_one).to receive(:start)
|
58
|
+
runner_two = double
|
59
|
+
expect(Pennyworth::ImageRunner).to receive(:new).with(image_two, anything) { runner_two }
|
60
|
+
expect(runner_two).to receive(:start)
|
61
|
+
expect(Pennyworth::SshKeysImporter).to receive(:import).twice
|
62
|
+
|
63
|
+
expect(self.class).to receive(:after).twice
|
64
|
+
start_system(image: image_one)
|
65
|
+
start_system(image: image_two)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "starts the given host" do
|
69
|
+
runner = double
|
70
|
+
expect(runner).to receive(:start)
|
71
|
+
expect(Pennyworth::HostRunner).to receive(:new).
|
72
|
+
with("test_host", instance_of(Pennyworth::HostConfig), "root").
|
73
|
+
and_return(runner)
|
74
|
+
expect(Pennyworth::SshKeysImporter).to_not receive(:import)
|
75
|
+
|
76
|
+
expect(self.class).to receive(:after).once
|
77
|
+
start_system(host: "test_host")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "forwards the username and password options" do
|
81
|
+
runner_one = double
|
82
|
+
expect(Pennyworth::VagrantRunner).to receive(:new).with(system_one, anything, "machinery") { runner_one }
|
83
|
+
expect(runner_one).to receive(:start)
|
84
|
+
expect(Pennyworth::SshKeysImporter).to receive(:import).with(anything, "machinery", "linux")
|
85
|
+
|
86
|
+
start_system(box: system_one, username: "machinery", password: "linux")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "uses LocalRunner for local tests" do
|
90
|
+
opts = {
|
91
|
+
env: { "FOO" => "BAR" }
|
92
|
+
}
|
93
|
+
expect(Pennyworth::LocalRunner).to receive(:new).with(opts).and_call_original
|
94
|
+
expect(Pennyworth::SshKeysImporter).to_not receive(:import)
|
95
|
+
|
96
|
+
start_system(opts.merge(local: true))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
shared_examples "a command runner" do
|
19
|
+
[
|
20
|
+
:run,
|
21
|
+
:inject_file,
|
22
|
+
:extract_file,
|
23
|
+
:inject_directory
|
24
|
+
].each do |method|
|
25
|
+
it "has a #{method} method" do
|
26
|
+
expect(command_runner).to respond_to(method)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
shared_examples "a runner" do
|
19
|
+
it "has a start method" do
|
20
|
+
expect(runner).to respond_to(:start)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has a stop method" do
|
24
|
+
expect(runner).to respond_to(:stop)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a command_runner method" do
|
28
|
+
expect(runner).to respond_to(:command_runner)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has a cleanup_directory method" do
|
32
|
+
expect(runner).to respond_to(:cleanup_directory)
|
33
|
+
end
|
34
|
+
end
|
data/spec/urls_spec.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
require "pennyworth/spec"
|
19
|
+
|
20
|
+
describe Pennyworth::URLs do
|
21
|
+
describe ".join" do
|
22
|
+
it "joins parts using slashes" do
|
23
|
+
expect(Pennyworth::URLs.join("a", "b", "c")).to eq("a/b/c")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "doesn't duplicate slashes before parts containing leading slashes" do
|
27
|
+
expect(Pennyworth::URLs.join("a", "/b", "/c")).to eq("a/b/c")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "doesn't duplicate slashes after parts containing trailing slashes" do
|
31
|
+
expect(Pennyworth::URLs.join("a/", "b/", "c")).to eq("a/b/c")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "doesn't duplicate slashes around empty parts" do
|
35
|
+
expect(Pennyworth::URLs.join("a", "", "c")).to eq("a/c")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "preserves leading slash in the first part" do
|
39
|
+
expect(Pennyworth::URLs.join("/a", "b", "c")).to eq("/a/b/c")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "preserves trailing slash in the last part" do
|
43
|
+
expect(Pennyworth::URLs.join("a", "b", "c/")).to eq("a/b/c/")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright (c) 2013-2014 SUSE LLC
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
5
|
+
# published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program; if not, contact SUSE LLC.
|
14
|
+
#
|
15
|
+
# To contact SUSE about this file by physical or electronic mail,
|
16
|
+
# you may find current contact information at www.suse.com
|
17
|
+
|
18
|
+
require "spec_helper"
|
19
|
+
|
20
|
+
describe Pennyworth::VagrantCommand do
|
21
|
+
|
22
|
+
it "parses output of `vagrant status`" do
|
23
|
+
status_output = <<-EOT
|
24
|
+
Current machine states:
|
25
|
+
|
26
|
+
opensuse123 running (libvirt)
|
27
|
+
opensuse131 not created (libvirt)
|
28
|
+
master not created (libvirt)
|
29
|
+
|
30
|
+
This environment represents multiple VMs. The VMs are all listed
|
31
|
+
above with their current state. For more information about a specific
|
32
|
+
VM, run `vagrant status NAME`.
|
33
|
+
EOT
|
34
|
+
vms = Pennyworth::VagrantCommand.parse_status status_output
|
35
|
+
expect( vms ).to eq [ "opensuse123 (running)","opensuse131","master" ]
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".setup_environment" do
|
39
|
+
it "creates <dir> and calls vagrant init if there is no Vagrantfile" do
|
40
|
+
Dir.mktmpdir("vagrant_command_test") do |tmp_dir|
|
41
|
+
dir = File.join(tmp_dir, "pennyworth")
|
42
|
+
expect(Dir.exists?(dir)).to be(false)
|
43
|
+
expect(Pennyworth::Vagrant).to receive(:new).with(dir).and_call_original
|
44
|
+
expect_any_instance_of(Pennyworth::Vagrant).to receive(:run).with("init")
|
45
|
+
|
46
|
+
Pennyworth::VagrantCommand.setup_environment(dir)
|
47
|
+
expect(Dir.exists?(dir)).to be(true)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|