blob: 705123037d29fac4d9fa471616846d4b198d39a4 [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
Martin Kopecd76178e2024-01-16 20:43:56 +010010One of Tempest's prime functions is to ensure that your OpenStack cloud
Sean Dague1937d092013-05-17 16:36:38 -040011works 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
Martin Kopecd76178e2024-01-16 20:43:56 +010017``negative tests`` in Tempest source code. Throughout the OpenStack
18project, Tempest has discovered many fundamental bugs by doing just
Sean Dague1937d092013-05-17 16:36:38 -040019this.
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
Martin Kopecd76178e2024-01-16 20:43:56 +010023spinning up a server, image, etc., and 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,
Martin Kopecd76178e2024-01-16 20:43:56 +010035but currently, in the OpenStack gate, this is a fundamentally important
Sean Dague1937d092013-05-17 16:36:38 -040036place 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
Martin Kopecd76178e2024-01-16 20:43:56 +010046They should test specific API calls and can build up complex states if
Sean Dague1937d092013-05-17 16:36:38 -040047it'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.