vrovachev | 99228d3 | 2017-06-08 19:46:10 +0400 | [diff] [blame] | 1 | # 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. |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 14 | import pytest |
vrovachev | 99228d3 | 2017-06-08 19:46:10 +0400 | [diff] [blame] | 15 | |
vrovachev | 99228d3 | 2017-06-08 19:46:10 +0400 | [diff] [blame] | 16 | from tcp_tests import logger |
| 17 | |
| 18 | LOG = logger.logger |
| 19 | |
| 20 | |
| 21 | class TestVirtletActions(object): |
| 22 | """Test class for testing Virtlet actions""" |
| 23 | |
Victor Ryzhenkin | 1bdb4aa | 2018-01-12 17:36:56 +0400 | [diff] [blame] | 24 | @pytest.mark.grab_versions |
| 25 | @pytest.mark.fail_snapshot |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 26 | def test_virtlet_create_delete_vm(self, show_step, config, k8s_deployed): |
vrovachev | 99228d3 | 2017-06-08 19:46:10 +0400 | [diff] [blame] | 27 | """Test for deploying an mcp environment with virtlet |
| 28 | |
| 29 | Scenario: |
| 30 | 1. Start VM as a virtlet pod |
| 31 | 2. Wait active state of VM |
| 32 | 3. Delete VM and wait to delete pod |
| 33 | |
| 34 | """ |
Victor Ryzhenkin | 42cfc31 | 2017-06-13 12:51:39 +0400 | [diff] [blame] | 35 | |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 36 | if not config.k8s_deploy.kubernetes_virtlet_enabled: |
| 37 | pytest.skip("Test requires Virtlet addon enabled") |
| 38 | |
| 39 | k8s_deployed.git_clone('https://github.com/Mirantis/virtlet', |
| 40 | '~/virtlet') |
| 41 | k8s_deployed.install_jq() |
| 42 | show_step(1) |
| 43 | vm_name = k8s_deployed.run_vm() |
| 44 | show_step(2) |
Victor Ryzhenkin | 26b5aaa | 2018-01-16 17:58:58 +0400 | [diff] [blame] | 45 | k8s_deployed.wait_active_state(vm_name, timeout=360) |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 46 | show_step(3) |
| 47 | k8s_deployed.delete_vm(vm_name) |
| 48 | |
Victor Ryzhenkin | 1bdb4aa | 2018-01-12 17:36:56 +0400 | [diff] [blame] | 49 | @pytest.mark.grab_versions |
| 50 | @pytest.mark.fail_snapshot |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 51 | def test_vm_resource_quotas(self, show_step, config, k8s_deployed): |
Victor Ryzhenkin | 42cfc31 | 2017-06-13 12:51:39 +0400 | [diff] [blame] | 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 | |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 62 | if not config.k8s_deploy.kubernetes_virtlet_enabled: |
| 63 | pytest.skip("Test requires Virtlet addon enabled") |
| 64 | |
| 65 | k8s_deployed.git_clone('https://github.com/Mirantis/virtlet', |
| 66 | '~/virtlet') |
| 67 | k8s_deployed.install_jq() |
| 68 | show_step(1) |
Victor Ryzhenkin | 42cfc31 | 2017-06-13 12:51:39 +0400 | [diff] [blame] | 69 | target_cpu = 2 # Cores |
| 70 | target_memory = 256 # Size in MB |
Dina Belova | e6fdffb | 2017-09-19 13:58:34 -0700 | [diff] [blame] | 71 | target_memory_kb = target_memory * 1024 |
Victor Ryzhenkin | 42cfc31 | 2017-06-13 12:51:39 +0400 | [diff] [blame] | 72 | target_yaml = 'virtlet/examples/cirros-vm-exp.yaml' |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 73 | k8s_deployed.adjust_cirros_resources(cpu=target_cpu, |
Dennis Dmitriev | 9b02c8b | 2017-11-13 15:31:35 +0200 | [diff] [blame] | 74 | memory=target_memory, |
| 75 | target_yaml=target_yaml) |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 76 | show_step(2) |
| 77 | vm_name = k8s_deployed.run_vm(target_yaml) |
Victor Ryzhenkin | 26b5aaa | 2018-01-16 17:58:58 +0400 | [diff] [blame] | 78 | k8s_deployed.wait_active_state(vm_name, timeout=360) |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 79 | show_step(3) |
| 80 | domain_name = k8s_deployed.get_domain_name(vm_name) |
| 81 | cpu = k8s_deployed.get_vm_cpu_count(domain_name) |
| 82 | mem = k8s_deployed.get_vm_memory_count(domain_name) |
Victor Ryzhenkin | 42cfc31 | 2017-06-13 12:51:39 +0400 | [diff] [blame] | 83 | fail_msg = '{0} is not correct memory unit for VM. Correct is {1}'.\ |
| 84 | format(mem, target_memory_kb) |
| 85 | assert target_memory_kb == mem, fail_msg |
| 86 | fail_msg = '{0} is not correct cpu cores count for VM. ' \ |
| 87 | 'Correct is {1}'.format(cpu, target_cpu) |
| 88 | assert target_cpu == cpu, fail_msg |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 89 | show_step(4) |
| 90 | k8s_deployed.delete_vm(target_yaml) |
Victor Ryzhenkin | 6609aaf | 2017-06-21 13:09:56 +0400 | [diff] [blame] | 91 | |
Victor Ryzhenkin | 8ff3c3f | 2018-01-17 19:37:05 +0400 | [diff] [blame] | 92 | @pytest.mark.grab_versions |
Victor Ryzhenkin | cf26c93 | 2018-03-29 20:08:21 +0400 | [diff] [blame^] | 93 | @pytest.mark.grab_k8s_results(name=['virtlet_conformance.log', |
| 94 | 'report.xml']) |
Victor Ryzhenkin | 8ff3c3f | 2018-01-17 19:37:05 +0400 | [diff] [blame] | 95 | @pytest.mark.fail_snapshot |
Victor Ryzhenkin | 62123da | 2018-01-25 18:24:34 +0400 | [diff] [blame] | 96 | def test_virtlet_conformance(self, show_step, config, k8s_deployed, |
Victor Ryzhenkin | cf26c93 | 2018-03-29 20:08:21 +0400 | [diff] [blame^] | 97 | k8s_logs): |
Victor Ryzhenkin | 8ff3c3f | 2018-01-17 19:37:05 +0400 | [diff] [blame] | 98 | """Test run of virtlet conformance tests |
| 99 | |
| 100 | Scenario: |
| 101 | 1. Perform virtlet conformance |
| 102 | |
| 103 | """ |
| 104 | |
| 105 | show_step(1) |
| 106 | k8s_deployed.run_virtlet_conformance() |
| 107 | |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 108 | @pytest.mark.skip(reason="No configuration with ceph and k8s") |
| 109 | def test_rbd_flexvolume_driver(self, show_step, config, k8s_deployed): |
Victor Ryzhenkin | 6609aaf | 2017-06-21 13:09:56 +0400 | [diff] [blame] | 110 | """Test for deploying a VM with Ceph RBD volume using flexvolumeDriver |
| 111 | |
| 112 | Scenario: |
| 113 | 1. Start VM with prepared yaml from run-ceph.sh scripts |
| 114 | 2. Check that RBD volume is listed in virsh domblklist for VM |
| 115 | 3. Destroy VM |
| 116 | |
| 117 | """ |
| 118 | # From: |
| 119 | # https://github.com/Mirantis/virtlet/blob/master/tests/e2e/run_ceph.sh |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 120 | if not config.k8s_deploy.kubernetes_virtlet_enabled: |
| 121 | pytest.skip("Test requires Virtlet addon enabled") |
| 122 | |
| 123 | k8s_deployed.git_clone('https://github.com/Mirantis/virtlet', |
| 124 | '~/virtlet') |
| 125 | k8s_deployed.install_jq() |
| 126 | |
Victor Ryzhenkin | 6609aaf | 2017-06-21 13:09:56 +0400 | [diff] [blame] | 127 | target_yaml = "virtlet/tests/e2e/cirros-vm-rbd-volume.yaml" |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 128 | vm_name = k8s_deployed.run_vm(target_yaml) |
| 129 | k8s_deployed.wait_active_state(vm_name) |
| 130 | domain_name = k8s_deployed.get_domain_name(vm_name) |
| 131 | vm_volumes_list = k8s_deployed.list_vm_volumes(domain_name) |
Victor Ryzhenkin | 6609aaf | 2017-06-21 13:09:56 +0400 | [diff] [blame] | 132 | assert 'rbd' in vm_volumes_list |
Victor Ryzhenkin | 3ffa2b4 | 2017-10-05 16:38:44 +0400 | [diff] [blame] | 133 | k8s_deployed.delete_vm(target_yaml) |