Commit eb1b9e52 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[1897] Add lettuce test for stats-http response/log

parent 769bbb5e
Feature: b10-stats-httpd module
Tests the stats httpd module
Scenario: Check that the module logs and responds to requests
Given I have bind10 running with configuration bindctl_commands.config
And wait for bind10 stderr message STATHTTPD_STARTED
When I request the URL http://127.0.0.1:47811/
# Should result in redirect, so two query logs
And wait for new bind10 stderr message localhost "GET / HTTP/1.0" 302 -
And wait for new bind10 stderr message localhost "GET /bind10/statistics/xml/ HTTP/1.0" 200 -
The last http response status code should be 200
When I request the URL http://127.0.0.1:47811/no_such_url
And wait for new bind10 stderr message localhost "GET /no_such_url HTTP/1.0" 404 -
The last http response status code should be 404
# Copyright (C) 2013 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from lettuce import *
import urllib
# Basic request
@step('request the URL (.*)')
def request_url(step, url):
"""
Performs one basic HTTP GET request. The resulting HTTPResponse object
will we placed in world.last_http_response
Parameters:
url: the full URL to query
"""
world.last_http_response = urllib.urlopen(url)
@step('last http response status code should be ([0-9]+)')
def check_last_response_code(step, code):
assert world.last_http_response != None, "No HTTP request made yet"
assert int(code) == world.last_http_response.getcode(),\
code + " != " +\
str(world.last_http_response.getcode())
# Copyright (C) 2011 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
......@@ -380,6 +381,9 @@ def initialize(scenario):
# Convenience variable to access the last query result from querying.py
world.last_query_result = None
# Convenience variable to access the last HTTP response from http.py
world.last_http_response = None
# For slightly better errors, initialize a process_pids for the relevant
# steps
world.process_pids = None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment