Commit dd12880f authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

including channels_statistics handler, adding some sanity check for...

including channels_statistics handler, adding some sanity check for configuration and removing unnecessary code for this version
parent 65a25ea5
/*
* ngx_http_push_stream_module_setup.h
*
* Created on: Oct 26, 2010
* Authors: Wandenberg Peixoto <wandenberg@gmail.com> & Rogério Schneider <stockrt@gmail.com>
*/
#ifndef NGX_HTTP_PUSH_STREAM_MODULE_SETUP_H_
#define NGX_HTTP_PUSH_STREAM_MODULE_SETUP_H_
#include <ngx_http_push_stream_module.h>
#include <ngx_http_push_stream_module_publisher.h>
#include <ngx_http_push_stream_module_subscriber.h>
#define NGX_HTTP_PUSH_STREAM_MAX_CHANNEL_ID_LENGTH 1024 // bytes
//
//#define NGX_HTTP_PUSH_STREAM_DEFAULT_SHM_SIZE 33554432 // 32 megs
#define NGX_HTTP_PUSH_STREAM_DEFAULT_BUFFER_TIMEOUT 7200 // 2 hours
#define NGX_HTTP_PUSH_STREAM_DEFAULT_MAX_MESSAGES 10
#define NGX_HTTP_PUSH_STREAM_DEFAULT_HEADER_TEMPLATE ""
#define NGX_HTTP_PUSH_STREAM_DEFAULT_MESSAGE_TEMPLATE ""
#define NGX_HTTP_PUSH_STREAM_DEFAULT_CONTENT_TYPE "text/plain"
#define NGX_HTTP_PUSH_STREAM_DEFAULT_BROADCAST_CHANNEL_PREFIX ""
// variables
static ngx_str_t ngx_http_push_stream_channel_id = ngx_string("push_stream_channel_id");
static ngx_str_t ngx_http_push_stream_channels_path = ngx_string("push_stream_channels_path");
static char * push_stream_channels_statistics(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
// publisher
static char * ngx_http_push_stream_publisher(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
// subscriber
static char * ngx_http_push_stream_subscriber(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
// setup
static char * ngx_http_push_stream_setup_handler(ngx_conf_t *cf, void *conf, ngx_int_t (*handler) (ngx_http_request_t *));
static ngx_int_t ngx_http_push_stream_init_module(ngx_cycle_t *cycle);
static ngx_int_t ngx_http_push_stream_init_worker(ngx_cycle_t *cycle);
static void ngx_http_push_stream_exit_worker(ngx_cycle_t *cycle);
static void ngx_http_push_stream_exit_master(ngx_cycle_t *cycle);
static ngx_int_t ngx_http_push_stream_postconfig(ngx_conf_t *cf);
static void * ngx_http_push_stream_create_main_conf(ngx_conf_t *cf);
static void * ngx_http_push_stream_create_loc_conf(ngx_conf_t *cf);
static char * ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child);
static ngx_int_t ngx_http_push_stream_movezig_channel_locked(ngx_http_push_stream_channel_t *channel, ngx_slab_pool_t *shpool);
#endif /* NGX_HTTP_PUSH_STREAM_MODULE_SETUP_H_ */
This diff is collapsed.
#require 'rubygems'
#require 'popen4'
#require 'test/unit'
#require File.expand_path('base_test_case', File.dirname(__FILE__))
#
#class TestSetuParameters < Test::Unit::TestCase
# include BaseTestCase
#
# def test_min_buffer_messages_greater_them_max_buffer_messages
# expected_error_message = "push_stream_max_message_buffer_length cannot be smaller than push_stream_min_message_buffer_length"
# @test_config_file = "test_min_buffer_messages_greater_them_max_buffer_messages.conf"
# @max_message_buffer_length = 20
# @min_message_buffer_length = 21
#
# self.create_config_file
# stderr_msg = self.start_server
# assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
# end
#
#end
require File.expand_path('base_test_case', File.dirname(__FILE__))
class TestSetuParameters < Test::Unit::TestCase
include BaseTestCase
def test_ping_message_interval_cannot_be_zero
expected_error_message = "push_stream_ping_message_interval cannot be zero"
@test_config_file = "test_ping_message_interval_cannot_be_zero.conf"
@ping_message_interval = 0
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_ping_message_interval_cannot_be_set_without_a_message_template
expected_error_message = "cannot have ping message if push_stream_message_template is not set or blank"
@test_config_file = "test_ping_message_interval_cannot_be_set_without_a_message_template.conf"
@ping_message_interval = "1s"
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_ping_message_interval_cannot_be_set_if_message_template_is_blank
expected_error_message = "cannot have ping message if push_stream_message_template is not set or blank"
@test_config_file = "test_ping_message_interval_cannot_be_set_if_message_template_is_blank.conf"
@ping_message_interval = "1s"
@message_template = ""
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_subscriber_disconnect_interval_cannot_be_zero
expected_error_message = "push_stream_subscriber_disconnect_interval cannot be zero"
@test_config_file = "test_subscriber_disconnect_interval_cannot_be_zero.conf"
@subscriber_disconnect_interval = 0
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_subscriber_connection_timeout_cannot_be_zero
expected_error_message = "push_stream_subscriber_connection_timeout cannot be zero"
@test_config_file = "test_subscriber_connection_timeout_cannot_be_zero.conf"
@subscriber_connection_timeout = 0
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_subscriber_disconnect_interval_cannot_be_set_without_a_connection_timeout
expected_error_message = "cannot set subscriber disconnect interval if push_stream_subscriber_connection_timeout is not set or zero"
@test_config_file = "test_subscriber_disconnect_interval_cannot_be_set_without_a_connection_timeout.conf"
@subscriber_disconnect_interval = "1s"
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_subscriber_connection_timeout_cannot_be_set_without_a_disconnect_interval
expected_error_message = "cannot set subscriber connection timeout if push_stream_subscriber_disconnect_interval is not set or zero"
@test_config_file = "test_subscriber_connection_timeout_cannot_be_set_without_a_disconnect_interval.conf"
@subscriber_connection_timeout = "1s"
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_max_channel_id_length_cannot_be_zero
expected_error_message = "push_stream_max_channel_id_length cannot be zero"
@test_config_file = "test_max_channel_id_length_cannot_be_zero.conf"
@max_channel_id_length = 0
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_min_message_buffer_timeout_cannot_be_zero
expected_error_message = "push_stream_min_message_buffer_timeout cannot be zero"
@test_config_file = "test_min_message_buffer_timeout_cannot_be_zero.conf"
@min_message_buffer_timeout = 0
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_max_message_buffer_length_cannot_be_zero
expected_error_message = "push_stream_max_message_buffer_length cannot be zero"
@test_config_file = "test_max_message_buffer_length_cannot_be_zero.conf"
@max_message_buffer_length = 0
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_store_messages_cannot_be_set_without_set_max_message_buffer_length_or_min_message_buffer_timeout
expected_error_message = "push_stream_store_messages cannot be set without set max message buffer length or min message buffer timeout"
@test_config_file = "test_store_messages_cannot_be_set_without_set_max_message_buffer_length_or_min_message_buffer_timeout.conf"
@store_messages = 'on'
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_broadcast_channel_max_qtd_cannot_be_zero
expected_error_message = "push_stream_broadcast_channel_max_qtd cannot be zero"
@test_config_file = "test_broadcast_channel_max_qtd_cannot_be_zero.conf"
@broadcast_channel_max_qtd = 0
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_broadcast_channel_max_qtd_cannot_be_set_without_broadcast_channel_prefix
expected_error_message = "cannot set broadcast channel max qtd if push_stream_broadcast_channel_prefix is not set or blank"
@test_config_file = "test_broadcast_channel_max_qtd_cannot_be_set_without_broadcast_channel_prefix.conf"
@broadcast_channel_max_qtd = 1
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_broadcast_channel_max_qtd_cannot_be_set_without_broadcast_channel_prefix
expected_error_message = "cannot set broadcast channel max qtd if push_stream_broadcast_channel_prefix is not set or blank"
@test_config_file = "test_broadcast_channel_max_qtd_cannot_be_set_without_broadcast_channel_prefix.conf"
@broadcast_channel_max_qtd = 1
@broadcast_channel_prefix = ""
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
def test_broadcast_channel_prefix_cannot_be_set_without_broadcast_channel_max_qtd
expected_error_message = "cannot set broadcast channel prefix if push_stream_broadcast_channel_max_qtd is not set"
@test_config_file = "test_broadcast_channel_prefix_cannot_be_set_without_broadcast_channel_max_qtd.conf"
@broadcast_channel_prefix = "broad_"
self.create_config_file
stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end
end
Markdown is supported
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