hammer_cli_katello 1.3.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello/content_export_complete.rb +8 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +55 -3
- data/lib/hammer_cli_katello/content_export_incremental.rb +8 -0
- data/lib/hammer_cli_katello/content_import.rb +9 -0
- data/lib/hammer_cli_katello/content_view_component.rb +4 -3
- data/lib/hammer_cli_katello/host_collection.rb +2 -0
- data/lib/hammer_cli_katello/id_resolver.rb +3 -2
- data/lib/hammer_cli_katello/organization.rb +11 -0
- data/lib/hammer_cli_katello/repository.rb +106 -22
- data/lib/hammer_cli_katello/version.rb +1 -1
- metadata +4 -394
- data/test/data/2.5/foreman_api.json +0 -1
- data/test/data/3.0/foreman_api.json +0 -1
- data/test/data/3.10/foreman_api.json +0 -1
- data/test/data/3.11/foreman_api.json +0 -1
- data/test/data/3.12/foreman_api.json +0 -1
- data/test/data/3.13/foreman_api.json +0 -1
- data/test/data/3.14/foreman_api.json +0 -1
- data/test/data/3.15/foreman_api.json +0 -1
- data/test/data/3.16/foreman_api.json +0 -1
- data/test/data/3.17/foreman_api.json +0 -1
- data/test/data/3.18/foreman_api.json +0 -1
- data/test/data/3.19/foreman_api.json +0 -1
- data/test/data/3.2/foreman_api.json +0 -1
- data/test/data/3.4/foreman_api.json +0 -1
- data/test/data/3.5/foreman_api.json +0 -1
- data/test/data/3.6/foreman_api.json +0 -1
- data/test/data/3.7/foreman_api.json +0 -1
- data/test/data/3.8/foreman_api.json +0 -1
- data/test/data/3.9/foreman_api.json +0 -1
- data/test/data/4.0/foreman_api.json +0 -1
- data/test/data/4.1/foreman_api.json +0 -1
- data/test/data/4.3/foreman_api.json +0 -1
- data/test/data/Readme.md +0 -5
- data/test/functional/activation_key/add_host_collection_test.rb +0 -62
- data/test/functional/activation_key/content_override_test.rb +0 -92
- data/test/functional/activation_key/create_test.rb +0 -33
- data/test/functional/activation_key/data/activation_key.json +0 -17
- data/test/functional/activation_key/info_test.rb +0 -29
- data/test/functional/activation_key/list_test.rb +0 -68
- data/test/functional/activation_key/product_content_test.rb +0 -23
- data/test/functional/activation_key/remove_host_collection_test.rb +0 -62
- data/test/functional/activation_key/subscriptions_test.rb +0 -74
- data/test/functional/activation_key/update_test.rb +0 -26
- data/test/functional/apipie_helper_test.rb +0 -31
- data/test/functional/capsule/capsule_helpers.rb +0 -13
- data/test/functional/capsule/content/add_lifecycle_environment_test.rb +0 -40
- data/test/functional/capsule/content/cancel_synchronization_test.rb +0 -42
- data/test/functional/capsule/content/capsule_content_helpers.rb +0 -24
- data/test/functional/capsule/content/data/library_env.json +0 -47
- data/test/functional/capsule/content/data/sync_status.json +0 -6
- data/test/functional/capsule/content/data/sync_tasks.json +0 -62
- data/test/functional/capsule/content/info_test.rb +0 -61
- data/test/functional/capsule/content/lifecycle_environments_test.rb +0 -19
- data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +0 -40
- data/test/functional/capsule/content/synchronization_status_test.rb +0 -107
- data/test/functional/capsule/info_test.rb +0 -25
- data/test/functional/capsule/list_test.rb +0 -24
- data/test/functional/content_credentials/create_test.rb +0 -32
- data/test/functional/content_credentials/data/test_cert.json +0 -43
- data/test/functional/content_credentials/info_test.rb +0 -50
- data/test/functional/content_credentials/list_test.rb +0 -66
- data/test/functional/content_export/complete/library_test.rb +0 -155
- data/test/functional/content_export/complete/version_test.rb +0 -252
- data/test/functional/content_export/content_export_helpers.rb +0 -26
- data/test/functional/content_export/generate_metadata_test.rb +0 -64
- data/test/functional/content_export/incremental/library_test.rb +0 -172
- data/test/functional/content_export/incremental/version_test.rb +0 -268
- data/test/functional/content_export/list_test.rb +0 -64
- data/test/functional/content_import/library_test.rb +0 -85
- data/test/functional/content_import/list_test.rb +0 -65
- data/test/functional/content_import/metadata.json +0 -1
- data/test/functional/content_import/version_test.rb +0 -85
- data/test/functional/content_units/info_test.rb +0 -29
- data/test/functional/content_units/list_test.rb +0 -106
- data/test/functional/content_view/add_content_view_version_test.rb +0 -88
- data/test/functional/content_view/add_repository_test.rb +0 -21
- data/test/functional/content_view/component/add_test.rb +0 -177
- data/test/functional/content_view/component/list_test.rb +0 -55
- data/test/functional/content_view/component/remove_test.rb +0 -107
- data/test/functional/content_view/component/update_test.rb +0 -134
- data/test/functional/content_view/content_view_helpers.rb +0 -20
- data/test/functional/content_view/copy_test.rb +0 -53
- data/test/functional/content_view/create_test.rb +0 -34
- data/test/functional/content_view/delete_test.rb +0 -62
- data/test/functional/content_view/filter/create_test.rb +0 -57
- data/test/functional/content_view/filter/delete_test.rb +0 -90
- data/test/functional/content_view/filter/info_test.rb +0 -89
- data/test/functional/content_view/filter/list_test.rb +0 -98
- data/test/functional/content_view/filter/update_test.rb +0 -91
- data/test/functional/content_view/list_test.rb +0 -68
- data/test/functional/content_view/publish_test.rb +0 -24
- data/test/functional/content_view/purge_test.rb +0 -97
- data/test/functional/content_view/remove_content_view_version_test.rb +0 -88
- data/test/functional/content_view/remove_test.rb +0 -79
- data/test/functional/content_view/update_test.rb +0 -53
- data/test/functional/content_view/version/incremental_update_test.rb +0 -108
- data/test/functional/content_view/version/list_test.rb +0 -44
- data/test/functional/content_view/version/promote_test.rb +0 -75
- data/test/functional/content_view/version/republish_repositories_test.rb +0 -34
- data/test/functional/content_view/version/update_test.rb +0 -48
- data/test/functional/erratum/erratum_helpers.rb +0 -91
- data/test/functional/erratum/info_test.rb +0 -29
- data/test/functional/erratum/list_test.rb +0 -108
- data/test/functional/file/file_helpers.rb +0 -13
- data/test/functional/file/info_test.rb +0 -162
- data/test/functional/file/list_test.rb +0 -112
- data/test/functional/filter_rule/create_test.rb +0 -99
- data/test/functional/filter_rule/delete_test.rb +0 -104
- data/test/functional/filter_rule/filter_rule_helpers.rb +0 -12
- data/test/functional/filter_rule/info_test.rb +0 -104
- data/test/functional/filter_rule/list_test.rb +0 -91
- data/test/functional/filter_rule/update_test.rb +0 -104
- data/test/functional/host/errata/apply_test.rb +0 -45
- data/test/functional/host/errata/info_test.rb +0 -27
- data/test/functional/host/errata/list_test.rb +0 -49
- data/test/functional/host/errata/recalculate_test.rb +0 -26
- data/test/functional/host/extensions/create_test.rb +0 -95
- data/test/functional/host/extensions/data/host.json +0 -320
- data/test/functional/host/extensions/data/host_list.json +0 -117
- data/test/functional/host/extensions/info_test.rb +0 -35
- data/test/functional/host/extensions/list_test.rb +0 -21
- data/test/functional/host/extensions/update_test.rb +0 -70
- data/test/functional/host/host_helpers.rb +0 -8
- data/test/functional/host/subscription/attach_test.rb +0 -54
- data/test/functional/host/subscription/auto_attach_test.rb +0 -35
- data/test/functional/host/subscription/content_override_test.rb +0 -96
- data/test/functional/host/subscription/product_content_test.rb +0 -27
- data/test/functional/host/subscription/register_test.rb +0 -53
- data/test/functional/host/subscription/remove_test.rb +0 -52
- data/test/functional/host/subscription/unregister_test.rb +0 -37
- data/test/functional/host/traces/list_test.rb +0 -37
- data/test/functional/host/traces/resolve_test.rb +0 -31
- data/test/functional/host_collection/add_host_test.rb +0 -90
- data/test/functional/host_collection/content_api_expectations.rb +0 -35
- data/test/functional/host_collection/content_install_test.rb +0 -62
- data/test/functional/host_collection/content_remove_test.rb +0 -37
- data/test/functional/host_collection/content_update_test.rb +0 -37
- data/test/functional/host_collection/copy_test.rb +0 -64
- data/test/functional/host_collection/create_test.rb +0 -54
- data/test/functional/host_collection/delete_test.rb +0 -57
- data/test/functional/host_collection/hosts_test.rb +0 -39
- data/test/functional/host_collection/info_test.rb +0 -57
- data/test/functional/host_collection/list_test.rb +0 -63
- data/test/functional/host_collection/remove_host_test.rb +0 -90
- data/test/functional/host_collection/update_test.rb +0 -57
- data/test/functional/hostgroup/create_test.rb +0 -112
- data/test/functional/hostgroup/data/hostgroup.json +0 -50
- data/test/functional/hostgroup/info_test.rb +0 -33
- data/test/functional/hostgroup/update_test.rb +0 -120
- data/test/functional/lifecycle_environment/create_test.rb +0 -14
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -18
- data/test/functional/lifecycle_environment/list_test.rb +0 -38
- data/test/functional/lifecycle_environment/update_test.rb +0 -14
- data/test/functional/local_helper_test.rb +0 -30
- data/test/functional/module_stream/info_test.rb +0 -58
- data/test/functional/module_stream/list_test.rb +0 -53
- data/test/functional/organization/cdn_configuration_test.rb +0 -42
- data/test/functional/organization/delete_test.rb +0 -26
- data/test/functional/organization/info_test.rb +0 -39
- data/test/functional/organization/organization_helpers.rb +0 -10
- data/test/functional/package/list_test.rb +0 -160
- data/test/functional/package_group/list_test.rb +0 -38
- data/test/functional/ping_test.rb +0 -61
- data/test/functional/product/create_test.rb +0 -54
- data/test/functional/product/delete_test.rb +0 -41
- data/test/functional/product/info_test.rb +0 -33
- data/test/functional/product/list_test.rb +0 -58
- data/test/functional/product/product_helpers.rb +0 -24
- data/test/functional/product/remove_sync_plan_test.rb +0 -35
- data/test/functional/product/set_sync_plan_test.rb +0 -49
- data/test/functional/product/update_proxy.rb +0 -48
- data/test/functional/product/update_test.rb +0 -46
- data/test/functional/repository/create_test.rb +0 -21
- data/test/functional/repository/delete_test.rb +0 -95
- data/test/functional/repository/info_test.rb +0 -156
- data/test/functional/repository/list_test.rb +0 -68
- data/test/functional/repository/remove_content_test.rb +0 -108
- data/test/functional/repository/repository_helpers.rb +0 -18
- data/test/functional/repository/synchronize_test.rb +0 -57
- data/test/functional/repository/update_test.rb +0 -149
- data/test/functional/repository/upload_test.rb +0 -345
- data/test/functional/repository_set/available_repositories_test.rb +0 -18
- data/test/functional/repository_set/disable_test.rb +0 -42
- data/test/functional/repository_set/enable_test.rb +0 -42
- data/test/functional/repository_set/info_test.rb +0 -17
- data/test/functional/repository_set/list_test.rb +0 -18
- data/test/functional/repository_set/repository_set_helpers.rb +0 -20
- data/test/functional/search_helpers.rb +0 -17
- data/test/functional/simple_content_access/disable_test.rb +0 -48
- data/test/functional/simple_content_access/enable_test.rb +0 -46
- data/test/functional/srpm/list_test.rb +0 -92
- data/test/functional/subscription/list_test.rb +0 -86
- data/test/functional/sync_plan/create_test.rb +0 -60
- data/test/functional/sync_plan/delete_test.rb +0 -46
- data/test/functional/sync_plan/info_test.rb +0 -37
- data/test/functional/sync_plan/list_test.rb +0 -31
- data/test/functional/sync_plan/sync_plan_helpers.rb +0 -8
- data/test/functional/sync_plan/update_test.rb +0 -44
- data/test/functional/test_helper.rb +0 -24
- data/test/task_helper.rb +0 -7
- data/test/test_helper.rb +0 -38
- data/test/unit/id_name_options_validator_test.rb +0 -96
- data/test/unit/id_resolver_test.rb +0 -58
- data/test/unit/messages_test.rb +0 -7
- data/test/unit/search_options_creators_test.rb +0 -145
@@ -1,155 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../../../test_helper')
|
2
|
-
require_relative '../../organization/organization_helpers'
|
3
|
-
require_relative '../content_export_helpers'
|
4
|
-
require 'hammer_cli_katello/content_export_complete'
|
5
|
-
|
6
|
-
describe 'content-export complete library' do
|
7
|
-
include ForemanTaskHelpers
|
8
|
-
include OrganizationHelpers
|
9
|
-
include ContentExportHelpers
|
10
|
-
|
11
|
-
before do
|
12
|
-
@cmd = %w(content-export complete library)
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:task_id) { '5' }
|
16
|
-
let(:response) do
|
17
|
-
{
|
18
|
-
'id' => task_id,
|
19
|
-
'state' => 'planned',
|
20
|
-
'output' => {
|
21
|
-
'export_history_id' => 2
|
22
|
-
}
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
let(:export_history) do
|
27
|
-
{
|
28
|
-
"id": 1000,
|
29
|
-
"path": "/tmp",
|
30
|
-
"metadata": {}
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
let(:organization_id) { '77' }
|
35
|
-
let(:organization_name) { 'Foo' }
|
36
|
-
let(:destination_server) { "dream.example.com" }
|
37
|
-
|
38
|
-
it "performs export with required options and async" do
|
39
|
-
params = [
|
40
|
-
"--organization-id=#{organization_id}",
|
41
|
-
'--destination-server=foo',
|
42
|
-
'--async'
|
43
|
-
]
|
44
|
-
expects_repositories_in_library(organization_id)
|
45
|
-
ex = api_expects(:content_exports, :library)
|
46
|
-
ex.returns(response)
|
47
|
-
|
48
|
-
result = run_cmd(@cmd + params)
|
49
|
-
|
50
|
-
assert_equal("Library environment is being exported in task #{task_id}.\n"\
|
51
|
-
+ "Once the task completes the export metadata must be generated with the "\
|
52
|
-
+ "command:\n hammer content-export generate-metadata --task-id #{task_id}\n", result.out)
|
53
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "performs export with required options" do
|
57
|
-
params = [
|
58
|
-
"--organization-id=#{organization_id}"
|
59
|
-
]
|
60
|
-
expects_repositories_in_library(organization_id)
|
61
|
-
ex = api_expects(:content_exports, :library)
|
62
|
-
ex.returns(response)
|
63
|
-
|
64
|
-
expect_foreman_task(task_id).at_least_once
|
65
|
-
|
66
|
-
HammerCLIKatello::ContentExportComplete::LibraryCommand.
|
67
|
-
any_instance.
|
68
|
-
expects(:fetch_export_history).
|
69
|
-
returns(export_history)
|
70
|
-
|
71
|
-
result = run_cmd(@cmd + params)
|
72
|
-
assert_match(/Generated .*metadata.*json/, result.out)
|
73
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'fails on missing required params' do
|
77
|
-
params = [
|
78
|
-
'--id=2'
|
79
|
-
]
|
80
|
-
|
81
|
-
result = run_cmd(@cmd + params)
|
82
|
-
expected_error = "Could not export the library:\n"
|
83
|
-
|
84
|
-
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
85
|
-
assert_equal(result.err[/#{expected_error}/], expected_error)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'fails on empty params' do
|
89
|
-
params = []
|
90
|
-
result = run_cmd(@cmd + params)
|
91
|
-
expected_error = "Could not find organization, please set one of options"
|
92
|
-
|
93
|
-
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
94
|
-
assert_equal(result.err[/#{expected_error}/], expected_error)
|
95
|
-
assert_match(/#{expected_error}/, result.err)
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'correctly resolves organization id from name' do
|
99
|
-
params = ["--organization=#{organization_name}",
|
100
|
-
"--async"]
|
101
|
-
expects_repositories_in_library(organization_id)
|
102
|
-
expect_organization_search(organization_name, organization_id)
|
103
|
-
|
104
|
-
ex = api_expects(:content_exports, :library) do |p|
|
105
|
-
assert_equal p['organization_id'].to_s, organization_id.to_s
|
106
|
-
end
|
107
|
-
ex.returns(response)
|
108
|
-
|
109
|
-
run_cmd(@cmd + params)
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'warns of lazy repositories' do
|
113
|
-
params = ["--organization-id=#{organization_id}"]
|
114
|
-
expects_repositories_in_library(organization_id, [{id: 200}])
|
115
|
-
|
116
|
-
ex = api_expects(:content_exports, :library)
|
117
|
-
ex.returns(response)
|
118
|
-
|
119
|
-
expect_foreman_task(task_id).at_least_once
|
120
|
-
|
121
|
-
HammerCLIKatello::ContentExportComplete::LibraryCommand.
|
122
|
-
any_instance.
|
123
|
-
expects(:fetch_export_history).
|
124
|
-
returns(export_history)
|
125
|
-
|
126
|
-
result = run_cmd(@cmd + params)
|
127
|
-
assert_match(/Unable to fully export this organization's library/, result.out)
|
128
|
-
assert_match(/200/, result.out)
|
129
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'Errors out on lazy repositories if --fail-on-missing-content' do
|
133
|
-
params = ["--organization-id=#{organization_id}",
|
134
|
-
"--fail-on-missing-content"]
|
135
|
-
expects_repositories_in_library(organization_id, [{id: 200}])
|
136
|
-
|
137
|
-
ex = api_expects(:content_exports, :library)
|
138
|
-
ex.returns(response)
|
139
|
-
|
140
|
-
expect_foreman_task(task_id).at_least_once
|
141
|
-
|
142
|
-
HammerCLIKatello::ContentExportComplete::LibraryCommand.
|
143
|
-
any_instance.
|
144
|
-
expects(:fetch_export_history).
|
145
|
-
returns(export_history)
|
146
|
-
|
147
|
-
HammerCLIKatello::ContentExportComplete::LibraryCommand.
|
148
|
-
any_instance.
|
149
|
-
expects(:exit).with(HammerCLI::EX_SOFTWARE)
|
150
|
-
|
151
|
-
result = run_cmd(@cmd + params)
|
152
|
-
assert_match(/Unable to fully export this organization's library/, result.out)
|
153
|
-
assert_match(/200/, result.out)
|
154
|
-
end
|
155
|
-
end
|
@@ -1,252 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../../../test_helper')
|
2
|
-
require 'hammer_cli_katello/content_export_complete'
|
3
|
-
require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
|
4
|
-
require_relative '../../content_view/content_view_helpers'
|
5
|
-
require_relative '../content_export_helpers'
|
6
|
-
|
7
|
-
describe 'content-export complete version' do
|
8
|
-
include ForemanTaskHelpers
|
9
|
-
include ContentExportHelpers
|
10
|
-
include ContentViewHelpers
|
11
|
-
include LifecycleEnvironmentHelpers
|
12
|
-
|
13
|
-
before do
|
14
|
-
@cmd = %w(content-export complete version)
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:task_id) { '5' }
|
18
|
-
let(:response) do
|
19
|
-
{
|
20
|
-
'id' => task_id,
|
21
|
-
'state' => 'planned',
|
22
|
-
'output' => {
|
23
|
-
'export_history_id' => 2
|
24
|
-
}
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:export_history) do
|
29
|
-
{
|
30
|
-
"id": 1000,
|
31
|
-
"path": "/tmp",
|
32
|
-
"metadata": {}
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:content_view_id) { '77' }
|
37
|
-
let(:content_view_version_id) { '1001' }
|
38
|
-
|
39
|
-
let(:version) { '10.0' }
|
40
|
-
let(:destination_server) { "dream.example.com" }
|
41
|
-
|
42
|
-
it "performs export with required options and async" do
|
43
|
-
params = [
|
44
|
-
"--id=#{content_view_version_id}",
|
45
|
-
'--destination-server=foo',
|
46
|
-
'--async'
|
47
|
-
]
|
48
|
-
expects_repositories_in_version(content_view_version_id)
|
49
|
-
ex = api_expects(:content_exports, :version)
|
50
|
-
ex.returns(response)
|
51
|
-
|
52
|
-
result = run_cmd(@cmd + params)
|
53
|
-
|
54
|
-
assert_equal("Content view version is being exported in task #{task_id}.\n"\
|
55
|
-
+ "Once the task completes the export metadata must be generated with the "\
|
56
|
-
+ "command:\n hammer content-export generate-metadata --task-id #{task_id}\n", result.out)
|
57
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "performs export with required options" do
|
61
|
-
params = [
|
62
|
-
"--id=#{content_view_version_id}",
|
63
|
-
'--destination-server=foo'
|
64
|
-
]
|
65
|
-
expects_repositories_in_version(content_view_version_id)
|
66
|
-
ex = api_expects(:content_exports, :version)
|
67
|
-
ex.returns(response)
|
68
|
-
|
69
|
-
expect_foreman_task(task_id).at_least_once
|
70
|
-
|
71
|
-
HammerCLIKatello::ContentExportComplete::VersionCommand.
|
72
|
-
any_instance.
|
73
|
-
expects(:fetch_export_history).
|
74
|
-
returns(export_history)
|
75
|
-
|
76
|
-
result = run_cmd(@cmd + params)
|
77
|
-
assert_match(/Generated .*metadata.*json/, result.out)
|
78
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'fails on missing required params' do
|
82
|
-
params = [
|
83
|
-
'--boo-id=2'
|
84
|
-
]
|
85
|
-
|
86
|
-
result = run_cmd(@cmd + params)
|
87
|
-
expected_error = "Could not export the content view version:\n"
|
88
|
-
|
89
|
-
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
90
|
-
assert_equal(result.err[/#{expected_error}/], expected_error)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'fails on missing content-view name/id' do
|
94
|
-
params = []
|
95
|
-
|
96
|
-
result = run_cmd(@cmd + params)
|
97
|
-
expected_error = "At least one of options --id, --content-view, --content-view-id is required"
|
98
|
-
|
99
|
-
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
100
|
-
assert_match(/#{expected_error}/, result.err)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'fails on missing content-view version' do
|
104
|
-
params = ["--content-view-id=2"]
|
105
|
-
result = run_cmd(@cmd + params)
|
106
|
-
expected_error = "--version, --lifecycle-environment-id, --lifecycle-environment is required."
|
107
|
-
|
108
|
-
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
109
|
-
assert_match(/#{expected_error}/, result.err)
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'fails on missing content-view missing org' do
|
113
|
-
params = ["--content-view=lol", "--version=4.0"]
|
114
|
-
result = run_cmd(@cmd + params)
|
115
|
-
expected_error = "At least one of options --organization-id, "\
|
116
|
-
"--organization, --organization-label is required."
|
117
|
-
|
118
|
-
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
119
|
-
assert_match(/#{expected_error}/, result.err)
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'correctly resolves content-view-id and content view version number' do
|
123
|
-
params = ["--content-view-id=#{content_view_id}",
|
124
|
-
"--version=#{version}",
|
125
|
-
"--destination-server=#{destination_server}",
|
126
|
-
"--async"]
|
127
|
-
|
128
|
-
cvv_expect = api_expects(:content_view_versions, :index) do |p|
|
129
|
-
assert_equal p['content_view_id'].to_s, content_view_id.to_s
|
130
|
-
assert_equal p["version"], version
|
131
|
-
end
|
132
|
-
|
133
|
-
cvv_expect.at_least_once.
|
134
|
-
returns(index_response([{'id' => content_view_version_id}]))
|
135
|
-
|
136
|
-
ex = api_expects(:content_exports, :version) do |p|
|
137
|
-
assert_equal p['id'], content_view_version_id
|
138
|
-
assert_equal p["destination_server"], destination_server
|
139
|
-
end
|
140
|
-
ex.returns(response)
|
141
|
-
|
142
|
-
expects_repositories_in_version(content_view_version_id)
|
143
|
-
run_cmd(@cmd + params)
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'correctly resolves chunk-size-gb' do
|
147
|
-
chunk_size = 1000
|
148
|
-
params = ["--id=#{content_view_version_id}",
|
149
|
-
"--chunk-size-gb=#{chunk_size}",
|
150
|
-
"--organization-id=99"]
|
151
|
-
|
152
|
-
expects_repositories_in_version(content_view_version_id)
|
153
|
-
|
154
|
-
ex = api_expects(:content_exports, :version) do |p|
|
155
|
-
assert_equal p["chunk_size_gb"], chunk_size
|
156
|
-
end
|
157
|
-
ex.returns(response)
|
158
|
-
|
159
|
-
expect_foreman_task(task_id).at_least_once
|
160
|
-
|
161
|
-
HammerCLIKatello::ContentExportComplete::VersionCommand.
|
162
|
-
any_instance.
|
163
|
-
expects(:fetch_export_history).
|
164
|
-
returns(export_history)
|
165
|
-
|
166
|
-
result = run_cmd(@cmd + params)
|
167
|
-
assert_match(/Generated .*metadata.*json/, result.out)
|
168
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'fails on invalid chunk-size-gb value' do
|
172
|
-
params = ["--id=#{content_view_version_id}",
|
173
|
-
"--chunk-size-gb=0.5",
|
174
|
-
"--organization-id=99"]
|
175
|
-
|
176
|
-
result = run_cmd(@cmd + params)
|
177
|
-
assert_match(/Error: Option '--chunk-size-gb': Numeric value is required/, result.err)
|
178
|
-
assert_equal(HammerCLI::EX_USAGE, result.exit_code)
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'warns of lazy repositories' do
|
182
|
-
params = ["--id=#{content_view_version_id}"]
|
183
|
-
expects_repositories_in_version(content_view_version_id, [{id: 200}])
|
184
|
-
|
185
|
-
ex = api_expects(:content_exports, :version)
|
186
|
-
ex.returns(response)
|
187
|
-
|
188
|
-
expect_foreman_task(task_id).at_least_once
|
189
|
-
|
190
|
-
HammerCLIKatello::ContentExportComplete::VersionCommand.
|
191
|
-
any_instance.
|
192
|
-
expects(:fetch_export_history).
|
193
|
-
returns(export_history)
|
194
|
-
|
195
|
-
result = run_cmd(@cmd + params)
|
196
|
-
assert_match(/Unable to fully export this version because/, result.out)
|
197
|
-
assert_match(/200/, result.out)
|
198
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
199
|
-
end
|
200
|
-
|
201
|
-
it 'Errors out on lazy repositories if --fail-on-missing-content' do
|
202
|
-
params = ["--id=#{content_view_version_id}",
|
203
|
-
"--fail-on-missing-content"]
|
204
|
-
expects_repositories_in_version(content_view_version_id, [{id: 200}])
|
205
|
-
|
206
|
-
ex = api_expects(:content_exports, :version)
|
207
|
-
ex.returns(response)
|
208
|
-
|
209
|
-
expect_foreman_task(task_id).at_least_once
|
210
|
-
|
211
|
-
HammerCLIKatello::ContentExportComplete::VersionCommand.
|
212
|
-
any_instance.
|
213
|
-
expects(:fetch_export_history).
|
214
|
-
returns(export_history)
|
215
|
-
|
216
|
-
HammerCLIKatello::ContentExportComplete::VersionCommand.
|
217
|
-
any_instance.
|
218
|
-
expects(:exit).with(HammerCLI::EX_SOFTWARE)
|
219
|
-
|
220
|
-
result = run_cmd(@cmd + params)
|
221
|
-
assert_match(/Unable to fully export this version because/, result.out)
|
222
|
-
assert_match(/200/, result.out)
|
223
|
-
end
|
224
|
-
|
225
|
-
it 'should accept content view and lifecycle environment and get the right version' do
|
226
|
-
env = "foo"
|
227
|
-
org_id = '100'
|
228
|
-
env_id = '223'
|
229
|
-
params = ["--content-view-id=#{content_view_id}",
|
230
|
-
"--lifecycle-environment=#{env}",
|
231
|
-
"--organization-id=#{org_id}"]
|
232
|
-
expect_lifecycle_environment_search(org_id, env, env_id)
|
233
|
-
expect_content_view_version_search({'environment_id' => env_id,
|
234
|
-
'content_view_id' => content_view_id},
|
235
|
-
'id' => content_view_version_id).at_least_once
|
236
|
-
|
237
|
-
expects_repositories_in_version(content_view_version_id)
|
238
|
-
ex = api_expects(:content_exports, :version)
|
239
|
-
ex.returns(response)
|
240
|
-
|
241
|
-
expect_foreman_task(task_id).at_least_once
|
242
|
-
|
243
|
-
HammerCLIKatello::ContentExportComplete::VersionCommand.
|
244
|
-
any_instance.
|
245
|
-
expects(:fetch_export_history).
|
246
|
-
returns(export_history)
|
247
|
-
|
248
|
-
result = run_cmd(@cmd + params)
|
249
|
-
assert_match(/Generated .*metadata.*json/, result.out)
|
250
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
251
|
-
end
|
252
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require_relative '../search_helpers'
|
2
|
-
|
3
|
-
module ContentExportHelpers
|
4
|
-
include SearchHelpers
|
5
|
-
def expects_repositories_in_library(organization_id, returns = [])
|
6
|
-
expect_lenient_search(:repositories,
|
7
|
-
params: {
|
8
|
-
organization_id: organization_id,
|
9
|
-
library: true,
|
10
|
-
search: "download_policy != immediate",
|
11
|
-
content_type: 'yum'
|
12
|
-
},
|
13
|
-
returns: returns)
|
14
|
-
end
|
15
|
-
|
16
|
-
def expects_repositories_in_version(version_id, returns = [])
|
17
|
-
expect_lenient_search(:repositories,
|
18
|
-
params: {
|
19
|
-
content_view_version_id: version_id,
|
20
|
-
library: true,
|
21
|
-
search: "download_policy != immediate",
|
22
|
-
content_type: 'yum'
|
23
|
-
},
|
24
|
-
returns: returns)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
-
require 'hammer_cli_katello/content_export'
|
3
|
-
|
4
|
-
describe('content-export generate-metadata') do
|
5
|
-
include ForemanTaskHelpers
|
6
|
-
|
7
|
-
before do
|
8
|
-
@cmd = %w(content-export generate-metadata)
|
9
|
-
@params = []
|
10
|
-
@export_history_id = 100
|
11
|
-
@export_history = {
|
12
|
-
'id' => @export_history_id,
|
13
|
-
'path' => '/tmp',
|
14
|
-
'metadata' => {}
|
15
|
-
}
|
16
|
-
@task_id = SecureRandom.uuid
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:cmd) { @cmd + @params }
|
20
|
-
let(:result) { run_cmd(cmd) }
|
21
|
-
|
22
|
-
describe('given an export history id') do
|
23
|
-
it('loads export history by id') do
|
24
|
-
@params = ["--id=#{@export_history_id}"]
|
25
|
-
|
26
|
-
HammerCLIKatello::ContentExport::GenerateMetadataCommand.
|
27
|
-
any_instance.
|
28
|
-
expects(:fetch_export_history).
|
29
|
-
returns(@export_history)
|
30
|
-
|
31
|
-
expected = success_result("Generated /tmp/metadata.json\n")
|
32
|
-
|
33
|
-
assert_cmd(expected, result)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe('given a task id') do
|
38
|
-
it('loads export history based on the task') do
|
39
|
-
@params = ["--task-id=#{@task_id}"]
|
40
|
-
|
41
|
-
HammerCLIKatello::ContentExport::GenerateMetadataCommand.
|
42
|
-
any_instance.
|
43
|
-
expects(:reload_task).
|
44
|
-
returns('id' => 'taskid')
|
45
|
-
|
46
|
-
HammerCLIKatello::ContentExport::GenerateMetadataCommand.
|
47
|
-
any_instance.
|
48
|
-
expects(:fetch_export_history).
|
49
|
-
returns(@export_history)
|
50
|
-
|
51
|
-
expected = success_result("Generated /tmp/metadata.json\n")
|
52
|
-
|
53
|
-
assert_cmd(expected, result)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe('given no arguments') do
|
58
|
-
it('tells the user to verify the arguments') do
|
59
|
-
expected = "Error: No export history was found. Verify the value given for "\
|
60
|
-
+ "--task-id or --id\n"
|
61
|
-
assert_equal(expected, result.err)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,172 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../../../test_helper')
|
2
|
-
require_relative '../../organization/organization_helpers'
|
3
|
-
require_relative '../content_export_helpers'
|
4
|
-
require 'hammer_cli_katello/content_export'
|
5
|
-
|
6
|
-
describe 'content-export incremental library' do
|
7
|
-
include ForemanTaskHelpers
|
8
|
-
include OrganizationHelpers
|
9
|
-
include ContentExportHelpers
|
10
|
-
|
11
|
-
before do
|
12
|
-
@cmd = %w(content-export incremental library)
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:task_id) { '5' }
|
16
|
-
let(:response) do
|
17
|
-
{
|
18
|
-
'id' => task_id,
|
19
|
-
'state' => 'planned',
|
20
|
-
'output' => {
|
21
|
-
'export_history_id' => 2
|
22
|
-
}
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
let(:export_history_id) { 1000 }
|
27
|
-
|
28
|
-
let(:export_history) do
|
29
|
-
{
|
30
|
-
"id": export_history_id,
|
31
|
-
"path": "/tmp",
|
32
|
-
"metadata": {}
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:organization_id) { 77 }
|
37
|
-
let(:organization_name) { 'Foo' }
|
38
|
-
let(:destination_server) { "dream.example.com" }
|
39
|
-
|
40
|
-
it "performs export with required options and async" do
|
41
|
-
params = [
|
42
|
-
"--organization-id=#{organization_id}",
|
43
|
-
'--destination-server=foo',
|
44
|
-
'--async'
|
45
|
-
]
|
46
|
-
expects_repositories_in_library(organization_id)
|
47
|
-
ex = api_expects(:content_export_incrementals, :library)
|
48
|
-
ex.returns(response)
|
49
|
-
|
50
|
-
result = run_cmd(@cmd + params)
|
51
|
-
|
52
|
-
assert_equal("Library environment is being exported in task #{task_id}.\n"\
|
53
|
-
+ "Once the task completes the export metadata must be generated with the "\
|
54
|
-
+ "command:\n hammer content-export generate-metadata --task-id #{task_id}\n", result.out)
|
55
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "performs export with required options" do
|
59
|
-
params = [
|
60
|
-
"--organization-id=#{organization_id}"
|
61
|
-
]
|
62
|
-
expects_repositories_in_library(organization_id)
|
63
|
-
ex = api_expects(:content_export_incrementals, :library)
|
64
|
-
ex.returns(response)
|
65
|
-
|
66
|
-
expect_foreman_task(task_id).at_least_once
|
67
|
-
|
68
|
-
HammerCLIKatello::ContentExportIncremental::LibraryCommand.
|
69
|
-
any_instance.
|
70
|
-
expects(:fetch_export_history).
|
71
|
-
returns(export_history)
|
72
|
-
|
73
|
-
result = run_cmd(@cmd + params)
|
74
|
-
assert_match(/Generated .*metadata.*json/, result.out)
|
75
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "performs export with history id" do
|
79
|
-
params = [
|
80
|
-
"--organization-id=#{organization_id}",
|
81
|
-
"--destination-server=#{destination_server}",
|
82
|
-
"--from-history-id=#{export_history_id}"
|
83
|
-
]
|
84
|
-
expects_repositories_in_library(organization_id)
|
85
|
-
api_expects(:content_export_incrementals, :library)
|
86
|
-
.with_params('organization_id' => organization_id,
|
87
|
-
'destination_server' => destination_server,
|
88
|
-
'from_history_id' => export_history_id)
|
89
|
-
.returns(response)
|
90
|
-
|
91
|
-
expect_foreman_task(task_id).at_least_once
|
92
|
-
|
93
|
-
HammerCLIKatello::ContentExportIncremental::LibraryCommand.
|
94
|
-
any_instance.
|
95
|
-
expects(:fetch_export_history).
|
96
|
-
returns(export_history)
|
97
|
-
|
98
|
-
result = run_cmd(@cmd + params)
|
99
|
-
assert_match(/Generated .*metadata.*json/, result.out)
|
100
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'fails on missing required params' do
|
104
|
-
params = [
|
105
|
-
'--id=2'
|
106
|
-
]
|
107
|
-
|
108
|
-
result = run_cmd(@cmd + params)
|
109
|
-
expected_error = "Could not export the library:\n"
|
110
|
-
|
111
|
-
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
112
|
-
assert_equal(result.err[/#{expected_error}/], expected_error)
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'correctly resolves organization id from name' do
|
116
|
-
params = ["--organization=#{organization_name}",
|
117
|
-
"--async"]
|
118
|
-
expects_repositories_in_library(organization_id)
|
119
|
-
expect_organization_search(organization_name, organization_id)
|
120
|
-
|
121
|
-
ex = api_expects(:content_export_incrementals, :library) do |p|
|
122
|
-
assert_equal p['organization_id'].to_s, organization_id.to_s
|
123
|
-
end
|
124
|
-
ex.returns(response)
|
125
|
-
|
126
|
-
run_cmd(@cmd + params)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'warns of lazy repositories' do
|
130
|
-
params = ["--organization-id=#{organization_id}"]
|
131
|
-
expects_repositories_in_library(organization_id, [{id: 200}])
|
132
|
-
|
133
|
-
ex = api_expects(:content_export_incrementals, :library)
|
134
|
-
ex.returns(response)
|
135
|
-
|
136
|
-
expect_foreman_task(task_id).at_least_once
|
137
|
-
|
138
|
-
HammerCLIKatello::ContentExportIncremental::LibraryCommand.
|
139
|
-
any_instance.
|
140
|
-
expects(:fetch_export_history).
|
141
|
-
returns(export_history)
|
142
|
-
|
143
|
-
result = run_cmd(@cmd + params)
|
144
|
-
assert_match(/Unable to fully export this organization's library/, result.out)
|
145
|
-
assert_match(/200/, result.out)
|
146
|
-
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'Errors out on lazy repositories if --fail-on-missing-content' do
|
150
|
-
params = ["--organization-id=#{organization_id}",
|
151
|
-
"--fail-on-missing-content"]
|
152
|
-
expects_repositories_in_library(organization_id, [{id: 200}])
|
153
|
-
|
154
|
-
ex = api_expects(:content_export_incrementals, :library)
|
155
|
-
ex.returns(response)
|
156
|
-
|
157
|
-
expect_foreman_task(task_id).at_least_once
|
158
|
-
|
159
|
-
HammerCLIKatello::ContentExportIncremental::LibraryCommand.
|
160
|
-
any_instance.
|
161
|
-
expects(:fetch_export_history).
|
162
|
-
returns(export_history)
|
163
|
-
|
164
|
-
HammerCLIKatello::ContentExportIncremental::LibraryCommand.
|
165
|
-
any_instance.
|
166
|
-
expects(:exit).with(HammerCLI::EX_SOFTWARE)
|
167
|
-
|
168
|
-
result = run_cmd(@cmd + params)
|
169
|
-
assert_match(/Unable to fully export this organization's library/, result.out)
|
170
|
-
assert_match(/200/, result.out)
|
171
|
-
end
|
172
|
-
end
|