50 Commits

Author SHA1 Message Date
KeithMnemonic
f5384ae16a Fix openstack server list --deleted --marker option
This patch removes using the "name" option for a marker when
--deleted is also used. The find_resource() function
that is being called does not correctly handle using the marker
as the "name" in the search when also using deleted=True.
One simple way to fix this is force the marker to only be an ID
when --deleted is used. This is how the nova client works.

Using the --deleted option is available to users with the admin
role by default. If you're an admin listing --deleted servers
with a marker by name, find_resource() is going to fail to find
it since it doesn't apply the --deleted filter to find_resource().

The find_resource() function is trying to find the marker server
by name if it's not found by id, and to find it by name it's
listing servers with the given marker as the name, but not
applying the --deleted filter so it doesn't get back any results.

In the story it was suggested modifying find_resource to include
the deleted query param when it's specified on the command line but
that didn't work because it still results in something like this:

http://192.168.1.123/compute/v2.1/servers?deleted=True&name=4cecd49f-bc25-4a7e-826e-4aea6f9267d9

It seems like there are bugs in find_resource().

Restricting the marker to be the server ID when listing deleted servers
is probably OK since if you're using --deleted you're an admin and you could
be listing across all projects and if you're filtering by a server across all
projects anyway (not that you have to, I'm just saying if you are), or even
showing a server in another project, you have to do it by id rather than name
because find_resource() won't find the server in another project by name, only ID.

story: 2006761
Task: 37258

Change-Id: Ib878982b1d469212ca3483dcfaf407a8e1d2b417
2020-01-02 20:05:56 +00:00
Eric Fried
3b409e4d0e Refactor AggregateTests
While investigating the referenced story/bug I noticed that
wait_for_status in
openstackclient.tests.functional.compute.v2.test_aggregate.AggregateTests
was doing a lot more than it should ever need to (it probably got copied
in from somewhere). The two places calling it only need to a) check the
output of `openstack aggregate show`, and b) try once -- since they just
got done creating the aggregate synchronously, there should never be a
need to delay/retry. So this commit removes the helper method and just
inlines the check.

At the same time, the addCleanup(aggregate delete) directives are moved
above their respective creates. This is a defensive best practice which
makes sure cleanup happens even if something fails very soon after the
actual back-end create (as was in fact the case with the referenced
bug/story).

It is unknown whether this will impact the referenced bug.

Change-Id: I0d7432f13642fbccd5ca79da9c76adfcbabb5fa9
Story: 2006811
Related-Bug: #1851391
2019-11-05 21:32:15 +00:00
Eric Fried
f1d742f32a Fix functional tests for py3
Fix various things so the functional tests will work under python3:

- A hashlib.md5() can only be update()d with an encoded string in py3.
- There's no dict.iteritems(), change to dict.items() (which is already
  an iterator).
- Open temp files with 'w+' mode rather than the default 'w+b' (as an
  alternative to encoding all the write and expected-read payloads as
  bytes).
- (This is a weird one) Explicitly raise SkipTest from unittest (rather
  than unittest2, which is where cls.skipException landed). Not sure why
  this is busted, but this moves the ball.

Change-Id: Ic9b2b47848a600e87a3674289ae7ae8c3e091fee
2019-10-31 00:17:35 +00:00
Dean Troyer
de8ab5e8fd More aggregate functional race chasing
AggregateTests.wait_for_status() was a classmethod, those often
are sources of conflict in parallel testing...

Change-Id: I6211fd9c36926ca97de51a11923933d4d9d2dfda
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-09-10 14:09:29 -05:00
Dean Troyer
03a2accb2f Format aggregate command fields and de-race functional tests
Rename metadata to property in all aggregate commands

Beef up functional tests to reduce street racing

Change-Id: I4598da73b85a954f3e6a3981db21891b45d9548c
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-26 17:50:06 -05:00
Matt Riedemann
b9d6310556 Add openstack server create --boot-from-volume option
This adds a --boot-from-volume option to the server create
command which is used with the --image or --image-property
option and will create a volume-backed server from the
specified image with the specified size. Similar to the
--volume option, the created root volume will not be deleted
when the server is deleted. The --boot-from-volume option
is not allowed with the --volume option since they both create
a block device mapping with boot_index=0.

Change-Id: I88c590361cb232c1df7b5bb010dcea307080d34c
Story: 2006302
Task: 36017
2019-08-09 16:44:46 +00:00
Matt Riedemann
6a199bd141 Support type=image with --block-device-mapping option
The --block-device-mapping option on the server create
command currently only supports booting from volume and
volume snapshot. A common boot-from-volume scenario is
providing an image and letting nova orchestrate the
creation of the image-backed volume and attaching it to
the server.

This adds support for type=image in the --block-device-mapping
option. The volume size is required in this case. Note that
the CLI currently says if type=snapshot that size is also required
but that's technically not true. When booting from a volume
snapshot, the compute API will use the size of the volume snapshot
to create the volume if an explicit size is not provided. For the
purposes of this patch, we need the size anyway for the image
being the block device mapping source type.

Change-Id: I57b3c261d8309f7b9f62a3e91612bce592a887a3
Story: 2006302
Task: 36016
2019-08-09 16:36:17 +00:00
Zuul
82823f89f0 Merge "Rename review.openstack.org to review.opendev.org" 2019-06-14 02:25:02 +00:00
zhangbailin
ef1fd38815 Add changes-before attribute to server list
Closes-Bug: #1827844
Part of bp support-to-query-nova-resources-filter-by-changes-before

Change-Id: I4f28168188973730247bcbcb70ba0e70eb81e3be
2019-05-31 05:39:29 +00:00
Dean Troyer
99c3be93c8 Serialize more aggregate functional tests
These tests are showing signs of problems running in parallel
so serialse the create/delete/list/set/unset tests.  They all
used two aggregates each anyway...

Change-Id: Iba4b52c179e6914eaeefea1da0f7eaefcdcf1f87
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-05-17 19:15:28 -05:00
Dean Troyer
bb659cf438 Aggregate functional test tweak
This seems to still be racy, lengthen the timeout to wait for
agregate creation.

Change-Id: I3601c5baee03745ae21714b9dff0e278ad016877
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-05-16 07:43:55 -05:00
melissaml
aabc67f3a2 Rename review.openstack.org to review.opendev.org
There are many references to review.openstack.org, and while the
redirect should work, we can also go ahead and fix them.

Change-Id: I82e3797dd4c05e4944f40c950b4fafe9a5334cbf
2019-05-12 04:41:27 +08:00
Glenn Van de Water
7741347041 Fix service discovery in functional tests
If a required service is not enabled then we skip the test.
The discovery is done by tests/functional/base.py:is_service_enabled
but this method is broken, credentials are not passed to the
'openstack service show' command so every call will fail and every test
that relies on it will be skipped. This commit fixed that method and
the issues that popped up when re-enabling tests.

Network segment range:
 - issue where we assumed network-segment-range extension is always
   present
 - issue where we compare integers and string representations of numbers

Subnet:
 - issue where we try to deepcopy an uncopyable object in UnsetSubnet

Change-Id: Id3cc907c1ed2a25b49cf6f4a7233e0401a02383a
Story: 2005169
Task: 29908
2019-03-13 16:16:24 +01:00
liuyamin
5bec3b7e3b Replace assertEqual(True/False, expr) with assertTrue/assertFalse
In some cases, If the result of expr is a boolen value, we shoud
use assertTrue/assertFalse to instead. Because it is clear and simple.

Change-Id: I53b345fc3915a7b0e737e9dd4d58fe09c746d61c
2018-11-14 14:50:05 +08:00
Zuul
0fa3c84b4f Merge "Default --nic to 'auto' if creating a server with >= 2.37" 2018-10-26 03:20:17 +00:00
Dean Troyer
26c268a910 Slow down and retry aggregate create/delete to lessen race
Change-Id: I676894c1bfd3156313d88e6457250b9ff226118b
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2018-07-06 13:15:59 -05:00
Dean Troyer
83a9db280d Retry floating IP tests
test_server_attach_detach_floating_ip() has a test for server
add/remove floating IP that seems to be racy, add a retry loop
to let neutron and nova do their thing before calling it bad.

Change-Id: I999a0d7dae1706d746053bafb7ab4e3b791d0042
2018-07-06 10:24:16 +00:00
Matt Riedemann
1008544882 Default --nic to 'auto' if creating a server with >= 2.37
Compute API version >= 2.37 requires a 'networks' value in
the server create request. The novaclient CLI defaults this
to 'auto' if not specified, but the novaclient ServerManager.create
python API binding code does not, as it wants clients to be explicit.

For the purposes of the OSC CLI, we should follow suit and if the
user is requesting OS_COMPUTE_API_VERSION>=2.37 without specific
nics, we should just default to 'auto'.

Change-Id: Ib760c55e31209223338a4086ff1f4fee88dc6959
Closes-Bug: #1750395
2018-03-21 01:44:29 +00:00
Jose Castro Leon
fd23ebfbf3 Add missing parameters on openstack server rescue
Change-Id: I27afca9e826378dbcb7feb7528e0c65c528b04b0
Closes-Bug: #1703278
2017-10-27 14:52:04 +00:00
Dean Troyer
949e0cb3c6 Attempt to work around chronically failing server issues with aggregates and qos
So yeah, this is not kosher for functional tests, but we're testing the
client interaction, not the raciness of Nova or Neutron.  Failure to delete
is not our problem.

Change-Id: I21043f1de0fbacee1aec63110fb12a7cff42e0a0
2017-09-15 12:34:15 -05:00
Akihiro Motoki
ff85c62707 flake8-import-order: Ensure to place project imports last
To ensure project imports are placed after third party import,
we need to specify application-import-names.
Previously flake8-import-check checked only standard imports or not.

Change-Id: Iad7afa456cec7cf5b44955f1ea03c593a4c0e426
2017-08-22 21:38:07 +00:00
Rui Chen
f1d32dbe9b Clean up the changes of os.environ in functional tests
Use fixtures to restore the API version changes of os.environ
in each functional tests, aims to avoid the following test cases
failing in unexpected context.

And make sure setUpClass/tearDownClass call super class's
corresponding methods first.

Change-Id: Ie248fe9d3a9e25f1b076c9f2c363200f29a83817
Closes-Bug: #1696080
2017-07-20 16:39:32 +00:00
Akihiro Motoki
eeb614c477 volume functest: ensure snapshots deleted when volume delete
Deleting snapshot may take time. The current volume API does not allow
to delete volumes with snapshots, so if deleting snapshot may take time,
a delete request for a parent volume will fail.
This sometimes causes functional test failures in slow environments.

wait_for_status() checks whether volume status is in error statuses
but previously the expected error status was wrong. Cinder API uses
lower case as volume status, so it did not work expectedly.

Change-Id: I095894ba39f23bf81d71351818d24dbb5ca459fb
2017-06-06 01:14:20 +00:00
Jenkins
3fabbe9b39 Merge "Create server with security group ID and name" 2017-05-22 23:09:02 +00:00
Rui Chen
45496feee6 Create server with security group ID and name
Both resource ID and name are supported to identify an object
in openstackclient to make user easy to input, for security group,
nova only support security group name in API when launch a new server,
this patch convert ID to name, then pass name to nova API, and check
the security group exist before creating server.

Change-Id: I1ed4a967fb9de3f91c8945a1ef63f6c7b6b2dfb2
Closes-Bug: #1687814
2017-05-22 20:32:01 +00:00
Rui Chen
7a7bb06377 Make block-device-mapping more stable and clear
The patch fix the following issues:

1. ValueError is raised if input don't contain "=". Sometimes the whole
"server create" command is very complex, it's difficult to find out root
reason directly.
2. Don't support to add block device from snapshot, like:
--block-device-mapping
vdb=0c8ae9d8-cadc-4a23-8337-4254614d277e:snapshot:1, it's supported by
novaclient, but not in osc.
3. If input "vdb=", not add any mapping information, the server will be
launched successfully, not raise error message to let use add
volume/snapshot id, just ignore "--block-device-mapping" option.
4. The help message of "block-device-mapping" option is so simple, need
to add some details about how to add <type>, <delete_on_terminate>
contains.

Change-Id: Ib7f7a654c3dc2a8272545f168b4c4ced230ce39e
Depends-On: Ib37913891bbf7a31b570404c4668c490d5ac859b
Closes-Bug: #1667266
2017-05-17 01:42:12 +00:00
Dean Troyer
07a4363e99 Skip floating ip attach functional test on nova-net
As of Ocata release Nova forces nova-network to run in a cells v1
configuration.  Floating IP and network functions currently do not
work in the gate jobs so we have to skip this.  It is known to work
tested against a Mitaka nova-net DevStack without cells.

Change-Id: I74f67ac8eb12c7a649ddcbd7979cf745fb35cc0c
2017-05-03 14:41:35 -05:00
Dean Troyer
346ac9da62 Nova-net functional tests: aggregates
Nova-net requires a cells v1 configuration to run as of Ocata, but
aggregates and cells v1 are not golfing buddies, so don't let them
meet on the back nine.

Skip the aggregate add/remove host commands in the cells v1 config,
leave the others because they should work, just not be very useful.

And format things consistently.

Change-Id: I131d9f883cb7aca53ad82fb7d5fc6ee1c1e7d923
2017-05-02 14:09:16 -05:00
Dean Troyer
190711ecd7 Nova net functional tests round 3
* network segment
* network service
* port
* router
* security group
* security group rule
* subnet
* subnet pool
* extension
  The extension tests were duplicated to have both compute and network
  extensions tests so the nova-net case will still exercise the extension
  commands.

Also clean up formatting from previous reviews to make the Network functional
tests look and act consistently.

Change-Id: I286c40572faa31ddcef595cec740da933b2defc1
2017-04-28 14:40:45 -05:00
Dean Troyer
bffc98e4e5 Fix server create with nova-net
A Neutron-ism slipped by in server create.

Change-Id: Id590d7f93df2a41d7bd7617459a2af159a6f8071
2017-04-26 18:49:50 -05:00
Dean Troyer
4289ddd47a Low-level Compute v2 API: security group
api.compute.APIv2 starts with security group functions.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Change-Id: Id007535f0598226a8202716232313e37fe6247f9
2017-04-11 02:08:04 -05:00
Dean Troyer
498d416bdd Refactor ServerTests and ServerEventTests functional test classes
Move common bits into a compute.v2.common.ComputeTestCase class
so they are available as needed without calling into other test
classes.

Change-Id: I1afcc04ba705b0bbb85628117e7ca91080cf1895
2017-03-10 14:50:21 +08:00
Jenkins
dcb2de9db2 Merge "Add "--private-key" option for "keypair create"" 2017-03-08 02:51:48 +00:00
Rui Chen
c03b9a871c Add server event list and show commands
OSC server event is similar to nova's instance action commands.

Server event is the event record that had been done on a server,
include: event type(create, delete, reboot and so on),
event result(success, error), start time, finish time and so on.
These are important information for server maintains.

Change-Id: I8111091f46a0d2755728d8f9d43cc0dfe8842d13
Closes-Bug: #1642030
2017-03-07 15:25:43 +08:00
Rui Chen
dee22d8faa Add "--private-key" option for "keypair create"
Aim to specify the private key file to save when keypair
is created. That is a convenient way to save private key
in OSC interactive mode, avoid to copy CLI output, then
paste it into file.

Change-Id: I119d2f2a3323d17ecbe3de4e27f35e1ceef6e0a5
Closes-Bug: #1549410
2017-03-06 08:34:28 +00:00
Dean Troyer
74a35fb005 Finish converting server functional tests to JSON format
Change-Id: Ic9563bd86feb1f7afd403e49499205a499f0c142
2017-02-18 11:50:39 -06:00
Jenkins
83a0db0a54 Merge "Fix "server create" command failed when --nic auto or none" 2017-02-18 06:41:14 +00:00
Dean Troyer
ef1a86a802 Fix image selection in server function tests
The image selection has been affected by Cirros image changes in DevStack,
make the logic moe robust and convert it to JSON.  The conversion for the
remainder of the file will follow.

Change-Id: I8f3318f55ed79d617c3594142f0c086e2bd1a7b1
2017-02-17 12:14:41 -06:00
Rui Chen
c051c5f090 Fix "server create" command failed when --nic auto or none
"auto" and "none" options was added into --nic argument of server create
command in patch https://review.openstack.org/#/c/412698/ , but that
don't work and raise internal error when execute command. The patch
fix that issue and add unit and functional tests.

Change-Id: Ia718c3bac0a5172a0cdbe9f0d97972a9346c1172
Co-Authored-By: Kevin_Zheng <zhengzhenyu@huawei.com>
Closes-Bug: #1663520
2017-02-15 14:25:37 +08:00
Jenkins
5de97e385f Merge "Functional test for aggregate" 2017-02-13 08:51:14 +00:00
Jenkins
46d1df0adf Merge "Functional test for agent" 2017-02-09 06:35:56 +00:00
zhiyong.dai
7d8602c9bc Functional test for aggregate
Using json format output in aggregate functional tests.
Remove resource create/delete from setupClass() and
teardownClass() methods

Change-Id: I6494ca63bfe8a51de0f65570fddcaf38f6c42dbb
2016-11-28 02:32:48 +08:00
Nikita Gerasimov
95c8661f86 Switch server create to block_device_mapping_v2
Current compute_client.servers.create() relies on block_device_mapping
arg which is legacy[1]. "block_device_mapping" format require
device_name which is leads to hard-coded hack in --volume key handler
to KVM specific. "block_device_mapping_v2" format is more friendly
to hypervisiors.
Support of block_device_mapping_v2 appear in python-novaclient 2.16.0,
openstackclient require at least 2.29.0

Makes options --volume and --block-device-mapping work simultaneously.
Appends --block-device-mapping data even if --volume used.
After bug 1383338 only --volume was taken when both are used.

[1]http://docs.openstack.org/developer/nova/block_device_mapping.html

NOTE(dtroyer): I moved the new test_boot_from_volume() functional
test to Ie51b1c375c5940856ec76a5770df3c6bd18a3eba to test our
previous behaviour.  The only changes required to support the new
behaviour should be that the empty_volume is now attached in that test.

Change-Id: I7bac3d870dd9ca404093142f8bce22a62e49180d
Closes-Bug: 1647406
Closes-Bug: 1497845
2017-01-26 02:02:30 +00:00
Dean Troyer
5ecb353f89 Add server_boot_from_volume() test
Plucked this test out of I5529f412578c50090e70d17aa0129217bf803fed in
order to validate the current behaviour before applying that change.
It was converted to the new JSON-style.

Change-Id: Ie51b1c375c5940856ec76a5770df3c6bd18a3eba
2017-01-25 19:56:34 +00:00
Dean Troyer
9ada3b529d Add server test for image and flavor lookups
Review Ia66e44e530799ce6531922dcf6a84e38528c8725 changes OSC's server
commands to use the image client rather than compute clirnt (yay!)
but we never really tested any of this in functional tests.  This review
adds a simple functional test (in the new style) to watch the client
change; it passes locally for me without the client change, due to timing
we went ahead and merged that first.

Change-Id: I5529f412578c50090e70d17aa0129217bf803fed
2017-01-25 02:34:27 +00:00
zhiyong.dai
2476a26d99 Update functional test for aggregate.
Add the following functional tests :
    option: "--no-property"
    command: "aggregate set --zone",
             "aggregate add host",
             "aggregate remove host".

Change-Id: Ia9c31facb5f0f5b92b8df950fd4021b8ecc924c5
2017-01-16 20:58:33 +00:00
Dean Troyer
f825c9b81b Functional tests - flavor
* Rework functional tests to remove resource create/delete from
  setupClass() and teardownClass() methods.
* Add tests for more command options
* Use JSON output

Change-Id: Ib99ef954fe8e1170c7445940180d80b8b9c0a92c
2017-01-06 14:03:39 -06:00
zhiyong.dai
ff3566ef48 Functional test for agent
Using json format output in compute agent functional tests.
Remove resource create/delete from setupClass() and
teardownClass() methods

Change-Id: Ic7c6c268dfccca097709378c0473eb82cddf7bc6
2016-11-26 02:13:30 +08:00
zhiyong.dai
c8ab58bf61 Functional test for server group
Rework functional tests to remove resource create/delete from
setupClass() and teardownClass() methods.

Change-Id: Ia852e48d3bcf706eefa56b03ba1f02b3fd7605cd
2016-11-24 22:50:44 +08:00
Steve Martinelli
c14d3efe61 move all functional tests to tests module
functional tests should be grouped with other tests (unit and
integration tests). as part of this commit the "common" module
was renamed to just "base", this was done for simplicity.

the post_test_hook.sh file was also copied to the functional module
since it should live there. a separate change to the infra repo
will be made to call the new location, once that is merged we
can remove the old one (a new change will also be posted for that)

Needed-By: I49d54f009021d65c1ae49faf6b3f0a7acdadd7b3
Change-Id: Ie8c334f6223373b8e06df8bd8466500d2a2c8ede
2016-09-09 03:29:47 +00:00