example.feature 8.1 KB

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