aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
Diffstat (limited to 'functest')
-rw-r--r--functest/api/swagger/creds.yaml55
-rw-r--r--functest/api/swagger/creds_action.yaml97
-rw-r--r--functest/api/swagger/envs.yaml37
-rw-r--r--functest/api/swagger/envs_action.yaml69
-rw-r--r--functest/api/swagger/task.yaml59
-rw-r--r--functest/api/swagger/task_log.yaml56
-rw-r--r--functest/api/swagger/testcase.yaml54
-rw-r--r--functest/api/swagger/testcase_run.yaml77
-rw-r--r--functest/api/swagger/testcases.yaml29
-rw-r--r--functest/api/swagger/testcases_in_tier.yaml41
-rw-r--r--functest/api/swagger/tier.yaml47
-rw-r--r--functest/api/swagger/tiers.yaml29
-rw-r--r--functest/ci/config_aarch64_patch.yaml4
-rw-r--r--functest/ci/config_patch.yaml3
-rw-r--r--functest/ci/run_tests.py35
-rw-r--r--functest/cli/commands/cli_env.py4
-rw-r--r--functest/cli/commands/cli_os.py13
-rw-r--r--functest/energy/energy.py6
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py10
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py1
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py6
-rw-r--r--functest/tests/unit/ci/test_run_tests.py50
-rw-r--r--functest/tests/unit/cli/commands/test_cli_os.py5
-rw-r--r--functest/tests/unit/energy/test_functest_energy.py50
-rw-r--r--functest/tests/unit/test_utils.py14
-rw-r--r--functest/tests/unit/utils/test_openstack_clean.py37
-rw-r--r--functest/tests/unit/utils/test_openstack_snapshot.py2
-rw-r--r--functest/tests/unit/utils/test_openstack_utils.py5
-rw-r--r--functest/utils/config.py49
-rw-r--r--functest/utils/functest_utils.py13
-rw-r--r--functest/utils/functest_vacation.py6
31 files changed, 488 insertions, 475 deletions
diff --git a/functest/api/swagger/creds.yaml b/functest/api/swagger/creds.yaml
index da3b2d90..eec7cb34 100644
--- a/functest/api/swagger/creds.yaml
+++ b/functest/api/swagger/creds.yaml
@@ -1,35 +1,36 @@
+---
Show credentials
This api offers the interface to show credentials.
The credentials dict will be returned.
---
tags:
- - Creds
+ - Creds
definitions:
- Credentials:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Name'
- Name:
- type: dict
+ Credentials:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Name'
+ Name:
+ type: dict
responses:
- 200:
- description: Show credentials
- schema:
- $ref: '#/definitions/Credentials'
- examples:
- "OS_AUTH_URL": "https://192.16.1.222:5000/v3"
- "OS_AUTH_VERSION": "3"
- "OS_CACERT": "/home/opnfv/functest/conf/os_cacert"
- "OS_ENDPOINT_TYPE": "publicURL"
- "OS_IDENTITY_API_VERSION": "3"
- "OS_INTERFACE": "publicURL"
- "OS_NO_CACHE": "1"
- "OS_PASSWORD": "990232e0885da343ac805528522d"
- "OS_PROJECT_DOMAIN_NAME": "Default"
- "OS_PROJECT_NAME": "admin"
- "OS_REGION_NAME": "RegionOne"
- "OS_TENANT_NAME": "admin"
- "OS_USERNAME": "admin"
- "OS_USER_DOMAIN_NAME": "Default"
+ 200:
+ description: Show credentials
+ schema:
+ $ref: '#/definitions/Credentials'
+ examples:
+ "OS_AUTH_URL": "https://192.16.1.222:5000/v3"
+ "OS_AUTH_VERSION": "3"
+ "OS_CACERT": "/home/opnfv/functest/conf/os_cacert"
+ "OS_ENDPOINT_TYPE": "publicURL"
+ "OS_IDENTITY_API_VERSION": "3"
+ "OS_INTERFACE": "publicURL"
+ "OS_NO_CACHE": "1"
+ "OS_PASSWORD": "990232e0885da343ac805528522d"
+ "OS_PROJECT_DOMAIN_NAME": "Default"
+ "OS_PROJECT_NAME": "admin"
+ "OS_REGION_NAME": "RegionOne"
+ "OS_TENANT_NAME": "admin"
+ "OS_USERNAME": "admin"
+ "OS_USER_DOMAIN_NAME": "Default"
diff --git a/functest/api/swagger/creds_action.yaml b/functest/api/swagger/creds_action.yaml
index d67d082d..7e7653bb 100644
--- a/functest/api/swagger/creds_action.yaml
+++ b/functest/api/swagger/creds_action.yaml
@@ -1,57 +1,56 @@
+---
Update openrc
This api offers the interface to Update openstack.creds.
-
-action: update_openrc
---
tags:
- - Creds
+ - Creds
parameters:
- - in: body
- name: body
- description: this is the input json dict
- schema:
- required:
- - action
- - args
- properties:
- action:
- type: string
- description: this is action for creds
- default: update_openrc
- args:
- schema:
- required:
- - openrc
- properties:
- openrc:
- type: string
- description: this is the test case name
- default:
- "OS_AUTH_URL": "http://192.16.1.222:5000/v3"
- "OS_ENDPOINT_TYPE": "publicURL"
- "OS_IDENTITY_API_VERSION": "3"
- "OS_INTERFACE": "publicURL"
- "OS_PASSWORD": "admn"
- "OS_PROJECT_DOMAIN_NAME": "Default"
- "OS_PROJECT_NAME": "admin"
- "OS_REGION_NAME": "RegionOne"
- "OS_TENANT_NAME": "admin"
- "OS_USERNAME": "admin"
- "OS_USER_DOMAIN_NAME": "Default"
+ - in: body
+ name: body
+ description: this is the input json dict
+ schema:
+ required:
+ - action
+ - args
+ properties:
+ action:
+ type: string
+ description: this is action for creds
+ default: update_openrc
+ args:
+ schema:
+ required:
+ - openrc
+ properties:
+ openrc:
+ type: string
+ description: this is the test case name
+ default:
+ "OS_AUTH_URL": "http://192.16.1.222:5000/v3"
+ "OS_ENDPOINT_TYPE": "publicURL"
+ "OS_IDENTITY_API_VERSION": "3"
+ "OS_INTERFACE": "publicURL"
+ "OS_PASSWORD": "admn"
+ "OS_PROJECT_DOMAIN_NAME": "Default"
+ "OS_PROJECT_NAME": "admin"
+ "OS_REGION_NAME": "RegionOne"
+ "OS_TENANT_NAME": "admin"
+ "OS_USERNAME": "admin"
+ "OS_USER_DOMAIN_NAME": "Default"
definitions:
- Credentials:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Name'
- Name:
- type: dict
+ Credentials:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Name'
+ Name:
+ type: dict
responses:
- 200:
- description: Update openrc
- schema:
- $ref: '#/definitions/Credentials'
- examples:
- 'status': 0
- 'result': 'Update openrc successfully'
+ 200:
+ description: Update openrc
+ schema:
+ $ref: '#/definitions/Credentials'
+ examples:
+ 'status': 0
+ 'result': 'Update openrc successfully'
diff --git a/functest/api/swagger/envs.yaml b/functest/api/swagger/envs.yaml
index e723deb3..4ff50c86 100644
--- a/functest/api/swagger/envs.yaml
+++ b/functest/api/swagger/envs.yaml
@@ -1,26 +1,27 @@
+---
Show environment
This api offers the interface to show environment.
The environment dict will be returned.
---
tags:
- - Envs
+ - Envs
definitions:
- Environment:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Name'
- Name:
- type: dict
+ Environment:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Name'
+ Name:
+ type: dict
responses:
- 200:
- description: Show environment
- schema:
- $ref: '#/definitions/Environment'
- examples:
- "DEBUG FLAG": "false"
- "INSTALLER": "compass, 192.168.200.2"
- "POD": "unknown_pod"
- "SCENARIO": "os-nosdn-nofeature-noha"
- "STATUS": "ready"
+ 200:
+ description: Show environment
+ schema:
+ $ref: '#/definitions/Environment'
+ examples:
+ "DEBUG FLAG": "false"
+ "INSTALLER": "compass, 192.168.200.2"
+ "POD": "unknown_pod"
+ "SCENARIO": "os-nosdn-nofeature-noha"
+ "STATUS": "ready"
diff --git a/functest/api/swagger/envs_action.yaml b/functest/api/swagger/envs_action.yaml
index 46faa6de..3ad6c880 100644
--- a/functest/api/swagger/envs_action.yaml
+++ b/functest/api/swagger/envs_action.yaml
@@ -1,43 +1,42 @@
+---
Update hosts info
This api offers the interface to update hosts info.
-
-action: update_hosts
---
tags:
- - Envs
+ - Envs
parameters:
- - in: body
- name: body
- description: this is the input json dict
- schema:
- required:
- - action
- - args
- properties:
- action:
- type: string
- description: this is action for envs
- default: update_hosts
- args:
- type: string
- description: Hosts info to be updated
- default:
- "identity.ac.dz.com": "8.20.11.22"
- "image.ac.dz.com": "8.20.11.22"
+ - in: body
+ name: body
+ description: this is the input json dict
+ schema:
+ required:
+ - action
+ - args
+ properties:
+ action:
+ type: string
+ description: this is action for envs
+ default: update_hosts
+ args:
+ type: string
+ description: Hosts info to be updated
+ default:
+ "identity.ac.dz.com": "8.20.11.22"
+ "image.ac.dz.com": "8.20.11.22"
definitions:
- Environment:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Name'
- Name:
- type: dict
+ Environment:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Name'
+ Name:
+ type: dict
responses:
- 200:
- description: Update hosts info
- schema:
- $ref: '#/definitions/Environment'
- examples:
- 'status': 0
- 'result': 'Update hosts info successfully' \ No newline at end of file
+ 200:
+ description: Update hosts info
+ schema:
+ $ref: '#/definitions/Environment'
+ examples:
+ 'status': 0
+ 'result': 'Update hosts info successfully'
diff --git a/functest/api/swagger/task.yaml b/functest/api/swagger/task.yaml
index abf68a0d..3375b906 100644
--- a/functest/api/swagger/task.yaml
+++ b/functest/api/swagger/task.yaml
@@ -1,38 +1,37 @@
+---
Get the result of the specified task
This api offers the interface to get the result of the specified task.
-
---
tags:
- - Tasks
+ - Tasks
parameters:
- - name: task_id
- description: task id
- in: path
- type: string
- required: true
+ - name: task_id
+ description: task id
+ in: path
+ type: string
+ required: true
definitions:
- Task:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Result'
- Result:
- type: dict
+ Task:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Result'
+ Result:
+ type: dict
responses:
- 200:
- description: Get the result of the specified task
- schema:
- $ref: '#/definitions/Task'
- examples:
- "result": {
- "case_name": "vping_ssh",
- "env_info": {
- "build_tag": null,
- "ci_loop": "weekly",
- "installer": "compass",
- "scenario": "os-nosdn-nofeature-noha" },
- "result": "PASS",
- "task_id": "1a9f3c5d-ce0b-4354-862e-dd08b26fc484"}
- "status": 2
-
+ 200:
+ description: Get the result of the specified task
+ schema:
+ $ref: '#/definitions/Task'
+ examples:
+ "result": {
+ "case_name": "vping_ssh",
+ "env_info": {
+ "build_tag": null,
+ "ci_loop": "weekly",
+ "installer": "compass",
+ "scenario": "os-nosdn-nofeature-noha"},
+ "result": "PASS",
+ "task_id": "1a9f3c5d-ce0b-4354-862e-dd08b26fc484"}
+ "status": 2
diff --git a/functest/api/swagger/task_log.yaml b/functest/api/swagger/task_log.yaml
index adaaaf40..120a8f6f 100644
--- a/functest/api/swagger/task_log.yaml
+++ b/functest/api/swagger/task_log.yaml
@@ -1,35 +1,37 @@
+---
Get the log of the specified task
This api offers the interface to get the log of the specified task.
-
---
tags:
- - Tasks
+ - Tasks
parameters:
- - name: task_id
- description: task id
- in: path
- type: string
- required: true
+ - name: task_id
+ description: task id
+ in: path
+ type: string
+ required: true
definitions:
- Task:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Result'
- Result:
- type: dict
+ Task:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Result'
+ Result:
+ type: dict
responses:
- 200:
- description: Get the log of the specified task
- schema:
- $ref: '#/definitions/Task'
- examples:
- "result": {
- "data": [
- "2017-09-14 06:46:26,106 - functest.ci.run_tests - DEBUG - Sourcing the OpenStack RC file... ",
- "2017-09-14 06:46:26,107 - functest.ci.run_tests - DEBUG - Test args: connection_check ",
- "2017-09-14 06:46:26,107 - functest.ci.run_tests - INFO - Running test case 'connection_check'... ",
- "..."]}
- "status": 2
-
+ 200:
+ description: Get the log of the specified task
+ schema:
+ $ref: '#/definitions/Task'
+ examples:
+ "result": {
+ "data": [
+ "2017-09-14 06:46:26,106 - functest.ci.run_tests - DEBUG ",
+ "- Sourcing the OpenStack RC file... ",
+ "2017-09-14 06:46:26,107 - functest.ci.run_tests - DEBUG ",
+ "- Test args: connection_check ",
+ "2017-09-14 06:46:26,107 - functest.ci.run_tests - INFO ",
+ "- Running test case 'connection_check'... ",
+ "..."]}
+ "status": 2
diff --git a/functest/api/swagger/testcase.yaml b/functest/api/swagger/testcase.yaml
index 70ee1af1..34c13d21 100644
--- a/functest/api/swagger/testcase.yaml
+++ b/functest/api/swagger/testcase.yaml
@@ -1,36 +1,36 @@
+---
Show the info of one testcase
This api offers the interface to show the detailed info of one testcase.
The info of one testcase will be returned.
---
tags:
- - Testcases
+ - Testcases
parameters:
- - name: testcase_name
- description: testcase name
- in: path
- type: string
- required: true
+ - name: testcase_name
+ description: testcase name
+ in: path
+ type: string
+ required: true
definitions:
- Testcases:
- type: object
- properties:
- case_name:
- $ref: '#/definitions/Tests'
- Tests:
- type: dict
+ Testcases:
+ type: object
+ properties:
+ case_name:
+ $ref: '#/definitions/Tests'
+ Tests:
+ type: dict
responses:
- 200:
- description: Show the detailed info of one testcase
- schema:
- $ref: '#/definitions/Testcases'
- examples:
- "testcase": ""
- "blocking":
- "criteria":
- "dependency": {
- "installer": "",
- "scenario": ""
- }
- "description": ""
- "enabled":
+ 200:
+ description: Show the detailed info of one testcase
+ schema:
+ $ref: '#/definitions/Testcases'
+ examples:
+ "testcase": ""
+ "blocking":
+ "criteria":
+ "dependency": {
+ "installer": "",
+ "scenario": ""}
+ "description": ""
+ "enabled":
diff --git a/functest/api/swagger/testcase_run.yaml b/functest/api/swagger/testcase_run.yaml
index d451457d..7b254c86 100644
--- a/functest/api/swagger/testcase_run.yaml
+++ b/functest/api/swagger/testcase_run.yaml
@@ -1,47 +1,46 @@
+---
Run a test case
This api offers the interface to run a test case
-
-action: run_test_case
---
tags:
- - Testcases
+ - Testcases
parameters:
- - in: body
- name: body
- description: this is the input json dict
- schema:
- required:
- - action
- - args
- properties:
- action:
- type: string
- description: this is action for creds
- default: run_test_case
- args:
- schema:
- required:
- - testcase
- properties:
- testcase:
- type: string
- description: this is the test case name
- default:
- vping_ssh
+ - in: body
+ name: body
+ description: this is the input json dict
+ schema:
+ required:
+ - action
+ - args
+ properties:
+ action:
+ type: string
+ description: this is action for creds
+ default: run_test_case
+ args:
+ schema:
+ required:
+ - testcase
+ properties:
+ testcase:
+ type: string
+ description: this is the test case name
+ default:
+ vping_ssh
definitions:
- Testcases:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Tests'
- Tests:
- type: dict
+ Testcases:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Tests'
+ Tests:
+ type: dict
responses:
- 200:
- description: Run a test case
- schema:
- $ref: '#/definitions/Testcases'
- examples:
- 'task_id': '94c8ec94-d873-466f-a205-bf592f31ff5b'
- 'testcase': 'vping_ssh'
+ 200:
+ description: Run a test case
+ schema:
+ $ref: '#/definitions/Testcases'
+ examples:
+ 'task_id': '94c8ec94-d873-466f-a205-bf592f31ff5b'
+ 'testcase': 'vping_ssh'
diff --git a/functest/api/swagger/testcases.yaml b/functest/api/swagger/testcases.yaml
index 56d9d71f..1dea2152 100644
--- a/functest/api/swagger/testcases.yaml
+++ b/functest/api/swagger/testcases.yaml
@@ -1,22 +1,23 @@
+---
List all test cases
This api offers the interface to list all test cases
The testcases list will be returned
---
tags:
- - Testcases
+ - Testcases
definitions:
- Testcases:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Tests'
- Tests:
- type: dict
+ Testcases:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Tests'
+ Tests:
+ type: dict
responses:
- 200:
- description: List all test cases
- schema:
- $ref: '#/definitions/Testcases'
- examples:
- "testcases": []
+ 200:
+ description: List all test cases
+ schema:
+ $ref: '#/definitions/Testcases'
+ examples:
+ "testcases": []
diff --git a/functest/api/swagger/testcases_in_tier.yaml b/functest/api/swagger/testcases_in_tier.yaml
index f6450826..af195ceb 100644
--- a/functest/api/swagger/testcases_in_tier.yaml
+++ b/functest/api/swagger/testcases_in_tier.yaml
@@ -1,29 +1,30 @@
+---
List all testcases within given tier
This api offers the interface to list all testcases within given tier.
All testcases within given tier will be returned.
---
tags:
- - Tiers
+ - Tiers
parameters:
- - name: tier_name
- description: tier name
- in: path
- type: string
- required: true
+ - name: tier_name
+ description: tier name
+ in: path
+ type: string
+ required: true
definitions:
- Testcases:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Tests'
- Tests:
- type: dict
+ Testcases:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Tests'
+ Tests:
+ type: dict
responses:
- 200:
- description: List all testcases within given tier
- schema:
- $ref: '#/definitions/Testcases'
- examples:
- "tier": ""
- "testcases": []
+ 200:
+ description: List all testcases within given tier
+ schema:
+ $ref: '#/definitions/Testcases'
+ examples:
+ "tier": ""
+ "testcases": []
diff --git a/functest/api/swagger/tier.yaml b/functest/api/swagger/tier.yaml
index 8616afb5..250cddf7 100644
--- a/functest/api/swagger/tier.yaml
+++ b/functest/api/swagger/tier.yaml
@@ -1,32 +1,33 @@
+---
Show the info of one tier
This api offers the interface to show the detailed info of one tier.
The info of one tier will be returned.
---
tags:
- - Tiers
+ - Tiers
parameters:
- - name: tier_name
- description: tier name
- in: path
- type: string
- required: true
+ - name: tier_name
+ description: tier name
+ in: path
+ type: string
+ required: true
definitions:
- Tiers:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Name'
- Name:
- type: string
+ Tiers:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Name'
+ Name:
+ type: string
responses:
- 200:
- description: Show the detailed info of one tier
- schema:
- $ref: '#/definitions/Tiers'
- examples:
- "tier": ""
- "ci_loop": ""
- "description": ""
- "order":
- "testcases": []
+ 200:
+ description: Show the detailed info of one tier
+ schema:
+ $ref: '#/definitions/Tiers'
+ examples:
+ "tier": ""
+ "ci_loop": ""
+ "description": ""
+ "order":
+ "testcases": []
diff --git a/functest/api/swagger/tiers.yaml b/functest/api/swagger/tiers.yaml
index 8a71c379..d42b2cd9 100644
--- a/functest/api/swagger/tiers.yaml
+++ b/functest/api/swagger/tiers.yaml
@@ -1,22 +1,23 @@
+---
List all tiers
This api offers the interface to list all tiers.
The tiers list will be returned.
---
tags:
- - Tiers
+ - Tiers
definitions:
- Tiers:
- type: object
- properties:
- creds_name:
- $ref: '#/definitions/Tier'
- Tier:
- type: dict
+ Tiers:
+ type: object
+ properties:
+ creds_name:
+ $ref: '#/definitions/Tier'
+ Tier:
+ type: dict
responses:
- 200:
- description: List all tiers
- schema:
- $ref: '#/definitions/Tiers'
- examples:
- "tiers": ""
+ 200:
+ description: List all tiers
+ schema:
+ $ref: '#/definitions/Tiers'
+ examples:
+ "tiers": ""
diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml
index a3f029a0..a87fe25b 100644
--- a/functest/ci/config_aarch64_patch.yaml
+++ b/functest/ci/config_aarch64_patch.yaml
@@ -12,8 +12,8 @@ os:
snaps:
images:
glance_tests:
- disk_file: /
- home/opnfv/functest/images/cirros-d161201-aarch64-disk.img
+ disk_file:
+ /home/opnfv/functest/images/cirros-d161201-aarch64-disk.img
extra_properties:
hw_firmware_type: 'uefi'
short_id: 'ubuntu16.04'
diff --git a/functest/ci/config_patch.yaml b/functest/ci/config_patch.yaml
index f54c2d7c..b6ba9790 100644
--- a/functest/ci/config_patch.yaml
+++ b/functest/ci/config_patch.yaml
@@ -6,9 +6,6 @@ lxd:
image_file_name: cirros-0.3.5-x86_64-lxc.tar.gz
image_disk_format: raw
- healthcheck:
- disk_image: /home/opnfv/functest/data/cirros-0.3.5-x86_64-lxc.tar.gz
- disk_format: raw
fdio:
general:
flavor_extra_specs: {'hw:mem_page_size':'large'}
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index 67a6f142..b8da3be6 100644
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -20,7 +20,6 @@ import textwrap
import prettytable
import six
-import yaml
import functest.ci.tier_builder as tb
import functest.core.testcase as testcase
@@ -33,13 +32,6 @@ logger = logging.getLogger('functest.ci.run_tests')
CONFIG_FUNCTEST_PATH = pkg_resources.resource_filename(
'functest', 'ci/config_functest.yaml')
-CONFIG_PATCH_PATH = pkg_resources.resource_filename(
- 'functest', 'ci/config_patch.yaml')
-CONFIG_AARCH64_PATCH_PATH = pkg_resources.resource_filename(
- 'functest', 'ci/config_aarch64_patch.yaml')
-# set the architecture to default
-pod_arch = os.getenv("POD_ARCH", None)
-arch_filter = ['aarch64']
class Result(enum.Enum):
@@ -88,31 +80,6 @@ class Runner(object):
pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
@staticmethod
- def update_config_file():
- Runner.patch_file(CONFIG_PATCH_PATH)
-
- if pod_arch and pod_arch in arch_filter:
- Runner.patch_file(CONFIG_AARCH64_PATCH_PATH)
-
- @staticmethod
- def patch_file(patch_file_path):
- logger.debug('Updating file: %s', patch_file_path)
- with open(patch_file_path) as f:
- patch_file = yaml.safe_load(f)
-
- updated = False
- for key in patch_file:
- if key in CONST.__getattribute__('DEPLOY_SCENARIO'):
- new_functest_yaml = dict(ft_utils.merge_dicts(
- ft_utils.get_functest_yaml(), patch_file[key]))
- updated = True
-
- if updated:
- os.remove(CONFIG_FUNCTEST_PATH)
- with open(CONFIG_FUNCTEST_PATH, "w") as f:
- f.write(yaml.dump(new_functest_yaml, default_style='"'))
-
- @staticmethod
def source_rc_file():
rc_file = CONST.__getattribute__('openstack_creds')
if not os.path.isfile(rc_file):
@@ -229,8 +196,6 @@ class Runner(object):
self.run_tier(tier)
def main(self, **kwargs):
- Runner.update_config_file()
-
if 'noclean' in kwargs:
self.clean_flag = not kwargs['noclean']
if 'report' in kwargs:
diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py
index 0e0afe52..c41f8f34 100644
--- a/functest/cli/commands/cli_env.py
+++ b/functest/cli/commands/cli_env.py
@@ -12,6 +12,8 @@ import prettytable
from functest.utils.constants import CONST
+import six
+
class Env(object):
@@ -52,7 +54,7 @@ class CliEnv(Env):
msg = prettytable.PrettyTable(
header_style='upper', padding_width=5,
field_names=['Functest Environment', 'value'])
- for key, value in env_info.iteritems():
+ for key, value in six.iteritems(env_info):
if key is not None:
msg.add_row([key, value])
click.echo(msg.get_string())
diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py
index 71cd78c5..1ec705a5 100644
--- a/functest/cli/commands/cli_os.py
+++ b/functest/cli/commands/cli_os.py
@@ -9,9 +9,10 @@
import os
-from urlparse import urlparse
import click
+import six
+from six.moves.urllib.parse import urlparse
from functest.ci import check_deployment
from functest.utils.constants import CONST
@@ -58,16 +59,18 @@ class OpenStack(object):
def snapshot_create(self):
self.ping_endpoint()
if os.path.isfile(self.snapshot_file):
- answer = raw_input("It seems there is already an OpenStack "
- "snapshot. Do you want to overwrite it with "
- "the current OpenStack status? [y|n]\n")
+ answer = six.moves.input(
+ "It seems there is already an OpenStack "
+ "snapshot. Do you want to overwrite it with "
+ "the current OpenStack status? [y|n]\n")
while True:
if answer.lower() in ["y", "yes"]:
break
elif answer.lower() in ["n", "no"]:
return
else:
- answer = raw_input("Invalid answer. Please type [y|n]\n")
+ answer = six.moves.input(
+ "Invalid answer. Please type [y|n]\n")
click.echo("Generating Openstack snapshot...")
os_snapshot.main()
diff --git a/functest/energy/energy.py b/functest/energy/energy.py
index 119942bb..2835e05c 100644
--- a/functest/energy/energy.py
+++ b/functest/energy/energy.py
@@ -12,10 +12,10 @@
import json
import logging
-import urllib
from functools import wraps
import requests
+from six.moves import urllib
from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
@@ -103,7 +103,7 @@ class EnergyRecorder(object):
assert environment
uri_comp = "/recorders/environment/"
- uri_comp += urllib.quote_plus(environment)
+ uri_comp += urllib.parse.quote_plus(environment)
# Creds
creds_usr = ft_utils.get_functest_config(
@@ -130,7 +130,7 @@ class EnergyRecorder(object):
except Exception as exc: # pylint: disable=broad-except
EnergyRecorder.logger.info(
"Energy recorder API is not available, cause=%s",
- exc.message)
+ str(exc))
api_available = False
# Final config
EnergyRecorder.energy_recorder_api = {
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index a808d036..c16e6d13 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -60,8 +60,12 @@ class RallyBase(testcase.TestCase):
FLAVOR_NAME = CONST.__getattribute__('rally_flavor_name')
FLAVOR_ALT_NAME = CONST.__getattribute__('rally_flavor_alt_name')
FLAVOR_EXTRA_SPECS = None
+ FLAVOR_RAM = 512
+ FLAVOR_RAM_ALT = 1024
if hasattr(CONST, 'flavor_extra_specs'):
FLAVOR_EXTRA_SPECS = CONST.__getattribute__('flavor_extra_specs')
+ FLAVOR_RAM = 1024
+ FLAVOR_RAM_ALT = 2048
RALLY_DIR = pkg_resources.resource_filename(
'functest', 'opnfv_tests/openstack/rally')
@@ -514,7 +518,7 @@ class RallyBase(testcase.TestCase):
LOGGER.debug("Creating flavor '%s'...", self.flavor_name)
flavor_creator = OpenStackFlavor(
self.os_creds, FlavorConfig(
- name=self.flavor_name, ram=512, disk=1, vcpus=1,
+ name=self.flavor_name, ram=self.FLAVOR_RAM, disk=1, vcpus=1,
metadata=self.FLAVOR_EXTRA_SPECS))
if flavor_creator is None or flavor_creator.create() is None:
raise Exception("Failed to create flavor")
@@ -523,8 +527,8 @@ class RallyBase(testcase.TestCase):
LOGGER.debug("Creating flavor '%s'...", self.flavor_alt_name)
flavor_alt_creator = OpenStackFlavor(
self.os_creds, FlavorConfig(
- name=self.flavor_alt_name, ram=1024, disk=1, vcpus=1,
- metadata=self.FLAVOR_EXTRA_SPECS))
+ name=self.flavor_alt_name, ram=self.FLAVOR_RAM_ALT, disk=1,
+ vcpus=1, metadata=self.FLAVOR_EXTRA_SPECS))
if flavor_alt_creator is None or flavor_alt_creator.create() is None:
raise Exception("Failed to create flavor")
self.creators.append(flavor_alt_creator)
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 979e992f..58882b99 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -438,6 +438,7 @@ class TempestResourcesManager(object):
flavor_metadata_alt = None
if 'ovs' in scenario or 'fdio' in scenario:
flavor_metadata_alt = create_flavor.MEM_PAGE_SIZE_LARGE
+ CONST.__setattr__('openstack_flavor_ram', 1024)
flavor_creator_alt = OpenStackFlavor(
self.os_creds, FlavorConfig(
name=CONST.__getattribute__(
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index f3d4d50f..df9774ec 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -156,12 +156,14 @@ class VPingBase(testcase.TestCase):
"Creating flavor with name: '%s'", self.flavor_name)
scenario = CONST.__getattribute__('DEPLOY_SCENARIO')
flavor_metadata = None
+ flavor_ram = 512
if 'ovs' in scenario or 'fdio' in scenario:
flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
+ flavor_ram = 1024
flavor_creator = OpenStackFlavor(
self.os_creds,
- FlavorConfig(name=self.flavor_name, ram=512, disk=1, vcpus=1,
- metadata=flavor_metadata))
+ FlavorConfig(name=self.flavor_name, ram=flavor_ram, disk=1,
+ vcpus=1, metadata=flavor_metadata))
flavor_creator.create()
self.creators.append(flavor_creator)
diff --git a/functest/tests/unit/ci/test_run_tests.py b/functest/tests/unit/ci/test_run_tests.py
index b5af18c9..bc95f8f3 100644
--- a/functest/tests/unit/ci/test_run_tests.py
+++ b/functest/tests/unit/ci/test_run_tests.py
@@ -58,56 +58,6 @@ class RunTestsTesting(unittest.TestCase):
self.run_tests_parser = run_tests.RunTestsParser()
- self.config_file_yaml = {'general': {
- 'openstack': {
- 'image_name': 'test_image_name'}},
- 'results': {
- 'test_db_url': 'url1'}}
- self.config_file_patch_yaml = {'fdio': {'general': {
- 'openstack': {
- 'image_name':
- 'test_image_name_2'}}}}
- self.config_file_aarcg64_patch_yaml = {'os': {'general': {
- 'openstack': {'image_name': 'test_image_name_3'}}}}
-
- @mock.patch('functest.ci.run_tests.Runner.patch_file')
- def test_update_config_file_default(self, mock_patch):
- self.runner.update_config_file()
- mock_patch.assert_called()
-
- def test_patch_file_missing_file(self):
- patch_file_path = "unexisting_file"
- with self.assertRaises(IOError):
- self.runner.patch_file(patch_file_path)
-
- @mock.patch('functest.ci.run_tests.ft_utils.merge_dicts')
- @mock.patch('functest.ci.run_tests.ft_utils.get_functest_yaml')
- def test_patch_file_default(self, *mock_methods):
- CONST.__setattr__('DEPLOY_SCENARIO', 'os-nosdn-nofeature-noha')
- with mock.patch(
- 'six.moves.builtins.open', mock.mock_open()), mock.patch(
- 'functest.ci.run_tests.yaml.safe_load') as yaml1, mock.patch(
- 'functest.ci.run_tests.ft_utils.get_functest_yaml') as yaml2:
- yaml1.return_value = self.config_file_patch_yaml
- yaml2.return_value = self.config_file_yaml
- self.runner.patch_file(yaml1)
- mock_methods[1].assert_not_called()
- mock_methods[0].assert_not_called()
-
- @mock.patch('functest.ci.run_tests.ft_utils.merge_dicts')
- @mock.patch('functest.ci.run_tests.os.remove')
- def test_patch_file_match_scenario(self, *mock_methods):
- CONST.__setattr__('DEPLOY_SCENARIO', 'os-nosdn-fdio-noha')
- with mock.patch(
- 'six.moves.builtins.open', mock.mock_open()), mock.patch(
- 'functest.ci.run_tests.yaml.safe_load') as yaml1, mock.patch(
- 'functest.ci.run_tests.ft_utils.get_functest_yaml') as yaml2:
- yaml1.return_value = self.config_file_patch_yaml
- yaml2.return_value = self.config_file_yaml
- self.runner.patch_file(yaml2)
- mock_methods[1].assert_called()
- mock_methods[0].assert_called()
-
@mock.patch('functest.ci.run_tests.logger.error')
def test_source_rc_file_missing_file(self, mock_logger_error):
with mock.patch('functest.ci.run_tests.os.path.isfile',
diff --git a/functest/tests/unit/cli/commands/test_cli_os.py b/functest/tests/unit/cli/commands/test_cli_os.py
index 806bc931..434370a5 100644
--- a/functest/tests/unit/cli/commands/test_cli_os.py
+++ b/functest/tests/unit/cli/commands/test_cli_os.py
@@ -82,7 +82,7 @@ class CliOpenStackTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_os.click.echo')
def test_snapshot_create_overwrite(self, mock_click_echo, mock_os_path):
- with mock.patch('__builtin__.raw_input', return_value="y") \
+ with mock.patch('six.moves.input', return_value="y") \
as mock_raw_input, \
mock.patch.object(self.cli_os, 'ping_endpoint'), \
mock.patch('functest.cli.commands.cli_os.os_snapshot.main') \
@@ -111,7 +111,8 @@ class CliOpenStackTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_os.click.echo')
def test_snapshot_show_default(self, mock_click_echo, mock_os_path):
- with mock.patch('__builtin__.open', mock.mock_open(read_data='0')) \
+ with mock.patch('six.moves.builtins.open',
+ mock.mock_open(read_data='0')) \
as m:
self.cli_os.snapshot_file = self.snapshot_file
self.cli_os.snapshot_show()
diff --git a/functest/tests/unit/energy/test_functest_energy.py b/functest/tests/unit/energy/test_functest_energy.py
index 99110802..f0711ca0 100644
--- a/functest/tests/unit/energy/test_functest_energy.py
+++ b/functest/tests/unit/energy/test_functest_energy.py
@@ -11,6 +11,7 @@
"""Unitary test for energy module."""
# pylint: disable=unused-argument
import logging
+import requests
import unittest
import mock
@@ -54,6 +55,10 @@ RECORDER_KO = MockHttpResponse(
'{"message": "An unhandled API exception occurred (MOCK)"}',
500
)
+RECORDER_NOT_FOUND = MockHttpResponse(
+ '{"message": "Recorder not found (MOCK)"}',
+ 404
+)
def config_loader_mock(config_key):
@@ -64,8 +69,6 @@ def config_loader_mock(config_key):
return "user"
elif config_key == "energy_recorder.api_password":
return "password"
- else:
- raise Exception("Config not mocked")
def config_loader_mock_no_creds(config_key):
@@ -76,10 +79,9 @@ def config_loader_mock_no_creds(config_key):
return ""
elif config_key == "energy_recorder.api_password":
return ""
- else:
- raise Exception("Config not mocked:" + config_key)
+# pylint: disable=too-many-public-methods
class EnergyRecorderTest(unittest.TestCase):
"""Energy module unitary test suite."""
@@ -116,6 +118,13 @@ class EnergyRecorderTest(unittest.TestCase):
timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
+ @mock.patch('functest.energy.energy.EnergyRecorder.load_config',
+ side_effect=Exception("Internal execution error (MOCK)"))
+ def test_start_exception(self, conf_loader_mock=None):
+ """EnergyRecorder.start test with exception during execution."""
+ start_status = EnergyRecorder.start(CASE_NAME)
+ self.assertFalse(start_status)
+
@mock.patch('functest.energy.energy.requests.post',
return_value=RECORDER_KO)
def test_start_api_error(self, post_mock=None):
@@ -172,6 +181,13 @@ class EnergyRecorderTest(unittest.TestCase):
timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
+ @mock.patch('functest.energy.energy.EnergyRecorder.load_config',
+ side_effect=requests.exceptions.ConnectionError())
+ def test_set_step_connection_error(self, conf_loader_mock=None):
+ """EnergyRecorder.start test with exception during execution."""
+ step_status = EnergyRecorder.set_step(STEP_NAME)
+ self.assertFalse(step_status)
+
@mock.patch('functest.energy.energy.requests.delete',
return_value=RECORDER_OK)
def test_stop(self, delete_mock=None):
@@ -266,7 +282,7 @@ class EnergyRecorderTest(unittest.TestCase):
with self.assertRaises(Exception) as context:
self.__decorated_method_with_ex()
self.assertTrue(
- self.exception_message_to_preserve in context.exception
+ self.exception_message_to_preserve in str(context.exception)
)
self.assertTrue(finish_mock.called)
@@ -339,6 +355,30 @@ class EnergyRecorderTest(unittest.TestCase):
scenario = EnergyRecorder.get_current_scenario()
self.assertTrue(scenario is not None)
+ @mock.patch('functest.energy.energy.requests.get',
+ return_value=RECORDER_NOT_FOUND)
+ def test_current_scenario_not_found(self, get_mock=None):
+ """Test get current scenario not existing."""
+ CONST.__setattr__('NODE_NAME', 'MOCK_POD')
+ self.test_load_config()
+ scenario = EnergyRecorder.get_current_scenario()
+ self.assertTrue(scenario is None)
+
+ @mock.patch('functest.energy.energy.requests.get',
+ return_value=RECORDER_KO)
+ def test_current_scenario_api_error(self, get_mock=None):
+ """Test get current scenario with API error."""
+ CONST.__setattr__('NODE_NAME', 'MOCK_POD')
+ self.test_load_config()
+ scenario = EnergyRecorder.get_current_scenario()
+ self.assertTrue(scenario is None)
+
+ @mock.patch('functest.energy.energy.EnergyRecorder.load_config',
+ side_effect=Exception("Internal execution error (MOCK)"))
+ def test_current_scenario_exception(self, get_mock=None):
+ """Test get current scenario with exception."""
+ scenario = EnergyRecorder.get_current_scenario()
+ self.assertTrue(scenario is None)
if __name__ == "__main__":
logging.disable(logging.CRITICAL)
diff --git a/functest/tests/unit/test_utils.py b/functest/tests/unit/test_utils.py
index e171db02..15904764 100644
--- a/functest/tests/unit/test_utils.py
+++ b/functest/tests/unit/test_utils.py
@@ -8,16 +8,22 @@
import re
-class RegexMatch(str):
+class RegexMatch(object):
+ def __init__(self, msg):
+ self.msg = msg
+
def __eq__(self, other):
- match = re.search(self, other)
+ match = re.search(self.msg, other)
if match:
return True
return False
-class SubstrMatch(str):
+class SubstrMatch(object):
+ def __init__(self, msg):
+ self.msg = msg
+
def __eq__(self, other):
- if self in other:
+ if self.msg in other:
return True
return False
diff --git a/functest/tests/unit/utils/test_openstack_clean.py b/functest/tests/unit/utils/test_openstack_clean.py
index 6ae7faa4..afd9120a 100644
--- a/functest/tests/unit/utils/test_openstack_clean.py
+++ b/functest/tests/unit/utils/test_openstack_clean.py
@@ -73,8 +73,9 @@ class OSCleanTesting(unittest.TestCase):
"-----------------"
"---------")
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.logger.debug')
- def test_remove_instances(self, mock_logger_debug):
+ def test_remove_instances(self, mock_logger_debug, *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_instances', return_value=self.test_list):
openstack_clean.remove_instances(self.client, self.update_list)
@@ -83,16 +84,19 @@ class OSCleanTesting(unittest.TestCase):
"instance and will "
"NOT be deleted.")
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.logger.debug')
- def test_remove_instances_missing_instances(self, mock_logger_debug):
+ def test_remove_instances_missing_instances(self, mock_logger_debug,
+ *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_instances', return_value=[]):
openstack_clean.remove_instances(self.client, self.update_list)
mock_logger_debug.assert_any_call("Removing Nova instances...")
mock_logger_debug.assert_any_call("No instances found.")
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.logger.debug')
- def test_remove_instances_delete_success(self, mock_logger_debug):
+ def test_remove_instances_delete_success(self, mock_logger_debug, *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_instances', return_value=self.test_list), \
mock.patch('functest.utils.openstack_clean.os_utils'
@@ -105,8 +109,10 @@ class OSCleanTesting(unittest.TestCase):
" '\s*\S+'"
" ..."))
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.logger.debug')
- def test_remove_instances_pending_delete_success(self, mock_logger_debug):
+ def test_remove_instances_pending_delete_success(self, mock_logger_debug,
+ *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_instances', return_value=self.deleted_list), \
mock.patch('functest.utils.openstack_clean.os_utils'
@@ -118,8 +124,10 @@ class OSCleanTesting(unittest.TestCase):
" '\s*\S+'"
" ...").assert_not_called()
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.logger.debug')
- def test_remove_instances_other_delete_success(self, mock_logger_debug):
+ def test_remove_instances_other_delete_success(self, mock_logger_debug,
+ *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_instances', return_value=self.other_list), \
mock.patch('functest.utils.openstack_clean.os_utils'
@@ -132,10 +140,11 @@ class OSCleanTesting(unittest.TestCase):
" '\s*\S+'"
" ..."))
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.logger.error')
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_remove_instances_delete_failed(self, mock_logger_debug,
- mock_logger_error):
+ mock_logger_error, *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_instances', return_value=self.test_list), \
mock.patch('functest.utils.openstack_clean.os_utils'
@@ -276,7 +285,7 @@ class OSCleanTesting(unittest.TestCase):
def test_remove_floatingips_delete_success(self, mock_logger_debug):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_floating_ips',
- return_value=self.floatingips_list), \
+ side_effect=[self.floatingips_list, None]), \
mock.patch('functest.utils.openstack_clean.os_utils'
'.delete_floating_ip', return_value=True):
openstack_clean.remove_floatingips(self.client, self.remove_list)
@@ -306,12 +315,13 @@ class OSCleanTesting(unittest.TestCase):
RegexMatch("Removing floating "
"IP \s*\S+ ..."))
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.remove_routers')
@mock.patch('functest.utils.openstack_clean.remove_ports')
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_remove_networks(self, mock_logger_debug,
mock_remove_ports,
- mock_remove_routers):
+ mock_remove_routers, *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_network_list',
return_value=self.test_dict_list), \
@@ -331,12 +341,13 @@ class OSCleanTesting(unittest.TestCase):
self.routers,
self.update_list)
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.remove_routers')
@mock.patch('functest.utils.openstack_clean.remove_ports')
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_remove_networks_missing_networks(self, mock_logger_debug,
mock_remove_ports,
- mock_remove_routers):
+ mock_remove_routers, *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_network_list', return_value=None), \
mock.patch('functest.utils.openstack_clean.os_utils'
@@ -354,12 +365,13 @@ class OSCleanTesting(unittest.TestCase):
self.routers,
self.update_list)
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.remove_routers')
@mock.patch('functest.utils.openstack_clean.remove_ports')
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_remove_networks_delete_success(self, mock_logger_debug,
mock_remove_ports,
- mock_remove_routers):
+ mock_remove_routers, *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_network_list',
@@ -385,6 +397,7 @@ class OSCleanTesting(unittest.TestCase):
self.routers,
self.remove_list)
+ @mock.patch('time.sleep')
@mock.patch('functest.utils.openstack_clean.remove_routers')
@mock.patch('functest.utils.openstack_clean.remove_ports')
@mock.patch('functest.utils.openstack_clean.logger.error')
@@ -392,7 +405,7 @@ class OSCleanTesting(unittest.TestCase):
def test_remove_networks_delete_failed(self, mock_logger_debug,
mock_logger_error,
mock_remove_ports,
- mock_remove_routers):
+ mock_remove_routers, *args):
with mock.patch('functest.utils.openstack_clean.os_utils'
'.get_network_list',
return_value=self.test_dict_list), \
@@ -711,7 +724,7 @@ class OSCleanTesting(unittest.TestCase):
as mock_remove_tenants, \
mock.patch('functest.utils.openstack_clean.yaml.safe_load',
return_value=mock.Mock()), \
- mock.patch('__builtin__.open', mock.mock_open()) as m:
+ mock.patch('six.moves.builtins.open', mock.mock_open()) as m:
openstack_clean.main()
self.assertTrue(mock_remove_instances)
self.assertTrue(mock_remove_images)
diff --git a/functest/tests/unit/utils/test_openstack_snapshot.py b/functest/tests/unit/utils/test_openstack_snapshot.py
index 33e74609..919b28c6 100644
--- a/functest/tests/unit/utils/test_openstack_snapshot.py
+++ b/functest/tests/unit/utils/test_openstack_snapshot.py
@@ -222,7 +222,7 @@ class OSSnapshotTesting(unittest.TestCase):
return_value=self.update_list), \
mock.patch('functest.utils.openstack_snapshot.get_tenants',
return_value=self.update_list), \
- mock.patch('__builtin__.open', mock.mock_open()) as m:
+ mock.patch('six.moves.builtins.open', mock.mock_open()) as m:
openstack_snapshot.main()
mock_logger_info.assert_called_once_with("Generating OpenStack "
"snapshot...")
diff --git a/functest/tests/unit/utils/test_openstack_utils.py b/functest/tests/unit/utils/test_openstack_utils.py
index 307cbe37..01085bb7 100644
--- a/functest/tests/unit/utils/test_openstack_utils.py
+++ b/functest/tests/unit/utils/test_openstack_utils.py
@@ -365,7 +365,8 @@ class OSUtilsTesting(unittest.TestCase):
except:
pass
f = 'rc_file'
- with mock.patch('__builtin__.open', mock.mock_open(read_data=msg),
+ with mock.patch('six.moves.builtins.open',
+ mock.mock_open(read_data=msg),
create=True) as m:
m.return_value.__iter__ = lambda self: iter(self.readline, '')
openstack_utils.source_credentials(f)
@@ -1460,7 +1461,7 @@ class OSUtilsTesting(unittest.TestCase):
return_value=True), \
mock.patch('functest.utils.openstack_utils.get_image_id',
return_value=''), \
- mock.patch('__builtin__.open',
+ mock.patch('six.moves.builtins.open',
mock.mock_open(read_data='1')) as m:
self.assertEqual(openstack_utils.
create_glance_image(self.glance_client,
diff --git a/functest/utils/config.py b/functest/utils/config.py
index 6bb4f58e..f4749a75 100644
--- a/functest/utils/config.py
+++ b/functest/utils/config.py
@@ -1,21 +1,45 @@
#!/usr/bin/env python
+# pylint: disable=missing-docstring
+
+import os
+import pkg_resources
import yaml
import six
-from functest.utils import env
-
class Config(object):
def __init__(self):
try:
- with open(env.ENV.CONFIG_FUNCTEST_YAML) as f:
- self.functest_yaml = yaml.safe_load(f)
- self._parse(None, self.functest_yaml)
+ with open(pkg_resources.resource_filename(
+ 'functest', 'ci/config_functest.yaml')) as yfile:
+ self.functest_yaml = yaml.safe_load(yfile)
except Exception as error:
raise Exception('Parse config failed: {}'.format(str(error)))
+ @staticmethod
+ def _merge_dicts(dict1, dict2):
+ for k in set(dict1.keys()).union(dict2.keys()):
+ if k in dict1 and k in dict2:
+ if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
+ yield (k, dict(Config._merge_dicts(dict1[k], dict2[k])))
+ else:
+ yield (k, dict2[k])
+ elif k in dict1:
+ yield (k, dict1[k])
+ else:
+ yield (k, dict2[k])
+
+ def patch_file(self, patch_file_path):
+ with open(patch_file_path) as yfile:
+ patch_file = yaml.safe_load(yfile)
+
+ for key in patch_file:
+ if key in os.environ.get('DEPLOY_SCENARIO', ""):
+ self.functest_yaml = dict(Config._merge_dicts(
+ self.functest_yaml, patch_file[key]))
+
def _parse(self, attr_now, left_parametes):
for param_n, param_v in six.iteritems(left_parametes):
attr_further = self._get_attr_further(attr_now, param_n)
@@ -24,9 +48,22 @@ class Config(object):
if isinstance(param_v, dict):
self._parse(attr_further, param_v)
- def _get_attr_further(self, attr_now, next):
+ @staticmethod
+ def _get_attr_further(attr_now, next): # pylint: disable=redefined-builtin
return attr_now if next == 'general' else (
'{}_{}'.format(attr_now, next) if attr_now else next)
+ def fill(self):
+ try:
+ self._parse(None, self.functest_yaml)
+ except Exception as error:
+ raise Exception('Parse config failed: {}'.format(str(error)))
+
CONF = Config()
+CONF.patch_file(pkg_resources.resource_filename(
+ 'functest', 'ci/config_patch.yaml'))
+if os.getenv("POD_ARCH", None) and os.getenv("POD_ARCH", None) in ['aarch64']:
+ CONF.patch_file(pkg_resources.resource_filename(
+ 'functest', 'ci/config_aarch64_patch.yaml'))
+CONF.fill()
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index bbb6b631..6c502ebc 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -317,19 +317,6 @@ def get_functest_config(parameter):
return get_parameter_from_yaml(parameter, yaml_)
-def merge_dicts(dict1, dict2):
- for k in set(dict1.keys()).union(dict2.keys()):
- if k in dict1 and k in dict2:
- if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
- yield (k, dict(merge_dicts(dict1[k], dict2[k])))
- else:
- yield (k, dict2[k])
- elif k in dict1:
- yield (k, dict1[k])
- else:
- yield (k, dict2[k])
-
-
def get_functest_yaml():
with open(constants.CONST.__getattribute__('CONFIG_FUNCTEST_YAML')) as f:
functest_yaml = yaml.safe_load(f)
diff --git a/functest/utils/functest_vacation.py b/functest/utils/functest_vacation.py
index c2e40b07..71861ba7 100644
--- a/functest/utils/functest_vacation.py
+++ b/functest/utils/functest_vacation.py
@@ -46,8 +46,8 @@ def main():
finally:
endwin()
- print '\nSnake.PY-26lines by Kris Cieslak (defaultset.blogspot.com).'
- print 'OPNFV adaptation by Functest dream team.'
+ print('\nSnake.PY-26ines by Kris Cieslak (defaultset.blogspot.com).')
+ print('OPNFV adaptation by Functest dream team.')
score = str(len(snake) - len(body) - 1)
print ('Thanks for playing, your score: %s.' % score)
- print 'Find and fix more bugs in your real OPNFV setup!\n'
+ print('Find and fix more bugs in your real OPNFV setup!\n')