summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2018-08-11 08:53:15 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-08-11 08:53:15 +0000
commit232464bfa350e41472ee659c27d9a4d4fb98585e (patch)
treec4b62692eda72f6105c13543650d0d546f8440c8
parent0aabe8ec3a60040208aff847ffecbcd9a5128a73 (diff)
parent86a239dba6e5c2abced2b1de53e57aba3c04b82c (diff)
Merge "Test OpenStack vGPU feature"
-rw-r--r--docker/features/testcases.yaml12
-rw-r--r--functest/core/singlevm.py15
-rw-r--r--functest/opnfv_tests/openstack/vgpu/__init__.py0
-rw-r--r--functest/opnfv_tests/openstack/vgpu/vgpu.py54
4 files changed, 78 insertions, 3 deletions
diff --git a/docker/features/testcases.yaml b/docker/features/testcases.yaml
index 23cd4d4a0..3912b3d8f 100644
--- a/docker/features/testcases.yaml
+++ b/docker/features/testcases.yaml
@@ -82,3 +82,15 @@ tiers:
args:
suites:
- /src/fds/testing/robot
+ -
+ case_name: vgpu
+ project_name: functest
+ criteria: 100
+ blocking: false
+ description: >-
+ Test suite for the OpenStack vGPU feature
+ dependencies:
+ - DEPLOY_SCENARIO: 'vgpu'
+ run:
+ module: 'functest.opnfv_tests.openstack.vgpu.vgpu'
+ class: 'vGPU'
diff --git a/functest/core/singlevm.py b/functest/core/singlevm.py
index 1de355e0d..f6abb7427 100644
--- a/functest/core/singlevm.py
+++ b/functest/core/singlevm.py
@@ -46,9 +46,11 @@ class VmReady1(tenantnetwork.TenantNetwork1):
flavor_ram = 512
flavor_vcpus = 1
flavor_disk = 1
+ flavor_extra_specs = {}
flavor_alt_ram = 1024
flavor_alt_vcpus = 1
flavor_alt_disk = 1
+ flavor_alt_extra_specs = {}
create_server_timeout = 180
def __init__(self, **kwargs):
@@ -138,8 +140,11 @@ class VmReady1(tenantnetwork.TenantNetwork1):
getattr(config.CONF, '{}_flavor_disk'.format(self.case_name),
self.flavor_disk))
self.__logger.debug("flavor: %s", flavor)
- self.orig_cloud.set_flavor_specs(
- flavor.id, getattr(config.CONF, 'flavor_extra_specs', {}))
+ flavor_extra_specs_updated = self.flavor_extra_specs.copy()
+ flavor_extra_specs_updated.update(
+ getattr(config.CONF,
+ '{}_flavor_extra_specs'.format(self.case_name), {}))
+ self.orig_cloud.set_flavor_specs(flavor.id, flavor_extra_specs_updated)
return flavor
def create_flavor_alt(self, name=None):
@@ -163,8 +168,12 @@ class VmReady1(tenantnetwork.TenantNetwork1):
getattr(config.CONF, '{}_flavor_alt_disk'.format(self.case_name),
self.flavor_alt_disk))
self.__logger.debug("flavor: %s", flavor)
+ flavor_alt_extra_specs_updated = self.flavor_alt_extra_specs.copy()
+ flavor_alt_extra_specs_updated.update(
+ getattr(config.CONF,
+ '{}_flavor_alt_extra_specs'.format(self.case_name), {}))
self.orig_cloud.set_flavor_specs(
- flavor.id, getattr(config.CONF, 'flavor_extra_specs', {}))
+ flavor.id, flavor_alt_extra_specs_updated)
return flavor
def boot_vm(self, name=None, **kwargs):
diff --git a/functest/opnfv_tests/openstack/vgpu/__init__.py b/functest/opnfv_tests/openstack/vgpu/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/functest/opnfv_tests/openstack/vgpu/__init__.py
diff --git a/functest/opnfv_tests/openstack/vgpu/vgpu.py b/functest/opnfv_tests/openstack/vgpu/vgpu.py
new file mode 100644
index 000000000..a900eb203
--- /dev/null
+++ b/functest/opnfv_tests/openstack/vgpu/vgpu.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2018 Kontron and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+
+"""vGPU testcase implementation."""
+
+from __future__ import division
+
+import logging
+
+from functest.core import singlevm
+
+
+class vGPU(singlevm.SingleVm2):
+ """OpenStack vGPU Test Case."""
+
+ __logger = logging.getLogger(__name__)
+
+ filename = ('/home/opnfv/functest/images/'
+ 'ubuntu-16.04-server-cloudimg-amd64-disk1.img')
+ flavor_ram = 4096
+ flavor_vcpus = 2
+ flavor_disk = 40
+ flavor_extra_specs = {'resources:VGPU': '1'}
+ username = 'ubuntu'
+ ssh_connect_loops = 12
+ create_server_timeout = 300
+
+ def __init__(self, **kwargs):
+ """Initialize vGPU testcase object."""
+ if "case_name" not in kwargs:
+ kwargs["case_name"] = "vgpu"
+ super(vGPU, self).__init__(**kwargs)
+
+ def execute(self):
+ """
+ Test if the vGPU exist.
+ """
+ (_, stdout, stderr) = self.ssh.exec_command('lspci')
+ lspci_output = stdout.read()
+ self.__logger.debug("output:\n%s", stdout.read())
+ self.__logger.debug("error:\n%s", stderr.read())
+ if ('VGA compatible controller: Intel' in lspci_output or
+ 'VGA compatible controller: Nvidia' in lspci_output):
+ self.__logger.info("The VM have a vGPU")
+ return 0
+ else:
+ self.__logger.error("The VM haven't any vGPU")
+ return 1