puppet-library 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/CHANGELOG.yml +1 -0
- data/README.md +9 -4
- data/Rakefile +44 -23
- data/TODO.yml +3 -4
- data/config.ru +28 -3
- data/lib/puppet_library/forge/cache.rb +19 -0
- data/lib/puppet_library/forge/directory.rb +16 -0
- data/lib/puppet_library/forge/git_repository.rb +57 -49
- data/lib/puppet_library/forge/proxy.rb +18 -4
- data/lib/puppet_library/forge/source.rb +10 -0
- data/lib/puppet_library/puppet_library.rb +1 -1
- data/lib/puppet_library/server.rb +12 -3
- data/lib/puppet_library/util/git.rb +103 -0
- data/lib/puppet_library/util/patches.rb +104 -0
- data/lib/puppet_library/util/temp_dir.rb +42 -0
- data/lib/puppet_library/util.rb +4 -70
- data/lib/puppet_library/version.rb +1 -1
- data/spec/archive/archive_reader_spec.rb +9 -2
- data/spec/archive/archiver_spec.rb +4 -0
- data/spec/forge/cache_spec.rb +4 -0
- data/spec/forge/directory_spec.rb +4 -0
- data/spec/forge/git_repository_spec.rb +5 -2
- data/spec/forge/source_spec.rb +4 -0
- data/spec/integration_test_helper.rb +42 -0
- data/spec/util/git_spec.rb +143 -0
- data/spec/util/patches_spec.rb +86 -0
- data/spec/util/temp_dir_spec.rb +35 -0
- data/test/directory_forge_integration_test.rb +96 -0
- data/test/offline_git_repo_forge_integration_test.rb +122 -0
- data/test/offline_proxy_forge_integration_test.rb +126 -0
- data/test/online_git_repo_forge_integration_test.rb +89 -0
- data/test/online_proxy_forge_integration_test.rb +93 -0
- data/test/source_forge_integration_test.rb +96 -0
- metadata +292 -118
- data/spec/util_spec.rb +0 -43
- data/test/librarian_puppet_integration_test.rb +0 -349
@@ -0,0 +1,96 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Puppet Library
|
3
|
+
# Copyright (C) 2014 drrb
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'integration_test_helper'
|
20
|
+
require 'open-uri'
|
21
|
+
|
22
|
+
module PuppetLibrary
|
23
|
+
describe "directory forge" do
|
24
|
+
include ModuleSpecHelper
|
25
|
+
|
26
|
+
let(:port) { Ports.next! }
|
27
|
+
let(:module_dir) { Tempdir.create("module_dir") }
|
28
|
+
let(:project_dir) { Tempdir.create("project_dir") }
|
29
|
+
let(:start_dir) { pwd }
|
30
|
+
let(:disk_server) do
|
31
|
+
Server.configure do |server|
|
32
|
+
server.forge Forge::Directory do |forge|
|
33
|
+
forge.path = module_dir
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
let(:disk_rack_server) do
|
38
|
+
Rack::Server.new(
|
39
|
+
:app => disk_server,
|
40
|
+
:Host => "localhost",
|
41
|
+
:Port => port,
|
42
|
+
:server => "webrick"
|
43
|
+
)
|
44
|
+
end
|
45
|
+
let(:disk_server_runner) do
|
46
|
+
Thread.new do
|
47
|
+
disk_rack_server.start
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
before do
|
52
|
+
# Initialize to catch wiring errors
|
53
|
+
disk_rack_server
|
54
|
+
|
55
|
+
# Start the servers
|
56
|
+
disk_server_runner
|
57
|
+
start_dir
|
58
|
+
cd project_dir
|
59
|
+
end
|
60
|
+
|
61
|
+
after do
|
62
|
+
rm_rf module_dir
|
63
|
+
rm_rf project_dir
|
64
|
+
cd start_dir
|
65
|
+
end
|
66
|
+
|
67
|
+
it "services queries, downloads and searches from a directory" do
|
68
|
+
add_module("puppetlabs", "apache", "1.0.0") do |metadata|
|
69
|
+
metadata["dependencies"] << { "name" => "puppetlabs/concat", "version_requirement" => ">= 2.0.0" }
|
70
|
+
metadata["dependencies"] << { "name" => "puppetlabs/stdlib", "version_requirement" => "~> 3.0.0" }
|
71
|
+
end
|
72
|
+
add_module("puppetlabs", "concat", "2.0.0")
|
73
|
+
add_module("puppetlabs", "stdlib", "3.0.0")
|
74
|
+
|
75
|
+
write_puppetfile <<-EOF
|
76
|
+
forge 'http://localhost:#{port}'
|
77
|
+
mod 'puppetlabs/apache'
|
78
|
+
EOF
|
79
|
+
|
80
|
+
# Install modules
|
81
|
+
system "librarian-puppet install" or fail "call to puppet-library failed"
|
82
|
+
expect("apache").to be_installed
|
83
|
+
expect("concat").to be_installed
|
84
|
+
expect("stdlib").to be_installed
|
85
|
+
|
86
|
+
# Search
|
87
|
+
search_results = JSON.parse(open("http://localhost:#{port}/modules.json").read)
|
88
|
+
found_modules = Hash[search_results.map do |result|
|
89
|
+
[ result["full_name"], result["version"] ]
|
90
|
+
end]
|
91
|
+
expect(found_modules["puppetlabs/apache"]).to eq "1.0.0"
|
92
|
+
expect(found_modules["puppetlabs/concat"]).to eq "2.0.0"
|
93
|
+
expect(found_modules["puppetlabs/stdlib"]).to eq "3.0.0"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Puppet Library
|
3
|
+
# Copyright (C) 2014 drrb
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'integration_test_helper'
|
20
|
+
require 'open-uri'
|
21
|
+
|
22
|
+
module PuppetLibrary
|
23
|
+
describe "offline git repo forge" do
|
24
|
+
@@repo_path = Tempdir.create("git-repo")
|
25
|
+
@@versions = [ "0.9.0", "1.0.0-rc1", "1.0.0" ]
|
26
|
+
@@tags = @@versions + [ "xxx" ]
|
27
|
+
|
28
|
+
before :all do
|
29
|
+
def git(command)
|
30
|
+
git_command = "git --git-dir=#{@@repo_path}/.git --work-tree=#{@@repo_path} #{command}"
|
31
|
+
`#{git_command}`
|
32
|
+
unless $?.success?
|
33
|
+
raise "Failed to run command: \"#{git_command}\""
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
git "init"
|
38
|
+
git "config user.name tester"
|
39
|
+
git "config user.email tester@example.com"
|
40
|
+
@@versions.zip(@@tags).each do |(version, tag)|
|
41
|
+
File.open(File.join(@@repo_path, "Modulefile"), "w") do |modulefile|
|
42
|
+
modulefile.write <<-MODULEFILE
|
43
|
+
name 'puppetlabs-apache'
|
44
|
+
version '#{version}'
|
45
|
+
author 'puppetlabs'
|
46
|
+
MODULEFILE
|
47
|
+
end
|
48
|
+
git "add ."
|
49
|
+
git "commit --message='Version #{version}'"
|
50
|
+
git "tag #{tag}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
after :all do
|
55
|
+
rm_rf @@repo_path
|
56
|
+
end
|
57
|
+
|
58
|
+
include ModuleSpecHelper
|
59
|
+
|
60
|
+
let(:port) { Ports.next! }
|
61
|
+
let(:project_dir) { Tempdir.create("project_dir") }
|
62
|
+
let(:start_dir) { pwd }
|
63
|
+
let(:git_server) do
|
64
|
+
Server.configure do |server|
|
65
|
+
server.forge Forge::GitRepository do |forge|
|
66
|
+
forge.source = @@repo_path
|
67
|
+
forge.include_tags = /^[0-9.]+/
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
let(:git_rack_server) do
|
72
|
+
Rack::Server.new(
|
73
|
+
:app => git_server,
|
74
|
+
:Host => "localhost",
|
75
|
+
:Port => port,
|
76
|
+
:server => "webrick"
|
77
|
+
)
|
78
|
+
end
|
79
|
+
let(:git_server_runner) do
|
80
|
+
Thread.new do
|
81
|
+
git_rack_server.start
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
before do
|
86
|
+
# Initialize to catch wiring errors
|
87
|
+
git_rack_server
|
88
|
+
|
89
|
+
# Start the servers
|
90
|
+
git_server_runner
|
91
|
+
start_dir
|
92
|
+
cd project_dir
|
93
|
+
end
|
94
|
+
|
95
|
+
after do
|
96
|
+
rm_rf project_dir
|
97
|
+
cd start_dir
|
98
|
+
end
|
99
|
+
|
100
|
+
it "services queries, downloads and searches from a git repository" do
|
101
|
+
write_puppetfile <<-EOF
|
102
|
+
forge 'http://localhost:#{port}'
|
103
|
+
mod 'puppetlabs/apache'
|
104
|
+
EOF
|
105
|
+
|
106
|
+
# Install modules
|
107
|
+
system "librarian-puppet install" or fail "call to puppet-library failed"
|
108
|
+
expect("apache").to be_installed
|
109
|
+
|
110
|
+
# Search
|
111
|
+
search_results = JSON.parse(open("http://localhost:#{port}/modules.json").read)
|
112
|
+
apache_result = search_results.first
|
113
|
+
expect(apache_result["full_name"]).to eq "puppetlabs/apache"
|
114
|
+
expect(apache_result["releases"]).to eq [{"version"=>"1.0.0"}, {"version"=>"1.0.0-rc1"}, {"version"=>"0.9.0"}]
|
115
|
+
|
116
|
+
# Download
|
117
|
+
archive = open("http://localhost:#{port}/modules/puppetlabs-apache-0.9.0.tar.gz")
|
118
|
+
expect(archive).to be_tgz_with /Modulefile/, /puppetlabs-apache/
|
119
|
+
expect(archive).to be_tgz_with /metadata.json/, /"name":"puppetlabs-apache"/
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Puppet Library
|
3
|
+
# Copyright (C) 2014 drrb
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'integration_test_helper'
|
20
|
+
require 'open-uri'
|
21
|
+
|
22
|
+
module PuppetLibrary
|
23
|
+
describe "offline proxy", :no_1_8 => true do
|
24
|
+
include ModuleSpecHelper
|
25
|
+
|
26
|
+
let(:proxy_port) { Ports.next! }
|
27
|
+
let(:disk_port) { Ports.next! }
|
28
|
+
let(:module_dir) { Tempdir.create("module_dir") }
|
29
|
+
let(:project_dir) { Tempdir.create("project_dir") }
|
30
|
+
let(:cache_dir) { Tempdir.create("cache_dir") }
|
31
|
+
let(:start_dir) { pwd }
|
32
|
+
let(:disk_server) do
|
33
|
+
Server.configure do |server|
|
34
|
+
server.forge Forge::Directory do |forge|
|
35
|
+
forge.path = module_dir
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
let(:disk_rack_server) do
|
40
|
+
Rack::Server.new(
|
41
|
+
:app => disk_server,
|
42
|
+
:Host => "localhost",
|
43
|
+
:Port => disk_port,
|
44
|
+
:server => "webrick"
|
45
|
+
)
|
46
|
+
end
|
47
|
+
let(:disk_server_runner) do
|
48
|
+
Thread.new do
|
49
|
+
disk_rack_server.start
|
50
|
+
end
|
51
|
+
end
|
52
|
+
let(:proxy_server) do
|
53
|
+
Server.configure do |server|
|
54
|
+
server.forge Forge::Cache do |forge|
|
55
|
+
forge.url = "http://localhost:#{disk_port}"
|
56
|
+
forge.path = cache_dir
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
let(:proxy_rack_server) do
|
61
|
+
Rack::Server.new(
|
62
|
+
:app => proxy_server,
|
63
|
+
:Host => "localhost",
|
64
|
+
:Port => proxy_port,
|
65
|
+
:server => "webrick"
|
66
|
+
)
|
67
|
+
end
|
68
|
+
let(:proxy_server_runner) do
|
69
|
+
Thread.new do
|
70
|
+
proxy_rack_server.start
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
before do
|
75
|
+
# Initialize to catch wiring errors
|
76
|
+
disk_rack_server
|
77
|
+
proxy_rack_server
|
78
|
+
|
79
|
+
# Start the servers
|
80
|
+
disk_server_runner
|
81
|
+
proxy_server_runner
|
82
|
+
start_dir
|
83
|
+
cd project_dir
|
84
|
+
end
|
85
|
+
|
86
|
+
after do
|
87
|
+
rm_rf module_dir
|
88
|
+
rm_rf project_dir
|
89
|
+
rm_rf cache_dir
|
90
|
+
cd start_dir
|
91
|
+
end
|
92
|
+
|
93
|
+
it "services queries, downloads and searches through a proxy to a directory" do
|
94
|
+
add_module("puppetlabs", "apache", "1.0.0") do |metadata|
|
95
|
+
metadata["dependencies"] << { "name" => "puppetlabs/concat", "version_requirement" => ">= 2.0.0" }
|
96
|
+
metadata["dependencies"] << { "name" => "puppetlabs/stdlib", "version_requirement" => "~> 3.0.0" }
|
97
|
+
end
|
98
|
+
add_module("puppetlabs", "concat", "2.0.0")
|
99
|
+
add_module("puppetlabs", "stdlib", "3.0.0")
|
100
|
+
|
101
|
+
write_puppetfile <<-EOF
|
102
|
+
forge 'http://localhost:#{proxy_port}'
|
103
|
+
mod 'puppetlabs/apache'
|
104
|
+
EOF
|
105
|
+
|
106
|
+
# Install modules through the proxy
|
107
|
+
system "librarian-puppet install" or fail "call to puppet-library failed"
|
108
|
+
expect("apache").to be_installed
|
109
|
+
expect("concat").to be_installed
|
110
|
+
expect("stdlib").to be_installed
|
111
|
+
|
112
|
+
expect("puppetlabs-apache-1.0.0.tar.gz").to be_cached
|
113
|
+
expect("puppetlabs-concat-2.0.0.tar.gz").to be_cached
|
114
|
+
expect("puppetlabs-stdlib-3.0.0.tar.gz").to be_cached
|
115
|
+
|
116
|
+
# Search through the proxy
|
117
|
+
search_results = JSON.parse(open("http://localhost:#{proxy_port}/modules.json").read)
|
118
|
+
found_modules = Hash[search_results.map do |result|
|
119
|
+
[ result["full_name"], result["version"] ]
|
120
|
+
end]
|
121
|
+
expect(found_modules["puppetlabs/apache"]).to eq "1.0.0"
|
122
|
+
expect(found_modules["puppetlabs/concat"]).to eq "2.0.0"
|
123
|
+
expect(found_modules["puppetlabs/stdlib"]).to eq "3.0.0"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Puppet Library
|
3
|
+
# Copyright (C) 2014 drrb
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'integration_test_helper'
|
20
|
+
require 'open-uri'
|
21
|
+
|
22
|
+
module PuppetLibrary
|
23
|
+
describe "online git repo forge", :online => true do
|
24
|
+
|
25
|
+
include ModuleSpecHelper
|
26
|
+
|
27
|
+
let(:port) { Ports.next! }
|
28
|
+
let(:project_dir) { Tempdir.create("project_dir") }
|
29
|
+
let(:start_dir) { pwd }
|
30
|
+
let(:git_server) do
|
31
|
+
Server.configure do |server|
|
32
|
+
server.forge Forge::GitRepository do |forge|
|
33
|
+
forge.source = "https://github.com/puppetlabs/puppetlabs-stdlib.git"
|
34
|
+
forge.include_tags = /^[0-9.]+/
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
let(:git_rack_server) do
|
39
|
+
Rack::Server.new(
|
40
|
+
:app => git_server,
|
41
|
+
:Host => "localhost",
|
42
|
+
:Port => port,
|
43
|
+
:server => "webrick"
|
44
|
+
)
|
45
|
+
end
|
46
|
+
let(:git_server_runner) do
|
47
|
+
Thread.new do
|
48
|
+
git_rack_server.start
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
before do
|
53
|
+
# Initialize to catch wiring errors
|
54
|
+
git_rack_server
|
55
|
+
|
56
|
+
# Start the servers
|
57
|
+
git_server_runner
|
58
|
+
start_dir
|
59
|
+
cd project_dir
|
60
|
+
end
|
61
|
+
|
62
|
+
after do
|
63
|
+
rm_rf project_dir
|
64
|
+
cd start_dir
|
65
|
+
end
|
66
|
+
|
67
|
+
it "services queries, downloads and searches from a git repository" do
|
68
|
+
write_puppetfile <<-EOF
|
69
|
+
forge 'http://localhost:#{port}'
|
70
|
+
mod 'puppetlabs/stdlib'
|
71
|
+
EOF
|
72
|
+
|
73
|
+
# Install modules
|
74
|
+
system "librarian-puppet install" or fail "call to puppet-library failed"
|
75
|
+
expect("stdlib").to be_installed
|
76
|
+
|
77
|
+
# Search
|
78
|
+
search_results = JSON.parse(open("http://localhost:#{port}/modules.json").read)
|
79
|
+
stdlib_result = search_results.first
|
80
|
+
expect(stdlib_result["full_name"]).to eq "puppetlabs/stdlib"
|
81
|
+
expect(stdlib_result["releases"]).to include({"version"=>"4.0.2"})
|
82
|
+
|
83
|
+
# Download
|
84
|
+
archive = open("http://localhost:#{port}/modules/puppetlabs-stdlib-4.0.2.tar.gz")
|
85
|
+
expect(archive).to be_tgz_with /Modulefile/, /puppetlabs-stdlib/
|
86
|
+
expect(archive).to be_tgz_with /metadata.json/, /"name":"puppetlabs-stdlib"/
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Puppet Library
|
3
|
+
# Copyright (C) 2014 drrb
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'integration_test_helper'
|
20
|
+
require 'open-uri'
|
21
|
+
|
22
|
+
module PuppetLibrary
|
23
|
+
describe "online proxy", :online => true do
|
24
|
+
include ModuleSpecHelper
|
25
|
+
|
26
|
+
let(:port) { Ports.next! }
|
27
|
+
let(:project_dir) { Tempdir.create("project_dir") }
|
28
|
+
let(:module_dir) { Tempdir.create("module_dir") }
|
29
|
+
let(:cache_dir) { Tempdir.create("cache_dir") }
|
30
|
+
let(:start_dir) { pwd }
|
31
|
+
let(:proxy_server) do
|
32
|
+
Server.configure do |server|
|
33
|
+
server.forge Forge::Directory do |forge|
|
34
|
+
forge.path = module_dir
|
35
|
+
end
|
36
|
+
server.forge Forge::Cache do |forge|
|
37
|
+
forge.url = "http://forge.puppetlabs.com"
|
38
|
+
forge.path = cache_dir
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
let(:proxy_rack_server) do
|
43
|
+
Rack::Server.new(
|
44
|
+
:app => proxy_server,
|
45
|
+
:Host => "localhost",
|
46
|
+
:Port => port,
|
47
|
+
:server => "webrick"
|
48
|
+
)
|
49
|
+
end
|
50
|
+
let(:proxy_server_runner) do
|
51
|
+
Thread.new do
|
52
|
+
proxy_rack_server.start
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
before do
|
57
|
+
# Initialize to catch wiring errors
|
58
|
+
proxy_rack_server
|
59
|
+
|
60
|
+
# Start the server
|
61
|
+
proxy_server_runner
|
62
|
+
start_dir
|
63
|
+
cd project_dir
|
64
|
+
end
|
65
|
+
|
66
|
+
after do
|
67
|
+
rm_rf module_dir
|
68
|
+
rm_rf project_dir
|
69
|
+
rm_rf cache_dir
|
70
|
+
cd start_dir
|
71
|
+
end
|
72
|
+
|
73
|
+
it "services queries, downloads and searches through a proxy to a remote forge" do
|
74
|
+
add_module("drrb", "tomcat", "1.0.0") do |metadata|
|
75
|
+
metadata["dependencies"] << { "name" => "puppetlabs/apache", "version_requirement" => "0.9.0" }
|
76
|
+
end
|
77
|
+
|
78
|
+
write_puppetfile <<-EOF
|
79
|
+
forge 'http://localhost:#{port}'
|
80
|
+
mod 'drrb/tomcat'
|
81
|
+
EOF
|
82
|
+
|
83
|
+
# Install modules through the proxy
|
84
|
+
system "librarian-puppet install" or fail "call to puppet-library failed"
|
85
|
+
expect("tomcat").to be_installed
|
86
|
+
expect("apache").to be_installed
|
87
|
+
expect("concat").to be_installed
|
88
|
+
expect("stdlib").to be_installed
|
89
|
+
|
90
|
+
expect("puppetlabs-apache-*.tar.gz").to be_cached
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Puppet Library
|
3
|
+
# Copyright (C) 2014 drrb
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'integration_test_helper'
|
20
|
+
require 'open-uri'
|
21
|
+
|
22
|
+
module PuppetLibrary
|
23
|
+
describe "source forge" do
|
24
|
+
include ModuleSpecHelper
|
25
|
+
|
26
|
+
let(:port) { Ports.next! }
|
27
|
+
let(:module_dir) { Tempdir.create("module_dir") }
|
28
|
+
let(:project_dir) { Tempdir.create("project_dir") }
|
29
|
+
let(:start_dir) { pwd }
|
30
|
+
let(:source_forge) { Forge::Source.new(module_dir) }
|
31
|
+
let(:source_server) do
|
32
|
+
Server.configure do |server|
|
33
|
+
server.forge source_forge
|
34
|
+
end
|
35
|
+
end
|
36
|
+
let(:source_rack_server) do
|
37
|
+
Rack::Server.new(
|
38
|
+
:app => source_server,
|
39
|
+
:Host => "localhost",
|
40
|
+
:Port => port,
|
41
|
+
:server => "webrick"
|
42
|
+
)
|
43
|
+
end
|
44
|
+
let(:source_server_runner) do
|
45
|
+
Thread.new do
|
46
|
+
source_rack_server.start
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
before do
|
51
|
+
# Initialize to catch wiring errors
|
52
|
+
source_rack_server
|
53
|
+
|
54
|
+
# Start the servers
|
55
|
+
source_server_runner
|
56
|
+
start_dir
|
57
|
+
cd project_dir
|
58
|
+
end
|
59
|
+
|
60
|
+
after do
|
61
|
+
rm_rf module_dir
|
62
|
+
rm_rf project_dir
|
63
|
+
cd start_dir
|
64
|
+
end
|
65
|
+
|
66
|
+
it "services queries, downloads and searches from a directory containg a module's source" do
|
67
|
+
add_file "Modulefile", <<-EOF
|
68
|
+
name 'puppetlabs-ficticious'
|
69
|
+
version '0.2.0'
|
70
|
+
author 'puppetlabs'
|
71
|
+
description 'Fake module'
|
72
|
+
EOF
|
73
|
+
|
74
|
+
write_puppetfile <<-EOF
|
75
|
+
forge 'http://localhost:#{port}'
|
76
|
+
mod 'puppetlabs/ficticious'
|
77
|
+
EOF
|
78
|
+
|
79
|
+
# Install modules
|
80
|
+
system "librarian-puppet install" or fail "call to puppet-library failed"
|
81
|
+
expect("ficticious").to be_installed
|
82
|
+
|
83
|
+
# Search
|
84
|
+
search_results = JSON.parse(open("http://localhost:#{port}/modules.json").read)
|
85
|
+
found_modules = Hash[search_results.map do |result|
|
86
|
+
[ result["full_name"], result["version"] ]
|
87
|
+
end]
|
88
|
+
expect(found_modules["puppetlabs/ficticious"]).to eq "0.2.0"
|
89
|
+
|
90
|
+
# Download
|
91
|
+
archive = open("http://localhost:#{port}/modules/puppetlabs-ficticious-0.2.0.tar.gz")
|
92
|
+
expect(archive).to be_tgz_with /Modulefile/, /puppetlabs-ficticious/
|
93
|
+
expect(archive).to be_tgz_with /metadata.json/, /"name":"puppetlabs-ficticious"/
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|