puppet 4.4.2 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CONTRIBUTING.md +5 -5
- data/Gemfile +2 -2
- data/LICENSE +2 -2
- data/README.md +5 -0
- data/ext/project_data.yaml +2 -0
- data/lib/hiera_puppet.rb +6 -14
- data/lib/puppet/application/agent.rb +2 -3
- data/lib/puppet/data_providers/hiera_config.rb +2 -4
- data/lib/puppet/data_providers/hiera_interpolate.rb +12 -154
- data/lib/puppet/data_providers/json_data_provider_factory.rb +0 -7
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -8
- data/lib/puppet/defaults.rb +70 -7
- data/lib/puppet/functions.rb +69 -0
- data/lib/puppet/functions/dig.rb +39 -0
- data/lib/puppet/functions/lest.rb +53 -0
- data/lib/puppet/functions/lookup.rb +40 -27
- data/lib/puppet/functions/new.rb +502 -0
- data/lib/puppet/functions/regsubst.rb +11 -10
- data/lib/puppet/functions/then.rb +74 -0
- data/lib/puppet/functions/type.rb +4 -4
- data/lib/puppet/functions/with.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +2 -0
- data/lib/puppet/indirector/resource_type/parser.rb +5 -0
- data/lib/puppet/indirector/rest.rb +5 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/metatype/manager.rb +19 -2
- data/lib/puppet/module_tool/applications/application.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +6 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +19 -4
- data/lib/puppet/module_tool/skeleton/templates/generator/{tests → examples}/init.pp.erb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +0 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +6 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +20 -3
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +24 -2
- data/lib/puppet/parser/e4_parser_adapter.rb +13 -12
- data/lib/puppet/parser/environment_compiler.rb +2 -2
- data/lib/puppet/parser/resource.rb +14 -5
- data/lib/puppet/parser/scope.rb +18 -15
- data/lib/puppet/plugins/data_providers/data_provider.rb +19 -8
- data/lib/puppet/pops.rb +6 -0
- data/lib/puppet/pops/adapters.rb +5 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +52 -14
- data/lib/puppet/pops/evaluator/compare_operator.rb +34 -4
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +75 -22
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +7 -6
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +13 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +14 -4
- data/lib/puppet/pops/functions/dispatcher.rb +1 -1
- data/lib/puppet/pops/issues.rb +18 -2
- data/lib/puppet/pops/loader/base_loader.rb +48 -7
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +12 -0
- data/lib/puppet/pops/loader/predefined_loader.rb +29 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +57 -0
- data/lib/puppet/pops/loader/static_loader.rb +92 -5
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +25 -3
- data/lib/puppet/pops/loaders.rb +84 -14
- data/lib/puppet/pops/lookup/explainer.rb +38 -1
- data/lib/puppet/pops/lookup/interpolation.rb +115 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +86 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +31 -8
- data/lib/puppet/pops/model/model.rb +8 -0
- data/lib/puppet/pops/model/model_label_provider.rb +1 -0
- data/lib/puppet/pops/model/model_meta.rb +7 -1
- data/lib/puppet/pops/model/model_tree_dumper.rb +4 -0
- data/lib/puppet/pops/parser/egrammar.ra +24 -7
- data/lib/puppet/pops/parser/eparser.rb +863 -798
- data/lib/puppet/pops/parser/evaluating_parser.rb +4 -0
- data/lib/puppet/pops/parser/locator.rb +8 -4
- data/lib/puppet/pops/pcore.rb +30 -0
- data/lib/puppet/pops/types/class_loader.rb +2 -4
- data/lib/puppet/pops/types/implementation_registry.rb +146 -0
- data/lib/puppet/pops/types/iterable.rb +4 -4
- data/lib/puppet/pops/types/p_object_type.rb +846 -0
- data/lib/puppet/pops/types/p_runtime_type.rb +102 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +164 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +113 -0
- data/lib/puppet/pops/types/puppet_object.rb +21 -0
- data/lib/puppet/pops/types/ruby_generator.rb +258 -0
- data/lib/puppet/pops/types/string_converter.rb +922 -0
- data/lib/puppet/pops/types/type_calculator.rb +29 -5
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +49 -16
- data/lib/puppet/pops/types/type_formatter.rb +335 -112
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -29
- data/lib/puppet/pops/types/type_parser.rb +205 -197
- data/lib/puppet/pops/types/types.rb +481 -103
- data/lib/puppet/pops/validation.rb +1 -1
- data/lib/puppet/pops/validation/checker4_0.rb +66 -4
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/pops/visitor.rb +3 -1
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +64 -20
- data/lib/puppet/provider/package/rpm.rb +112 -0
- data/lib/puppet/provider/package/yum.rb +7 -68
- data/lib/puppet/provider/service/daemontools.rb +3 -3
- data/lib/puppet/provider/service/init.rb +4 -2
- data/lib/puppet/provider/service/runit.rb +3 -3
- data/lib/puppet/provider/service/smf.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +59 -73
- data/lib/puppet/reference/providers.rb +1 -2
- data/lib/puppet/resource.rb +54 -37
- data/lib/puppet/resource/catalog.rb +31 -29
- data/lib/puppet/resource/type_collection.rb +23 -8
- data/lib/puppet/settings.rb +4 -2
- data/lib/puppet/settings/base_setting.rb +9 -3
- data/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/lib/puppet/test/test_helper.rb +0 -1
- data/lib/puppet/type.rb +9 -3
- data/lib/puppet/type/exec.rb +17 -17
- data/lib/puppet/type/file.rb +12 -0
- data/lib/puppet/type/file/content.rb +6 -6
- data/lib/puppet/type/file/ensure.rb +4 -4
- data/lib/puppet/type/file/source.rb +4 -4
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/mount.rb +18 -1
- data/lib/puppet/type/package.rb +3 -3
- data/lib/puppet/type/schedule.rb +4 -4
- data/lib/puppet/type/service.rb +15 -0
- data/lib/puppet/type/sshkey.rb +5 -3
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/zone.rb +5 -5
- data/lib/puppet/util/feature.rb +1 -1
- data/lib/puppet/util/monkey_patches.rb +8 -0
- data/lib/puppet/util/network_device/cisco/device.rb +16 -6
- data/lib/puppet/util/network_device/cisco/interface.rb +5 -6
- data/lib/puppet/util/plist.rb +3 -3
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +13 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp +2 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/data/empty_key.json +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/data/empty_key.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/data/empty.yaml +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/type/usee_type.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +6 -0
- data/spec/fixtures/unit/provider/service/smf/svcs.out +4 -3
- data/spec/integration/module_tool/tar/mini_spec.rb +27 -27
- data/spec/integration/parser/catalog_spec.rb +14 -2
- data/spec/integration/parser/compiler_spec.rb +94 -3
- data/spec/integration/parser/resource_expressions_spec.rb +1 -1
- data/spec/integration/resource/type_collection_spec.rb +8 -0
- data/spec/lib/puppet_spec/compiler.rb +11 -4
- data/spec/shared_contexts/types_setup.rb +4 -0
- data/spec/unit/application/lookup_spec.rb +91 -9
- data/spec/unit/appmgmt_spec.rb +44 -35
- data/spec/unit/capability_spec.rb +33 -53
- data/spec/unit/data_providers/function_data_provider_spec.rb +19 -1
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +1 -1
- data/spec/unit/defaults_spec.rb +18 -0
- data/spec/unit/functions/assert_type_spec.rb +1 -1
- data/spec/unit/functions/dig_spec.rb +58 -0
- data/spec/unit/functions/lest_spec.rb +34 -0
- data/spec/unit/functions/lookup_spec.rb +108 -2
- data/spec/unit/functions/new_spec.rb +543 -0
- data/spec/unit/functions/regsubst_spec.rb +8 -0
- data/spec/unit/functions/then_spec.rb +40 -0
- data/spec/unit/functions4_spec.rb +78 -10
- data/spec/unit/hiera_puppet_spec.rb +49 -8
- data/spec/unit/indirector/resource_type/parser_spec.rb +5 -0
- data/spec/unit/indirector/rest_spec.rb +12 -0
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +60 -0
- data/spec/unit/node/environment_spec.rb +10 -0
- data/spec/unit/parser/compiler_spec.rb +20 -1
- data/spec/unit/parser/functions/create_resources_spec.rb +2 -2
- data/spec/unit/parser/functions/shared.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +8 -1
- data/spec/unit/parser/scope_spec.rb +45 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +14 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +13 -5
- data/spec/unit/pops/loaders/static_loader_spec.rb +92 -1
- data/spec/unit/{data_providers/hiera_interpolation_spec.rb → pops/lookup/interpolation_spec.rb} +7 -5
- data/spec/unit/pops/parser/lexer2_spec.rb +2 -9
- data/spec/unit/pops/parser/parse_application_spec.rb +3 -8
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +3 -10
- data/spec/unit/pops/parser/parse_site_spec.rb +19 -10
- data/spec/unit/pops/parser/parser_rspec_helper.rb +0 -4
- data/spec/unit/pops/types/enumeration_spec.rb +13 -12
- data/spec/unit/pops/types/iterable_spec.rb +2 -2
- data/spec/unit/pops/types/p_object_type_spec.rb +1060 -0
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +285 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +19 -17
- data/spec/unit/pops/types/ruby_generator_spec.rb +261 -0
- data/spec/unit/pops/types/string_converter_spec.rb +904 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +430 -406
- data/spec/unit/pops/types/type_factory_spec.rb +119 -104
- data/spec/unit/pops/types/type_formatter_spec.rb +73 -6
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +2 -2
- data/spec/unit/pops/types/type_parser_spec.rb +54 -15
- data/spec/unit/pops/types/types_spec.rb +113 -8
- data/spec/unit/pops/validator/validator_spec.rb +84 -10
- data/spec/unit/provider/package/pip3_spec.rb +9 -270
- data/spec/unit/provider/package/pip_spec.rb +85 -30
- data/spec/unit/provider/package/rpm_spec.rb +160 -3
- data/spec/unit/provider/package/yum_spec.rb +23 -134
- data/spec/unit/provider/service/smf_spec.rb +14 -2
- data/spec/unit/provider/service/systemd_spec.rb +33 -41
- data/spec/unit/resource/capability_finder_spec.rb +10 -2
- data/spec/unit/settings/file_setting_spec.rb +6 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +80 -65
- data/spec/unit/type/mount_spec.rb +51 -10
- data/spec/unit/type/service_spec.rb +16 -0
- data/spec/unit/type_spec.rb +14 -0
- data/spec/unit/util/feature_spec.rb +1 -1
- data/spec/unit/util/monkey_patches_spec.rb +60 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- metadata +63 -11
- data/lib/puppet/pops/types/types_meta.rb +0 -0
- data/spec/integration/provider/package_spec.rb +0 -35
@@ -2,282 +2,21 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
provider_class = Puppet::Type.type(:package).provider(:pip3)
|
5
|
-
osfamilies = { ['All', nil] => ['pip3'] }
|
6
5
|
|
7
6
|
describe provider_class do
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@client.stubs(:call).with('package_releases', 'fake_package').returns([])
|
15
|
-
XMLRPC::Client.stubs(:new2).returns(@client)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'provider features' do
|
19
|
-
it { is_expected.to be_installable }
|
20
|
-
it { is_expected.to be_uninstallable }
|
21
|
-
it { is_expected.to be_upgradeable }
|
22
|
-
it { is_expected.to be_versionable }
|
23
|
-
it { is_expected.to be_install_options }
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "parse" do
|
27
|
-
|
28
|
-
it "should return a hash on valid input" do
|
29
|
-
expect(provider_class.parse("real_package==1.2.5")).to eq({
|
30
|
-
:ensure => "1.2.5",
|
31
|
-
:name => "real_package",
|
32
|
-
:provider => :pip3,
|
33
|
-
})
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return nil on invalid input" do
|
37
|
-
expect(provider_class.parse("foo")).to eq(nil)
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "cmd" do
|
43
|
-
|
44
|
-
it "should return #{osfamilies[['All', nil]][0]} by default" do
|
45
|
-
Facter.stubs(:value).with(:osfamily).returns("Not RedHat")
|
46
|
-
expect(provider_class.cmd[0]).to eq(osfamilies[['All', nil]][0])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "instances" do
|
51
|
-
|
52
|
-
osfamilies.each do |osfamily, pip_cmds|
|
53
|
-
it "should return an array on #{osfamily} when #{pip_cmds.join(' or ')} is present" do
|
54
|
-
Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
|
55
|
-
Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
|
56
|
-
pip_cmds.each do |pip_cmd|
|
57
|
-
pip_cmds.each do |cmd|
|
58
|
-
unless cmd == pip_cmd
|
59
|
-
provider_class.expects(:which).with(cmd).returns(nil)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
provider_class.expects(:which).with(pip_cmd).returns("/fake/bin/#{pip_cmd}")
|
63
|
-
p = stub("process")
|
64
|
-
p.expects(:collect).yields("real_package==1.2.5")
|
65
|
-
provider_class.expects(:execpipe).with("/fake/bin/#{pip_cmd} freeze").yields(p)
|
66
|
-
provider_class.instances
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should return an empty array on #{osfamily} when #{pip_cmds.join(' and ')} is missing" do
|
71
|
-
Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
|
72
|
-
Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
|
73
|
-
pip_cmds.each do |pip_cmd|
|
74
|
-
provider_class.expects(:which).with(pip_cmd).returns nil
|
75
|
-
end
|
76
|
-
expect(provider_class.instances).to eq([])
|
77
|
-
end
|
78
|
-
end
|
8
|
+
it { is_expected.to be_installable }
|
9
|
+
it { is_expected.to be_uninstallable }
|
10
|
+
it { is_expected.to be_upgradeable }
|
11
|
+
it { is_expected.to be_versionable }
|
12
|
+
it { is_expected.to be_install_options }
|
79
13
|
|
14
|
+
it "should inherit most things from pip provider" do
|
15
|
+
expect(provider_class < Puppet::Type.type(:package).provider(:pip))
|
80
16
|
end
|
81
17
|
|
82
|
-
|
83
|
-
|
84
|
-
before do
|
85
|
-
@resource[:name] = "real_package"
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should return a hash when pip3 and the package are present" do
|
89
|
-
provider_class.expects(:instances).returns [provider_class.new({
|
90
|
-
:ensure => "1.2.5",
|
91
|
-
:name => "real_package",
|
92
|
-
:provider => :pip3,
|
93
|
-
})]
|
94
|
-
|
95
|
-
expect(@provider.query).to eq({
|
96
|
-
:ensure => "1.2.5",
|
97
|
-
:name => "real_package",
|
98
|
-
:provider => :pip3,
|
99
|
-
})
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should return nil when the package is missing" do
|
103
|
-
provider_class.expects(:instances).returns []
|
104
|
-
expect(@provider.query).to eq(nil)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should be case insensitive" do
|
108
|
-
@resource[:name] = "Real_Package"
|
109
|
-
|
110
|
-
provider_class.expects(:instances).returns [provider_class.new({
|
111
|
-
:ensure => "1.2.5",
|
112
|
-
:name => "real_package",
|
113
|
-
:provider => :pip3,
|
114
|
-
})]
|
115
|
-
|
116
|
-
expect(@provider.query).to eq({
|
117
|
-
:ensure => "1.2.5",
|
118
|
-
:name => "real_package",
|
119
|
-
:provider => :pip3,
|
120
|
-
})
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "latest" do
|
126
|
-
|
127
|
-
it "should find a version number for real_package" do
|
128
|
-
@resource[:name] = "real_package"
|
129
|
-
expect(@provider.latest).not_to eq(nil)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should not find a version number for fake_package" do
|
133
|
-
@resource[:name] = "fake_package"
|
134
|
-
expect(@provider.latest).to eq(nil)
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should handle a timeout gracefully" do
|
138
|
-
@resource[:name] = "fake_package"
|
139
|
-
@client.stubs(:call).raises(Timeout::Error)
|
140
|
-
expect { @provider.latest }.to raise_error(Puppet::Error)
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
describe "install" do
|
146
|
-
|
147
|
-
before do
|
148
|
-
@resource[:name] = "fake_package"
|
149
|
-
@url = "git+https://example.com/fake_package.git"
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should install" do
|
153
|
-
@resource[:ensure] = :installed
|
154
|
-
@resource[:source] = nil
|
155
|
-
@provider.expects(:lazy_pip).
|
156
|
-
with("install", '-q', "fake_package")
|
157
|
-
@provider.install
|
158
|
-
end
|
159
|
-
|
160
|
-
it "omits the -e flag (GH-1256)" do
|
161
|
-
# The -e flag makes the provider non-idempotent
|
162
|
-
@resource[:ensure] = :installed
|
163
|
-
@resource[:source] = @url
|
164
|
-
@provider.expects(:lazy_pip).with() do |*args|
|
165
|
-
not args.include?("-e")
|
166
|
-
end
|
167
|
-
@provider.install
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should install from SCM" do
|
171
|
-
@resource[:ensure] = :installed
|
172
|
-
@resource[:source] = @url
|
173
|
-
@provider.expects(:lazy_pip).
|
174
|
-
with("install", '-q', "#{@url}#egg=fake_package")
|
175
|
-
@provider.install
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should install a particular SCM revision" do
|
179
|
-
@resource[:ensure] = "0123456"
|
180
|
-
@resource[:source] = @url
|
181
|
-
@provider.expects(:lazy_pip).
|
182
|
-
with("install", "-q", "#{@url}@0123456#egg=fake_package")
|
183
|
-
@provider.install
|
184
|
-
end
|
185
|
-
|
186
|
-
it "should install a particular version" do
|
187
|
-
@resource[:ensure] = "0.0.0"
|
188
|
-
@resource[:source] = nil
|
189
|
-
@provider.expects(:lazy_pip).with("install", "-q", "fake_package==0.0.0")
|
190
|
-
@provider.install
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should upgrade" do
|
194
|
-
@resource[:ensure] = :latest
|
195
|
-
@resource[:source] = nil
|
196
|
-
@provider.expects(:lazy_pip).
|
197
|
-
with("install", "-q", "--upgrade", "fake_package")
|
198
|
-
@provider.install
|
199
|
-
end
|
200
|
-
|
201
|
-
it "should handle install options" do
|
202
|
-
@resource[:ensure] = :installed
|
203
|
-
@resource[:source] = nil
|
204
|
-
@resource[:install_options] = [{"--timeout" => "10"}, "--no-index"]
|
205
|
-
@provider.expects(:lazy_pip).
|
206
|
-
with("install", "-q", "--timeout=10", "--no-index", "fake_package")
|
207
|
-
@provider.install
|
208
|
-
end
|
209
|
-
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "uninstall" do
|
213
|
-
|
214
|
-
it "should uninstall" do
|
215
|
-
@resource[:name] = "fake_package"
|
216
|
-
@provider.expects(:lazy_pip).
|
217
|
-
with('uninstall', '-y', '-q', 'fake_package')
|
218
|
-
@provider.uninstall
|
219
|
-
end
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
describe "update" do
|
224
|
-
|
225
|
-
it "should just call install" do
|
226
|
-
@provider.expects(:install).returns(nil)
|
227
|
-
@provider.update
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "lazy_pip" do
|
233
|
-
|
234
|
-
after(:each) do
|
235
|
-
Puppet::Type::Package::ProviderPip.instance_variable_set(:@confine_collection, nil)
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should succeed if pip3 is present" do
|
239
|
-
@provider.stubs(:pip).returns(nil)
|
240
|
-
@provider.method(:lazy_pip).call "freeze"
|
241
|
-
end
|
242
|
-
|
243
|
-
osfamilies.each do |osfamily, pip_cmds|
|
244
|
-
pip_cmds.each do |pip_cmd|
|
245
|
-
it "should retry on #{osfamily} if #{pip_cmd} has not yet been found" do
|
246
|
-
Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
|
247
|
-
Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
|
248
|
-
@provider.expects(:pip).twice.with('freeze').raises(NoMethodError).then.returns(nil)
|
249
|
-
pip_cmds.each do |cmd|
|
250
|
-
unless cmd == pip_cmd
|
251
|
-
@provider.expects(:which).with(cmd).returns(nil)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
@provider.expects(:which).with(pip_cmd).returns("/fake/bin/#{pip_cmd}")
|
255
|
-
@provider.method(:lazy_pip).call "freeze"
|
256
|
-
end
|
257
|
-
|
258
|
-
it "should fail on #{osfamily} if #{pip_cmd} is missing" do
|
259
|
-
Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
|
260
|
-
Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
|
261
|
-
@provider.expects(:pip).with('freeze').raises(NoMethodError)
|
262
|
-
pip_cmds.each do |pip_cmd|
|
263
|
-
@provider.expects(:which).with(pip_cmd).returns(nil)
|
264
|
-
end
|
265
|
-
expect { @provider.method(:lazy_pip).call("freeze") }.to raise_error(NoMethodError)
|
266
|
-
end
|
267
|
-
|
268
|
-
it "should output a useful error message on #{osfamily} if #{pip_cmd} is missing" do
|
269
|
-
Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
|
270
|
-
Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
|
271
|
-
@provider.expects(:pip).with('freeze').raises(NoMethodError)
|
272
|
-
pip_cmds.each do |pip_cmd|
|
273
|
-
@provider.expects(:which).with(pip_cmd).returns(nil)
|
274
|
-
end
|
275
|
-
expect { @provider.method(:lazy_pip).call("freeze") }.
|
276
|
-
to raise_error(NoMethodError, "Could not locate command #{pip_cmd}.")
|
277
|
-
end
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
18
|
+
it "should use pip3 command" do
|
19
|
+
expect(provider_class.cmd).to eq(["pip3"])
|
281
20
|
end
|
282
21
|
|
283
22
|
end
|
@@ -14,14 +14,6 @@ describe provider_class do
|
|
14
14
|
@client.stubs(:call).with('package_releases', 'fake_package').returns([])
|
15
15
|
end
|
16
16
|
|
17
|
-
describe 'provider features' do
|
18
|
-
it { is_expected.to be_installable }
|
19
|
-
it { is_expected.to be_uninstallable }
|
20
|
-
it { is_expected.to be_upgradeable }
|
21
|
-
it { is_expected.to be_versionable }
|
22
|
-
it { is_expected.to be_install_options }
|
23
|
-
end
|
24
|
-
|
25
17
|
describe "parse" do
|
26
18
|
|
27
19
|
it "should return a hash on valid input" do
|
@@ -63,6 +55,7 @@ describe provider_class do
|
|
63
55
|
provider_class.expects(:which).with(cmd).returns(nil)
|
64
56
|
end
|
65
57
|
end
|
58
|
+
provider_class.stubs(:pip_version).returns('8.0.1')
|
66
59
|
provider_class.expects(:which).with(pip_cmd).returns("/fake/bin/#{pip_cmd}")
|
67
60
|
p = stub("process")
|
68
61
|
p.expects(:collect).yields("real_package==1.2.5")
|
@@ -127,52 +120,97 @@ describe provider_class do
|
|
127
120
|
end
|
128
121
|
|
129
122
|
describe "latest" do
|
130
|
-
context "
|
131
|
-
|
123
|
+
context "with pip version < 1.5.4" do
|
132
124
|
before :each do
|
133
|
-
|
125
|
+
provider_class.stubs(:pip_version).returns('1.0.1')
|
126
|
+
provider_class.stubs(:which).with('pip').returns("/fake/bin/pip")
|
127
|
+
provider_class.stubs(:which).with('pip-python').returns("/fake/bin/pip")
|
134
128
|
end
|
135
129
|
|
136
|
-
it "should find a version number for
|
130
|
+
it "should find a version number for new_pip_package" do
|
131
|
+
p = StringIO.new(
|
132
|
+
<<-EOS
|
133
|
+
Downloading/unpacking fake-package
|
134
|
+
Using version 0.10.1 (newest of versions: 0.10.1, 0.10, 0.9, 0.8.1, 0.8, 0.7.2, 0.7.1, 0.7, 0.6.1, 0.6, 0.5.2, 0.5.1, 0.5, 0.4, 0.3.1, 0.3, 0.2, 0.1)
|
135
|
+
Downloading real-package-0.10.1.tar.gz (544Kb): 544Kb downloaded
|
136
|
+
Saved ./foo/real-package-0.10.1.tar.gz
|
137
|
+
Successfully downloaded real-package
|
138
|
+
EOS
|
139
|
+
)
|
140
|
+
Puppet::Util::Execution.expects(:execpipe).yields(p).once
|
137
141
|
@resource[:name] = "real_package"
|
138
|
-
expect(@provider.latest).
|
142
|
+
expect(@provider.latest).to eq('0.10.1')
|
139
143
|
end
|
140
144
|
|
141
145
|
it "should not find a version number for fake_package" do
|
146
|
+
p = StringIO.new(
|
147
|
+
<<-EOS
|
148
|
+
Downloading/unpacking fake-package
|
149
|
+
Could not fetch URL http://pypi.python.org/simple/fake_package: HTTP Error 404: Not Found
|
150
|
+
Will skip URL http://pypi.python.org/simple/fake_package when looking for download links for fake-package
|
151
|
+
Could not fetch URL http://pypi.python.org/simple/fake_package/: HTTP Error 404: Not Found
|
152
|
+
Will skip URL http://pypi.python.org/simple/fake_package/ when looking for download links for fake-package
|
153
|
+
Could not find any downloads that satisfy the requirement fake-package
|
154
|
+
No distributions at all found for fake-package
|
155
|
+
Exception information:
|
156
|
+
Traceback (most recent call last):
|
157
|
+
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
|
158
|
+
self.run(options, args)
|
159
|
+
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 223, in run
|
160
|
+
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
|
161
|
+
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 948, in prepare_files
|
162
|
+
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
|
163
|
+
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 152, in find_requirement
|
164
|
+
raise DistributionNotFound('No distributions at all found for %s' % req)
|
165
|
+
DistributionNotFound: No distributions at all found for fake-package
|
166
|
+
|
167
|
+
Storing complete log in /root/.pip/pip.log
|
168
|
+
EOS
|
169
|
+
)
|
170
|
+
Puppet::Util::Execution.expects(:execpipe).yields(p).once
|
142
171
|
@resource[:name] = "fake_package"
|
143
172
|
expect(@provider.latest).to eq(nil)
|
144
173
|
end
|
145
|
-
|
146
|
-
it "should handle a timeout gracefully" do
|
147
|
-
@resource[:name] = "fake_package"
|
148
|
-
@client.stubs(:call).raises(Timeout::Error)
|
149
|
-
expect { @provider.latest }.to raise_error(Puppet::Error)
|
150
|
-
end
|
151
174
|
end
|
152
175
|
|
153
|
-
context "
|
176
|
+
context "with pip version >= 1.5.4" do
|
177
|
+
# For Pip 1.5.4 and above, you can get a version list from CLI - which allows for native pip behavior
|
178
|
+
# with regards to custom repositories, proxies and the like
|
179
|
+
|
154
180
|
before :each do
|
155
|
-
|
156
|
-
|
157
|
-
|
181
|
+
provider_class.stubs(:pip_version).returns('1.5.4')
|
182
|
+
provider_class.stubs(:which).with('pip').returns("/fake/bin/pip")
|
183
|
+
provider_class.stubs(:which).with('pip-python').returns("/fake/bin/pip")
|
158
184
|
end
|
159
185
|
|
160
186
|
it "should find a version number for real_package" do
|
187
|
+
p = StringIO.new(
|
188
|
+
<<-EOS
|
189
|
+
Collecting real-package==versionplease
|
190
|
+
Could not find a version that satisfies the requirement real-package==versionplease (from versions: 1.1.3, 1.2, 1.9b1)
|
191
|
+
No matching distribution found for real-package==versionplease
|
192
|
+
EOS
|
193
|
+
)
|
194
|
+
Puppet::Util::Execution.expects(:execpipe).with(["/fake/bin/pip", "install", "real_package==versionplease"]).yields(p).once
|
161
195
|
@resource[:name] = "real_package"
|
162
|
-
|
196
|
+
latest = @provider.latest
|
197
|
+
expect(latest).to eq('1.9b1')
|
163
198
|
end
|
164
199
|
|
165
200
|
it "should not find a version number for fake_package" do
|
201
|
+
p = StringIO.new(
|
202
|
+
<<-EOS
|
203
|
+
Collecting fake-package==versionplease
|
204
|
+
Could not find a version that satisfies the requirement fake-package==versionplease (from versions: )
|
205
|
+
No matching distribution found for fake-package==versionplease
|
206
|
+
EOS
|
207
|
+
)
|
208
|
+
Puppet::Util::Execution.expects(:execpipe).with(["/fake/bin/pip", "install", "fake_package==versionplease"]).yields(p).once
|
166
209
|
@resource[:name] = "fake_package"
|
167
210
|
expect(@provider.latest).to eq(nil)
|
168
211
|
end
|
169
|
-
|
170
|
-
it "should handle a timeout gracefully" do
|
171
|
-
@resource[:name] = "fake_package"
|
172
|
-
@client.stubs(:call).raises(Timeout::Error)
|
173
|
-
expect { @provider.latest }.to raise_error(Puppet::Error)
|
174
|
-
end
|
175
212
|
end
|
213
|
+
|
176
214
|
end
|
177
215
|
|
178
216
|
describe "install" do
|
@@ -262,6 +300,23 @@ describe provider_class do
|
|
262
300
|
|
263
301
|
end
|
264
302
|
|
303
|
+
describe "pip_version" do
|
304
|
+
|
305
|
+
it "should return nil on missing pip" do
|
306
|
+
provider_class.stubs(:pip_cmd).returns(nil)
|
307
|
+
expect(provider_class.pip_version).to eq(nil)
|
308
|
+
end
|
309
|
+
|
310
|
+
it "should look up version if pip is present" do
|
311
|
+
provider_class.stubs(:pip_cmd).returns('/fake/bin/pip')
|
312
|
+
p = stub("process")
|
313
|
+
p.expects(:collect).yields('pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)')
|
314
|
+
provider_class.expects(:execpipe).with(['/fake/bin/pip', '--version']).yields(p)
|
315
|
+
expect(provider_class.pip_version).to eq('8.0.2')
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
265
320
|
describe "lazy_pip" do
|
266
321
|
|
267
322
|
after(:each) do
|