Commit 51958d2a authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

QA for KVM instance shutdown



Add QA for instance shutdown for KVM.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 2a60db50
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
import os import os
import re import re
import time
from ganeti import utils from ganeti import utils
from ganeti import constants from ganeti import constants
...@@ -1097,7 +1098,7 @@ def TestInstanceCreationRestrictedByDiskTemplates(): ...@@ -1097,7 +1098,7 @@ def TestInstanceCreationRestrictedByDiskTemplates():
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def _TestInstanceUserDown(instance, master, hv_shutdown_fn): def _TestInstanceUserDown(instance, master, hv_shutdown_fn):
# Shutdown instance in Xen and bring instance status to 'USER_down' # Shutdown instance and bring instance status to 'USER_down'
hv_shutdown_fn() hv_shutdown_fn()
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name] cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name]
...@@ -1150,19 +1151,27 @@ def _TestInstanceUserDown(instance, master, hv_shutdown_fn): ...@@ -1150,19 +1151,27 @@ def _TestInstanceUserDown(instance, master, hv_shutdown_fn):
def _TestInstanceUserDownXen(instance, master): def _TestInstanceUserDownXen(instance, master):
primary = _GetInstanceField(instance.name, "pnode") primary = _GetInstanceField(instance.name, "pnode")
fn = lambda: AssertCommand(["xm", "shutdown", "-w", instance.name], fn = lambda: AssertCommand(["xm", "shutdown", "-w", instance.name],
fail=False, node=primary) node=primary)
_TestInstanceUserDown(instance, master, fn) _TestInstanceUserDown(instance, master, fn)
# FIXME: User shutdown is not implemented for KVM yet @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
# def _TestInstanceUserDownKvm(instance, master):
# @InstanceCheck(INST_UP, INST_UP, FIRST_ARG) def _StopKVMInstance():
# def _TestInstanceUserDownKvm(instance, master): AssertCommand("pkill -f \"kvm -name %s\"" % instance.name, node=primary)
# fn = lambda: hv_kvm.KVMHypervisor._StopInstance(None, True, instance.name) time.sleep(5)
# _TestInstanceUserDown(instance, master, fn)
# AssertCommand(["gnt-instance", "modify", "-H", "user_shutdown=true",
def _TestInstanceUserDownKvm(_1, _2): instance.name])
pass
# The instance needs to reboot not because the 'user_shutdown'
# parameter was modified but because the KVM daemon need to be
# started, given that the instance was first created with user
# shutdown disabled.
AssertCommand(["gnt-instance", "reboot", instance.name])
primary = _GetInstanceField(instance.name, "pnode")
_TestInstanceUserDown(instance, master, _StopKVMInstance)
def TestInstanceUserDown(instance, master): def TestInstanceUserDown(instance, master):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment