blob: e5c01a12a77b58bd73b038248c5824e8260d9715 [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
29 #salt_cmd = 'salt -l debug ' # For debug output
30 #salt_call_cmd = 'salt-call -l debug ' # For debug output
31 salt_cmd = 'salt --hard-crash --state-output=mixed --state-verbose=False ' # For cause only output
32 salt_call_cmd = 'salt-call --hard-crash --state-output=mixed --state-verbose=False ' # For cause only output
33 #salt_cmd = 'salt --state-output=terse --state-verbose=False ' # For reduced output
34 #salt_call_cmd = 'salt-call --state-output=terse --state-verbose=False ' # For reduced output
35
36 def test_virtlet_create_delete_vm(self, underlay, virtlet_deployed,
37 show_step, virtlet_actions):
38 """Test for deploying an mcp environment with virtlet
39
40 Scenario:
41 1. Start VM as a virtlet pod
42 2. Wait active state of VM
43 3. Delete VM and wait to delete pod
44
45 """
46 vm_name = virtlet_actions.run_vm()
47 virtlet_actions.wait_active_state(vm_name)
48 virtlet_actions.delete_vm(vm_name)
Victor Ryzhenkin42cfc312017-06-13 12:51:39 +040049
50 def test_vm_resource_quotas(self, underlay, virtlet_deployed, show_step,
51 virtlet_actions):
52 """Test for deploying a VM with specific quotas
53
54 Scenario:
55 1. Prepare VM's yaml
56 2. Start a VM
57 3. Check that VM resources is equal to provided in yaml
58 4. Destroy VM
59
60 """
61
62 target_cpu = 2 # Cores
63 target_memory = 256 # Size in MB
64 target_memory_kb = target_memory*1024
65 target_yaml = 'virtlet/examples/cirros-vm-exp.yaml'
66 virtlet_actions.adjust_cirros_resources(cpu=target_cpu,
67 memory=target_memory,
68 target_yaml=target_yaml)
69 vm_name = virtlet_actions.run_vm(target_yaml)
70 virtlet_actions.wait_active_state(vm_name)
71 domain_name = virtlet_actions.get_domain_name(vm_name)
72 cpu = virtlet_actions.get_vm_cpu_count(domain_name)
73 mem = virtlet_actions.get_vm_memory_count(domain_name)
74 fail_msg = '{0} is not correct memory unit for VM. Correct is {1}'.\
75 format(mem, target_memory_kb)
76 assert target_memory_kb == mem, fail_msg
77 fail_msg = '{0} is not correct cpu cores count for VM. ' \
78 'Correct is {1}'.format(cpu, target_cpu)
79 assert target_cpu == cpu, fail_msg
80 virtlet_actions.delete_vm(target_yaml)
Victor Ryzhenkin6609aaf2017-06-21 13:09:56 +040081
82 def test_rbd_flexvolume_driver(self, underlay, virtlet_ceph_deployed,
83 show_step, virtlet_actions):
84 """Test for deploying a VM with Ceph RBD volume using flexvolumeDriver
85
86 Scenario:
87 1. Start VM with prepared yaml from run-ceph.sh scripts
88 2. Check that RBD volume is listed in virsh domblklist for VM
89 3. Destroy VM
90
91 """
92 # From:
93 # https://github.com/Mirantis/virtlet/blob/master/tests/e2e/run_ceph.sh
94 target_yaml = "virtlet/tests/e2e/cirros-vm-rbd-volume.yaml"
95 vm_name = virtlet_actions.run_vm(target_yaml)
96 virtlet_actions.wait_active_state(vm_name)
97 domain_name = virtlet_actions.get_domain_name(vm_name)
98 vm_volumes_list = virtlet_actions.list_vm_volumes(domain_name)
99 assert 'rbd' in vm_volumes_list
100 virtlet_actions.delete_vm(target_yaml)