Masayuki Igawa | c268dd6 | 2013-09-18 00:51:05 +0900 | [diff] [blame] | 1 | Tempest Field Guide to CLI tests |
| 2 | ================================ |
Sean Dague | f682579 | 2013-05-08 13:51:26 -0400 | [diff] [blame] | 3 | |
| 4 | |
| 5 | What are these tests? |
Attila Fazekas | 23fdf1d | 2013-06-09 16:35:23 +0200 | [diff] [blame] | 6 | --------------------- |
Sean Dague | f682579 | 2013-05-08 13:51:26 -0400 | [diff] [blame] | 7 | The cli tests test the various OpenStack command line interface tools |
| 8 | to ensure that they minimally function. The current scope is read only |
| 9 | operations on a cloud that are hard to test via unit tests. |
| 10 | |
| 11 | |
| 12 | Why are these tests in tempest? |
Attila Fazekas | 23fdf1d | 2013-06-09 16:35:23 +0200 | [diff] [blame] | 13 | ------------------------------- |
Sean Dague | f682579 | 2013-05-08 13:51:26 -0400 | [diff] [blame] | 14 | These tests exist here because it is extremely difficult to build a |
Attila Fazekas | 58d2330 | 2013-07-24 10:25:02 +0200 | [diff] [blame] | 15 | functional enough environment in the python-\*client unit tests to |
Sean Dague | f682579 | 2013-05-08 13:51:26 -0400 | [diff] [blame] | 16 | provide this kind of testing. Because we already put up a cloud in the |
| 17 | gate with devstack + tempest it was decided it was better to have |
| 18 | these as a side tree in tempest instead of another QA effort which |
| 19 | would split review time. |
| 20 | |
| 21 | |
| 22 | Scope of these tests |
Attila Fazekas | 23fdf1d | 2013-06-09 16:35:23 +0200 | [diff] [blame] | 23 | -------------------- |
Sean Dague | f682579 | 2013-05-08 13:51:26 -0400 | [diff] [blame] | 24 | This should stay limited to the scope of testing the cli. Functional |
| 25 | testing of the cloud should be elsewhere, this is about exercising the |
| 26 | cli code. |
| 27 | |
| 28 | |
| 29 | Example of a good test |
Attila Fazekas | 23fdf1d | 2013-06-09 16:35:23 +0200 | [diff] [blame] | 30 | ---------------------- |
Sean Dague | f682579 | 2013-05-08 13:51:26 -0400 | [diff] [blame] | 31 | Tests should be isolated to a single command in one of the python |
| 32 | clients. |
| 33 | |
| 34 | Tests should not modify the cloud. |
| 35 | |
| 36 | If a test is validating the cli for bad data, it should do it with |
| 37 | assertRaises. |
| 38 | |
Michael Chapman | f826380 | 2013-06-25 15:17:24 +1000 | [diff] [blame] | 39 | A reasonable example of an existing test is as follows:: |
Sean Dague | f682579 | 2013-05-08 13:51:26 -0400 | [diff] [blame] | 40 | |
| 41 | def test_admin_list(self): |
| 42 | self.nova('list') |
| 43 | self.nova('list', params='--all-tenants 1') |
| 44 | self.nova('list', params='--all-tenants 0') |
| 45 | self.assertRaises(subprocess.CalledProcessError, |
| 46 | self.nova, |
| 47 | 'list', |
| 48 | params='--all-tenants bad') |