example.feature 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. Feature: Example feature
  2. This is an example Feature set. Is is mainly intended to show
  3. our use of the lettuce tool and our own framework for it
  4. The first scenario is to show what a simple test would look like, and
  5. is intentionally uncommented.
  6. The later scenarios have comments to show what the test steps do and
  7. support
  8. Scenario: A simple example
  9. Given I have bind10 running with configuration example.org.config
  10. And wait for bind10 stderr message BIND10_STARTED_CC
  11. And wait for bind10 stderr message CMDCTL_STARTED
  12. And wait for bind10 stderr message AUTH_SERVER_STARTED
  13. bind10 module Auth should be running
  14. And bind10 module Resolver should not be running
  15. And bind10 module Xfrout should not be running
  16. And bind10 module Zonemgr should not be running
  17. And bind10 module Xfrin should not be running
  18. And bind10 module Stats should not be running
  19. And bind10 module StatsHttpd should not be running
  20. A query for www.example.org should have rcode NOERROR
  21. A query for www.doesnotexist.org should have rcode REFUSED
  22. The SOA serial for example.org should be 1234
  23. Scenario: New database
  24. # This test checks whether a database file is automatically created
  25. # Underwater, we take advantage of our intialization routines so
  26. # that we are sure this file does not exist, see
  27. # features/terrain/terrain.py
  28. # Standard check to test (non-)existence of a file.
  29. # This file is actually automatically created.
  30. The file data/test_nonexistent_db.sqlite3 should not exist
  31. # In the first scenario, we used 'given I have bind10 running', which
  32. # is actually a compound step consisting of the following two
  33. # one to start the server
  34. When I start bind10 with configuration no_db_file.config
  35. And wait for bind10 stderr message BIND10_STARTED_CC
  36. And wait for bind10 stderr message CMDCTL_STARTED
  37. And wait for bind10 stderr message AUTH_SERVER_STARTED
  38. # Now we use the first step again to see if the file has been created
  39. The file data/test_nonexistent_db.sqlite3 should exist
  40. bind10 module Auth should be running
  41. And bind10 module Resolver should not be running
  42. And bind10 module Xfrout should not be running
  43. And bind10 module Zonemgr should not be running
  44. And bind10 module Xfrin should not be running
  45. And bind10 module Stats should not be running
  46. And bind10 module StatsHttpd should not be running
  47. # This is a general step to stop a named process. By convention,
  48. # the default name for any process is the same as the one we
  49. # use in the start step (for bind 10, that is 'I start bind10 with')
  50. # See scenario 'Multiple instances' for more.
  51. Then stop process bind10
  52. Scenario: example.org queries
  53. # This scenario performs a number of queries and inspects the results
  54. # Simple queries have already been show, but after we have sent a query,
  55. # we can also do more extensive checks on the result.
  56. # See querying.py for more information on these steps.
  57. # note: lettuce can group similar checks by using tables, but we
  58. # intentionally do not make use of that here
  59. # This is a compound statement that starts and waits for the
  60. # started message
  61. Given I have bind10 running with configuration example.org.config
  62. And wait for bind10 stderr message BIND10_STARTED_CC
  63. And wait for bind10 stderr message CMDCTL_STARTED
  64. And wait for bind10 stderr message AUTH_SERVER_STARTED
  65. bind10 module Auth should be running
  66. And bind10 module Resolver should not be running
  67. And bind10 module Xfrout should not be running
  68. And bind10 module Zonemgr should not be running
  69. And bind10 module Xfrin should not be running
  70. And bind10 module Stats should not be running
  71. And bind10 module StatsHttpd should not be running
  72. # Some simple queries that is not examined further
  73. A query for www.example.com should have rcode REFUSED
  74. A query for www.example.org should have rcode NOERROR
  75. # A query where we look at some of the result properties
  76. A query for www.example.org should have rcode NOERROR
  77. The last query response should have qdcount 1
  78. The last query response should have ancount 1
  79. The last query response should have nscount 3
  80. The last query response should have adcount 0
  81. # The answer section can be inspected in its entirety; in the future
  82. # we may add more granular inspection steps
  83. The answer section of the last query response should be
  84. """
  85. www.example.org. 3600 IN A 192.0.2.1
  86. """
  87. A query for example.org type NS should have rcode NOERROR
  88. The answer section of the last query response should be
  89. """
  90. example.org. 3600 IN NS ns1.example.org.
  91. example.org. 3600 IN NS ns2.example.org.
  92. example.org. 3600 IN NS ns3.example.org.
  93. """
  94. # We have a specific step for checking SOA serial numbers
  95. The SOA serial for example.org should be 1234
  96. # Another query where we look at some of the result properties
  97. A query for doesnotexist.example.org should have rcode NXDOMAIN
  98. The last query response should have qdcount 1
  99. The last query response should have ancount 0
  100. The last query response should have nscount 1
  101. The last query response should have adcount 0
  102. # When checking flags, we must pass them exactly as they appear in
  103. # the output of dig.
  104. The last query response should have flags qr aa rd
  105. A query for www.example.org type TXT should have rcode NOERROR
  106. The last query response should have ancount 0
  107. # Some queries where we specify more details about what to send and
  108. # where
  109. A query for www.example.org class CH should have rcode REFUSED
  110. A query for www.example.org to 127.0.0.1 should have rcode NOERROR
  111. A query for www.example.org to 127.0.0.1:47806 should have rcode NOERROR
  112. A query for www.example.org type A class IN to 127.0.0.1:47806 should have rcode NOERROR
  113. Scenario: changing database
  114. # This scenario contains a lot of 'wait for' steps
  115. # If those are not present, the asynchronous nature of the application
  116. # can cause some of the things we send to be handled out of order;
  117. # for instance auth could still be serving the old zone when we send
  118. # the new query, or already respond from the new database.
  119. # Therefore we wait for specific log messages after each operation
  120. #
  121. # This scenario outlines every single step, and does not use
  122. # 'steps of steps' (e.g. Given I have bind10 running)
  123. # We can do that but as an example this is probably better to learn
  124. # the system
  125. When I start bind10 with configuration example.org.config
  126. And wait for bind10 stderr message BIND10_STARTED_CC
  127. And wait for bind10 stderr message CMDCTL_STARTED
  128. And wait for bind10 stderr message AUTH_SERVER_STARTED
  129. bind10 module Auth should be running
  130. And bind10 module Resolver should not be running
  131. And bind10 module Xfrout should not be running
  132. And bind10 module Zonemgr should not be running
  133. And bind10 module Xfrin should not be running
  134. And bind10 module Stats should not be running
  135. And bind10 module StatsHttpd should not be running
  136. A query for www.example.org should have rcode NOERROR
  137. Wait for new bind10 stderr message AUTH_SEND_NORMAL_RESPONSE
  138. Then set bind10 configuration data_sources/classes/IN[0]/params to {"database_file": "data/empty_db.sqlite3"}
  139. # The 'not missing placeholder' check is for #2743
  140. And wait for new bind10 stderr message DATASRC_SQLITE_CONNOPEN not Missing placeholder
  141. A query for www.example.org should have rcode REFUSED
  142. Wait for new bind10 stderr message AUTH_SEND_NORMAL_RESPONSE
  143. Then set bind10 configuration data_sources/classes/IN[0]/params to {"database_file": "data/example.org.sqlite3"}
  144. # The 'not missing placeholder' check is for #2743
  145. And wait for new bind10 stderr message DATASRC_SQLITE_CONNOPEN not Missing placeholder
  146. A query for www.example.org should have rcode NOERROR
  147. Scenario: two bind10 instances
  148. # This is more a test of the test system, start 2 bind10's
  149. When I start bind10 with configuration example.org.config as bind10_one
  150. And wait for bind10_one stderr message BIND10_STARTED_CC
  151. And wait for bind10_one stderr message CMDCTL_STARTED
  152. And wait for bind10_one stderr message AUTH_SERVER_STARTED
  153. And I start bind10 with configuration example2.org.config with cmdctl port 47804 as bind10_two
  154. And wait for bind10_two stderr message BIND10_STARTED_CC
  155. And wait for bind10_two stderr message CMDCTL_STARTED
  156. And wait for bind10_two stderr message AUTH_SERVER_STARTED
  157. A query for www.example.org to 127.0.0.1:47806 should have rcode NOERROR
  158. A query for www.example.org to [::1]:47807 should have rcode NOERROR
  159. The SOA serial for example.org should be 1234
  160. The SOA serial for example.org at 127.0.0.1:47806 should be 1234
  161. The SOA serial for example.org at ::1:47807 should be 1234
  162. Then set bind10 configuration data_sources/classes/IN[0]/params to {"database_file": "data/empty_db.sqlite3"}
  163. And wait for bind10_one stderr message DATASRC_SQLITE_CONNOPEN
  164. A query for www.example.org to 127.0.0.1:47806 should have rcode REFUSED
  165. A query for www.example.org to [::1]:47807 should have rcode NOERROR