blob: a79692219302c940eddbe62b1fa2b56a41d633bf [file] [log] [blame]
Matthew Treinisha9aef872014-07-25 16:03:08 -04001.. _api_field_guide:
2
Masayuki Igawac268dd62013-09-18 00:51:05 +09003Tempest Field Guide to API tests
4================================
Sean Dague1937d092013-05-17 16:36:38 -04005
6
7What are these tests?
Attila Fazekas23fdf1d2013-06-09 16:35:23 +02008---------------------
Sean Dague1937d092013-05-17 16:36:38 -04009
10One of Tempest's prime function is to ensure that your OpenStack cloud
11works with the OpenStack API as documented. The current largest
12portion of Tempest code is devoted to test cases that do exactly this.
13
Yong Sheng Gonge99072d2013-08-15 13:52:41 +080014It's also important to test not only the expected positive path on
Sean Dague1937d092013-05-17 16:36:38 -040015APIs, but also to provide them with invalid data to ensure they fail
Jordan Pittier74a56ab2017-04-26 16:46:20 +020016in expected and documented ways. The latter type of tests is called
17``negative tests`` in Tempest source code. Over the course of the OpenStack
Sean Dague1937d092013-05-17 16:36:38 -040018project Tempest has discovered many fundamental bugs by doing just
19this.
20
Yong Sheng Gonge99072d2013-08-15 13:52:41 +080021In order for some APIs to return meaningful results, there must be
Sean Dague1937d092013-05-17 16:36:38 -040022enough data in the system. This means these tests might start by
Yong Sheng Gonge99072d2013-08-15 13:52:41 +080023spinning up a server, image, etc, then operating on it.
Sean Dague1937d092013-05-17 16:36:38 -040024
25
Jordan Pittier74a56ab2017-04-26 16:46:20 +020026Why are these tests in Tempest?
Attila Fazekas23fdf1d2013-06-09 16:35:23 +020027-------------------------------
Sean Dague1937d092013-05-17 16:36:38 -040028
29This is one of the core missions for the Tempest project, and where it
30started. Many people use this bit of function in Tempest to ensure
31their clouds haven't broken the OpenStack API.
32
33It could be argued that some of the negative testing could be done
34back in the projects themselves, and we might evolve there over time,
35but currently in the OpenStack gate this is a fundamentally important
36place to keep things.
37
38
39Scope of these tests
Attila Fazekas23fdf1d2013-06-09 16:35:23 +020040--------------------
Sean Dague1937d092013-05-17 16:36:38 -040041
42API tests should always use the Tempest implementation of the
43OpenStack API, as we want to ensure that bugs aren't hidden by the
44official clients.
45
46They should test specific API calls, and can build up complex state if
47it's needed for the API call to be meaningful.
48
49They should send not only good data, but bad data at the API and look
50for error codes.
51
52They should all be able to be run on their own, not depending on the
53state created by a previous test.