Commit Graph

38 Commits

Author SHA1 Message Date
Andrey Pavlov f9e75281b4 fix UT for cinderclient
- bump version from 2 to 3 for cinderclient
- update aws ec2 interface for create_colume and
  create_network_interface. add cilent_token param
- fix describe network interface - something was
  changed in neutron ports output
- set metadata port for OVN conf file also

Change-Id: Ie3e5a5930d5a8159050ecc0900239935558dddd7
2021-09-28 19:24:15 +00:00
Sean McGinnis 21c15aa680
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: Iadefcc287b8557723a9bebc816080cf65636686b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 12:15:29 -05:00
chenghuiyu c65cb663de Fix usage of isotime
The commit I34b12b96de3ea21beaf935ed8a9f6bae2fe0d0bc and
Ib384ae8130dcc6cbd47a837d11ca171ce02ef29e introduced the
deprecated oslo_utils.timeutils.isotime() is deprecated
as of 1.6.

The deprecation message says to use the datetime.datetime.isoformat()
instead, but the format of the string generated by isoformat isn't
the same as the format of the string generated by isotime. The string
is used in tokens and other public APIs and we can't change it
without potentially breaking clients.

So the workaround is to copy the current implementation from
oslo_utils.timeutils.isotime() to ec2api.api.ec2utils.

For more informations:
https://docs.openstack.org/oslo.utils/latest/reference/timeutils.html

Change-Id: Id62fb53264b04a7ea6ae3035a129353c5cfa040a
Closes-Bug: #1461251
2018-06-29 16:00:40 +03:00
Andrey Pavlov 38b882d97d synchronize default vpc creation across threads
when two clients come for functions where check_default_vpc
is present then one goes to create default vpc and other fails.
it fails because vpc with is_default flag is already in DB
but children objects (like subnets) are not yet created.
For we will lock check_default_vpc function.

Another way is to rework _create_vpc. It can create VPC
without is_default flag. And at the end it can set the flag.
First thread will pass this. And second thread will fail at flag set
operation and will revert all created object. Then second thread
can check presence of default VPC again.
This way is better cause it can work across several controllers.

Change-Id: I5586fa234257b72721e328a9fa2375a56d1553c2
2018-03-24 00:49:01 +03:00
Andrey Pavlov 6d30c69895 use glanceclient version '2'. fix keystone error message.
current devstack deploys glance version '2' only.
use it.

messages in keystone's exceptions was changed.
fix unit tests that checks it.

Change-Id: I7ed1f0ff518efa374a5e3b693c5785958c77340d
2017-04-19 13:10:40 +03:00
Andrey Pavlov 3a39d4d5f8 switch to using new versions of cinder service
cinder v1 is deprecated now. switching to v2.

Change-Id: I1a9f3de37c8a53ce99277d4c1bd83c9f24f1b9ef
2016-09-13 12:01:57 +03:00
Ronald Bradford f70ab5b46d Graduate to oslo.utils.timeutils
Remove the Oslo Incubator code for timeutils in favor for the
 oslo.utils functionality.

Change-Id: Idb7917b80add6aa0f492e6974b630c3a8ffce71f
Depends-On: Ieff34b88d857727e02a3918908b2719535ff4b55
2016-03-18 14:11:42 -04:00
Jenkins d8b5c89da0 Merge "Replace oslo_utils.timeutils.isotime" 2015-12-17 12:58:58 +00:00
Zhihai Song ed23159ebc Replace oslo_utils.timeutils.isotime
This change introduces ec2api.openstack.common.timeutils that
substitutes the deprecating functions from oslo_utils. Using the
isoformat in the datetime lib will change the time format in API.
So it is better to carry this function in ec2-api. The deprecation
happens in this commit.
https://review.openstack.org/#/c/252898/

Change-Id: Id3606e7ca73ab3e7d58cfe6131984dbf0f3b7e4d
2015-12-17 19:02:59 +08:00
Andrey Pavlov e22e6a1bc0 fix working with cinder API v2
add cinder_service_type to config
and fix code to be compatible with cinderclient v2

Change-Id: Ia7eec95e19c5472d741fc9759ef4f8929ac516f7
2015-12-15 09:23:54 +03:00
Andrey Pavlov b4e26993b0 Update from global requirements and bump master version
Change-Id: I96a00fe31b5b860d2c68b7d3f8a03b42bb94ce03
2015-11-19 14:39:50 +03:00
Jenkins 44dfe5bf67 Merge "Extract DB mock to a separate test mixin class" 2015-09-11 13:16:28 +00:00
Feodor Tersin b1890b3ddd Remove support for usage OS clients with no session
Now this kind of client initialization is not used.

Change-Id: Id1003b8d6d1ea772f350fe750962e56dea02c787
2015-09-11 13:10:39 +03:00
Feodor Tersin 3013a54c90 Extract DB mock to a separate test mixin class
We need to have powerful mock db features outside of ApiTestCase.

Change-Id: I1bf199ee523650c2a05b562949a1027892d1e410
2015-09-11 07:32:09 +03:00
Feodor Tersin 1ad56c01f6 Discover version of given compute service type
An admin may specify nova_service_type which doesn't support v2.1. Or
ec2-api can be run against Nova which doesn't support a required
microversion. ec2-api should check this and put warning to log.

This patch does that. If Nova service doesn't suport the required
microversion, ec2-api uses the last microvertions the service supports.
But do not switch to v2 or v2.1 with no microversions at all. This will
be useful for a future cases, when ec2-api uses new features with their
own microversions.

Change-Id: I1cc828b8cad908d9d029c57d514e4ce7e8f47352
2015-09-03 17:06:01 +03:00
Feodor Tersin 2a69f13f37 Fix mock glanceclient initialization
glanceclient 1.0.0 requires not empty endpoint url part before the
version part.

Change-Id: I14763f840d12b817026c94d9127b0b0351d7f7b1
2015-09-01 11:35:57 +03:00
Feodor Tersin f7fbf1424f Commonize config usage for base test classes
Derive DbTestCase from BaseTestClass to use config fixture as a
preffered way for such things. Initialize full set of config options for
all tests.

This leaded to some reworking of db initialization in DBTestCase.

Change-Id: Ibec8406f141a74c6f42f6c9d502ced0008ae0214
2015-08-19 17:49:50 +03:00
Feodor Tersin 5ee7187465 Use config fixrute in BaseTestCase
This gives all tests ability to set custom config options in all derived
classes with no extra efforts.
Also this patch sets fatal_exception_format_errors to True for
BaseTestCase, which will control parameters passed in an exception for
all derived classes.

Change-Id: I5a4c52a7d18fe406b67dabda9f32759a9190597c
2015-08-19 17:49:50 +03:00
Feodor Tersin 0d95b00cc9 Commonize mock of get_admin_context for api tests
Change-Id: I1f6240aa1bab97f3b3d74cc8c4d76745140b7e41
2015-07-24 13:47:28 +03:00
Feodor Tersin ac293deb33 Move OS related mocks to a separate base test case
We want to mock OpenStack independently from db and other features.

Change-Id: Id83d53730875e2b0aa5fa9c814fc23a0fc452c21
2015-07-24 13:46:05 +03:00
Feodor Tersin 029f0338a5 Move create fake context function to outside of ApiTestCase
This function is useful everywhere in unit tests and should be used
instead of custom initialization.

Change-Id: Ie05f8c66a2e46aef181cbf04f4e9e2365b748c90
2015-07-24 13:40:55 +03:00
Feodor Tersin 75f150c835 Extract sqlite db preparation to a separate base test case
This is needed to make integrated tests to check ec2api behavior in
complex cases.

Change-Id: Ie6c3838dadd6cf1860ba0ae429ca73ecf8e39c42
2015-07-24 13:40:41 +03:00
Feodor Tersin 80655cb362 Fix and rename get_item_ids
1 Rename to get_items_ids
2 Fix a bug of filtering
3 Add a test on it
4 Add a test on ec2utils.os_id_to_ec2_id

Change-Id: I0ae4b0d2cd937ffa810f7cea3d818a72e3fac845
2015-04-13 11:09:35 +03:00
Alexandre Levine e6d37da955 Added repair default group feature.
Added unit-test for nova group with "vpc-..." name

Change-Id: I2007eb532edf4df6d55e27e63c9429e59841b8fe
2015-04-07 17:29:17 +04:00
Andrey Pavlov 1cdaf9fe00 add absent filters
Change-Id: I3e5de1b5bd3a0fe238d78c32b627609e1ef886ae
2015-04-02 12:27:45 +03:00
Feodor Tersin 8282371da4 Get rid of Nova DB access
Important features:
- Nova client with microversion support is required.
- Nova API server may not support microversion 2.3 (not tested).
- Attaching volumes are not displayed in an instance bdm. Because Cinder
volume doesn't yet contain attachment info (which contains a device
name), and Nova instance volumes_attached doesn't contain a device name
(mountpoint). But a bdm must contain it.

Other features:
- v2.3 is requested always
- RunInstance result is formatted w/o extra v2.3 info, so it doesn't
contain rootDeviceName and other such info
- if rootDeviceName property is empty it's omitted instead of
to report fake /dev/sda1 as Nova EC2 does it. This leads to omit
rootDeviceType property in this case as well.
Also the same is done for corresponding image's properties.
- deleteOnTermination volume property is omitted for volume at all, and
for instance bdm if Nova doesn't report it. Previously this volume
property contained 'False' only.
- DescribeVolumes isn't used in DescribeInstances (as opposed to
DescribeNetworkInterfaces), because both methods require actual state
of corresponding OS objects, so we prevent duplication of OS requests.
- Not merged Nova client is used
https://review.openstack.org/#/c/152569/

Also:
- fix multi-run instances for EC2 Classic mode
- safe getting of OS instance security groups
- ec2context module alias is renamed to ec2_context, as it is in other
code
- fakes.CinderVolume is renamed to local standard OSVolume
- fakes.OSInstance it transformed to be initialized from a dictionary,
as it is for other fakes.OSXxx objects
- fix code style

Depends-On: Icf2b9739aaf87b4c9af13ad64a310081a68f776e
Change-Id: Id65ea0f56ffd889286d5ca082e1daf2643205c52
2015-03-20 15:33:05 +03:00
Feodor Tersin 2c1d2dc9fb Rework fake action execute interface
Change-Id: Iedd8ee3d2303bd8e3f6cd511be433ae443259cef
2015-03-06 00:56:19 +03:00
Feodor Tersin a3e52b6402 Restrict fake OS calls exactly to OS clients' interfaces
Change-Id: I0777f1e7b6dc1db0c7abdca11362630007980af9
2015-03-05 16:38:13 +03:00
Feodor Tersin a7fd598800 Don't use mock shortcuts on novaclient object managers
Change-Id: I21e6c2a086f3df50762cd7ac8e6e851c904c7a2d
2015-03-05 09:43:12 +03:00
Feodor Tersin 5032355da3 Use oslo config fixture in unit tests
Change-Id: Ie523623417d8e30d05b4c8b05e9f2ddf74d4f5e3
2015-03-05 09:43:06 +03:00
Feodor Tersin 87ace458a8 Move mock function generators to test tools
Change-Id: I714543e6fe7cafb5db29ec28cc10b00aec48364b
2015-03-05 09:40:36 +03:00
Feodor Tersin 9bf0b9e1b2 Simplify setting of mock db data in unit tests
Change-Id: Ia4b746e7e1ed6b4616b09b5fee697f814bcdcac0
2015-03-05 09:37:53 +03:00
Feodor Tersin 6aa510365c Restrict fake db_api calls to db_api interface exactly
Change-Id: I3d32ddb7e49f12d97fc09eec4c203746c9200778
2015-03-03 20:27:55 +03:00
Andrey Pavlov 67eae1069d follow oslo
move to oslo.db and some other oslo libraries

Change-Id: I57e4f01bd46339cdfe3ed2e4748eb1e923cea584
2015-02-26 22:04:09 +03:00
Feodor Tersin 49c721f8c7 Use timeutils from oslo.utils instead of oslo incubator
Change-Id: I4ad485df22bb3779f855b17b74c012f380f12d8e
2015-02-26 13:38:39 +03:00
Feodor Tersin 1c30d32264 Common exception handling
Change-Id: Ibb2b9623f8d5fa7380c930e1b099028a94932b70
2015-02-21 01:41:12 +03:00
Feodor Tersin 7377e3f7d9 Implement DescribeAccountAttributes action
Change-Id: I2e67e88f5e804fc400109c762ca9b9be1a8f930e
2015-02-11 01:15:11 +03:00
Andrey Pavlov 592cf818c8 move unit tests to subdirectory. part 2.
Change-Id: I9372f140c1499572961195baf15f09623c29e7ed
2015-02-06 22:01:40 +03:00