summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/compute/v2
Commit message (Collapse)AuthorAgeFilesLines
* Migrate server_groups to the new APIViolet Kurtz2022-08-021-12/+12
| | | | | | Moved the server_groups to the new API. Change-Id: Ied7bd6f56e277f0c5efcd5ba028765f9be65050f
* Merge "tests: Improve logging for executed commands"Zuul2022-05-131-8/+25
|\
| * tests: Improve logging for executed commandsStephen Finucane2021-12-091-8/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | We're seeing failures in a recently added tests, 'ServerTests.test_server_add_remove_volume' from 'openstackclient/tests/functional/compute/v2/test_server.py'. These failures are likely the result of slow CI nodes, but we don't have enough information in the CI logs to debug them. Starting logging the various commands executed in tests so that we can see these logs if and when tests fail. Change-Id: I4584dc5e6343fe8c8544431a527d8c3c7e7b3c5b Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | Fix 'server event list|show' for deleted serversmelanie witt2022-02-091-0/+35
|/ | | | | | | | | | | | | | | | | | | | As of compute microversion >= 2.21, support for list and show of server events for deleted servers was added. This however wasn't working using the openstackclient because the compute GET /servers/{server_id} will not return a deleted server, so osc_lib.utils.find_resource() fails to find the server and the command bails early. This adds a check for a uuid-like <server> arg and uses it directly if the <server> cannot be found via find_resource(). A note is also added to the command help to indicate that list and show for deleted servers will only work if a server ID is passed (name will not work). Story: 2009841 Task: 44443 Change-Id: Icd33b3b9a3a1855d7893dd111bbb2aca059f45fd
* Switch openstack server remove port/network to using sdkDiwei Zhu2021-11-291-11/+83
| | | | Change-Id: I1540c1f52e9a107dba20eeea9dc323c5510fe2b1
* Add functional test for server add/remove volume.Diwei Zhu2021-11-261-0/+59
| | | | Change-Id: I86a76f32790cafcff1d94364fb72f8890a8cb025
* Switch openstack server add port/network to using sdk.Diwei Zhu2021-11-141-0/+48
| | | | | | | | | | | | | The old novaclient.v2.server.Server.interface_attach() method is replaced with proxy.create_server_interface(). In swargs, 'net_id' and 'port_id' are mutual-exclusive, if one of them is given with value, the other one cannot be None, as the API would responde with 400 (None is not string). In unit test, temporary method 'setup_sdk_servers_mock' is added, because other tests are still using the old 'setup_servers_mock'. Functional tests are added. Releasenote is generated. Change-Id: I9899f0509febc5143560a1859ae6344d0a6d1427
* compute: Add functional tests for --block-deviceStephen Finucane2021-03-051-16/+148
| | | | | | | | | | | | | | | | | | | | | | This mostly reuses the existing tests for '--block-device-mapping', which can hopefully be removed at some point in the future. This highlights two issues with the implementation of this option. Firstly, the 'boot_index' parameter is not required so don't mandate it. Secondly, and more significantly, we were defaulting the destination type for the 'image' source type to 'local'. Nova only allows you to attach a single image to local mapping [1], which means this default would only make sense if you were expecting users to use the '--block-device' option exclusively and omit the '--image' option. This is the *less common* case so this is a bad default. Default instead to a destination type of 'volume' like everything else, and require users specifying '--block-device' alone to pass 'destination_type=local' explicitly. [1] https://github.com/openstack/nova/blob/c8a6f8d2e/nova/block_device.py#L193-L206 Change-Id: I1718be965f57c3bbdb8a14f3cfac967dd4c55b4d Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Fix 'server group * -f yaml' outputStephen Finucane2021-01-061-6/+6
| | | | | | | | | Make use of 'FormattableColumn'-derived formatters, which provide better output than what we were using before, particularly for the YAML output format. Change-Id: Id6d25a0a348596d5a0430ff7afbf87b049a76bc8 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Fix 'server * -f yaml' outputStephen Finucane2021-01-061-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make use of 'FormattableColumn'-derived formatters, which provide better output than what we were using before, particularly for the YAML output format. For example, compare before for the 'server show' command: $ openstack --os-compute-api-version 2.79 server show test-server -f yaml ... addresses: private=fdff:77e3:9bb4:0:f816:3eff:fe6d:a944, 10.0.0.44 flavor: disk='1', ephemeral='0', extra_specs.hw_rng:allowed='True', original_name='m1.tiny', ram='512', swap='0', vcpus='1' ... To after: $ openstack --os-compute-api-version 2.79 server show test-server -f yaml ... addresses: private: - fdff:77e3:9bb4:0:f816:3eff:fe6d:a944 - 10.0.0.44 flavor: disk: 1 ephemeral: 0 extra_specs: hw_rng:allowed: 'True' original_name: m1.tiny ram: 512 swap: 0 vcpus: 1 ... Similarly, compare before for 'server list': $ openstack --os-compute-api-version 2.79 server list -f yaml - ... Networks: private=fdff:77e3:9bb4:0:f816:3eff:fe6d:a944, 10.0.0.44 Power State: Running Properties: '' ... To after: $ openstack --os-compute-api-version 2.79 server list -f yaml - ... Networks: private: - fdff:77e3:9bb4:0:f816:3eff:fe6d:a944 - 10.0.0.44 Power State: 1 Properties: {} ... We also fix the human-readable output for the 'tags' field. Before: $ openstack --os-compute-api-version 2.79 server list ... | tags | ['bar', 'foo'] | After: $ openstack --os-compute-api-version 2.79 server list ... | tags | bar, foo | Change-Id: I7a8349106e211c57c4577b75326b39b88bd9ac1e Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* tests: Remove 'agent' functional testsStephen Finucane2020-11-161-196/+0
| | | | | | | | | | | | | | The 'os-agents' API was recently removed from nova [1]. Remove the functional tests, since they will always fail going forward but will continue to run on older stable branches. Also Squeeze https://review.opendev.org/#/c/762559/ inside, since those 2 are simultaneously blocking gate [1] https://review.opendev.org/#/c/749309/ Change-Id: I0bf7d4c0ba2a9d4637db0d209d8d52163d772f12 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Fix formatting of the flavor propertiesArtem Goncharov2020-11-021-17/+26
| | | | | | | Do not stringify flavor properties to allow proper output formatting to json/yaml/etc Change-Id: I9f4c42acb85b726af87123134dd19de98fe95074
* Merge "Show words indicating booted from volume for server image"Zuul2020-09-301-2/+17
|\
| * Show words indicating booted from volume for server imagemelanie witt2020-08-271-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | For a server booted from a volume, nova API does not store an image_id and instead returns an empty string. Currently, openstackclient similarly shows an empty string for Image Name and Image ID for servers booted from volumes. To aid CLI users in understanding the meaning of no image_id, we can display the string "N/A (booted from volume)" in the image field if the server was booted from a volume. Change-Id: I9c62cf6fe23b2e934dcbf5ebbf706b2705d2e424
* | Output correct json for security groups in 'openstack server show'jay2020-09-141-15/+24
|/ | | | | | | | | | | | | Fixes incorrect json output for 'openstack server show -f json'. The security group json output groups all the json as one for e.g. "security_groups": "name='group1'\nname='group2'" The correct output should be "security_groups" : [{"name" : "group1"}, {"name" : "group2"}] properties and volumes_attached fields also has similar issue. Story: 2007755 Change-Id: I1b1cac716329e0530400aff782c08000b21d8e1d
* Fix openstack server list --deleted --marker optionKeithMnemonic2020-01-021-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Refactor AggregateTestsEric Fried2019-11-051-41/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix functional tests for py3Eric Fried2019-10-312-4/+4
| | | | | | | | | | | | | | | | 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
* More aggregate functional race chasingDean Troyer2019-09-101-5/+3
| | | | | | | | 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>
* Format aggregate command fields and de-race functional testsDean Troyer2019-08-261-8/+51
| | | | | | | | | 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>
* Add openstack server create --boot-from-volume optionMatt Riedemann2019-08-091-0/+76
| | | | | | | | | | | | | | | 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
* Support type=image with --block-device-mapping optionMatt Riedemann2019-08-091-0/+87
| | | | | | | | | | | | | | | | | | | | | | 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
* Merge "Rename review.openstack.org to review.opendev.org"Zuul2019-06-141-1/+1
|\
| * Rename review.openstack.org to review.opendev.orgmelissaml2019-05-121-1/+1
| | | | | | | | | | | | | | 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
* | Add changes-before attribute to server listzhangbailin2019-05-311-0/+78
| | | | | | | | | | | | | | Closes-Bug: #1827844 Part of bp support-to-query-nova-resources-filter-by-changes-before Change-Id: I4f28168188973730247bcbcb70ba0e70eb81e3be
* | Serialize more aggregate functional testsDean Troyer2019-05-171-98/+50
| | | | | | | | | | | | | | | | | | 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>
* | Aggregate functional test tweakDean Troyer2019-05-161-2/+3
|/ | | | | | | | 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>
* Fix service discovery in functional testsGlenn Van de Water2019-03-131-2/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Replace assertEqual(True/False, expr) with assertTrue/assertFalseliuyamin2018-11-141-4/+2
| | | | | | | 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
* Merge "Default --nic to 'auto' if creating a server with >= 2.37"Zuul2018-10-261-4/+6
|\
| * Default --nic to 'auto' if creating a server with >= 2.37Matt Riedemann2018-03-211-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Slow down and retry aggregate create/delete to lessen raceDean Troyer2018-07-061-0/+18
| | | | | | | | | | Change-Id: I676894c1bfd3156313d88e6457250b9ff226118b Signed-off-by: Dean Troyer <dtroyer@gmail.com>
* | Retry floating IP testsDean Troyer2018-07-061-4/+36
|/ | | | | | | | 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
* Add missing parameters on openstack server rescueJose Castro Leon2017-10-271-1/+12
| | | | | Change-Id: I27afca9e826378dbcb7feb7528e0c65c528b04b0 Closes-Bug: #1703278
* Attempt to work around chronically failing server issues with aggregates and qosDean Troyer2017-09-151-2/+10
| | | | | | | | 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
* flake8-import-order: Ensure to place project imports lastAkihiro Motoki2017-08-221-2/+2
| | | | | | | | 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
* Clean up the changes of os.environ in functional testsRui Chen2017-07-202-2/+7
| | | | | | | | | | | | 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
* volume functest: ensure snapshots deleted when volume deleteAkihiro Motoki2017-06-062-17/+15
| | | | | | | | | | | | | 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
* Merge "Create server with security group ID and name"Jenkins2017-05-221-0/+46
|\
| * Create server with security group ID and nameRui Chen2017-05-221-0/+46
| | | | | | | | | | | | | | | | | | | | | | 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
* | Make block-device-mapping more stable and clearRui Chen2017-05-171-0/+107
|/ | | | | | | | | | | | | | | | | | | | | | 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
* Skip floating ip attach functional test on nova-netDean Troyer2017-05-031-9/+9
| | | | | | | | | 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
* Nova-net functional tests: aggregatesDean Troyer2017-05-021-21/+44
| | | | | | | | | | | | | 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
* Nova net functional tests round 3Dean Troyer2017-04-281-0/+14
| | | | | | | | | | | | | | | | | | | | * 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
* Fix server create with nova-netDean Troyer2017-04-261-2/+10
| | | | | | A Neutron-ism slipped by in server create. Change-Id: Id590d7f93df2a41d7bd7617459a2af159a6f8071
* Low-level Compute v2 API: security groupDean Troyer2017-04-111-2/+2
| | | | | | | | | | 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
* Refactor ServerTests and ServerEventTests functional test classesDean Troyer2017-03-103-135/+156
| | | | | | | | 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
* Merge "Add "--private-key" option for "keypair create""Jenkins2017-03-081-0/+21
|\
| * Add "--private-key" option for "keypair create"Rui Chen2017-03-061-0/+21
| | | | | | | | | | | | | | | | | | | | 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
* | Add server event list and show commandsRui Chen2017-03-071-0/+97
|/ | | | | | | | | | | | 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