example.feature 8.9 KB

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