blob: 1935cffe01856ef257102220d989e5989f1ca4be [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.
14import copy
15import time
16
17import pytest
18
19from tcp_tests import settings
20from tcp_tests.helpers import ext
21from tcp_tests import logger
22
23LOG = logger.logger
24
25
26class TestVirtletActions(object):
27 """Test class for testing Virtlet actions"""
28
vrovachev99228d32017-06-08 19:46:10 +040029 def test_virtlet_create_delete_vm(self, underlay, virtlet_deployed,
30 show_step, virtlet_actions):
31 """Test for deploying an mcp environment with virtlet
32
33 Scenario:
34 1. Start VM as a virtlet pod
35 2. Wait active state of VM
36 3. Delete VM and wait to delete pod
37
38 """
39 vm_name = virtlet_actions.run_vm()
40 virtlet_actions.wait_active_state(vm_name)
41 virtlet_actions.delete_vm(vm_name)
Victor Ryzhenkin42cfc312017-06-13 12:51:39 +040042
43 def test_vm_resource_quotas(self, underlay, virtlet_deployed, show_step,
44 virtlet_actions):
45 """Test for deploying a VM with specific quotas
46
47 Scenario:
48 1. Prepare VM's yaml
49 2. Start a VM
50 3. Check that VM resources is equal to provided in yaml
51 4. Destroy VM
52
53 """
54
55 target_cpu = 2 # Cores
56 target_memory = 256 # Size in MB
57 target_memory_kb = target_memory*1024
58 target_yaml = 'virtlet/examples/cirros-vm-exp.yaml'
59 virtlet_actions.adjust_cirros_resources(cpu=target_cpu,
60 memory=target_memory,
61 target_yaml=target_yaml)
62 vm_name = virtlet_actions.run_vm(target_yaml)
63 virtlet_actions.wait_active_state(vm_name)
64 domain_name = virtlet_actions.get_domain_name(vm_name)
65 cpu = virtlet_actions.get_vm_cpu_count(domain_name)
66 mem = virtlet_actions.get_vm_memory_count(domain_name)
67 fail_msg = '{0} is not correct memory unit for VM. Correct is {1}'.\
68 format(mem, target_memory_kb)
69 assert target_memory_kb == mem, fail_msg
70 fail_msg = '{0} is not correct cpu cores count for VM. ' \
71 'Correct is {1}'.format(cpu, target_cpu)
72 assert target_cpu == cpu, fail_msg
73 virtlet_actions.delete_vm(target_yaml)
Victor Ryzhenkin6609aaf2017-06-21 13:09:56 +040074
75 def test_rbd_flexvolume_driver(self, underlay, virtlet_ceph_deployed,
76 show_step, virtlet_actions):
77 """Test for deploying a VM with Ceph RBD volume using flexvolumeDriver
78
79 Scenario:
80 1. Start VM with prepared yaml from run-ceph.sh scripts
81 2. Check that RBD volume is listed in virsh domblklist for VM
82 3. Destroy VM
83
84 """
85 # From:
86 # https://github.com/Mirantis/virtlet/blob/master/tests/e2e/run_ceph.sh
87 target_yaml = "virtlet/tests/e2e/cirros-vm-rbd-volume.yaml"
88 vm_name = virtlet_actions.run_vm(target_yaml)
89 virtlet_actions.wait_active_state(vm_name)
90 domain_name = virtlet_actions.get_domain_name(vm_name)
91 vm_volumes_list = virtlet_actions.list_vm_volumes(domain_name)
92 assert 'rbd' in vm_volumes_list
93 virtlet_actions.delete_vm(target_yaml)