blob: 5c8c9ea3c731b52be5790c52862643c8d964176e [file] [log] [blame]
vrovachev99228d32017-06-08 19:46:10 +04001# Copyright 2017 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# 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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
vrovachev99228d32017-06-08 19:46:10 +040014
vrovachev99228d32017-06-08 19:46:10 +040015from tcp_tests import logger
16
17LOG = logger.logger
18
19
20class TestVirtletActions(object):
21 """Test class for testing Virtlet actions"""
22
vrovachev99228d32017-06-08 19:46:10 +040023 def test_virtlet_create_delete_vm(self, underlay, virtlet_deployed,
Dina Belovae6fdffb2017-09-19 13:58:34 -070024 show_step, virtlet_actions):
vrovachev99228d32017-06-08 19:46:10 +040025 """Test for deploying an mcp environment with virtlet
26
27 Scenario:
28 1. Start VM as a virtlet pod
29 2. Wait active state of VM
30 3. Delete VM and wait to delete pod
31
32 """
33 vm_name = virtlet_actions.run_vm()
34 virtlet_actions.wait_active_state(vm_name)
35 virtlet_actions.delete_vm(vm_name)
Victor Ryzhenkin42cfc312017-06-13 12:51:39 +040036
37 def test_vm_resource_quotas(self, underlay, virtlet_deployed, show_step,
38 virtlet_actions):
39 """Test for deploying a VM with specific quotas
40
41 Scenario:
42 1. Prepare VM's yaml
43 2. Start a VM
44 3. Check that VM resources is equal to provided in yaml
45 4. Destroy VM
46
47 """
48
49 target_cpu = 2 # Cores
50 target_memory = 256 # Size in MB
Dina Belovae6fdffb2017-09-19 13:58:34 -070051 target_memory_kb = target_memory * 1024
Victor Ryzhenkin42cfc312017-06-13 12:51:39 +040052 target_yaml = 'virtlet/examples/cirros-vm-exp.yaml'
53 virtlet_actions.adjust_cirros_resources(cpu=target_cpu,
54 memory=target_memory,
55 target_yaml=target_yaml)
56 vm_name = virtlet_actions.run_vm(target_yaml)
57 virtlet_actions.wait_active_state(vm_name)
58 domain_name = virtlet_actions.get_domain_name(vm_name)
59 cpu = virtlet_actions.get_vm_cpu_count(domain_name)
60 mem = virtlet_actions.get_vm_memory_count(domain_name)
61 fail_msg = '{0} is not correct memory unit for VM. Correct is {1}'.\
62 format(mem, target_memory_kb)
63 assert target_memory_kb == mem, fail_msg
64 fail_msg = '{0} is not correct cpu cores count for VM. ' \
65 'Correct is {1}'.format(cpu, target_cpu)
66 assert target_cpu == cpu, fail_msg
67 virtlet_actions.delete_vm(target_yaml)
Victor Ryzhenkin6609aaf2017-06-21 13:09:56 +040068
69 def test_rbd_flexvolume_driver(self, underlay, virtlet_ceph_deployed,
70 show_step, virtlet_actions):
71 """Test for deploying a VM with Ceph RBD volume using flexvolumeDriver
72
73 Scenario:
74 1. Start VM with prepared yaml from run-ceph.sh scripts
75 2. Check that RBD volume is listed in virsh domblklist for VM
76 3. Destroy VM
77
78 """
79 # From:
80 # https://github.com/Mirantis/virtlet/blob/master/tests/e2e/run_ceph.sh
81 target_yaml = "virtlet/tests/e2e/cirros-vm-rbd-volume.yaml"
82 vm_name = virtlet_actions.run_vm(target_yaml)
83 virtlet_actions.wait_active_state(vm_name)
84 domain_name = virtlet_actions.get_domain_name(vm_name)
85 vm_volumes_list = virtlet_actions.list_vm_volumes(domain_name)
86 assert 'rbd' in vm_volumes_list
87 virtlet_actions.delete_vm(target_yaml)