chef-provisioning-opennebula 0.4.8 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -3
- data/lib/chef/provisioning/opennebula_driver/driver.rb +7 -1
- data/lib/chef/provisioning/opennebula_driver/version.rb +1 -1
- data/spec/config_sample.rb +19 -18
- data/spec/integration/one_driver_spec.rb +84 -0
- data/spec/integration/one_flow_spec.rb +340 -0
- data/spec/recipes/OneDriver/{instantiate_one_template_vnet.rb → allocate_one_vm.rb} +6 -4
- data/spec/recipes/OneDriver/attach_one_image.rb +2 -2
- data/spec/recipes/OneDriver/converge_one_vm.rb +17 -0
- data/spec/recipes/OneDriver/create_one_image.rb +1 -1
- data/spec/recipes/OneDriver/create_one_template.rb +18 -0
- data/spec/recipes/OneDriver/create_one_vnet.rb +2 -2
- data/spec/recipes/OneDriver/{delete/OpenNebula-test-vm.rb → delete_one_img.rb} +1 -1
- data/spec/recipes/OneDriver/{delete/OpenNebula-test-img.rb → delete_one_snap-img.rb} +1 -1
- data/spec/recipes/{OneFlowService/delete/test_role_action.rb → OneDriver/delete_one_template.rb} +1 -1
- data/spec/recipes/OneDriver/{delete/OpenNebula-test-vm-vnet.rb → delete_one_vm.rb} +1 -1
- data/spec/recipes/OneDriver/{delete/OpenNebula-test-vnet.rb → delete_one_vnet.rb} +1 -1
- data/spec/recipes/OneDriver/ready_one_vm.rb +17 -0
- data/spec/recipes/OneDriver/snapshot_one_image.rb +3 -3
- data/spec/recipes/OneDriver/update_one_template.rb +20 -0
- data/spec/recipes/{OneFlowTemplate/create_branch_from_one_id.rb → OneFlow/branch_json_template_by_id.rb} +6 -6
- data/spec/recipes/OneFlow/branch_json_template_by_name.rb +42 -0
- data/spec/recipes/{OneFlowTemplate/chmod_simple_from_hash.rb → OneFlow/chmod_file_template.rb} +1 -1
- data/spec/recipes/{OneFlowService/chmod_simple_by_name_2.rb → OneFlow/chmod_json_service_by_id.rb} +2 -2
- data/spec/recipes/{OneFlowService/instance_simple_by_name.rb → OneFlow/chmod_json_service_by_name.rb} +2 -2
- data/spec/recipes/{OneDriver/delete/OpenNebula-test-snap-img.rb → OneFlow/chmod_json_template.rb} +2 -2
- data/spec/recipes/OneFlow/create_file_template.rb +18 -0
- data/spec/recipes/{OneFlowTemplate/create_tpl_opts_from_hash.rb → OneFlow/create_file_template_with_opts.rb} +8 -11
- data/spec/recipes/OneFlow/create_http_template.rb +17 -0
- data/spec/recipes/{OneFlowService/instance_simple_by_id.rb → OneFlow/create_json_service_by_id.rb} +4 -2
- data/spec/recipes/{OneFlowService/chmod_simple_by_name.rb → OneFlow/create_json_service_by_name.rb} +2 -2
- data/spec/recipes/{OneFlowService/instance_tpl_opts.rb → OneFlow/create_json_service_with_opts.rb} +8 -6
- data/spec/recipes/{OneFlowTemplate/create_simple_from_hash.rb → OneFlow/create_json_template.rb} +4 -3
- data/spec/recipes/{OneFlowTemplate/create_tpl_opts_from_file.rb → OneFlow/create_json_template_with_opts.rb} +15 -7
- data/spec/recipes/{OneFlowService/instance_role_action.rb → OneFlow/create_role_action_service.rb} +8 -8
- data/spec/recipes/OneFlow/create_role_action_template.rb +89 -0
- data/spec/recipes/OneFlow/delete_branched_template_by_id.rb +17 -0
- data/spec/recipes/OneFlow/delete_branched_template_by_name.rb +17 -0
- data/spec/recipes/{OneDriver/delete/OpenNebula-test-tpl-strings.rb → OneFlow/delete_file_template.rb} +1 -1
- data/spec/recipes/OneFlow/delete_file_template_with_opts.rb +17 -0
- data/spec/recipes/{OneDriver/delete/OpenNebula-test-tpl-ints.rb → OneFlow/delete_http_template.rb} +1 -1
- data/spec/recipes/{OneDriver/delete/OpenNebula-test-tpl-mix.rb → OneFlow/delete_json_service_by_id.rb} +1 -1
- data/spec/recipes/OneFlow/delete_json_service_by_name.rb +17 -0
- data/spec/recipes/OneFlow/delete_json_service_with_opts.rb +17 -0
- data/spec/recipes/OneFlow/delete_json_template.rb +17 -0
- data/spec/recipes/OneFlow/delete_json_template_with_opts.rb +17 -0
- data/spec/recipes/OneFlow/delete_role_action_service.rb +17 -0
- data/spec/recipes/OneFlow/delete_role_action_template.rb +17 -0
- data/spec/recipes/{OneFlowService/action/boot.rb → OneFlow/service_action_boot.rb} +4 -3
- data/spec/recipes/OneFlow/service_action_delete.rb +18 -0
- data/spec/recipes/{OneFlowService/action/delete_recreate.rb → OneFlow/service_action_delete_recreate.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/hold.rb → OneFlow/service_action_hold.rb} +4 -3
- data/spec/recipes/{OneFlowService/action/poweroff.rb → OneFlow/service_action_poweroff.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/poweroff_hard.rb → OneFlow/service_action_poweroff_hard.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/reboot.rb → OneFlow/service_action_reboot.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/reboot_hard.rb → OneFlow/service_action_reboot_hard.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/release.rb → OneFlow/service_action_release.rb} +4 -3
- data/spec/recipes/OneFlow/service_action_resume_poweroff.rb +18 -0
- data/spec/recipes/OneFlow/service_action_resume_poweroff_hard.rb +18 -0
- data/spec/recipes/{OneFlowService/action/resume.rb → OneFlow/service_action_resume_stop.rb} +2 -2
- data/spec/recipes/OneFlow/service_action_resume_suspend.rb +18 -0
- data/spec/recipes/OneFlow/service_action_resume_undeploy.rb +18 -0
- data/spec/recipes/OneFlow/service_action_resume_undeploy_hard.rb +18 -0
- data/spec/recipes/{OneFlowService/action/scale.rb → OneFlow/service_action_scale.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/shutdown.rb → OneFlow/service_action_shutdown.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/shutdown_hard.rb → OneFlow/service_action_shutdown_hard.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/snapshot_create.rb → OneFlow/service_action_snapshot_create.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/stop.rb → OneFlow/service_action_stop.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/suspend.rb → OneFlow/service_action_suspend.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/undeploy.rb → OneFlow/service_action_undeploy.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/undeploy_hard.rb → OneFlow/service_action_undeploy_hard.rb} +2 -2
- data/spec/recipes/{OneFlowService/action/shutdown_service.rb → OneFlow/shutdown_role_action_service.rb} +1 -1
- data/spec/recipes/{OneFlowTemplate/update_simple_from_hash.rb → OneFlow/update_json_template.rb} +17 -14
- data/spec/recipes/common.rb +0 -2
- data/spec/spec_helper.rb +97 -42
- metadata +86 -89
- data/spec/integration/test_all_integration_spec.rb +0 -21
- data/spec/integration/test_one_driver.rb +0 -177
- data/spec/integration/test_one_flow.rb +0 -546
- data/spec/recipes/OneDriver/allocate_change_profile.rb +0 -23
- data/spec/recipes/OneDriver/create_one_template_ints.rb +0 -38
- data/spec/recipes/OneDriver/create_one_template_mix.rb +0 -51
- data/spec/recipes/OneDriver/create_one_template_strings.rb +0 -34
- data/spec/recipes/OneDriver/instantiate_one_template.rb +0 -21
- data/spec/recipes/OneFlowService/action/delete.rb +0 -18
- data/spec/recipes/OneFlowService/chmod_tpl_opts.rb +0 -31
- data/spec/recipes/OneFlowService/delete/test_instance_template_options.rb +0 -17
- data/spec/recipes/OneFlowService/delete/test_simple_instance.rb +0 -17
- data/spec/recipes/OneFlowService/delete/test_simple_instance_by_id.rb +0 -17
- data/spec/recipes/OneFlowTemplate/chmod_update_simple_from_file.rb +0 -19
- data/spec/recipes/OneFlowTemplate/create_branch_from_one_name.rb +0 -20
- data/spec/recipes/OneFlowTemplate/create_role_action_instance.rb +0 -99
- data/spec/recipes/OneFlowTemplate/create_simple_from_file.rb +0 -18
- data/spec/recipes/OneFlowTemplate/create_simple_from_web.rb +0 -17
- data/spec/recipes/OneFlowTemplate/create_simple_instance_tpl.rb +0 -22
- data/spec/recipes/OneFlowTemplate/delete/branch_from_one_id.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/branch_from_one_name.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/role_action_instance.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/simple_from_file.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/simple_from_hash.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/simple_from_web.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/simple_instance_tpl.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/tpl_opts_from_file.rb +0 -17
- data/spec/recipes/OneFlowTemplate/delete/tpl_opts_from_hash.rb +0 -17
- data/spec/support/opennebula_support.rb +0 -129
data/spec/recipes/{OneFlowService/action/reboot_hard.rb → OneFlow/service_action_reboot_hard.rb}
RENAMED
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_reboot_hard'
|
17
17
|
action :reboot_hard
|
18
18
|
end
|
@@ -12,8 +12,9 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
17
|
-
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_hold'
|
17
|
+
# The following setting will ignore the fact the feature is not fully tested and run it anyway
|
18
|
+
#override_failsafe true
|
18
19
|
action :release
|
19
20
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2016, BlackBerry Limited
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_poweroff'
|
17
|
+
action :resume
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2016, BlackBerry Limited
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_poweroff_hard'
|
17
|
+
action :resume
|
18
|
+
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_stop'
|
17
17
|
action :resume
|
18
18
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2016, BlackBerry Limited
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_suspend'
|
17
|
+
action :resume
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2016, BlackBerry Limited
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_undeploy'
|
17
|
+
action :resume
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2016, BlackBerry Limited
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_undeploy_hard'
|
17
|
+
action :resume
|
18
|
+
end
|
@@ -12,8 +12,8 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_scale'
|
17
17
|
cardinality 2
|
18
18
|
action :scale
|
19
19
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_shutdown'
|
17
17
|
action :shutdown
|
18
18
|
end
|
data/spec/recipes/{OneFlowService/action/shutdown_hard.rb → OneFlow/service_action_shutdown_hard.rb}
RENAMED
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_shutdown_hard'
|
17
17
|
action :shutdown_hard
|
18
18
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_snapshot_create'
|
17
17
|
action :snapshot_create
|
18
18
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_stop'
|
17
17
|
action :stop
|
18
18
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_suspend'
|
17
17
|
action :suspend
|
18
18
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_undeploy'
|
17
17
|
action :undeploy
|
18
18
|
end
|
data/spec/recipes/{OneFlowService/action/undeploy_hard.rb → OneFlow/service_action_undeploy_hard.rb}
RENAMED
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_service '
|
16
|
-
role '
|
15
|
+
one_flow_service 'RSpec-role-action-service' do
|
16
|
+
role 'RSpec_undeploy_hard'
|
17
17
|
action :undeploy_hard
|
18
18
|
end
|
data/spec/recipes/{OneFlowTemplate/update_simple_from_hash.rb → OneFlow/update_json_template.rb}
RENAMED
@@ -12,42 +12,45 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
one_flow_template '
|
15
|
+
one_flow_template 'RSpec-flow-json-template' do
|
16
16
|
template :deployment => 'none',
|
17
|
+
:ready_status_gate => false,
|
17
18
|
:roles => [
|
18
19
|
{
|
19
|
-
:name => '
|
20
|
+
:name => 'RSpecTest',
|
21
|
+
:cooldown => 2,
|
20
22
|
:min_vms => 1,
|
21
23
|
:max_vms => 5,
|
22
24
|
:scheduled_policies => [
|
23
25
|
{
|
24
26
|
:type => "PERCENTAGE_CHANGE",
|
27
|
+
:cooldown => 2,
|
25
28
|
:recurrence => "0 1 1-10 * *",
|
26
|
-
:adjust =>
|
27
|
-
:min_adjust_step =>
|
29
|
+
:adjust => 1,
|
30
|
+
:min_adjust_step => 5
|
28
31
|
}
|
29
32
|
]
|
30
33
|
},
|
31
34
|
{
|
32
|
-
:name => '
|
33
|
-
:vm_template => '
|
34
|
-
:cooldown =>
|
35
|
+
:name => 'RSpecRetest',
|
36
|
+
:vm_template => 'RSpec-test-template',
|
37
|
+
:cooldown => 2,
|
35
38
|
:min_vms => 1,
|
36
39
|
:max_vms => 5,
|
37
40
|
:elasticity_policies => [
|
38
41
|
{
|
39
42
|
:type => "CHANGE",
|
40
|
-
:cooldown =>
|
41
|
-
:period =>
|
42
|
-
:adjust =>
|
43
|
-
:period_number =>
|
43
|
+
:cooldown => 2,
|
44
|
+
:period => 2,
|
45
|
+
:adjust => 1,
|
46
|
+
:period_number => 1,
|
44
47
|
:expression => "ATT == 20"
|
45
48
|
},
|
46
49
|
{
|
47
50
|
:type => "CARDINALITY",
|
48
|
-
:cooldown =>
|
49
|
-
:period =>
|
50
|
-
:adjust =>
|
51
|
+
:cooldown => 2,
|
52
|
+
:period => 2,
|
53
|
+
:adjust => 1,
|
51
54
|
:period_number => 1,
|
52
55
|
:expression => "ATT > 20"
|
53
56
|
}
|
data/spec/recipes/common.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -12,57 +12,112 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require 'chef/dsl/recipe'
|
16
|
-
require 'chef/mixin/shell_out'
|
17
|
-
require 'chef/platform'
|
18
|
-
require 'chef/provisioning'
|
19
15
|
require 'chef/provisioning/opennebula_driver'
|
20
|
-
require '
|
21
|
-
require '
|
22
|
-
require 'support/opennebula_support'
|
16
|
+
require 'open3'
|
17
|
+
require 'tempfile'
|
23
18
|
require 'fileutils'
|
24
|
-
|
19
|
+
require "#{File.dirname(__FILE__)}/config.rb"
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.filter_run :runme
|
23
|
+
config.run_all_when_everything_filtered = true
|
24
|
+
config.add_setting :log_dir, :default => File.join(File.expand_path('..', File.dirname(__FILE__)), 'rspec-results')
|
25
|
+
config.before(:suite) do
|
26
|
+
# Cleanup nodes and log_dir from previous run
|
27
|
+
FileUtils.rm_rf(File.join(File.expand_path('..', File.dirname(__FILE__)), 'nodes'))
|
28
|
+
FileUtils.mkdir_p(config.log_dir) unless Dir.exist?(config.log_dir)
|
29
|
+
Dir.entries(config.log_dir).reject{|entry| entry =~ /^\.\.?$/}.each do |f|
|
30
|
+
FileUtils.rm_rf(File.join(config.log_dir, f))
|
31
|
+
end
|
32
|
+
cleanup
|
29
33
|
end
|
30
|
-
|
31
|
-
|
34
|
+
config.after(:suite) do
|
35
|
+
FileUtils.rm_rf(File.join(File.expand_path('..', File.dirname(__FILE__)), 'nodes'))
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
RSpec::Matchers.define :converge_with_result do |expected|
|
40
|
+
match do |recipe|
|
41
|
+
recipe_file = createRecipe([File.join('./spec/recipes/', recipe)])
|
42
|
+
@stdout, @stderr, status = Open3.capture3('chef-client', '-z', recipe_file, '--force-formatter')
|
43
|
+
|
44
|
+
# Save stdout, stderr and stacktrace to log_dir
|
45
|
+
saveLogs(recipe, @stdout, @stderr)
|
46
|
+
|
47
|
+
# Evaluate outcome by looking at STDOUT
|
48
|
+
if status.success?
|
49
|
+
@stdout.scan(Regexp.union(expected)).any? ? true : false
|
50
|
+
else
|
51
|
+
false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
failure_message do |recipe|
|
56
|
+
"expecting #{recipe} return #{expected} - instead we received:\n\n#{@stdout}\n#{@stderr}"
|
57
|
+
end
|
58
|
+
|
59
|
+
failure_message_when_negated do |recipe|
|
60
|
+
"expecting #{recipe} NOT return #{expected} - instead we received:\n\n#{@stdout}\n#{@stderr}"
|
61
|
+
end
|
51
62
|
end
|
52
63
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
private
|
65
|
+
|
66
|
+
# Create a temporary recipe file
|
67
|
+
# NB - file is removed after rspec terminates
|
68
|
+
def createRecipe(recipes_list)
|
69
|
+
recipes_list.unshift('./spec/recipes/common.rb')
|
70
|
+
file = Tempfile.new(['recipe-', '.rb'], '/tmp')
|
71
|
+
file << "require '#{File.dirname(__FILE__)}/config.rb'\n\n"
|
72
|
+
recipes_list.each do |r|
|
73
|
+
file << File.read(r) + "\n\n"
|
62
74
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
75
|
+
file.close
|
76
|
+
file.path
|
77
|
+
end
|
78
|
+
|
79
|
+
# Save output streams and stacktrace to log files
|
80
|
+
# Log filenames are timestamped to make then unique
|
81
|
+
def saveLogs(recipe, stdout, stderr)
|
82
|
+
# Establish what filename to use for logging
|
83
|
+
FileUtils.mkdir_p(File.join(RSpec.configuration.log_dir, File.dirname(recipe)))
|
84
|
+
log_basename = File.join(RSpec.configuration.log_dir, File.dirname(recipe),
|
85
|
+
File.basename(recipe, File.extname(recipe)))
|
86
|
+
ts = Time.now.strftime('%H-%M-%S-%4N')
|
87
|
+
|
88
|
+
# Find out if we have a stacktrace in stdout
|
89
|
+
st = @stdout.scan(/FATAL: Stacktrace dumped to (.*?chef-stacktrace\.out)/)
|
90
|
+
stacktrace = st.any? && File.exist?(st.last.join) ? File.read(st.last.join) : ''
|
91
|
+
|
92
|
+
# Write the logs
|
93
|
+
File.open(log_basename + ".#{ts}" + '.stdout', 'w') { |f| f.puts(stdout); f.close} unless stdout.empty?
|
94
|
+
File.open(log_basename + ".#{ts}" + '.stderr', 'w') { |f| f.puts(stderr); f.close} unless stderr.empty?
|
95
|
+
File.open(log_basename + ".#{ts}" + '.stacktrace', 'w') { |f| f.puts(stacktrace); f.close} unless stacktrace.empty?
|
96
|
+
end
|
97
|
+
|
98
|
+
# Cleanup objects created in previous run
|
99
|
+
def cleanup
|
100
|
+
# List of recipes we're going to use for cleanup
|
101
|
+
cleanup_list = %w(
|
102
|
+
OneDriver/delete_one_snap-img.rb
|
103
|
+
OneDriver/delete_one_vm.rb
|
104
|
+
OneDriver/delete_one_template.rb
|
105
|
+
OneDriver/delete_one_img.rb
|
106
|
+
OneDriver/delete_one_vnet.rb
|
107
|
+
).map { |f| File.join(File.dirname(__FILE__), "recipes", f) }
|
108
|
+
cleanup_list += Dir["#{File.dirname(__FILE__)}/recipes/OneFlow/delete_*.rb"] unless ONE_FLOW_URL.nil?
|
109
|
+
|
110
|
+
# Create temporary cleanup recipe and run it
|
111
|
+
recipe_file = createRecipe(cleanup_list)
|
112
|
+
@stdout, @stderr, status = Open3.capture3('chef-client', '-z', recipe_file, '--force-formatter')
|
113
|
+
|
114
|
+
# Save stdout, stderr and stacktrace to log_dir
|
115
|
+
saveLogs('cleanup.rb', @stdout, @stderr)
|
116
|
+
|
117
|
+
# Evaluate outcome by looking at STDOUT
|
118
|
+
if status.success?
|
119
|
+
raise "Cleanup attempt failed:\n\n#{@stdout}\n#{@stderr}" if @stdout.scan(/FATAL:/).any?
|
120
|
+
else
|
121
|
+
raise "Cleanup attempt failed:\n\n#{@stdout}\n#{@stderr}"
|
67
122
|
end
|
68
123
|
end
|