Browse Source

[1290] add example test with two instances of bind10

Jelte Jansen 13 years ago
parent
commit
aa35477883

+ 2 - 1
tests/lettuce/README

@@ -25,7 +25,8 @@ This port must be free. (TODO: can we make this run-time discovered?).
 Port 47805 is used for cmdctl, and must also be available.
 
 The bind10 main script, bindctl script, and dig must all be in the default
-search path of your environment.
+search path of your environment, and BIND 10 must not be running if you use
+the installed version when you run the tests.
 
 To run the tests, just run 'lettuce' in this directory.
 

+ 1 - 0
tests/lettuce/configurations/example2.org.config

@@ -0,0 +1 @@
+{"version": 2, "Logging": {"loggers": [{"severity": "DEBUG", "name": "auth", "debuglevel": 99}]}, "Auth": {"database_file": "data/example.org.sqlite3", "listen_on": [{"port": 47807, "address": "127.0.0.1"}]}}

+ 12 - 4
tests/lettuce/features/bind10_control.py

@@ -25,7 +25,8 @@ def wait_for_output_lines_stdout(process_name, lines, examine_past = True):
 
 @world.absorb
 def wait_for_output_lines_stderr(process_name, lines, examine_past = True):
-    assert process_name in world.processes
+    assert process_name in world.processes,\
+        "No process named '" + process_name + "' known"
     if examine_past:
         for output in world.processes_stderr[process_name]:
             for line in lines:
@@ -40,17 +41,24 @@ def wait_for_output_lines_stderr(process_name, lines, examine_past = True):
             if output.find(line) != -1:
                 return line
 
-@step('start bind10(?: with configuration ([\w.]+))?(?: as (\w+))?')
-def start_bind10(step, config_file, process_name):
+@step('start bind10(?: with configuration (\S+))?' +\
+      '(?: with cmdctl port (\d+))?(?: as (\S+))?')
+def start_bind10(step, config_file, cmdctl_port, process_name):
     args = [ 'bind10', '-v' ]
     if config_file is not None:
         args.append('-p')
         args.append("configurations/")
         args.append('-c')
         args.append(config_file)
+    if cmdctl_port is None:
         args.append('--cmdctl-port=47805')
+    else:
+        args.append('--cmdctl-port=' + cmdctl_port)
     if process_name is None:
         process_name = "bind10"
+    else:
+        args.append('-m')
+        args.append(process_name + '_msgq.socket')
 
     assert process_name not in world.processes,\
         "There already seems to be a process named " + process_name
@@ -65,7 +73,7 @@ def start_bind10(step, config_file, process_name):
     message = world.wait_for_output_lines_stderr(process_name,
                                                  ["BIND10_STARTUP_COMPLETE",
                                                   "BIND10_STARTUP_ERROR"])
-    assert message == "BIND10_STARTUP_COMPLETE"
+    assert message == "BIND10_STARTUP_COMPLETE", "Got: " + message
 
 @step('wait for bind10 auth (?:of (\w+) )?to start')
 def wait_for_auth(step, process_name):

+ 1 - 1
tests/lettuce/features/querying.py

@@ -40,7 +40,7 @@ class QueryResult(object):
                           "([0-9]+), AUTHORITY: ([0-9]+), ADDITIONAL: ([0-9]+)")
 
     def __init__(self, name, qtype, qclass, address, port):
-        args = [ 'dig', '@' + address, '-p', str(port) ]
+        args = [ 'dig', '+tries=1', '@' + address, '-p', str(port) ]
         if qtype is not None:
             args.append('-t')
             args.append(str(qtype))

+ 16 - 0
tests/lettuce/features/server_from_sqlite3.feature

@@ -73,3 +73,19 @@ Feature: SQLite3 backend
         Then set bind10 configuration Auth/database_file to data/example.org.sqlite3
         And wait for bind10 stderr message DATASRC_SQLITE_OPEN
         A query for www.example.org should have rcode NOERROR
+
+    Scenario: two bind10 instances
+        # This is more a test of the test system, start 2 bind10's
+        When I start bind10 with configuration example.org.config as bind10_one
+        And I start bind10 with configuration example2.org.config with cmdctl port 47804 as bind10_two
+
+        Then wait for bind10 auth of bind10_one to start
+        Then wait for bind10 auth of bind10_two to start
+        A query for www.example.org to 127.0.0.1:47806 should have rcode NOERROR
+        A query for www.example.org to 127.0.0.1:47807 should have rcode NOERROR
+
+        Then set bind10 configuration Auth/database_file to data/empty_db.sqlite3
+        And wait for bind10_one stderr message DATASRC_SQLITE_OPEN
+
+        A query for www.example.org to 127.0.0.1:47806 should have rcode REFUSED
+        A query for www.example.org to 127.0.0.1:47807 should have rcode NOERROR