hybrid_platforms_conductor 32.13.0 → 32.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/README.md +10 -3
- data/bin/get_impacted_nodes +1 -1
- data/bin/setup +6 -1
- data/docs/executables/check-node.md +1 -1
- data/docs/executables/deploy.md +1 -1
- data/docs/executables/free_ips.md +1 -1
- data/docs/executables/free_veids.md +1 -1
- data/docs/executables/get_impacted_nodes.md +1 -1
- data/docs/executables/last_deploys.md +1 -1
- data/docs/executables/nodes_to_deploy.md +1 -1
- data/docs/executables/report.md +1 -1
- data/docs/executables/run.md +1 -1
- data/docs/executables/setup.md +1 -1
- data/docs/executables/ssh_config.md +1 -1
- data/docs/executables/test.md +1 -1
- data/docs/plugins.md +1 -0
- data/docs/plugins/platform_handler/serverless_chef.md +105 -0
- data/docs/tutorial.md +10 -6
- data/docs/tutorial/01_installation.md +14 -12
- data/docs/tutorial/02_first_node.md +14 -12
- data/docs/tutorial/03_scale.md +14 -12
- data/docs/tutorial/04_test.md +26 -14
- data/docs/tutorial/05_extend_with_plugins.md +17 -17
- data/examples/tutorial/01_installation/my-platforms/Gemfile +3 -0
- data/examples/tutorial/01_installation/my-platforms/hpc_config.rb +0 -0
- data/examples/tutorial/02_first_node/my-platforms/Gemfile +3 -0
- data/examples/tutorial/02_first_node/my-platforms/hpc_config.rb +1 -0
- data/examples/tutorial/02_first_node/my-service-conf-repo/inventory.yaml +13 -0
- data/examples/tutorial/02_first_node/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/02_first_node/node/my-service.conf +4 -0
- data/examples/tutorial/03_scale/my-platforms/Gemfile +3 -0
- data/examples/tutorial/03_scale/my-platforms/hpc_config.rb +1 -0
- data/examples/tutorial/03_scale/my-platforms/my_commands.bash +2 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/inventory.yaml +90 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/service_web-hello.rb +43 -0
- data/examples/tutorial/03_scale/node/my-service.conf +4 -0
- data/examples/tutorial/03_scale/web_docker_image/Dockerfile +33 -0
- data/examples/tutorial/03_scale/web_docker_image/hello_world.txt +1 -0
- data/examples/tutorial/03_scale/web_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/03_scale/web_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/03_scale/web_docker_image/main.go +43 -0
- data/examples/tutorial/03_scale/web_docker_image/start.sh +7 -0
- data/examples/tutorial/03_scale/web_docker_image/test.bash +6 -0
- data/examples/tutorial/04_test/my-platforms/Gemfile +3 -0
- data/examples/tutorial/04_test/my-platforms/hpc_config.rb +12 -0
- data/examples/tutorial/04_test/my-platforms/images/debian_10/Dockerfile +13 -0
- data/examples/tutorial/04_test/my-platforms/my_commands.bash +2 -0
- data/examples/tutorial/04_test/my-service-conf-repo/inventory.yaml +100 -0
- data/examples/tutorial/04_test/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/04_test/my-service-conf-repo/service_web-hello.rb +43 -0
- data/examples/tutorial/04_test/node/my-service.conf +4 -0
- data/examples/tutorial/04_test/web_docker_image/Dockerfile +33 -0
- data/examples/tutorial/04_test/web_docker_image/hello_world.txt +1 -0
- data/examples/tutorial/04_test/web_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/04_test/web_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/04_test/web_docker_image/main.go +43 -0
- data/examples/tutorial/04_test/web_docker_image/start.sh +7 -0
- data/examples/tutorial/04_test/web_docker_image/test.bash +6 -0
- data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/hosts.json +12 -0
- data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-gcc.bash +14 -0
- data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-python.bash +14 -0
- data/examples/tutorial/05_extend_with_plugins/dev_docker_image/Dockerfile +20 -0
- data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/Gemfile +4 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/hpc_config.rb +13 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/images/debian_10/Dockerfile +13 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/my_commands.bash +2 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/inventory.yaml +100 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_web-hello.rb +43 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/platform_handler/json_bash.rb +115 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/report/web_report.rb +52 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/test/root_space.rb +44 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/my_hpc_plugins.gemspec +15 -0
- data/examples/tutorial/05_extend_with_plugins/node/my-service.conf +4 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/Dockerfile +33 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/hello_world.txt +1 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/main.go +43 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/start.sh +7 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/test.bash +6 -0
- data/lib/hybrid_platforms_conductor/deployer.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +440 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +51 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +271 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +1 -0
- data/lib/hybrid_platforms_conductor/nodes_handler.rb +9 -5
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +23 -0
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +11 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +17 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +94 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +317 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +65 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +213 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +268 -0
- data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +53 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/chef_versions.yml +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +14 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/policyfiles/test_policy.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/chef_versions.yml +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/data_bags/my_bag/my_item.json +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +14 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/policyfiles/test_policy.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_1/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/recipes/other_recipe.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/resources/my_resource.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node1.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node2.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_1.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_2.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/config.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/cookbooks/test_cookbook_1/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/nodes/node1.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/nodes/node2.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/recipes/other_recipe.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/resources/my_resource.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/policyfiles/test_policy_1.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/policyfiles/test_policy_2.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/chef_versions.yml +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/nodes/local.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/nodes/node1.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/nodes/node2.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/policyfiles/test_policy_1.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/policyfiles/test_policy_2.rb +3 -0
- data/tools/generate_mermaid +1 -1
- metadata +260 -86
@@ -0,0 +1,94 @@
|
|
1
|
+
describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef do
|
2
|
+
|
3
|
+
context 'checking how deployment output is parsed' do
|
4
|
+
|
5
|
+
it 'parses a deployment output properly' do
|
6
|
+
with_serverless_chef_platforms('empty') do |platform|
|
7
|
+
stdout = <<~EOS
|
8
|
+
Starting Chef Client, version 14.14.29
|
9
|
+
resolving cookbooks for run list: ["policy_xae_websql::xae"]
|
10
|
+
Synchronizing Cookbooks:
|
11
|
+
- policy_xae_websql (0.1.0)
|
12
|
+
- chef-ruby (0.1.2)
|
13
|
+
- nginx (10.1.0)
|
14
|
+
Installing Cookbook Gems:
|
15
|
+
Compiling Cookbooks...
|
16
|
+
Recipe: site_debian::default
|
17
|
+
* apt_update[apt update] action update
|
18
|
+
- force update new lists of packages
|
19
|
+
* directory[/etc/apt/apt.conf.d] action create (up to date)
|
20
|
+
* file[/etc/apt/apt.conf.d/15update-stamp] action create_if_missing (up to date)
|
21
|
+
* execute[apt-get -q update] action run
|
22
|
+
- execute ["apt-get", "-q", "update"]
|
23
|
+
|
24
|
+
Converging 145 resources
|
25
|
+
Recipe: policy_xae_websql::api
|
26
|
+
* site_artifactory_dpkg_package[xaecalcite] action install
|
27
|
+
* remote_file[/opt/chef_cache/xaecalcite_0.2.4-1_amd64.deb] action create
|
28
|
+
- create new file /opt/chef_cache/xaecalcite_0.2.4-1_amd64.deb
|
29
|
+
- update content in file /opt/chef_cache/xaecalcite_0.2.4-1_amd64.deb from none to 39b0ca
|
30
|
+
(file sizes exceed 10000000 bytes, diff output suppressed)
|
31
|
+
* dpkg_package[xaecalcite] action install
|
32
|
+
- install version 0.2.4-1 of package xaecalcite
|
33
|
+
|
34
|
+
* service[/var/lib/xaecalcite/xaecalcite.service] action enable (skipped due to not_if)
|
35
|
+
|
36
|
+
Running handlers:
|
37
|
+
Running handlers complete
|
38
|
+
Chef Client finished, 16/300 resources updated in 27 seconds
|
39
|
+
EOS
|
40
|
+
expect(platform.parse_deploy_output(stdout, '')). to eq [
|
41
|
+
{
|
42
|
+
action: 'update',
|
43
|
+
diffs: "force update new lists of packages\n",
|
44
|
+
name: 'apt_update[apt update]',
|
45
|
+
status: :changed
|
46
|
+
},
|
47
|
+
{
|
48
|
+
action: 'create (up to date)',
|
49
|
+
name: 'directory[/etc/apt/apt.conf.d]',
|
50
|
+
status: :identical
|
51
|
+
},
|
52
|
+
{
|
53
|
+
action: 'create_if_missing (up to date)',
|
54
|
+
name: 'file[/etc/apt/apt.conf.d/15update-stamp]',
|
55
|
+
status: :identical
|
56
|
+
},
|
57
|
+
{
|
58
|
+
action: 'run',
|
59
|
+
diffs: "execute [\"apt-get\", \"-q\", \"update\"]\n",
|
60
|
+
name: 'execute[apt-get -q update]',
|
61
|
+
status: :changed
|
62
|
+
},
|
63
|
+
{
|
64
|
+
action: 'install',
|
65
|
+
name: 'site_artifactory_dpkg_package[xaecalcite]',
|
66
|
+
status: :identical
|
67
|
+
},
|
68
|
+
{
|
69
|
+
action: 'create',
|
70
|
+
diffs: <<~EOS,
|
71
|
+
create new file /opt/chef_cache/xaecalcite_0.2.4-1_amd64.deb
|
72
|
+
update content in file /opt/chef_cache/xaecalcite_0.2.4-1_amd64.deb from none to 39b0ca
|
73
|
+
EOS
|
74
|
+
name: 'remote_file[/opt/chef_cache/xaecalcite_0.2.4-1_amd64.deb]',
|
75
|
+
status: :changed
|
76
|
+
},
|
77
|
+
{
|
78
|
+
action: 'install',
|
79
|
+
diffs: "install version 0.2.4-1 of package xaecalcite\n",
|
80
|
+
name: 'dpkg_package[xaecalcite]',
|
81
|
+
status: :changed
|
82
|
+
},
|
83
|
+
{
|
84
|
+
action: 'enable (skipped due to not_if)',
|
85
|
+
name: 'service[/var/lib/xaecalcite/xaecalcite.service]',
|
86
|
+
status: :identical
|
87
|
+
}
|
88
|
+
]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb
ADDED
@@ -0,0 +1,317 @@
|
|
1
|
+
describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef do
|
2
|
+
|
3
|
+
context 'checking files diff impacts' do
|
4
|
+
|
5
|
+
it 'returns no impact for no diffs' do
|
6
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
7
|
+
expect(platform.impacts_from({})).to eq [
|
8
|
+
[],
|
9
|
+
[],
|
10
|
+
false
|
11
|
+
]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'ignores files with no impact' do
|
16
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
17
|
+
expect(platform.impacts_from(
|
18
|
+
'cookbooks/test_cookbook_1/README.md' => {}
|
19
|
+
)).to eq [
|
20
|
+
[],
|
21
|
+
[],
|
22
|
+
false
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns all nodes impact for global files' do
|
28
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
29
|
+
expect(platform.impacts_from(
|
30
|
+
'global.rb' => {}
|
31
|
+
)).to eq [
|
32
|
+
[],
|
33
|
+
[],
|
34
|
+
true
|
35
|
+
]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns direct impacted nodes' do
|
40
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
41
|
+
expect(platform.impacts_from(
|
42
|
+
'nodes/node1.json' => {}
|
43
|
+
)).to eq [
|
44
|
+
%w[node1],
|
45
|
+
[],
|
46
|
+
false
|
47
|
+
]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns direct impacted nodes with strange characters' do
|
52
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
53
|
+
expect(platform.impacts_from(
|
54
|
+
'nodes/node-v45.env_@user.json' => {}
|
55
|
+
)).to eq [
|
56
|
+
['node-v45.env_@user'],
|
57
|
+
[],
|
58
|
+
false
|
59
|
+
]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns impacted service due to a change in its recipes' do
|
64
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
65
|
+
expect(platform.impacts_from(
|
66
|
+
'cookbooks/test_cookbook_1/recipes/default.rb' => {}
|
67
|
+
)).to eq [
|
68
|
+
[],
|
69
|
+
%w[test_policy_1],
|
70
|
+
false
|
71
|
+
]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns impacted service due to a change in its attributes' do
|
76
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
77
|
+
expect(platform.impacts_from(
|
78
|
+
'cookbooks/test_cookbook_1/attributes/default.rb' => {}
|
79
|
+
)).to eq [
|
80
|
+
[],
|
81
|
+
%w[test_policy_1],
|
82
|
+
false
|
83
|
+
]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns impacted service due to a change in an included template' do
|
88
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
89
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
90
|
+
template '/home/file' do
|
91
|
+
source 'test_template.erb'
|
92
|
+
end
|
93
|
+
EOS
|
94
|
+
expect(platform.impacts_from(
|
95
|
+
'cookbooks/test_cookbook_1/templates/default/test_template.erb' => {}
|
96
|
+
)).to eq [
|
97
|
+
[],
|
98
|
+
%w[test_policy_1],
|
99
|
+
false
|
100
|
+
]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'does not return impacted service due to a change in a non included template' do
|
105
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
106
|
+
expect(platform.impacts_from(
|
107
|
+
'cookbooks/test_cookbook_1/templates/default/test_template.erb' => {}
|
108
|
+
)).to eq [
|
109
|
+
[],
|
110
|
+
[],
|
111
|
+
false
|
112
|
+
]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'returns impacted service due to a change in an included file' do
|
117
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
118
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
119
|
+
file '/home/file' do
|
120
|
+
source 'test_file'
|
121
|
+
end
|
122
|
+
EOS
|
123
|
+
expect(platform.impacts_from(
|
124
|
+
'cookbooks/test_cookbook_1/files/default/test_file' => {}
|
125
|
+
)).to eq [
|
126
|
+
[],
|
127
|
+
%w[test_policy_1],
|
128
|
+
false
|
129
|
+
]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'does not return impacted service due to a change in a non included file' do
|
134
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
135
|
+
expect(platform.impacts_from(
|
136
|
+
'cookbooks/test_cookbook_1/files/default/test_file' => {}
|
137
|
+
)).to eq [
|
138
|
+
[],
|
139
|
+
[],
|
140
|
+
false
|
141
|
+
]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'returns impacted service due to a resource usage in a recipe' do
|
146
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
147
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
148
|
+
test_cookbook_2_my_resource
|
149
|
+
EOS
|
150
|
+
expect(platform.impacts_from(
|
151
|
+
'cookbooks/test_cookbook_2/resources/my_resource.rb' => {}
|
152
|
+
)).to eq [
|
153
|
+
[],
|
154
|
+
%w[test_policy_1],
|
155
|
+
false
|
156
|
+
]
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'does not return impacted service due to a resource not being used in a recipe' do
|
161
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
162
|
+
expect(platform.impacts_from(
|
163
|
+
'cookbooks/test_cookbook_2/resources/my_resource.rb' => {}
|
164
|
+
)).to eq [
|
165
|
+
[],
|
166
|
+
[],
|
167
|
+
false
|
168
|
+
]
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'returns impacted service due to a library helper usage in a recipe' do
|
173
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
174
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
175
|
+
a = my_library_helper(42)
|
176
|
+
EOS
|
177
|
+
expect(platform.impacts_from(
|
178
|
+
'cookbooks/test_cookbook_2/libraries/default.rb' => {}
|
179
|
+
)).to eq [
|
180
|
+
[],
|
181
|
+
%w[test_policy_1],
|
182
|
+
false
|
183
|
+
]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'ignored impacted service from an unknown helper' do
|
188
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
189
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
190
|
+
a = unknown_helper(42)
|
191
|
+
EOS
|
192
|
+
expect(platform.impacts_from(
|
193
|
+
'cookbooks/test_cookbook_2/recipes/default.rb' => {}
|
194
|
+
)).to eq [
|
195
|
+
[],
|
196
|
+
%w[test_policy_2],
|
197
|
+
false
|
198
|
+
]
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'returns impacted service due to an unknown library helper usage that has been configured' do
|
203
|
+
with_serverless_chef_platforms(
|
204
|
+
'recipes',
|
205
|
+
additional_config: <<~EOS
|
206
|
+
helpers_including_recipes(unknown_helper: ['test_cookbook_2'])
|
207
|
+
EOS
|
208
|
+
) do |platform, repository|
|
209
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
210
|
+
a = unknown_helper(42)
|
211
|
+
EOS
|
212
|
+
expect(platform.impacts_from(
|
213
|
+
'cookbooks/test_cookbook_2/recipes/default.rb' => {}
|
214
|
+
)).to eq [
|
215
|
+
[],
|
216
|
+
%w[test_policy_1 test_policy_2],
|
217
|
+
false
|
218
|
+
]
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'does not return impacted service due to a library helper not being used in a recipe' do
|
223
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
224
|
+
expect(platform.impacts_from(
|
225
|
+
'cookbooks/test_cookbook_2/libraries/default.rb' => {}
|
226
|
+
)).to eq [
|
227
|
+
[],
|
228
|
+
[],
|
229
|
+
false
|
230
|
+
]
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'returns impacted service due to a usage of another cookbook\'s default recipe' do
|
235
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
236
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
237
|
+
include_recipe 'test_cookbook_2'
|
238
|
+
EOS
|
239
|
+
expect(platform.impacts_from(
|
240
|
+
'cookbooks/test_cookbook_2/recipes/default.rb' => {}
|
241
|
+
)).to eq [
|
242
|
+
[],
|
243
|
+
%w[test_policy_1 test_policy_2],
|
244
|
+
false
|
245
|
+
]
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'returns impacted service due to a usage of another cookbook\'s recipe' do
|
250
|
+
with_serverless_chef_platforms('recipes') do |platform, repository|
|
251
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
252
|
+
include_recipe 'test_cookbook_2::other_recipe'
|
253
|
+
EOS
|
254
|
+
expect(platform.impacts_from(
|
255
|
+
'cookbooks/test_cookbook_2/recipes/other_recipe.rb' => {}
|
256
|
+
)).to eq [
|
257
|
+
[],
|
258
|
+
%w[test_policy_1],
|
259
|
+
false
|
260
|
+
]
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'ignores cookbooks from cookbook paths that are not configured' do
|
265
|
+
with_serverless_chef_platforms('several_cookbooks') do |platform, repository|
|
266
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
267
|
+
include_recipe 'test_cookbook_2'
|
268
|
+
EOS
|
269
|
+
expect(platform.impacts_from(
|
270
|
+
'other_cookbooks/test_cookbook_2/recipes/default.rb' => {}
|
271
|
+
)).to eq [
|
272
|
+
[],
|
273
|
+
%w[],
|
274
|
+
true
|
275
|
+
]
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'considers cookbooks from non-standard cookbook paths that are configured' do
|
280
|
+
with_serverless_chef_platforms('several_cookbooks') do |platform, repository|
|
281
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
282
|
+
include_recipe 'test_cookbook_2'
|
283
|
+
EOS
|
284
|
+
ENV['hpc_test_cookbooks_path'] = 'other_cookbooks'
|
285
|
+
expect(platform.impacts_from(
|
286
|
+
'other_cookbooks/test_cookbook_2/recipes/default.rb' => {}
|
287
|
+
)).to eq [
|
288
|
+
[],
|
289
|
+
%w[test_policy_1 test_policy_2],
|
290
|
+
false
|
291
|
+
]
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'ignores cookbooks from cookbook paths that are configured but lie outside the platform' do
|
296
|
+
with_repository('other_cookbooks') do |other_repo|
|
297
|
+
FileUtils.mkdir_p("#{other_repo}/cookbooks/test_cookbook_2/recipes")
|
298
|
+
File.write("#{other_repo}/cookbooks/test_cookbook_2/recipes/default.rb", '')
|
299
|
+
with_serverless_chef_platforms('several_cookbooks') do |platform, repository|
|
300
|
+
File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EOS)
|
301
|
+
include_recipe 'test_cookbook_2'
|
302
|
+
EOS
|
303
|
+
ENV['hpc_test_cookbooks_path'] = "#{other_repo}:other_cookbooks"
|
304
|
+
expect(platform.impacts_from(
|
305
|
+
'unknown_cookbooks/test_cookbook_2/recipes/default.rb' => {}
|
306
|
+
)).to eq [
|
307
|
+
[],
|
308
|
+
%w[],
|
309
|
+
true
|
310
|
+
]
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef do
|
2
|
+
|
3
|
+
context 'checking inventory' do
|
4
|
+
|
5
|
+
context 'with an empty platform' do
|
6
|
+
|
7
|
+
it 'returns no node' do
|
8
|
+
with_serverless_chef_platforms('empty') do |platform|
|
9
|
+
expect(platform.known_nodes).to eq []
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns no nodes list' do
|
14
|
+
with_serverless_chef_platforms('empty') do |platform|
|
15
|
+
expect(platform.respond_to?(:known_nodes_lists)).to eq false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns no deployable services' do
|
20
|
+
with_serverless_chef_platforms('empty') do |platform|
|
21
|
+
expect(platform.deployable_services).to eq []
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with a platform having 1 node' do
|
28
|
+
|
29
|
+
it 'returns the node' do
|
30
|
+
with_serverless_chef_platforms('1_node') do |platform|
|
31
|
+
expect(platform.known_nodes).to eq ['node']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns correct metadata for this node' do
|
36
|
+
with_serverless_chef_platforms('1_node') do |platform|
|
37
|
+
expect(platform.metadata_for('node')).to eq(
|
38
|
+
description: 'Single test node',
|
39
|
+
image: 'debian_9',
|
40
|
+
private_ips: ['172.16.0.1'],
|
41
|
+
property1: {
|
42
|
+
'property11' => 'value11'
|
43
|
+
},
|
44
|
+
property2: 'value2'
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns correct service for this node' do
|
50
|
+
with_serverless_chef_platforms('1_node') do |platform|
|
51
|
+
expect(platform.services_for('node')).to eq %w[test_policy]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns deployable services' do
|
56
|
+
with_serverless_chef_platforms('1_node') do |platform|
|
57
|
+
expect(platform.deployable_services).to eq %w[test_policy]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|