runcible 0.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.
- data/.gitignore +18 -0
- data/Gemfile +19 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +37 -0
- data/lib/runcible.rb +25 -0
- data/lib/runcible/base.rb +113 -0
- data/lib/runcible/extensions/repository.rb +67 -0
- data/lib/runcible/oauth_setup.rb +29 -0
- data/lib/runcible/resources/repository.rb +82 -0
- data/lib/runcible/resources/role.rb +46 -0
- data/lib/runcible/resources/task.rb +49 -0
- data/lib/runcible/resources/user.rb +50 -0
- data/lib/runcible/version.rb +3 -0
- data/rel-eng/packages/.readme +3 -0
- data/rel-eng/tito.props +5 -0
- data/runcible.gemspec +17 -0
- data/runcible.spec +48 -0
- data/test/.gitkeep +0 -0
- data/test/integration/extensions/repository_test.rb +117 -0
- data/test/integration/fixtures/repositories/zoo5/.treeinfo +12 -0
- data/test/integration/fixtures/repositories/zoo5/CHANGESET +11 -0
- data/test/integration/fixtures/repositories/zoo5/PULP_MANIFEST +1 -0
- data/test/integration/fixtures/repositories/zoo5/cheetah-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/create.sh +20 -0
- data/test/integration/fixtures/repositories/zoo5/elephant-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/empty.iso +0 -0
- data/test/integration/fixtures/repositories/zoo5/giraffe-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/images/test1.img +0 -0
- data/test/integration/fixtures/repositories/zoo5/images/test2.img +0 -0
- data/test/integration/fixtures/repositories/zoo5/lion-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/monkey-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/penguin-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/06661e2a9839cf0beebcf409410ca4f93c09081f4e772fd0d03e1faf62705a11-comps.xml +39 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/0c4d57a68f9a3b13dabc6f8b01ca8958aa796167cececee04717edfc26d02f2d-other.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/298ce23f48b3613e030d19f3d9c2ff2df31c2f08479bdf94cebb87c208e48c0e-filelists.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/32c0e38317aade0c057b173ff62344e912e1bd650409c6ac31aecee78e3413af-comps.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/34d954906c7ce7aa2254e24d7be0a9049e0a2f436add023ca056123a2d48e30e-updateinfo.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/63aedd074d9f0daf7c6be8c61f91d76a962bb6ceda86b9abd2140f154c320fa2-other.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/69d65cdebffc6199d3adb3e38b06ca9abaae6c1c7366805099987b28f182178d-filelists.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/799241a518a4a6b11a68f8e6fbdb719875f87832f60accc0851ced0d6a0497c6-updateinfo.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/a4ea9fcdce31dc8673c7a9ba66c086bd6a16e1eff717e3896dd1cac444a1423c-primary.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/fb9b9508e148368d0edf7e03dc905b343937fd958e6531cce6380933d18c3455-primary.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/repomd.xml +75 -0
- data/test/integration/fixtures/repositories/zoo5/squirrel-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/updateinfo.xml +26 -0
- data/test/integration/fixtures/repositories/zoo5/walrus-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/vcr_cassettes/extensions/pulp_repository_extensions.yml +137 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer.yml +1529 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer_group.yml +430 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer_helper.yml +120 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_distribution.yml +77 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_errata.yml +77 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_filter.yml +233 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_filter_helper.yml +81 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package.yml +155 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package_group.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package_group_category.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_ping.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository.yml +1196 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository_helper.yml +8659 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository_sync.yml +215 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_role.yml +133 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_roles.yml +120 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_task.yml +943 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_user.yml +288 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_user_helper.yml +195 -0
- data/test/integration/resources/helpers/consumer_helper.rb +49 -0
- data/test/integration/resources/helpers/filter_helper.rb +44 -0
- data/test/integration/resources/helpers/repository_helper.rb +127 -0
- data/test/integration/resources/pulp_consumer_group_test.rb +182 -0
- data/test/integration/resources/pulp_consumer_test.rb +200 -0
- data/test/integration/resources/pulp_distribution_test.rb +55 -0
- data/test/integration/resources/pulp_errata_test.rb +60 -0
- data/test/integration/resources/pulp_filter_test.rb +92 -0
- data/test/integration/resources/pulp_package_group_category_test.rb +55 -0
- data/test/integration/resources/pulp_package_group_test.rb +56 -0
- data/test/integration/resources/pulp_package_test.rb +79 -0
- data/test/integration/resources/pulp_ping_test.rb +31 -0
- data/test/integration/resources/pulp_repository_test.rb +307 -0
- data/test/integration/resources/pulp_role_test.rb +62 -0
- data/test/integration/resources/pulp_task_test.rb +79 -0
- data/test/integration/resources/pulp_user_test.rb +105 -0
- data/test/integration/test_runner.rb +113 -0
- data/test/integration/vcr_setup.rb +22 -0
- data/test/unit/test_base.rb +62 -0
- metadata +218 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Copyright 2012 Red Hat, Inc.
|
|
2
|
+
#
|
|
3
|
+
# This software is licensed to you under the GNU General Public
|
|
4
|
+
# License as published by the Free Software Foundation; either version
|
|
5
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
|
6
|
+
# There is NO WARRANTY for this software, express or implied,
|
|
7
|
+
# including the implied warranties of MERCHANTABILITY,
|
|
8
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
|
9
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
|
10
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
|
11
|
+
|
|
12
|
+
require 'rubygems'
|
|
13
|
+
require 'test/integration/pulp/vcr_pulp_setup'
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
module ConsumerHelper
|
|
17
|
+
|
|
18
|
+
@consumer_resource = Resources::Pulp::Consumer
|
|
19
|
+
@consumer_id = "integration_test_consumer"
|
|
20
|
+
|
|
21
|
+
def self.consumer_id
|
|
22
|
+
@consumer_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.create_consumer(package_profile=false)
|
|
26
|
+
consumer = {}
|
|
27
|
+
destroy_consumer
|
|
28
|
+
VCR.use_cassette('pulp_consumer_helper') do
|
|
29
|
+
consumer = @consumer_resource.create("", @consumer_id)
|
|
30
|
+
|
|
31
|
+
if package_profile
|
|
32
|
+
@consumer_resource.upload_package_profile(@consumer_id, [{"name" => "elephant", "version" => "0.2", "release" => "0.7",
|
|
33
|
+
"epoch" => 0, "arch" => "noarch"}])
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
return consumer
|
|
37
|
+
rescue Exception => e
|
|
38
|
+
p "TestPulpConsumer: Consumer #{@consumer_id} already existed."
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.destroy_consumer
|
|
42
|
+
VCR.use_cassette('pulp_consumer_helper') do
|
|
43
|
+
@consumer_resource.destroy(@consumer_id)
|
|
44
|
+
end
|
|
45
|
+
rescue Exception => e
|
|
46
|
+
p "TestPulpConsumer: No consumer #{@consumer_id} to delete."
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Copyright 2012 Red Hat, Inc.
|
|
2
|
+
#
|
|
3
|
+
# This software is licensed to you under the GNU General Public
|
|
4
|
+
# License as published by the Free Software Foundation; either version
|
|
5
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
|
6
|
+
# There is NO WARRANTY for this software, express or implied,
|
|
7
|
+
# including the implied warranties of MERCHANTABILITY,
|
|
8
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
|
9
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
|
10
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
|
11
|
+
|
|
12
|
+
require 'rubygems'
|
|
13
|
+
require 'test/integration/pulp/vcr_pulp_setup'
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
module FilterHelper
|
|
17
|
+
|
|
18
|
+
@filter_resource = Resources::Pulp::Filter
|
|
19
|
+
@filter_id = "integration_test_filter"
|
|
20
|
+
|
|
21
|
+
def self.filter_id
|
|
22
|
+
@filter_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.create_filter
|
|
26
|
+
filter = {}
|
|
27
|
+
destroy_filter
|
|
28
|
+
VCR.use_cassette('pulp_filter_helper') do
|
|
29
|
+
filter = @filter_resource.create(:id => @filter_id, :type => "blacklist", :package_list => ['cheetah'])
|
|
30
|
+
end
|
|
31
|
+
return filter
|
|
32
|
+
rescue Exception => e
|
|
33
|
+
p "TestPulpFilter: Filter #{@filter_id} already existed."
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.destroy_filter
|
|
37
|
+
VCR.use_cassette('pulp_filter_helper') do
|
|
38
|
+
@filter_resource.destroy(@filter_id)
|
|
39
|
+
end
|
|
40
|
+
rescue Exception => e
|
|
41
|
+
p "TestPulpFilter: No filter #{@filter_id} to delete."
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Copyright 2012 Red Hat, Inc.
|
|
2
|
+
#
|
|
3
|
+
# This software is licensed to you under the GNU General Public
|
|
4
|
+
# License as published by the Free Software Foundation; either version
|
|
5
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
|
6
|
+
# There is NO WARRANTY for this software, express or implied,
|
|
7
|
+
# including the implied warranties of MERCHANTABILITY,
|
|
8
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
|
9
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
|
10
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
|
11
|
+
|
|
12
|
+
require 'rubygems'
|
|
13
|
+
|
|
14
|
+
require './lib/runcible/resources/repository'
|
|
15
|
+
require './lib/runcible/resources/task'
|
|
16
|
+
require './lib/runcible/extensions/repository'
|
|
17
|
+
|
|
18
|
+
module RepositoryHelper
|
|
19
|
+
|
|
20
|
+
@repo_url = "file://#{File.expand_path(File.dirname(__FILE__))}".gsub("resources/helpers", "fixtures/repositories/zoo5")
|
|
21
|
+
@repo_id = "integration_test_id"
|
|
22
|
+
@repo_name = @repo_id
|
|
23
|
+
@repo_resource = Runcible::Pulp::Repository
|
|
24
|
+
@repo_extension = Runcible::Pulp::RepositoryExtension
|
|
25
|
+
@task_resource = Runcible::Pulp::Task
|
|
26
|
+
|
|
27
|
+
def self.repo_name
|
|
28
|
+
@repo_name
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.repo_id
|
|
32
|
+
@repo_id
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.repo_url
|
|
36
|
+
@repo_url
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.task_resource
|
|
40
|
+
@task_resource
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.repo_resource
|
|
44
|
+
@repo_resource
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.task=(task)
|
|
48
|
+
@task = task
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.task
|
|
52
|
+
@task
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.create_and_sync_repo(options={})
|
|
56
|
+
puts "Creating and Sync'ing repository."
|
|
57
|
+
create_repo(options)
|
|
58
|
+
sync_repo(options)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.create_repo(options={})
|
|
62
|
+
repo = nil
|
|
63
|
+
|
|
64
|
+
VCR.use_cassette('pulp_repository_helper') do
|
|
65
|
+
repo = @repo_resource.retrieve(@repo_id)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if !repo.nil?
|
|
69
|
+
destroy_repo
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
VCR.use_cassette('pulp_repository_helper') do
|
|
73
|
+
if options[:importer]
|
|
74
|
+
repo = @repo_extension.create_with_importer(@repo_id, "yum_importer", {:feed_url => @repo_url})
|
|
75
|
+
else
|
|
76
|
+
repo = @repo_resource.create(@repo_id)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
rescue RestClient::ResourceNotFound
|
|
81
|
+
|
|
82
|
+
VCR.use_cassette('pulp_repository_helper') do
|
|
83
|
+
if options[:importer]
|
|
84
|
+
repo = @repo_extension.create_with_importer(@repo_id, "yum_importer", {:feed_url => @repo_url})
|
|
85
|
+
else
|
|
86
|
+
repo = @repo_resource.create(@repo_id)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
return repo
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.sync_repo(options={})
|
|
94
|
+
VCR.use_cassette('pulp_repository_helper') do
|
|
95
|
+
@task = @repo_resource.sync(@repo_name).first
|
|
96
|
+
|
|
97
|
+
if !options[:wait]
|
|
98
|
+
while !(['finished', 'error', 'timed_out', 'canceled', 'reset'].include?(@task['state'])) do
|
|
99
|
+
@task = @task_resource.poll(@task["task_id"]).first
|
|
100
|
+
sleep 0.5 # do not overload backend engines
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
rescue Exception => e
|
|
105
|
+
puts e
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self.destroy_repo(id=@repo_id)
|
|
109
|
+
puts "Destroying Repository."
|
|
110
|
+
|
|
111
|
+
VCR.use_cassette('pulp_repository_helper') do
|
|
112
|
+
if @task
|
|
113
|
+
while !(['finished', 'error', 'timed_out', 'canceled', 'reset'].include?(@task['state'])) do
|
|
114
|
+
@task = @task_resource.poll(@task["task_id"])
|
|
115
|
+
sleep 0.5 # do not overload backend engines
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
@task = nil
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
@repo_resource.delete(id)
|
|
122
|
+
end
|
|
123
|
+
rescue Exception => e
|
|
124
|
+
puts "RepositoryHelper: Repository #{id} could not be destroyed."
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Copyright 2012 Red Hat, Inc.
|
|
2
|
+
#
|
|
3
|
+
# This software is licensed to you under the GNU General Public
|
|
4
|
+
# License as published by the Free Software Foundation; either version
|
|
5
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
|
6
|
+
# There is NO WARRANTY for this software, express or implied,
|
|
7
|
+
# including the implied warranties of MERCHANTABILITY,
|
|
8
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
|
9
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
|
10
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
|
11
|
+
|
|
12
|
+
require 'rubygems'
|
|
13
|
+
require 'minitest/autorun'
|
|
14
|
+
require 'test/integration/pulp/vcr_pulp_setup'
|
|
15
|
+
require 'test/integration/pulp/helpers/repository_helper'
|
|
16
|
+
require 'test/integration/pulp/helpers/consumer_helper'
|
|
17
|
+
require 'active_support/core_ext/time/calculations'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module TestPulpConsumerGroupBase
|
|
21
|
+
include RepositoryHelper
|
|
22
|
+
include ConsumerHelper
|
|
23
|
+
|
|
24
|
+
def setup
|
|
25
|
+
@resource = Resources::Pulp::ConsumerGroup
|
|
26
|
+
@consumer_group_id = "integration_test_consumer_group"
|
|
27
|
+
VCR.insert_cassette('pulp_consumer_group')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def teardown
|
|
31
|
+
if @task
|
|
32
|
+
RepositoryHelper.task_resource.destroy(@task["id"])
|
|
33
|
+
end
|
|
34
|
+
VCR.eject_cassette
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_consumer_group
|
|
38
|
+
@resource.create(:id => @consumer_group_id, :description => 'Test description.', :consumerids => [])
|
|
39
|
+
rescue Exception => e
|
|
40
|
+
p "TestPulpConsumerGroup: ConsumerGroup #{@consumer_group_id} already existed."
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def destroy_consumer_group
|
|
44
|
+
@resource.destroy(@consumer_group_id)
|
|
45
|
+
rescue Exception => e
|
|
46
|
+
p "TestPulpConsumerGroup: No consumer_group #{@consumer_group_id} to delete."
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TestPulpConsumerGroupCreate < MiniTest::Unit::TestCase
|
|
53
|
+
include TestPulpConsumerGroupBase
|
|
54
|
+
|
|
55
|
+
def teardown
|
|
56
|
+
destroy_consumer_group
|
|
57
|
+
super
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_create
|
|
61
|
+
response = create_consumer_group
|
|
62
|
+
assert response['id'] == @consumer_group_id
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class TestPulpConsumerGroupDestroy < MiniTest::Unit::TestCase
|
|
68
|
+
include TestPulpConsumerGroupBase
|
|
69
|
+
|
|
70
|
+
def setup
|
|
71
|
+
super
|
|
72
|
+
create_consumer_group
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_destroy
|
|
76
|
+
response = @resource.destroy(@consumer_group_id)
|
|
77
|
+
assert response == 200
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class TestPulpConsumerGroup < MiniTest::Unit::TestCase
|
|
84
|
+
include TestPulpConsumerGroupBase
|
|
85
|
+
|
|
86
|
+
def setup
|
|
87
|
+
super
|
|
88
|
+
create_consumer_group
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def teardown
|
|
92
|
+
destroy_consumer_group
|
|
93
|
+
super
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_path
|
|
97
|
+
path = @resource.path
|
|
98
|
+
assert_match('/api/consumergroups/', path)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_path_with_id
|
|
102
|
+
path = @resource.path(@consumer_group_id)
|
|
103
|
+
assert_match("/api/consumergroups/#{@consumer_group_id}/", path)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_find
|
|
107
|
+
response = @resource.find(@consumer_group_id)
|
|
108
|
+
assert response.length > 0
|
|
109
|
+
assert response['id'] == @consumer_group_id
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class TestPulpConsumerGroupRequiresRepo < MiniTest::Unit::TestCase
|
|
115
|
+
include TestPulpConsumerGroupBase
|
|
116
|
+
|
|
117
|
+
def self.before_suite
|
|
118
|
+
ConsumerHelper.create_consumer(true)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def self.after_suite
|
|
122
|
+
ConsumerHelper.destroy_consumer
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def setup
|
|
126
|
+
super
|
|
127
|
+
create_consumer_group
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def teardown
|
|
131
|
+
destroy_consumer_group
|
|
132
|
+
super
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_add_consumer
|
|
136
|
+
response = @resource.add_consumer(@consumer_group_id, ConsumerHelper.consumer_id)
|
|
137
|
+
assert response == "true"
|
|
138
|
+
response = @resource.delete_consumer(@consumer_group_id, ConsumerHelper.consumer_id)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_delete_consumer
|
|
142
|
+
@resource.add_consumer(@consumer_group_id, ConsumerHelper.consumer_id)
|
|
143
|
+
response = @resource.delete_consumer(@consumer_group_id, ConsumerHelper.consumer_id)
|
|
144
|
+
assert response == "null"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_install_errata
|
|
148
|
+
response = @resource.install_errata(@consumer_group_id, ['RHEA-2010:0002'], Time.now.advance(:years => 1).iso8601)
|
|
149
|
+
assert response.has_key?('tasks')
|
|
150
|
+
assert response.has_key?('id')
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def test_install_packages
|
|
154
|
+
response = @resource.install_packages(@consumer_group_id, ['cheetah'], Time.now.advance(:years => 1).iso8601)
|
|
155
|
+
assert response.has_key?('tasks')
|
|
156
|
+
assert response.has_key?('id')
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def test_uninstall_packages
|
|
160
|
+
response = @resource.uninstall_packages(@consumer_group_id, ['elephant'], Time.now.advance(:years => 1).iso8601)
|
|
161
|
+
assert response.has_key?('tasks')
|
|
162
|
+
assert response.has_key?('id')
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_update_packages
|
|
166
|
+
response = @resource.update_packages(@consumer_group_id, ['elephant'], Time.now.advance(:years => 1).iso8601)
|
|
167
|
+
assert response.has_key?('tasks')
|
|
168
|
+
assert response.has_key?('id')
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_install_package_groups
|
|
172
|
+
response = @resource.install_package_groups(@consumer_group_id, ['mammals'], Time.now.advance(:years => 1).iso8601)
|
|
173
|
+
assert response.has_key?('tasks')
|
|
174
|
+
assert response.has_key?('id')
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_uninstall_package_groups
|
|
178
|
+
response = @resource.uninstall_package_groups(@consumer_group_id, ['mammals'], Time.now.advance(:years => 1).iso8601)
|
|
179
|
+
assert response.has_key?('tasks')
|
|
180
|
+
assert response.has_key?('id')
|
|
181
|
+
end
|
|
182
|
+
end
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Copyright 2012 Red Hat, Inc.
|
|
2
|
+
#
|
|
3
|
+
# This software is licensed to you under the GNU General Public
|
|
4
|
+
# License as published by the Free Software Foundation; either version
|
|
5
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
|
6
|
+
# There is NO WARRANTY for this software, express or implied,
|
|
7
|
+
# including the implied warranties of MERCHANTABILITY,
|
|
8
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
|
9
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
|
10
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
|
11
|
+
|
|
12
|
+
require 'rubygems'
|
|
13
|
+
require 'minitest/autorun'
|
|
14
|
+
require 'test/integration/pulp/vcr_pulp_setup'
|
|
15
|
+
require 'test/integration/pulp/helpers/repository_helper'
|
|
16
|
+
require 'test/integration/pulp/helpers/consumer_helper'
|
|
17
|
+
require 'active_support/core_ext/time/calculations'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module TestPulpConsumerBase
|
|
21
|
+
include RepositoryHelper
|
|
22
|
+
include ConsumerHelper
|
|
23
|
+
|
|
24
|
+
def setup
|
|
25
|
+
@resource = Resources::Pulp::Consumer
|
|
26
|
+
@consumer_id = "integration_test_consumer"
|
|
27
|
+
VCR.insert_cassette('pulp_consumer')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def teardown
|
|
31
|
+
if @task
|
|
32
|
+
RepositoryHelper.task_resource.cancel(@task["id"])
|
|
33
|
+
RepositoryHelper.task_resource.destroy(@task["id"])
|
|
34
|
+
end
|
|
35
|
+
VCR.eject_cassette
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def bind_repo
|
|
39
|
+
@resource.bind(@consumer_id, RepositoryHelper.repo_id)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class TestPulpConsumerCreate < MiniTest::Unit::TestCase
|
|
46
|
+
include TestPulpConsumerBase
|
|
47
|
+
|
|
48
|
+
def teardown
|
|
49
|
+
ConsumerHelper.destroy_consumer
|
|
50
|
+
super
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_create
|
|
54
|
+
response = ConsumerHelper.create_consumer
|
|
55
|
+
assert response.kind_of? Hash
|
|
56
|
+
assert response['id'] == @consumer_id
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class TestPulpConsumer < MiniTest::Unit::TestCase
|
|
63
|
+
include TestPulpConsumerBase
|
|
64
|
+
|
|
65
|
+
def setup
|
|
66
|
+
super
|
|
67
|
+
ConsumerHelper.create_consumer
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def teardown
|
|
71
|
+
ConsumerHelper.destroy_consumer
|
|
72
|
+
super
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_consumer_path
|
|
76
|
+
path = @resource.consumer_path
|
|
77
|
+
assert_match('/api/consumers/', path)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_consumer_path_with_id
|
|
81
|
+
path = @resource.consumer_path(@consumer_id)
|
|
82
|
+
assert_match("/api/consumers/#{@consumer_id}/", path)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_find
|
|
86
|
+
response = @resource.find(@consumer_id)
|
|
87
|
+
assert response.length > 0
|
|
88
|
+
assert response['id'] == @consumer_id
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_update
|
|
92
|
+
response = @resource.update("", @consumer_id, "Test description")
|
|
93
|
+
assert response == "true"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_upload_package_profile
|
|
97
|
+
response = @resource.upload_package_profile(@consumer_id, [{"vendor" => "FedoraHosted", "name" => "elephant",
|
|
98
|
+
"version" => "0.3", "release" => "0.8",
|
|
99
|
+
"arch" => "noarch"}])
|
|
100
|
+
assert response == "true"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_destroy
|
|
104
|
+
response = ConsumerHelper.destroy_consumer
|
|
105
|
+
assert response == 200
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class TestPulpConsumerRequiresRepo < MiniTest::Unit::TestCase
|
|
111
|
+
include TestPulpConsumerBase
|
|
112
|
+
|
|
113
|
+
def self.before_suite
|
|
114
|
+
RepositoryHelper.create_and_sync_repo
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def self.after_suite
|
|
118
|
+
RepositoryHelper.destroy_repo
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def setup
|
|
122
|
+
super
|
|
123
|
+
ConsumerHelper.create_consumer(true)
|
|
124
|
+
bind_repo
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def teardown
|
|
128
|
+
ConsumerHelper.destroy_consumer
|
|
129
|
+
super
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_installed_packages
|
|
133
|
+
response = @resource.installed_packages(@consumer_id)
|
|
134
|
+
assert response.length > 0
|
|
135
|
+
assert response.select { |pack| pack['name'] == 'elephant' }.length > 0
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_errata
|
|
139
|
+
response = @resource.errata(@consumer_id)
|
|
140
|
+
assert response.select { |errata| errata['id'] == "RHEA-2010:0002" }.length > 0
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def test_bind
|
|
144
|
+
@resource.unbind(@consumer_id, RepositoryHelper.repo_id)
|
|
145
|
+
response = @resource.bind(@consumer_id, RepositoryHelper.repo_id)
|
|
146
|
+
response = JSON.parse(response)
|
|
147
|
+
assert response['repo']['name'] = RepositoryHelper.repo_name
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_unbind
|
|
151
|
+
response = @resource.unbind(@consumer_id, RepositoryHelper.repo_id)
|
|
152
|
+
assert response == "true"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_repoids
|
|
156
|
+
response = @resource.repoids(@consumer_id)
|
|
157
|
+
assert response.key?(RepositoryHelper.repo_id)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_errata_by_consumer
|
|
161
|
+
response = @resource.errata_by_consumer([OpenStruct.new({ :pulp_id => RepositoryHelper.repo_id})])
|
|
162
|
+
assert response.key?("RHEA-2010:0002")
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_install_errata
|
|
166
|
+
response = @resource.install_errata(@consumer_id, ['RHEA-2010:0002'], Time.now.advance(:years => 1).iso8601)
|
|
167
|
+
@task = response
|
|
168
|
+
assert response["method_name"] == "__installpackages"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_install_packages
|
|
172
|
+
response = @resource.install_packages(@consumer_id, ['cheetah'], Time.now.advance(:years => 1).iso8601)
|
|
173
|
+
@task = response
|
|
174
|
+
assert response["method_name"] == "__installpackages"
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_uninstall_packages
|
|
178
|
+
response = @resource.uninstall_packages(@consumer_id, ['elephant'], Time.now.advance(:years => 1).iso8601)
|
|
179
|
+
@task = response
|
|
180
|
+
assert response["method_name"] == "__uninstallpackages"
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_update_packages
|
|
184
|
+
response = @resource.update_packages(@consumer_id, ['elephant'], Time.now.advance(:years => 1).iso8601)
|
|
185
|
+
@task = response
|
|
186
|
+
assert response["method_name"] == "__updatepackages"
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def test_install_package_groups
|
|
190
|
+
response = @resource.install_package_groups(@consumer_id, ['mammals'], Time.now.advance(:years => 1).iso8601)
|
|
191
|
+
@task = response
|
|
192
|
+
assert response["method_name"] == "__installpackagegroups"
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def test_uninstall_package_groups
|
|
196
|
+
response = @resource.uninstall_package_groups(@consumer_id, ['mammals'], Time.now.advance(:years => 1).iso8601)
|
|
197
|
+
@task = response
|
|
198
|
+
assert response["method_name"] == "__uninstallpackagegroups"
|
|
199
|
+
end
|
|
200
|
+
end
|