Browse Source

[1290] clear config on each start, and look for specific message

Jelte Jansen 13 years ago
parent
commit
bbfee9cc07

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

@@ -1 +0,0 @@
-{"version": 2, "Auth": {"database_file": "data/example.org.sqlite3", "listen_on": [{"port": 47806, "address": "127.0.0.1"}]}}

+ 1 - 0
tests/lettuce/configurations/example.org.config.orig

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

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

@@ -49,6 +49,10 @@ def start_bind10(step, config_file):
 def wait_for_auth(step):
     world.wait_for_output_lines(['AUTH_SERVER_STARTED'])
 
+@step(u'wait for log message (\w+)')
+def wait_for_message(step, message):
+    world.wait_for_output_lines([message], False)
+
 @step(u'stop bind10')
 def stop_the_server(step):
     world.shutdown_server()

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

@@ -22,6 +22,8 @@ Feature: SQLite3 backend
         Then wait for bind10 auth to start
         A query for www.example.org should have rcode NOERROR
         Then set bind10 configuration Auth/database_file to data/empty_db.sqlite3
+        And wait for log message DATASRC_SQLITE_OPEN
         A query for www.example.org should have rcode REFUSED
         Then set bind10 configuration Auth/database_file to data/example.org.sqlite3
+        And wait for log message DATASRC_SQLITE_OPEN
         A query for www.example.org should have rcode NOERROR

+ 11 - 0
tests/lettuce/features/steps.py

@@ -1,6 +1,11 @@
 from lettuce import *
 import subprocess
 import os.path
+import shutil
+
+copylist = [
+["configurations/example.org.config.orig", "configurations/example.org.config"]
+]
 
 @before.each_scenario
 def initialize(feature):
@@ -9,6 +14,12 @@ def initialize(feature):
     world.bind10 = None
     world.bind10_output = []
 
+    # Some tests can modify the settings. If the tests fail half-way, or
+    # don't clean up, this can leave configurations or data in a bad state,
+    # so we copy them from originals before each scenario
+    for item in copylist:
+        shutil.copy(item[0], item[1])
+
 @after.each_scenario
 def cleanup(feature):
     world.shutdown_server()