Fix reboot plugin test

Since tasks.yaml is not supported we need to move our tasks to
deployment_tasks.yaml

+ create task in the new format
+ refactor code to use ssh_manager

Change-Id: I7b431b6a5dbcdadf68c064e9f29e919e2c2aabdc
CLoses-Bug: #1573490
This commit is contained in:
Volodymyr Shypyguzov 2016-06-14 20:18:06 +03:00
parent 0dd72977fa
commit 251bae4d1a
2 changed files with 50 additions and 22 deletions

View File

@ -1,19 +1,41 @@
- role: ['controller', 'ceph-osd']
stage: pre_deployment
type: shell
parameters:
cmd: sleep 20
timeout: 30
# These tasks will be merged into deployment graph. Here you
# can specify new tasks for any roles, even built-in ones.
- role: ['controller', 'ceph-osd']
stage: pre_deployment
- id: reboot_plugin-sleep-before
type: shell
role: ['primary-controller', 'controller', 'ceph-osd']
version: 2.0.0
requires: [pre_deployment_start] # version 1.0.0
required_for: [reboot_plugin-create-file]
parameters:
cmd: sleep 20
timeout: 30
- id: reboot_plugin-create-file
type: shell
role: ['primary-controller', 'controller', 'ceph-osd']
version: 2.0.0
requires: [reboot_plugin-sleep-before] # version 1.0.0
required_for: [reboot_plugin-task]
parameters:
cmd: if ! ls /run/cloud-init/status.json;then mkdir /run/cloud-init; touch /run/cloud-init/status.json;fi
timeout: 30
- id: reboot_plugin-task
role: ['primary-controller', 'controller', 'ceph-osd']
version: 2.0.0
requires: [reboot_plugin-create-file] # version 1.0.0
required_for: [reboot_plugin-sleep-after]
type: reboot
parameters:
timeout: 180
timeout: 180
- role: ['controller', 'ceph-osd']
stage: pre_deployment
- id: reboot_plugin-sleep-after
role: ['primary-controller', 'controller', 'ceph-osd']
version: 2.0.0
requires: [reboot_plugin-task] # version 1.0.0
required_for: [pre_deployment_end]
type: shell
parameters:
cmd: sleep 50
timeout: 60
cmd: sleep 50
timeout: 60

View File

@ -72,7 +72,7 @@ class RebootPlugin(TestBasic):
# replace plugin tasks with our file
fpb.fpb_replace_plugin_content(
os.path.join(tasks_path, tasks_file),
os.path.join(source_plugin_path, 'tasks.yaml'))
os.path.join(source_plugin_path, 'deployment_tasks.yaml'))
# build plugin
self.show_step(4)
packet_name = fpb.fpb_build_plugin(source_plugin_path)
@ -128,8 +128,11 @@ class RebootPlugin(TestBasic):
logger.debug(
"Get init object creation time from node {0}".format(node))
cmd = 'stat --printf=\'%Y\' /proc/1'
with self.fuel_web.get_ssh_for_node(node) as node_ssh:
old_timestamps[node] = node_ssh.execute(cmd)['stdout'][0]
old_timestamps[node] = int(
self.ssh_manager.execute_on_remote(
ip=self.fuel_web.get_node_ip_by_devops_name(node),
cmd=cmd)['stdout_str']
)
# start deploying nodes
# here nodes with controller and ceph roles should be rebooted
@ -142,8 +145,11 @@ class RebootPlugin(TestBasic):
logger.debug(
"Get init object creation time from node {0}".format(node))
cmd = 'stat --printf=\'%Y\' /proc/1'
with self.fuel_web.get_ssh_for_node(node) as node_ssh:
new_timestamp = node_ssh.execute(cmd)['stdout'][0]
new_timestamp = int(
self.ssh_manager.execute_on_remote(
ip=self.fuel_web.get_node_ip_by_devops_name(node),
cmd=cmd)['stdout_str']
)
# compute node without ceph role shouldn't reboot
if not nodes[node]:
asserts.assert_equal(
@ -178,7 +184,7 @@ class RebootPlugin(TestBasic):
6. Create cluster and enable plugin
7. Provision nodes
8. Deploy cluster
9. Check deployment was failed by reboot task
9. Check that deployment task failed
10. Check error msg at the logs
Duration 15m
@ -201,7 +207,7 @@ class RebootPlugin(TestBasic):
# change timeout to a new value '1'
fpb.put_value_to_local_yaml(os.path.join(tasks_path, tasks_file),
os.path.join('/tmp/', tasks_file),
[1, 'parameters', 'timeout'],
[2, 'parameters', 'timeout'],
1)
self.show_step(3)
# create plugin template on the master node
@ -210,7 +216,7 @@ class RebootPlugin(TestBasic):
# replace plugin tasks with our file
fpb.fpb_replace_plugin_content(
os.path.join('/tmp/', tasks_file),
os.path.join(source_plugin_path, 'tasks.yaml'))
os.path.join(source_plugin_path, 'deployment_tasks.yaml'))
# build plugin
self.show_step(4)
packet_name = fpb.fpb_build_plugin(source_plugin_path)
@ -252,7 +258,7 @@ class RebootPlugin(TestBasic):
self.show_step(9)
self.fuel_web.assert_task_failed(task)
msg = 'Time detection (1 sec) for node reboot has expired'
msg = 'reboot_plugin-task failed becausereboot timeout 1 expired'
cmd = 'grep "{0}" /var/log/astute/astute.log'.format(msg)
self.show_step(10)
self.ssh_manager.execute_on_remote(