aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/tests
diff options
context:
space:
mode:
Diffstat (limited to 'legacy/tests')
-rw-r--r--legacy/tests/__init__.py0
-rw-r--r--legacy/tests/api/__init__.py0
-rw-r--r--legacy/tests/api/test_server.py131
-rw-r--r--legacy/tests/create_zones_test.py118
-rw-r--r--legacy/tests/functional/__init__.py0
-rw-r--r--legacy/tests/functional/yaml_schema_test.py24
-rw-r--r--legacy/tests/helper/perftest.yaml13
-rw-r--r--legacy/tests/helper/suite.yaml14
-rw-r--r--legacy/tests/helper/version.yaml20
-rw-r--r--legacy/tests/spawn_vm_test.py64
10 files changed, 0 insertions, 384 deletions
diff --git a/legacy/tests/__init__.py b/legacy/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/legacy/tests/__init__.py
+++ /dev/null
diff --git a/legacy/tests/api/__init__.py b/legacy/tests/api/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/legacy/tests/api/__init__.py
+++ /dev/null
diff --git a/legacy/tests/api/test_server.py b/legacy/tests/api/test_server.py
deleted file mode 100644
index bf316f5d..00000000
--- a/legacy/tests/api/test_server.py
+++ /dev/null
@@ -1,131 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 ZTE Corporation 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
-##############################################################################
-import json
-import time
-
-import mock
-import pytest
-
-import qtip.api.cmd.server as server
-
-
-def setup_module():
- server.add_routers()
-
-
-@pytest.fixture
-def app():
- return server.app
-
-
-@pytest.fixture
-def app_client(app):
- client = app.test_client()
- return client
-
-
-def side_effect_sleep(sleep_time):
- time.sleep(sleep_time)
-
-
-def side_effect_pass():
- pass
-
-
-class TestClass:
- @pytest.mark.parametrize("body, expected", [
- ({'installer_type': 'fuel',
- 'installer_ip': '10.20.0.2'},
- {'job_id': '',
- 'installer_type': 'fuel',
- 'installer_ip': '10.20.0.2',
- 'pod_name': 'default',
- 'suite_name': 'compute',
- 'max_minutes': 60,
- 'type': 'BM',
- 'testdb_url': None,
- 'node_name': None,
- 'state': 'finished',
- 'state_detail': [{'state': 'finished', 'benchmark': 'dhrystone_bm.yaml'},
- {'state': 'finished', 'benchmark': 'whetstone_bm.yaml'},
- {'state': 'finished', 'benchmark': 'ramspeed_bm.yaml'},
- {'state': 'finished', 'benchmark': 'dpi_bm.yaml'},
- {'state': 'finished', 'benchmark': 'ssl_bm.yaml'}],
- 'result': 0}),
- ({'installer_type': 'fuel',
- 'installer_ip': '10.20.0.2',
- 'pod_name': 'default',
- 'max_minutes': 20,
- 'suite_name': 'compute',
- 'type': 'VM',
- 'benchmark_name': 'dhrystone_vm.yaml',
- 'testdb_url': 'http://testresults.opnfv.org/test/api/v1',
- 'node_name': 'zte-pod2'},
- {'job_id': '',
- 'installer_type': 'fuel',
- 'installer_ip': '10.20.0.2',
- 'pod_name': 'default',
- 'suite_name': 'compute',
- 'max_minutes': 20,
- 'type': 'VM',
- 'testdb_url': 'http://testresults.opnfv.org/test/api/v1',
- 'node_name': 'zte-pod2',
- 'state': 'finished',
- 'state_detail': [{u'state': u'finished', u'benchmark': u'dhrystone_vm.yaml'}],
- 'result': 0})
- ])
- @mock.patch('qtip.utils.args_handler.prepare_and_run_benchmark')
- def test_post_get_delete_job_successful(self, mock_args_handler, app_client, body, expected):
- mock_args_handler.return_value = {'result': 0,
- 'detail': {'host': [(u'10.20.6.14', {'unreachable': 0,
- 'skipped': 13,
- 'ok': 27,
- 'changed': 26,
- 'failures': 0}),
- ('localhost', {'unreachable': 0,
- 'skipped': 0,
- 'ok': 6,
- 'changed': 6,
- 'failures': 0}),
- (u'10.20.6.13', {'unreachable': 0,
- 'skipped': 13,
- 'ok': 27,
- 'changed': 26,
- 'failures': 0})]}}
-
- reply = app_client.post("/api/v1.0/jobs", data=body)
- print(reply.data)
- id = json.loads(reply.data)['job_id']
- expected['job_id'] = id
- post_process = ''
- while post_process != 'finished':
- get_reply = app_client.get("/api/v1.0/jobs/%s" % id)
- reply_data = json.loads(get_reply.data)
- post_process = reply_data['state']
- print(reply_data)
- assert len(filter(lambda x: reply_data[x] == expected[x], expected.keys())) == len(expected)
- delete_reply = app_client.delete("/api/v1.0/jobs/%s" % id)
- assert "successful" in delete_reply.data
-
- @pytest.mark.parametrize("body, expected", [
- ([{'installer_type': 'fuel',
- 'installer_ip': '10.20.0.2'},
- {'installer_type': 'compass',
- 'installer_ip': '192.168.20.50'}],
- ['job_id',
- 'It already has one job running now!'])
- ])
- @mock.patch('qtip.utils.args_handler.prepare_and_run_benchmark',
- side_effect=[side_effect_sleep(0.5), side_effect_pass])
- def test_post_two_jobs_unsuccessful(self, mock_args_hanler, app_client, body, expected):
- reply_1 = app_client.post("/api/v1.0/jobs", data=body[0])
- reply_2 = app_client.post("/api/v1.0/jobs", data=body[1])
- assert expected[0] in json.loads(reply_1.data).keys()
- app_client.delete("/api/v1.0/jobs/%s" % json.loads(reply_1.data)['job_id'])
- assert expected[1] in json.dumps(reply_2.data)
diff --git a/legacy/tests/create_zones_test.py b/legacy/tests/create_zones_test.py
deleted file mode 100644
index 1aa37477..00000000
--- a/legacy/tests/create_zones_test.py
+++ /dev/null
@@ -1,118 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 ZTE Corporation 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
-##############################################################################
-import pytest
-import mock
-from mock import Mock, MagicMock
-import os
-from qtip.utils.create_zones import AvailabilityZone
-
-return_list = []
-
-
-def get_agg_mock(host):
- agg = Mock()
- agg.name = host
- agg.id = host
- return agg
-
-
-class HyperMock(MagicMock):
- def list(self):
- mock_hypervisor = [Mock(service={'host': '10.20.0.4'}), Mock(service={'host': '10.20.0.5'})]
- return mock_hypervisor
-
-
-class AggMock(MagicMock):
- def get_details(self, agg_id):
- print "get_details:{0}".format(agg_id)
- return Mock(hosts=[])
-
- def create(self, host, agg):
- print "create:{0}:{1}".format(host, agg)
- return agg
-
- def list(self):
- return return_list
-
- def delete(self, agg_id):
- print "delete:{0}".format(agg_id)
- pass
-
- def add_host(self, aggregate, host):
- print "add_host:{0}:{1}".format(aggregate, host)
- pass
-
- def remove_host(self, agg_id, host):
- print "remove_host:{0}:{1}".format(agg_id, host)
- pass
-
-
-class NovaMock(MagicMock):
- hypervisors = HyperMock()
- aggregates = AggMock()
-
-
-@pytest.mark.xfail(reason="unstable result")
-class TestClass:
- @pytest.mark.parametrize("test_input, expected", [
- (['compute1', 'compute2'],
- ['create:compute1:compute1',
- 'add_host:compute1:10.20.0.4',
- 'create:compute2:compute2',
- 'add_host:compute2:10.20.0.5']),
- (['compute1'],
- ['create:compute1:compute1',
- 'add_host:compute1:10.20.0.4']),
- ])
- @mock.patch('qtip.utils.create_zones.client', autospec=True)
- @mock.patch('qtip.utils.create_zones.v2', autospec=True)
- @mock.patch('qtip.utils.create_zones.session')
- def test_create_zones_success(self, mock_keystone_session, mock_keystone_v2, mock_nova_client, test_input, expected, capfd):
- nova_obj = NovaMock()
- mock_nova_client.Client.return_value = nova_obj()
- k = mock.patch.dict(os.environ, {'OS_AUTH_URL': 'http://172.10.0.5:5000',
- 'OS_USERNAME': 'admin',
- 'OS_PASSWORD': 'admin',
- 'OS_TENANT_NAME': 'admin'})
- k.start()
- azone = AvailabilityZone()
- azone.create_aggs(test_input)
- k.stop()
- resout, reserr = capfd.readouterr()
- for x in expected:
- assert x in resout
-
- @pytest.mark.parametrize("test_input, expected", [
- ([get_agg_mock('10.20.0.4'), get_agg_mock('10.20.0.5')],
- ['get_details:10.20.0.4',
- 'delete:10.20.0.4',
- 'get_details:10.20.0.5',
- 'delete:10.20.0.5']),
- ([],
- []),
- ])
- @mock.patch('qtip.utils.create_zones.client', autospec=True)
- @mock.patch('qtip.utils.create_zones.v2', autospec=True)
- @mock.patch('qtip.utils.create_zones.session')
- def test_clean_all_aggregates(self, mock_keystone_session, mock_keystone_v2, mock_nova_client, test_input, expected, capfd):
- global return_list
- return_list = test_input
- nova_obj = NovaMock()
- mock_nova_client.Client.return_value = nova_obj()
- k = mock.patch.dict(os.environ, {'OS_AUTH_URL': 'http://172.10.0.5:5000',
- 'OS_USERNAME': 'admin',
- 'OS_PASSWORD': 'admin',
- 'OS_TENANT_NAME': 'admin'})
- k.start()
- azone = AvailabilityZone()
- azone.clean_all_aggregates()
- k.stop()
- resout, reserr = capfd.readouterr()
- for x in expected:
- assert x in resout
diff --git a/legacy/tests/functional/__init__.py b/legacy/tests/functional/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/legacy/tests/functional/__init__.py
+++ /dev/null
diff --git a/legacy/tests/functional/yaml_schema_test.py b/legacy/tests/functional/yaml_schema_test.py
deleted file mode 100644
index 3c7994a5..00000000
--- a/legacy/tests/functional/yaml_schema_test.py
+++ /dev/null
@@ -1,24 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 ZTE Corporation 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
-##############################################################################
-import os
-import os.path
-from pykwalify.core import Core
-
-
-class TestClass:
- def test_schema_success(self):
- for root, dirs, files in os.walk("test_cases"):
- for name in files:
- print root + "/" + name
- if "_bm" in name:
- schema = "tests/schema/test_bm_schema.yaml"
- if "_vm" in name:
- schema = "tests/schema/test_vm_schema.yaml"
- c = Core(source_file=root + "/" + name, schema_files=[schema])
- c.validate(raise_exception=True)
diff --git a/legacy/tests/helper/perftest.yaml b/legacy/tests/helper/perftest.yaml
deleted file mode 100644
index 57948b62..00000000
--- a/legacy/tests/helper/perftest.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 taseer94@gmail.com 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
-##############################################################################
----
-
- tests:
- - command: ['perftest', 'run']
- output: "Run a perftest\n"
diff --git a/legacy/tests/helper/suite.yaml b/legacy/tests/helper/suite.yaml
deleted file mode 100644
index 84bf9239..00000000
--- a/legacy/tests/helper/suite.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 taseer94@gmail.com 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
-##############################################################################
----
-
- tests:
- - command: ['suite', 'run']
- output: "Run a suite\n"
-
diff --git a/legacy/tests/helper/version.yaml b/legacy/tests/helper/version.yaml
deleted file mode 100644
index 59be4256..00000000
--- a/legacy/tests/helper/version.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 taseer94@gmail.com 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
-##############################################################################
----
-
- tests:
- - command: ['version', 'list']
- output: "Lists all the different versions\n"
-
- - command: ['version', 'install', 'Colorado']
- output: "Install: Colorado\n"
-
- - command: ['version', 'uninstall', 'Arno']
- output: "Uninstall: Arno\n"
-
diff --git a/legacy/tests/spawn_vm_test.py b/legacy/tests/spawn_vm_test.py
deleted file mode 100644
index ac58db27..00000000
--- a/legacy/tests/spawn_vm_test.py
+++ /dev/null
@@ -1,64 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 ZTE Corporation 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
-##############################################################################
-import pytest
-import mock
-from mock import Mock, MagicMock
-import os
-from qtip.utils.spawn_vm import SpawnVM
-
-
-class KeystoneMock(MagicMock):
- auth_token = Mock()
- v2_0 = Mock()
-
-
-class StackMock(MagicMock):
- status = 'COMPLETE'
- outputs = [{'output_key': 'availability_instance_1',
- 'output_value': 'output_value_1'},
- {'output_key': 'instance_ip_1',
- "output_value": "172.10.0.154"},
- {"output_key": "instance_PIP_1",
- "output_value": "10.10.17.5"}]
-
-
-class HeatMock(MagicMock):
- def list(self):
- return []
-
- def get(self, stackname):
- return StackMock()
-
- def create(self, stack_name, template):
- pass
-
-
-class TestClass:
- @pytest.mark.parametrize("test_input, expected", [
- ({'availability_zone': ['compute1', 'compute1'],
- 'OS_image': ['QTIP_CentOS', 'QTIP_CentOS'],
- 'public_network': ['admin-floating_net', 'admin-floating_net'],
- 'flavor': ['m1.large', 'm1.large'],
- 'role': ['1-server', '2-host']},
- [('172.10.0.154', '')]),
- ])
- @mock.patch('qtip.utils.spawn_vm.Env_setup')
- @mock.patch('qtip.utils.spawn_vm.AvailabilityZone')
- @mock.patch('qtip.utils.spawn_vm.keystoneclient.v2_0', autospec=True)
- @mock.patch('qtip.utils.spawn_vm.heatclient.client', autospec=True)
- def test_create_zones_success(self, mock_heat, mock_keystone,
- mock_zone, mock_setup, test_input, expected):
- open('./config/QtipKey.pub', 'a').close()
- mock_heat.Client.return_value = Mock(stacks=HeatMock())
- k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel'})
- k.start()
- SpawnVM(test_input)
- k.stop()
- os.remove('./config/QtipKey.pub')
- mock_setup.ip_pw_list.append.assert_called_with(expected[0])