summaryrefslogtreecommitdiff
path: root/openstackclient/tests/compute/v2/test_server.py
Commit message (Collapse)AuthorAgeFilesLines
* move unit tests to new "unit" test moduleSteve Martinelli2016-09-081-1844/+0
| | | | | | | | this will better isolate the unit tests from the functional tests. unfortunately, the "integration" tests had to be lumped into the "unit" tests since we need the separation in testr.conf Change-Id: Ifd12198c1f90e4e3c951c73bfa1884ab300d8ded
* Pass security group id to novaclient while adding securityRajasi Kulkarni2016-07-281-0/+48
| | | | | | | | | | | | | | group to server In AddServerSecurityGroup, we currently pass the security group name to novaclient. If multiple security groups with same name exist, then even while passing secuity group using id to command 'openstack server add security group <server> <group>' it results in error 'Multiple security_group matches found'. Added unit test case to test the command. Change-Id: I6097eb36e1545c85209cfd767c477e10f82c6999 Closes-Bug: 1604076
* Use assertEqual() instead of assertDictEqual()Tang Chen2016-07-251-1/+1
| | | | | | | | | | | In unittest2, assertDictEqual() is implemented by using != operator to compare two dicts. So is assertEqual() in testtools. assertEqual() in testtools is able to handle dict, list, set and so on. So we just call assertEqual() to make the unit tests simpler. Change-Id: Ice343b2ce468acae39d2ad79f7121503e3627656
* Merge ""server list": "Image Name", "Image ID" columns"Jenkins2016-07-221-1/+14
|\
| * "server list": "Image Name", "Image ID" columnsMarc Abramowitz2016-07-061-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `Image Name` column is shown by default (i.e.: without passing `--long`). E.g.: ``` $ openstack server list WARNING: openstackclient.common.utils is deprecated and will be removed after Jun 2017. Please use osc_lib.utils +--------------------------------------+-----------------+---------+----------------------+----------------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+-----------------+---------+----------------------+----------------------+ | abe67035-b14f-4541-b436-e0e778ec4227 | n9anonw302mgm1 | ACTIVE | mnky3-3000=10.3.0.55 | Koala.2016-07-01-175 | | 8f6a2d12-2bc3-4d89-ba94-8916ce9cdf92 | n9anonw301mgm1 | ACTIVE | mnky3-3000=10.3.0.37 | Koala.2016-07-01-175 | | b316d6d1-67cf-4f75-94a4-4c9a2b03f6a4 | n9dobby301mgm0 | ACTIVE | mnky3-3000=10.3.0.36 | Koala.2016-05-04-130 | +--------------------------------------+-----------------+---------+----------------------+----------------------+ ``` The `Image ID` column is only available with `--long`. E.g.: ``` $ openstack server list --long -c Name -c "Image Name" -c "Image ID" WARNING: openstackclient.common.utils is deprecated and will be removed after Jun 2017. Please use osc_lib.utils +-----------------+----------------------+--------------------------------------+ | Name | Image Name | Image ID | +-----------------+----------------------+--------------------------------------+ | n9anonw302mgm1 | Koala.2016-07-01-175 | f587c6fc-1df3-42cd-ac86-8cd2c995a8d9 | | n9anonw301mgm1 | Koala.2016-07-01-175 | f587c6fc-1df3-42cd-ac86-8cd2c995a8d9 | | n9dobby301mgm0 | Koala.2016-05-04-130 | 37ff47a6-3e51-4986-bfa5-62afbfad5dfc | +-----------------+----------------------+--------------------------------------+ ``` Closes-Bug: #1599304 Change-Id: I477995b840eb9520b285948926ebbfe1777dd86c
* | Pass security group id to novaclientRajasi Kulkarni2016-07-111-0/+53
| | | | | | | | | | | | | | | | | | | | In RemoveServerSecurityGroup we currently pass the entire security group object, which results in TypeError in novaclient. Added unit test case to test command 'openstack server remove security group -h <server> <group>' Change-Id: I6d486403a83804c3a30d6f89d2cf7f64f09797c6 Closes-Bug: 1590883
* | Merge "Transfer "ip fixed add/remove" to "server add/remove fixed ip""Jenkins2016-07-061-0/+71
|\ \
| * | Transfer "ip fixed add/remove" to "server add/remove fixed ip"Tang Chen2016-07-041-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does the following things to transfer "ip fixed add/remove" to "server add/remove fixed ip": * Add new command "server add/remove fixed ip", and unit tests and doc. * Deprecate "ip fixed add/remove" command. compute/v2/fixedip.py is not removed because the arguments' positions are different between the new and old commands. * ip fixed add <network> <server> server add fixed ip <server> <network> * ip fixed remove <ip-address> <server> server remove fixed ip <server> <ip-address> Change-Id: Ica07ccf92a76c21fd5608ecaff86ff7c4d96f5a0 Implements: blueprint rework-ip-commands Partial-bug: 1555990 Co-Authored-By: Dean Troyer <dtroyer@gmail.com>
* | | Merge "Transfer "ip floating add/remove" to "server add/remove floating ip""Jenkins2016-07-061-0/+67
|\ \ \ | |/ / | | / | |/ |/|
| * Transfer "ip floating add/remove" to "server add/removeTang Chen2016-07-041-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | floating ip" This patch does the following things to transfer "ip floating add/remove" to "server add/remove floating ip": * Add new command "server add/remove floating ip", and unit tests and doc. * Deprecate "ip floating add/remove" command. compute/v2/floatingip.py is not removed because the arguments' positions are different between the new and old commands. * ip floating add <ip-address> <server> server add floating ip <server> <ip-address> * ip floating remove <ip-address> <server> server remove floating ip <server> <ip-address> Change-Id: Ic0dd22ca6fb7b7bc3e820fd5a14d7c551e7ab963 Implements: blueprint rework-ip-commands Partial-bug: 1555990 Co-Authored-By: Dean Troyer <dtroyer@gmail.com>
* | fix a few spelling mistakesgecong19732016-07-041-2/+2
|/ | | | | | | - overwriten should be overwritten - retrun should be return Change-Id: I1567402f4d5c7253e6a54d8753e3f201af7e6a54
* Merge "Move server image create command to its own resource file."Jenkins2016-06-161-144/+0
|\
| * Move server image create command to its own resource file.Dean Troyer2016-06-031-144/+0
| | | | | | | | Change-Id: If37e82072bd7a32b81bfb1a8bb048f018dd5b04f
* | osc-lib: utilsDean Troyer2016-06-131-2/+2
| | | | | | | | | | | | | | | | Use osc-lib directly for utils. Leave openstackclient.common.utils for deprecation period. Change-Id: I5bd9579abc4e07f45219ccd0565626e6667472f7
* | osc-lib: exceptionsDean Troyer2016-06-131-2/+3
| | | | | | | | | | | | | | | | Use osc-lib directly for exceptions. Leave openstackclient.common.exceptions for deprecation period. Change-Id: Iea3e862302372e1b31ccd27f69db59b4953ca828
* | Add server set/unset unit test casesRui Chen2016-06-061-0/+87
|/ | | | | | | Unit test cases don't cover compute "server set/unset" commands, the patch add some test cases for them. Change-Id: I440c32968bd41b948352a9764a37c9af3e68803d
* Support to set server stateRui Chen2016-05-281-0/+61
| | | | | | | | | | When a server is unexpected state, OSC don't support reset the server to active or error state, that's supported by novaclient, and it's an important command for operators, the patch implement this function. Change-Id: I3e7800feb192832b0719ef9a353945beb6bfd509 Implements: blueprint server-reset-state
* Merge "Add unit tests for "server show" command"Jenkins2016-05-111-0/+95
|\
| * Add unit tests for "server show" commandTang Chen2016-05-111-0/+95
| | | | | | | | Change-Id: I6eb0c4e7d5d3e677764b253e3324720a784a110b
* | Merge "Use find_resource() instead of get() in _prep_server_detail()"Jenkins2016-05-111-7/+5
|\ \ | |/ |/|
| * Use find_resource() instead of get() in _prep_server_detail()Tang Chen2016-05-091-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There is such a comment in test_server.py: # Call .get() to retrieve all of the server information # as findall(name=blah) and REST /details are not the same # and do not return flavor and image information. This is an out of date comment. There is no function named findall() in OSC now. So use find_resource() instead of get(), and remove this comment. Change-Id: I8d79afc5f341fb5caf771d905506b7f1c7a41ae8
* | Merge "Map server power state num to meanful string"Jenkins2016-05-091-0/+5
|\ \ | |/ |/|
| * Map server power state num to meanful stringTang Chen2016-05-071-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | In _prep_server_detail(), power_state is not formatted by _format_servers_list_power_state(). So when executing "server show" or "server create", the power state is represented by number. This patch map the numbers to meanful strings. This patch also adds power_state attribute to FakeServer, and improves unit tests for this attribute. Change-Id: I2ec674327de4e5133b8712ba6bb53fa5ce55e3f4
* | Trivial: Remove unuseful comments for assertRaise() checkingTang Chen2016-05-061-1/+0
|/ | | | | | | | "Missing required args should bail here" is not understandable and not necessary. The code is obvious enough. And some of the comments are misused because of code copy. So remove them. Change-Id: I031395f2c882386c7a708db5cf4eee75393dc639
* Merge "[compute] Support restore server"Jenkins2016-03-041-0/+20
|\
| * [compute] Support restore serverjichenjc2016-02-231-0/+20
| | | | | | | | | | | | Server in soft-delete state can be restored, add this command. Change-Id: Id9d7246f89ae65273505f36dcb664996534ae986
* | Merge "Add test cases to test some commands with '--wait' and fix bug"Jenkins2016-03-041-0/+188
|\ \
| * | Add test cases to test some commands with '--wait' and fix bugting.wang2016-03-021-0/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "server image create" "server rebuild" "server resize" Above 3 commands are not covered by unit test. So add some unit tests. Meanwhile, fix bug. Now that image name is an optional argument, we'd better record error messages with positional arguments instead of optional argument. So, record server name. Change-Id: I41bc025d4824dc46f63a3213d82e1528bacbbe12
* | | [Compute] Check return value is None in compute unit tests.Tang Chen2016-02-271-40/+25
| |/ |/| | | | | | | | | | | | | | | take_action() in commands inheriting from Command returns nothing. So we should assert the return is None in the unit tests of these commands. Change-Id: I953480ecff3b5beb12255d866d0e1df45f130efd Partial-Bug: #1550636
* | Add some test cases for "server list" commandting.wang2016-02-241-27/+72
|/ | | | | | | | Add some test cases that test 'server list' command when specifying flavor or image. Because I add some attribution to fake.py, I have to change some code in create server test. Despite all this, I think it's good for testing. Change-Id: I714deac1f6f940b790a3c20af5f7ffa724ac44d1
* Use assertRaises() to check if an exception is raisedTang Chen2016-02-141-5/+4
| | | | | | | In some test cases, try/except is used to check if an exception has been raised. We should use assertRaises() instead. Change-Id: I15c8e757dcab77fd6f895feb018184e1eb7e617b
* Trivial: Fix "abstractmethod" to "abstract method"Tang Chen2016-02-101-5/+5
| | | | | | | | | As Richard <rtheis@us.ibm.com> has pointed out, "abstractmethod" should be "abstract method". This is a small typo I have made when I fix DisplayCommandBase comment bug. Change-Id: I84f1a3158896257686a0a7efa1123eef1b85139f Partial-bug: #1477199
* Compute: Fix DisplayCommandBase comments for cliff ShowOne subclass testsTang Chen2016-02-061-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As bug #1477199 describes, the wrong comment below is all over the unit test code of OSC. # DisplayCommandBase.take_action() returns two tuples There is no such class named DisplayCommandBase in OSC. It is in cliff. All OSC command classes inherit from the base classes in cliff, class Command, class Lister and class ShowOne. It is like this: Object |--> Command |--> DisplayCommandBase |--> Lister |--> ShowOne take_action() is an abstract method of class Command, and generally is overwritten by subclasses. * Command.take_action() returns nothing. * Lister.take_action() returns a tuple which contains a tuple of columns and a generator used to generate the data. * ShowOne.take_action() returns an iterator which contains a tuple of columns and a tuple of data So, this problem should be fixed in 3 steps: 1. Remove all DisplayCommandBase comments for tests of classes inheriting from class Command in cliff as it returns nothing. 2. Fix all DisplayCommandBase comments for tests of classes inheriting from class Lister in cliff. Lister.take_action() returns a tuple and a generator. 3. Fix all DisplayCommandBase comments for tests of classes inheriting from class ShowOne in cliff. ShowOne.take_action() returns two tuples. This patch finishes step 3 in compute tests. Change-Id: I4df224ec82b5d82a3d6d3f366c0f68a7ea0d87cd Partial-bug: #1477199
* Compute: Fix DisplayCommandBase comments for cliff Command subclass testsTang Chen2016-02-061-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As bug #1477199 describes, the wrong comment below is all over the unit test code of OSC. # DisplayCommandBase.take_action() returns two tuples There is no such class named DisplayCommandBase in OSC. It is in cliff. All OSC command classes inherit from the base classes in cliff, class Command, class Lister and class ShowOne. It is like this: Object |--> Command |--> DisplayCommandBase |--> Lister |--> ShowOne take_action() is an abstract method of class Command, and generally is overwritten by subclasses. * Command.take_action() returns nothing. * Lister.take_action() returns a tuple which contains a tuple of columns and a generator used to generate the data. * ShowOne.take_action() returns an iterator which contains a tuple of columns and a tuple of data So, this problem should be fixed in 3 steps: 1. Remove all DisplayCommandBase comments for tests of classes inheriting from class Command in cliff as it returns nothing. 2. Fix all DisplayCommandBase comments for tests of classes inheriting from class Lister in cliff. Lister.take_action() returns a tuple and a generator. 3. Fix all DisplayCommandBase comments for tests of classes inheriting from class ShowOne in cliff. ShowOne.take_action() returns two tuples. This patch finishes step 1 in compute tests. Change-Id: I99ab42a7de69af0e5de802a1bb5aac647245a200 Partial-bug: #1477199
* Add support for triggering an crash dumpxiexs2016-02-051-0/+20
| | | | | | | | | | | | | The triggering crash dump feature is supported by nova [1] and novaclient [2] now, it's time to introduce this feature into OSC correspondingly. [1]The change id is: I6ed777ff637254b4b79417008f9055dd19fc7405 [2]The change id is: If03b1864bbe7074c720b946fc2700bd5d07debc3 Change-Id: I5a411f283fdf0fc3c00380d069848a332c799cdd Closes-Bug: #1538372 Co-Authored-By: Tang Chen <chen.tang@easystack.cn>
* Refactor abstract columns and datalist out in compute test casesSaiKiran2016-01-211-94/+52
| | | | | | | | | columns and datalist has been set in each test case in compute, which is not necessary. This patch abstract it out and remove all redundant code. Change-Id: I5e8423722416ea31fdced4c932ed141de90028ab Closes-Bug: #1531816
* Merge "Make --image parameter optional in "server rebuild""Jenkins2016-01-151-0/+70
|\
| * Make --image parameter optional in "server rebuild"David Moreau Simard2015-12-111-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | The command will now default to the image currently in-use by the server, effectively making the --image parameter optional. This commit also adds basic tests for ServerRebuild since there wasn't any. Will add more full tests for it. Change-Id: I733fd3ad5a825f06563c72aa430122e1a0e3b3b0 Closes-bug: #1524406 Co-Authored-By: David Moreau Simard <dms@redhat.com> Co-Authored-By: Tang Chen <tangchen@cn.fujitsu.com>
* | TestServerGeneral: Add test for _prep_server_detail()Tang Chen2015-12-201-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | 1. Make TestServerGeneral inherit from TestServer because we need to use servers_mock, image_mock and flavor_mock in compute_client. 2. Create a dict containing all info of a server in the original format, and pass it to _prep_server_detail(). 3. Compare the original and formatted dict. Change-Id: Ie0b83c42a5c3bbba630a064d28374d07e2ce9caf Implements: blueprint osc-unit-test-framework-improvement
* | TestServerGeneral: Add test for _format_servers_list_networks()Tang Chen2015-12-201-0/+24
| | | | | | | | | | | | | | | | The items in a dict are in random order. So if a server is in two networks, there may be two results after formatted. Change-Id: I2e15d202639e3fff427935f46650a405b0e51bcc Implements: blueprint osc-unit-test-framework-improvement
* | Merge "TestServerGeneral: Add test for _format_servers_list_power_state()"Jenkins2015-12-171-0/+20
|\ \
| * | TestServerGeneral: Add test for _format_servers_list_power_state()Tang Chen2015-12-101-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | If we have tests for each helper function, then we can call them in other tests without worrying about error. Change-Id: I1e4273aef201fe9d8936e5c365ebb46068039892 Implements: blueprint osc-unit-test-framework-improvement
* | | Merge "Trivial: Improve unclear comments in test_server.py"Jenkins2015-12-141-5/+5
|\ \ \
| * | | Trivial: Improve unclear comments in test_server.pyTang Chen2015-12-111-5/+5
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | In test_server.py, there are two ImageManagers are faked: 1. the one in compute client 2. the one in image client But the comments are the same. And so is volume. This patch makes the comments more clear. Change-Id: I2c52f48a7b3c005c185a4ac64abbb3e18d5fb3de
* | | Merge "Add unit test for TestServerList to test --long option."Jenkins2015-12-101-5/+50
|\ \ \ | |/ / |/| |
| * | Add unit test for TestServerList to test --long option.Tang Chen2015-12-091-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In two steps: 1. Setup all necessary attributes of a server in setUp(), including the ones that are not faked in FaseServer by default. 2. Run a similar process with no option test case. The future plan is to move all these attributes to FakeServer. But it will cause some other changes which has nothing to do with this patch. So leave this job to do later. Change-Id: I1134812a0ea146ef737b0f0ffbef8ca23684accd Implements: blueprint osc-unit-test-framework-improvement
* | | Fix poorly named test mocksTerry Howe2015-12-091-6/+6
| | | | | | | | | | | | Change-Id: I6e2911e88fc458b39d5024a5714ed8af3f519946
* | | SDK integration extensions and server create networksTerry Howe2015-12-091-6/+11
| |/ |/| | | | | | | | | | | Finish up the SDK integration with server create network and port find and extension list. Change-Id: I18dbada784d8aa92a45a937f251023ddf899c53e
* | Merge "Use FakeVolume in server test cases."Jenkins2015-12-091-12/+7
|\ \
| * | Use FakeVolume in server test cases.Tang Chen2015-12-081-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | We have a class FakeVolume to fake one or more volumes. So use it in test_server.py. Change-Id: I735ae7f678a6799e0ae4c7c25c8083d9ebf47b09 Implements: blueprint improve-volume-unittest-framework