Added unit tests for api_check, health_check, and smoke tests.
[functest.git] / functest / opnfv_tests / openstack / snaps / smoke.py
1 # Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
2 #
3 # This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8
9 import os
10 import unittest
11
12 from snaps import test_suite_builder
13
14 from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
15     SnapsTestRunner
16 from functest.utils.constants import CONST
17
18
19 class SnapsSmoke(SnapsTestRunner):
20     """
21     This test executes the Python Tests included with the SNAPS libraries
22     that exercise many of the OpenStack APIs within Keystone, Glance, Neutron,
23     and Nova
24     """
25     def __init__(self, **kwargs):
26         if "case_name" not in kwargs:
27             kwargs["case_name"] = "snaps_smoke"
28         super(SnapsSmoke, self).__init__(**kwargs)
29
30         self.suite = unittest.TestSuite()
31
32     def run(self, **kwargs):
33         """
34         Builds the test suite then calls super.run()
35         :param kwargs: the arguments to pass on
36         :return:
37         """
38         image_config = None
39         if hasattr(CONST, 'snaps_images_cirros'):
40             image_config = CONST.__getattribute__('snaps_images_cirros')
41
42         # Tests requiring floating IPs leverage files contained within the
43         # SNAPS repository and are found relative to that path
44         if self.use_fip:
45             snaps_dir = os.path.join(CONST.__getattribute__('dir_repo_snaps'),
46                                      'snaps')
47             os.chdir(snaps_dir)
48
49         test_suite_builder.add_openstack_integration_tests(
50             suite=self.suite,
51             os_creds=self.os_creds,
52             ext_net_name=self.ext_net_name,
53             use_keystone=self.use_keystone,
54             flavor_metadata=self.flavor_metadata,
55             image_metadata=image_config,
56             use_floating_ips=self.use_fip)
57         return super(self.__class__, self).run()