example.feature 6.9 KB

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